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

bisitz bisitz at source.lon-capa.org
Wed Dec 4 06:20:07 EST 2013


bisitz		Wed Dec  4 11:20:07 2013 EDT

  Modified files:              
    /loncom/interface/statistics	lonpercentage.pm 
  Log:
  - Improved and consistent layout:
      - Error style for error messages
      - data_table (implies simplified code), table header
  - Internationalization: Added missing &mt() calls
  - XHTML: action attribute required in <form>
  
  
  
Index: loncom/interface/statistics/lonpercentage.pm
diff -u loncom/interface/statistics/lonpercentage.pm:1.12 loncom/interface/statistics/lonpercentage.pm:1.13
--- loncom/interface/statistics/lonpercentage.pm:1.12	Sat May 16 23:21:07 2009
+++ loncom/interface/statistics/lonpercentage.pm	Wed Dec  4 11:20:07 2013
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonpercentage.pm,v 1.12 2009/05/16 23:21:07 bisitz Exp $
+# $Id: lonpercentage.pm,v 1.13 2013/12/04 11:20:07 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -42,7 +42,7 @@
 
     my %cache;
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-        $r->print('Unable to tie database.6');
+        $r->print('<p class="LC_error">'.&mt('Unable to tie [_1]','database.6').'</p>');
         return;
     }
 
@@ -57,7 +57,7 @@
     }
 
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-        $r->print('Unable to tie database.6');
+        $r->print('<p class="LC_error">'.&mt('Unable to tie [_1]','database.6').'</p>');
         return;
     }
 
@@ -76,7 +76,7 @@
 
     my $Ptr = '';
     $Ptr .= '<table border="0" cellspacing="5"><tbody>';
-    $Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n";
+    $Ptr .= '<tr><td align="right"><b>'.&mt('Select Map').'</b></td>'."\n";
     $Ptr .= '<td align="left">';
     $Ptr .= &Apache::lonhtmlcommon::MapOptions($cache, 'Statistics',
                                                'Statistics');
@@ -107,7 +107,7 @@
 
     $Ptr .= '</tr>'."\n";
 
-    $Ptr .= '<tr><td align="right"><b>Select Sections</b>';
+    $Ptr .= '<tr><td align="right"><b>'.&mt('Select Sections').'</b>';
     $Ptr .= '</td>'."\n";
     $Ptr .= '<td align="left">'."\n";
     my @sections = split(':',$cache->{'sectionList'});
@@ -143,7 +143,7 @@
     my %cache;
 
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
-        $r->print('Unable to tie database1.1.');
+        $r->print('<p class="LC_error">'.&mt('Unable to tie [_1]','database1.1.').'</p>');
         return ('ERROR');
     }
 
@@ -290,7 +290,7 @@
     $Ptr .= '</form>'."\n";
     $Ptr .= '<IMG src="/cgi-bin/graph.png?'.(join('&', @GData));
     $Ptr .= '" border="1" />';
-    $Ptr .= '<form>'."\n";
+    $Ptr .= '<form action="">'."\n";
 
     return ($Ptr, \%percentages);
 }
@@ -301,47 +301,36 @@
 
 sub TableData {
     my($cache,$percentage)=@_;
-    my $Ptr;
+    my $Ptr =
+        &Apache::loncommon::start_data_table()
+       .&Apache::loncommon::start_data_table_header_row()
+       .'<th>'&mt('% Correct').'</th>'
+       .'<th>'&mt('Frequency').'</th>'
+       .'<th>'&mt('Students').'</th>'
+       .&Apache::loncommon::end_data_table_header_row();
 
-    $Ptr .= '<table border="0"><tr><td bgcolor="#D7D7D7">'."\n";
-    $Ptr .= '<table border="0" cellpadding="3"><tr bgcolor="#e6ffff">'."\n";
-
-    $Ptr .= '<tr>'."\n";
-    $Ptr .= '<td>% Correct</td>'.
-            '<td>Frequency</td>'.
-            '<td>Students</td>';
-    $Ptr .= '</tr>'."\n";
-
-    my $alternate=0;
     foreach (sort NumericSort keys(%$percentage)) {
 
         my @temp = split(':::', $percentage->{$_});
         my $count = scalar(@temp);
 
-        if($alternate) {
-            $Ptr .= '<tr bgcolor="#ffffe6">';
-        } else {
-            $Ptr .= '<tr bgcolor="#ffffc6">';
+        $Ptr .=
+            &Apache::loncommon::start_data_table_row()
+           .'<td>'.$_.'</td>'
+           .'<td>'.$count.'</td><td>';
+
+        foreach my $name (sort(split(':::', $percentage->{$_}))) {
+            $Ptr .=
+                '<a href="/adm/statistics?reportSelected='
+               .&escape('Student Assessment')
+               .'&StudentAssessmentStudent='
+               .&escape($cache->{$name.':fullname'}).'">'
+               .$cache->{$name.':fullname'}
+               .'</a>,  ';
         }
-        $alternate = ($alternate + 1) % 2;
-
-	$Ptr .= '<td>'.$_.'</td>';
-        $Ptr .= '<td>'.$count.'</td><td>';
-
-	foreach my $name (sort(split(':::', $percentage->{$_}))) {
-	    $Ptr .= '<a href="/adm/statistics?reportSelected=';
-	    $Ptr .= &escape('Student Assessment');
-	    $Ptr .= '&StudentAssessmentStudent=';
-	    $Ptr .= &escape($cache->{$name.':fullname'}).'">';
-	    $Ptr .= $cache->{$name.':fullname'};
-	    $Ptr .= '</a>,  ';
-        }
-
-	$Ptr .= '</td></tr>'."\n";
+        $Ptr .= '</td>'.&Apache::loncommon::end_data_table_row();
     }
-
-    $Ptr .= '</tr>'."\n";
-    $Ptr .= '</table></td></tr></table>'."\n";
+    $Ptr .= &Apache::loncommon::end_data_table();
 
     return $Ptr;
 }




More information about the LON-CAPA-cvs mailing list