[LON-CAPA-cvs] cvs: modules /albertel course_info.pl

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 19 Jan 2006 17:51:01 -0000


albertel		Thu Jan 19 12:51:01 2006 EDT

  Modified files:              
    /modules/albertel	course_info.pl 
  Log:
  - addin start/end times summariztion of students
  
  
Index: modules/albertel/course_info.pl
diff -u modules/albertel/course_info.pl:1.6 modules/albertel/course_info.pl:1.7
--- modules/albertel/course_info.pl:1.6	Thu Jan 19 09:04:57 2006
+++ modules/albertel/course_info.pl	Thu Jan 19 12:50:59 2006
@@ -10,9 +10,12 @@
 use GDBM_File;
 use Date::Manip;
 use Getopt::Long;
+use POSIX;
 
 my $year;
-my $result = GetOptions ("year=i" => \$year,);
+my $domain = 'all';
+my $result = GetOptions ("year=i"   => \$year,
+			 "domain=s" => \$domain,);
                                
 
 my $perlvar = LONCAPA::Configuration::read_conf('loncapa.conf');
@@ -25,7 +28,11 @@
 sub main {
     my @domains = &Apache::lonnet::current_machine_domains();
     my @hostids = &Apache::lonnet::current_machine_ids();
+    my @domains_do = split(',',$domain);
     foreach my $dom (sort(@domains)) {
+	if ($domain ne 'all') {
+	    if (!grep(/\Q$dom\E/,@domains_do)) { print("$dom isn't in @domains_do\n"); next; }
+	}
 	&logfile("output/$year/$year.$dom.info");
 	&log("\n\n$dom\n");
 	&increaselog();
@@ -176,9 +183,11 @@
 	? &Apache::loncoursedata::get_classlist($cdom.'_'.$cnum,$cdom,$cnum)
 	: &Apache::loncoursedata::get_classlist($cdom,$cnum);
     my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
-    my %sections;
+    my (%sections,%activity_count);
     my $numsections = &Apache::loncommon::get_sections($cdom,$cnum,\%sections);
-    my $seccol = &Apache::loncoursedata::CL_SECTION();
+    my $seccol   = &Apache::loncoursedata::CL_SECTION();
+    my $startcol = &Apache::loncoursedata::CL_START();
+    my $endcol   = &Apache::loncoursedata::CL_END();
     &log("Total \# of students: ".scalar(keys(%{ $classlist })));
     &increaselog();
     foreach my $section (sort(keys(%sections))) {
@@ -186,6 +195,9 @@
 	my ($active_users,$total_logins) = (0,0);
 	foreach my $user (keys(%{ $classlist })) {
 	    if ($classlist->{$user}[$seccol] ne $section) { next; }
+	    my $act_key = strftime("%F",localtime($classlist->{$user}[$startcol])).':'.
+		          strftime("%F",localtime($classlist->{$user}[$endcol]));
+	    $activity_count{$act_key}++;
 	    my ($uname,$udom) = split(':',$user);
 	    my $num_logins = &num_logins($cdom,$cnum,$udom,$uname);
 	    if ($num_logins > 2) {
@@ -197,6 +209,11 @@
 	     " -- $active_users have logged in ".
 	     ($active_users ? "$total_logins times" : q{}));
     }
+    foreach my $timespan (sort(keys(%activity_count))) {
+	my ($start,$end)=split(':',$timespan,2);
+	&log(sprintf("%4s from %6s til %6s",$activity_count{$timespan},
+	     $start,$end));
+    }
     &decreaselog();
 }