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

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 04 Oct 2004 19:10:26 -0000


matthew		Mon Oct  4 15:10:26 2004 EDT

  Modified files:              
    /loncom/interface/statistics	lonproblemanalysis.pm 
  Log:
  Added 'show problem' checkbox.  Time analysis would always show a plot, now
  it does not show a plot if there is no data.
  
  
Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.90 loncom/interface/statistics/lonproblemanalysis.pm:1.91
--- loncom/interface/statistics/lonproblemanalysis.pm:1.90	Wed Sep 29 10:38:35 2004
+++ loncom/interface/statistics/lonproblemanalysis.pm	Mon Oct  4 15:10:26 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemanalysis.pm,v 1.90 2004/09/29 14:38:35 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.91 2004/10/04 19:10:26 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,7 +56,6 @@
                      { name => 'ExcelOutput',
                        text => 'Produce Excel Output' });
 
-
 sub BuildProblemAnalysisPage {
     my ($r,$c)=@_;
     #
@@ -135,7 +134,9 @@
             my $resource = $current_problem->{'resource'};
             $r->print('<h1>'.$resource->{'title'}.'</h1>');
             $r->print('<h3>'.$resource->{'src'}.'</h3>');
-            $r->print(&Apache::lonstathelpers::render_resource($resource));
+            if ($ENV{'form.show_prob'} eq 'true') {
+                $r->print(&Apache::lonstathelpers::render_resource($resource));
+            }
             $r->rflush();
             my %Data = &Apache::lonstathelpers::get_problem_data
                 ($resource->{'src'});
@@ -404,7 +405,7 @@
     } else {
         $analysis_html .= '<h2>'.
            &mt('The analysis you have selected is not supported at this time').
-           '</h2>';
+            '</h2>';
     }
     $r->print($analysis_html);
 }
@@ -481,8 +482,8 @@
                 }
             }
         }
-        my $title='Attempt '.$try;
-        my $xlabel = $total.' Submissions';
+        my $title='Attempt '.$try.' (N='.$total.')';
+        my $xlabel = 'Foil Chosen';
         $html.=  &Apache::loncommon::DrawBarGraph($title,
                                                   $xlabel,
                                                   'Percent Choosing',
@@ -830,8 +831,12 @@
                                                               > $starttime);
         }
         $begin_index = $j;
-        while (++$j < scalar(@$performance_data)) {
-            last if (&get_time_from_row($performance_data->[$j]) > $endtime);
+        while ($j < scalar(@$performance_data)) {
+            if (&get_time_from_row($performance_data->[$j]) > $endtime) {
+                last;
+            } else {
+                $j++;
+            }
         }
         $end_index = $j;
         ##
@@ -924,12 +929,13 @@
     #
     # Create the plot
     my $count = $end_index-$begin_index;
+    return ('No data','') if ($count <= 0);
     my $title;
     if ($count == 0) {
         $title = 'no submissions';
     } elsif ($count == 1) {
         $title = 'one submission';
-    } else {
+    } elsif ($count > 1) {
         $title = $count.' submissions';
     }
     my $correct_plot = &Apache::loncommon::DrawBarGraph($title,
@@ -945,6 +951,8 @@
     $count = $end_index-$begin_index-$TimeData{'_correct'};
     if ($count == 0) {
         $title = 'no submissions';
+    } elsif ($count < 0) {
+        return ($correct_plot,'');
     } elsif ($count == 1) {
         $title = 'one submission';
     } else {
@@ -956,8 +964,7 @@
                                                  100,
                                                  $plotcolors,
                                                  undef,
-                                                 @plotdata);        
-
+                                                 @plotdata);
     return ($correct_plot,$incorrect_plot);
 }
 
@@ -1376,6 +1383,17 @@
     ##
     ##
     $Str .= '<td>';
+    ##
+    my $showprob_checkbox = 
+        '<input type="checkbox" name="show_prob" value="true" ';
+    if ($ENV{'form.show_prob'} eq 'true') {
+        $showprob_checkbox .= 'checked ';
+    }
+    $showprob_checkbox.= ' />';
+    $Str.= '<nobr><label>'.
+        &mt('Show problem [_1]',$showprob_checkbox).
+        '</label></nobr><br />';
+    ##
     my $analyze_selector = '<select name="AnalyzeOver" >';
     $analyze_selector .= '<option value="Tries" ';
     if (! exists($ENV{'form.AnalyzeOver'}) || 
@@ -1388,11 +1406,11 @@
     $analyze_selector .= ' selected ' if ($ENV{'form.AnalyzeOver'} eq 'Time');
     $analyze_selector .= '>'.&mt('Time').'</option>';
     $analyze_selector .= '</select>';
-    $Str .= '<nobr>'.
+    $Str .= '<nobr><label>'.
         &mt('Analyze Over [_1] [_2]',
             $analyze_selector,
             &Apache::loncommon::help_open_topic('Analysis_Analyze_Over')).
-            '</nobr><br />'.$/;
+            '</label></nobr><br />'.$/;
     ##
     my $numplots_selector = '<select name="NumPlots">';
     if (! exists($ENV{'form.NumPlots'})