[LON-CAPA-cvs] cvs: loncom /cgi userstatus.pl

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 01 Sep 2006 10:54:10 -0000


albertel		Fri Sep  1 06:54:10 2006 EDT

  Modified files:              
    /loncom/cgi	userstatus.pl 
  Log:
  - order output by activity level then username
  - change the 'Active' calss to be activity in the last 5 minutes
  
  
Index: loncom/cgi/userstatus.pl
diff -u loncom/cgi/userstatus.pl:1.13 loncom/cgi/userstatus.pl:1.14
--- loncom/cgi/userstatus.pl:1.13	Fri Jun  2 17:36:21 2006
+++ loncom/cgi/userstatus.pl	Fri Sep  1 06:54:08 2006
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 $|=1;
 # User Status
-# $Id: userstatus.pl,v 1.13 2006/06/02 21:36:21 albertel Exp $
+# $Id: userstatus.pl,v 1.14 2006/09/01 10:54:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -48,9 +48,9 @@
     my ($since)=@_;
     my $color="#000000";
     my $userclass=$actl[0];
-    if ($since>300) { $color="#222222"; }
+    if ($since>300) { $color="#222222"; $userclass=$actl[1]; }
     if ($since>600) { $color="#444444"; }
-    if ($since>1800) { $color="#666666"; $userclass=$actl[1]; }
+    if ($since>1800) { $color="#666666"; }
     if ($since>7200) { $color="#888888"; }
     if ($since>21600) { $color="#AAAAAA"; $userclass=$actl[2]; }
     return ($color,$userclass);
@@ -78,6 +78,7 @@
 
     opendir(DIR,$$perlvar{'lonIDsDir'});
     my @allfiles=(sort(readdir(DIR)));
+    my %users;
     foreach my $filename (@allfiles) {
 	if ($filename=~/^\./) { next; }
 	if ($filename=~/^publicuser_/) { next; }
@@ -88,7 +89,7 @@
 	my $now=time;
 	my $since=$now-$mtime;
 	my $sinceacc=$now-$atime;
-	unless ($oneline || $justsummary) { print ("\n\n<hr />"); }
+	#unless ($oneline || $justsummary) { print ("\n\n<hr />"); }
 	my %userinfo;
 	($userinfo{'user.name'},undef,$userinfo{'user.domain'})=
 	    split('_',$filename);
@@ -107,8 +108,9 @@
 	    }
 	    $fh->close();
 	    if (!$justsummary) {
-		print '<font color="'.$color.'">';
-		print '<h3>'.$userinfo{'environment.lastname'}.', '.
+		$users{$userclass}{$filename} .=
+		    '<font color="'.$color.'">'.
+		    '<h3>'.$userinfo{'environment.lastname'}.', '.
 		    $userinfo{'environment.firstname'}.' '.
 		    $userinfo{'environment.middlename'}.' '.
 		    $userinfo{'environment.generation'}." (".
@@ -126,20 +128,36 @@
 		my $cid=$userinfo{'request.course.id'};
 		my $coursename= $userinfo{'course.'.$cid.'.description'}.
 		    ' ('.$cid.')';
-		if (!$justsummary) { print "<b>Course:</b> ".$coursename; }
+		if (!$justsummary) { 
+		    $users{$userclass}{$filename} .= 
+			"<b>Course:</b> ".$coursename; 
+		}
 		&add_count('Course',$coursename,$userclass);
 	    } else {
-		if (!$justsummary) { print "Not in a course."; }
+		if (!$justsummary) {
+		    $users{$userclass}{$filename} .= 
+			"Not in a course.";
+		}
 		&add_count('Course','No Course',$userclass);
 	    }
 	    if (!$justsummary) {
-		print "<br /><b>Last Transaction:</b> ".localtime($mtime).
+		$users{$userclass}{$filename} .=
+		    "<br /><b>Last Transaction:</b> ".localtime($mtime).
 		    " (".$since." secs ago) <br /><b>Last Access:</b> ".
-		    localtime($atime)." (".$sinceacc." secs ago)";
-		print ("</font>"); 
+		    localtime($atime)." (".$sinceacc." secs ago)".
+		    "</font>";
+	    }
+	}
+    }
+    if (!$oneline && !$justsummary) {
+       	foreach my $class (@actl) {
+	    print("\n\n<hr /><h1>$class</h1>");    
+	    foreach my $filename (sort(keys(%{$users{$class}}))) {
+		print("\n\n".$users{$class}{$filename}."\n\n<hr />");    
 	    }
 	}
     }
+
     closedir(DIR);
     open (LOADAVGH,"/proc/loadavg");
     my $loadavg=<LOADAVGH>;