[LON-CAPA-cvs] cvs: loncom /interface/statistics lonproblemanalysis.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 13 Oct 2003 21:12:56 -0000


matthew		Mon Oct 13 17:12:56 2003 EDT

  Modified files:              
    /loncom/interface/statistics	lonproblemanalysis.pm 
  Log:
  Added date specification ability to time analysis.
  Makes the interface seem really ugly.  Advice would be appreciated.
  
  
Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.33 loncom/interface/statistics/lonproblemanalysis.pm:1.34
--- loncom/interface/statistics/lonproblemanalysis.pm:1.33	Mon Oct 13 15:17:42 2003
+++ loncom/interface/statistics/lonproblemanalysis.pm	Mon Oct 13 17:12:56 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 #
 
-# $Id: lonproblemanalysis.pm,v 1.33 2003/10/13 19:17:42 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.34 2003/10/13 21:12:56 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -308,21 +308,47 @@
     my ($PerformanceData,$ORdata) = @_;
     my $num_plots = $ENV{'form.NumPlots'};
     my ($table,@Foils) = &build_foil_index($ORdata);
-    my ($begin_index,$end_index);
     my $num_data = scalar(@$PerformanceData)-1;
     my $percent = sprintf('%2f',100/$num_plots);
     for (my $i=0;$i<$num_plots;$i++) {
-        $begin_index = $i*int($num_data/$num_plots);
-        $end_index = ($i+1)*int($num_data/$num_plots);
-        my $lownum  = sprintf('%2.1f',$i*$percent);
-        $lownum =~ s/(\.0)$//;
-        my $highnum = sprintf('%2.1f',($i+1)*$percent);
-        $highnum =~ s/(\.0)$//;
-        my ($plothtml,$starttime,$endtime,$data) = 
+        my $starttime = &Apache::lonhtmlcommon::get_date_from_form
+            ('startdate_'.$i);
+        my $endtime = &Apache::lonhtmlcommon::get_date_from_form
+            ('enddate_'.$i);
+        my ($begin_index,$end_index,$plottitle,$plothtml,$data);
+        if (! defined($starttime) || ! defined($endtime)) {
+            $begin_index = $i*int($num_data/$num_plots);
+            $end_index = ($i+1)*int($num_data/$num_plots);
+            my $lownum  = sprintf('%2.1f',$i*$percent);
+            $lownum =~ s/(\.0)$//;
+            my $highnum = sprintf('%2.1f',($i+1)*$percent);
+            $highnum =~ s/(\.0)$//;
+            $plottitle = $lownum.'% to '.$highnum.'% of submissions';
+        } else {
+            my $j;
+            while (++$j < scalar(@$PerformanceData)) {
+                last if ($PerformanceData->[$j]->[2] > $starttime);
+            }
+            $begin_index = $j;
+            while (++$j < scalar(@$PerformanceData)) {
+                last if ($PerformanceData->[$j]->[2] > $endtime);
+            }
+            $end_index = $j;
+            $plottitle = 'Tries plot '.$i;
+        }
+
+        ($plothtml,$starttime,$endtime,$data) = 
             &analyze_option_data_by_time($PerformanceData,
                                          $begin_index,$end_index,
-            $lownum.'% to '.$highnum.'% of submissions',
+                                         $plottitle,
                                          @Foils);
+        my $startdateform = &Apache::lonhtmlcommon::date_setter
+            ('Statistics','startdate_'.$i,$starttime);
+        my $enddateform = &Apache::lonhtmlcommon::date_setter
+            ('Statistics','enddate_'.$i,$endtime);
+        $plothtml.= "<br />\n".
+            "<b>Start Time</b>: "."&nbsp;".$startdateform."<br />\n".
+            "<b>End Time</b>&nbsp;&nbsp;: "."&nbsp;".$enddateform."<br />\n";
         $table.=$plothtml;
     }
     return $table;
@@ -379,9 +405,6 @@
          'Percent Correct / Incorrect',
          100,
          \@Plotdata1,\@Plotdata2);
-    $graphlink .= "<br />\n".
-        "<b>Start Time</b>: ".localtime($starttime)."<br />\n".
-        "<b>End Time</b>: ".localtime($endtime)."<br />\n";
     #
     return ($graphlink,$starttime,$endtime,\%TimeData);
 }