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

bisitz bisitz at source.lon-capa.org
Mon Feb 3 13:52:30 EST 2014


bisitz		Mon Feb  3 18:52:30 2014 EDT

  Modified files:              
    /loncom/interface/statistics	lonproblemstatistics.pm 
  Log:
  - Corrected unbalanced tags
  - XHTML
  - Internationalization:
      - Added missing &mt() calls
      - Time window info for Excel:
          - Improved output
          - Corrected start date (use correct variable)
  
  
  
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.124 loncom/interface/statistics/lonproblemstatistics.pm:1.125
--- loncom/interface/statistics/lonproblemstatistics.pm:1.124	Mon Dec 30 13:51:37 2013
+++ loncom/interface/statistics/lonproblemstatistics.pm	Mon Feb  3 18:52:30 2014
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemstatistics.pm,v 1.124 2013/12/30 13:51:37 raeburn Exp $
+# $Id: lonproblemstatistics.pm,v 1.125 2014/02/03 18:52:30 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -587,14 +587,14 @@
 
 sub field_selection_input {
     my $Str = '<select name="fieldselections" multiple="multiple" size="5">'."\n";
-    $Str .= '<option value="all">all</option>'."\n";
+    $Str .= '<option value="all">'.&mt('all').'</option>'."\n";
     foreach my $field (@Fields) {
         next if ($field->{'selectable'} ne 'yes');
         $Str .= '    <option value="'.$field->{'name'}.'" ';
         if ($field->{'selected'} eq 'yes') {
-            $Str .= 'selected ';
+            $Str .= 'selected="selected" ';
         }
-        $Str .= '>'.$field->{'title'}.'</option>'."\n";
+        $Str .= '>'.&mt($field->{'title'}).'</option>'."\n";
     }
     $Str .= "</select>\n";
 }
@@ -619,7 +619,6 @@
     &parse_field_selection();
     #
     my $Str = '';
-    $Str .= '<p>';
     $Str .= &Apache::loncommon::start_data_table();
     $Str .= &Apache::loncommon::start_data_table_header_row();
     $Str .= '<th>'.&mt('Sections').'</th>';
@@ -645,14 +644,13 @@
     $Str .= &field_selection_input();
     $Str .= '</td><td align="center" valign="top">';
     $Str .= &plot_dropdown();
-    $Str .= '</td>'."\n";
+    $Str .= "\n";
     $Str .= '</td><td align="center" valign="top">';
     $Str .= &Apache::lonstathelpers::limit_by_time_form();
     $Str .= '</td>'."\n";
     $Str .=  &Apache::loncommon::end_data_table_row();
     $Str .= &Apache::loncommon::end_data_table();
     #
-    $Str .= '</p>';
     $Str .= '<input type="submit" name="GenerateStatistics" value="'.
         &mt('Generate Statistics').'" />';
     $Str .= (' 'x10);
@@ -803,9 +801,8 @@
     $r->print('<h2>'.&mt('Sequence Statistics').
 	      &Apache::loncommon::help_open_topic('Statistics_Sequence').
 	      '</h2>');
-    $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row());
+    $r->print(&Apache::loncommon::start_data_table());
     $r->print(&sequence_html_header());
-    $r->print(&Apache::loncommon::end_data_table_header_row());
     foreach my $seq (@sequences) {
         last if ($c->aborted);
         &compute_sequence_statistics($seq);
@@ -827,7 +824,7 @@
 sub output_html_by_sequence {
     my ($r) = @_;
     my $c = $r->connection();
-    $r->print('<br>'.&html_preamble());
+    $r->print('<br />'.&html_preamble());
     #
     foreach my $seq (@sequences) {
         last if ($c->aborted);
@@ -931,14 +928,16 @@
         next if ($options =~ /no $field->{'name'}/);
         next if ($field->{'selected'} ne 'yes');
         $header_row .= '<th>';
+        my $header_row_text = &mt($field->{'title'});
         if (exists($field->{'sortable'}) && $field->{'sortable'} eq 'yes') {
-            $header_row .= '<a href="javascript:'.
+            $header_row .=
+                '<a href="javascript:'.
                 'document.Statistics.sortby.value='."'".$field->{'name'}."'".
-                    ';document.Statistics.submit();">';
-        }
-        $header_row .= &mt($field->{'title'});
-        if ($options =~ /sortable/) {
-            $header_row.= '</a>';
+                ';document.Statistics.submit();">'.
+                $header_row_text.
+                '</a>';
+        } else {
+            $header_row .= $header_row_text;
         }
         if ($options !~ /no plots/        && 
             exists($field->{'graphable'}) && 
@@ -955,13 +954,13 @@
 }
 
 sub sequence_html_header {
-    my $Str .= '<tr>';
+    my $Str .= &Apache::loncommon::start_data_table_header_row();
     foreach my $field (@SeqFields) {
 #        next if ($field->{'selected'} ne 'yes');
         $Str .= '<th bgcolor="'.$field->{'color'}.'"';
-        $Str .= '>'.$field->{'title'}.'</th>';
+        $Str .= '>'.&mt($field->{'title'}).'</th>';
     }
-    $Str .= '</tr>';
+    $Str .= &Apache::loncommon::end_data_table_header_row();
     return $Str;
 }
 
@@ -969,7 +968,7 @@
 sub sequence_html_output {
     my ($seq) = @_;
     my $data = $SeqStat{$seq->symb};
-    my $row = '<tr>';
+    my $row = &Apache::loncommon::start_data_table_row();
     foreach my $field (@SeqFields) {
         next if ($field->{'selected'} ne 'yes');
         $row .= '<td bgcolor="'.$field->{'color'}.'"';
@@ -984,7 +983,7 @@
         }
         $row .= '</td>';
     }
-    $row .= '</tr>'."\n";
+    $row .= &Apache::loncommon::end_data_table_row()."\n";
     return $row;
 }
 
@@ -1346,16 +1345,17 @@
     # Time restrictions
     my $time_string;
     if (defined($starttime)) {
-        # call localtime but not lonlocal:locallocaltime because excel probably
-        # cannot handle localized text.  Probably.
-        $time_string .= 'Data collected from '.localtime($time_string);
         if (defined($endtime)) {
-            $time_string .= ' to '.localtime($endtime);
+            $time_string .=  &mt('Data collected from [_1] to [_2]',
+                                 &Apache::lonlocal::locallocaltime($starttime),
+                                 &Apache::lonlocal::locallocaltime($endtime));
+        } else {
+            $time_string .=  &mt('Data collected from [_1]',
+                                 &Apache::lonlocal::locallocaltime($starttime));
         }
-        $time_string .= '.';
     } elsif (defined($endtime)) {
-        # See note above about lonlocal:locallocaltime
-        $time_string .= 'Data collected before '.localtime($endtime).'.';
+        $time_string .=  &mt('Data collected before [_1]',
+                             &Apache::lonlocal::locallocaltime($endtime));
     }
     if (defined($time_string)) {
         $excel_sheet->write($rows_output,$cols_output++,$time_string);
@@ -1364,7 +1364,7 @@
     #
     # Put the date in there too
     $excel_sheet->write($rows_output,$cols_output++,
-                        'Compiled on '.localtime(time));
+                        &mt('Compiled on [_1]',&Apache::lonlocal::locallocaltime(time)));
     #
     $rows_output++;
     $cols_output=0;




More information about the LON-CAPA-cvs mailing list