[LON-CAPA-cvs] cvs: modules /albertel course_info.pl
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 17 Jan 2006 19:59:30 -0000
albertel Tue Jan 17 14:59:30 2006 EDT
Modified files:
/modules/albertel course_info.pl
Log:
- count role acquires rather than login in events
Index: modules/albertel/course_info.pl
diff -u modules/albertel/course_info.pl:1.1 modules/albertel/course_info.pl:1.2
--- modules/albertel/course_info.pl:1.1 Mon Nov 14 00:42:17 2005
+++ modules/albertel/course_info.pl Tue Jan 17 14:59:30 2006
@@ -1,5 +1,5 @@
use strict;
-#use Apache2::compat;
+use Apache2::compat;
use strict;
use lib '/home/httpd/lib/perl';
use IO::File;
@@ -129,6 +129,7 @@
my $classlist = ($ver =~ /^2\.0/)
? &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 $numsections = &Apache::loncommon::get_sections($cdom,$cnum,\%sections);
&log("Total \# of students: ".scalar(keys(%{ $classlist })));
@@ -158,21 +159,32 @@
my %login_cache;
sub num_logins {
my ($cdom,$cnum,$udom,$uname) = @_;
- if (exists($login_cache{"$udom:$uname"})) {
- return $login_cache{"$udom:$uname"};
+ my $cachekey = join(':',$udom,$uname,$cdom,$cnum);
+ if (exists($login_cache{$cachekey})) {
+ &log("$uname\@$udom cached");
+ return $login_cache{$cachekey};
}
- my $logins = 0;
+ my ($logins,$accrole);
my $userdir = &Apache::loncommon::propath($udom,$uname);
open(ACTIVITY,"<$userdir/activity.log");
# &log("<$userdir/activity.log");
while (my $line=<ACTIVITY>) {
+ chomp($line);
my ($date,$mahine,$action) = split(':',$line);
+ if ($action =~ /Role/) {
+ $action =~ s/Role //;
+ my ($role,$scope) = split(/\./,$action);
+ my (undef,$scopedom,$scopenum,$scopesec) = split(m|/|,$scope);
+ if ($scopedom eq $cdom && $scopenum eq $cnum) {
+ $accrole++;
+ }
+ }
if ($action =~ /Login/) {
$logins++;
}
}
- $login_cache{"$udom:$uname"}=$logins;
- return $logins;
+ $login_cache{$cachekey}=$accrole;
+ return $accrole;
}
sub log_adv_users {