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

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 22 Dec 2004 22:54:59 -0000


albertel		Wed Dec 22 17:54:59 2004 EDT

  Modified files:              
    /loncom/interface	lontrackstudent.pm 
  Log:
  - make trackstudent more readable
  
  
Index: loncom/interface/lontrackstudent.pm
diff -u loncom/interface/lontrackstudent.pm:1.10 loncom/interface/lontrackstudent.pm:1.11
--- loncom/interface/lontrackstudent.pm:1.10	Thu Dec 16 17:04:41 2004
+++ loncom/interface/lontrackstudent.pm	Wed Dec 22 17:54:59 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lontrackstudent.pm,v 1.10 2004/12/16 22:04:41 matthew Exp $
+# $Id: lontrackstudent.pm,v 1.11 2004/12/22 22:54:59 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -281,12 +281,13 @@
         }
         my ($symb,$timestamp,$student,$action,$machine,$values);
         if ($mode eq 'full_class') {
-            ($symb,$timestamp,$student,$action,$machine,$values) =
-                map { &Apache::lonnet::unescape($_); } split(',',$line,6);
+            ($symb,$timestamp,$student,$action,$machine,$values) = split(',',$line,6);
         } else {
-            ($symb,$timestamp,$action,$machine,$values) =
-                map { &Apache::lonnet::unescape($_); } split(',',$line,5);
+            ($symb,$timestamp,$action,$machine,$values) = split(',',$line,5);
         }
+	foreach ($symb,$timestamp,$student,$action,$machine) {
+	    $_=&Apache::lonnet::unescape($_);
+	}
         my ($title,$src);
         if ($symb =~ m:^/adm/:) {
             $title = $symb;
@@ -294,7 +295,7 @@
         } else {
             my $nav_res = $navmap->getBySymb($symb);
             if (defined($nav_res)) {
-                $title = $nav_res->title();
+                $title = $nav_res->compTitle();
                 $src   = $nav_res->src();
             } else {
                 if ($src =~ m|^/res|) {
@@ -334,27 +335,27 @@
             $class = 'warning';
         }
         # Clean up the values
-        $values =~ s/counter=\d+$//;
+	$values = &display_values($action,$values);
         #
         # Build the row for output
         my $tablerow = qq{<tr class="$class">};
         if ($src =~ m|^/adm/|) {
             $tablerow .= 
-                '<td><nobr>'.$title.'</td>';
+                '<td valign="top"><nobr>'.$title.'</nobr></td>';
         } else {
             $tablerow .= 
-                '<td><nobr>'.
+                '<td valign="top"><nobr>'.
                 '<a href="'.$src.'">'.$title.'</a>'.
                 '</nobr></td>';
         }
-        $tablerow .= '<td><nobr>'.$timestamp.'</nobr></td>';
+        $tablerow .= '<td valign="top"><nobr>'.$timestamp.'</nobr></td>';
         if ($mode eq 'full_class') {
-            $tablerow.='<td>'.$student.'</td>';
+            $tablerow.='<td valign="top">'.$student.'</td>';
         }
         $tablerow .= 
-            '<td>'.$action.'</td>'.
+            '<td valign="top">'.$action.'</td>'.
 #            '<td>'.$machine.'</td>'.
-            '<td>'.$values.'</td>'.
+            '<td valign="top">'.$values.'</td>'.
             '</tr>';
         $r->print($tablerow.$/);
     }
@@ -365,6 +366,34 @@
 
 ###################################################################
 ###################################################################
+sub display_values {
+    my ($action,$values)=@_;
+    my $result='<table>';
+    if ($action eq 'CSTORE') {
+	my %values=map {split('=',$_,-1)} split(/\&/,$values);
+	foreach my $key (sort(keys(%values))) {
+	    $result.='<tr><td align="right">'.
+		&Apache::lonnet::unescape($key).
+		'</td><td>=</td><td align="left">'.
+		&Apache::lonnet::unescape($values{$key}).'</td></tr>';
+	}
+	$result.='</table>';
+    } elsif ($action eq 'POST') {
+	my %values=
+	    map {split('=',&Apache::lonnet::unescape($_),-1)} split(/\&/,$values);
+	foreach my $key (sort(keys(%values))) {
+	    if ($key eq 'counter') { next; }
+	    $result.='<tr><td align="right">'.$key.'</td>'.
+		'<td>=</td><td align="left">'.$values{$key}.'</td></tr>';
+	}
+	$result.='</table>';
+    } else {
+	$result=&Apache::lonnet::unescape($values)
+    }
+    return $result;
+}
+###################################################################
+###################################################################
 sub request_data_update {
     my $command = 'prepare activity log';
     my $cid = $ENV{'request.course.id'};