[LON-CAPA-cvs] cvs: modules /albertel course_info.pl
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 17 Jan 2006 21:07:41 -0000
albertel Tue Jan 17 16:07:41 2006 EDT
Modified files:
/modules/albertel course_info.pl
Log:
- try to get a total count of tries on all problems in the course
Index: modules/albertel/course_info.pl
diff -u modules/albertel/course_info.pl:1.3 modules/albertel/course_info.pl:1.4
--- modules/albertel/course_info.pl:1.3 Tue Jan 17 15:23:22 2006
+++ modules/albertel/course_info.pl Tue Jan 17 16:07:38 2006
@@ -56,6 +56,8 @@
my $hash = &tie_course($cdom,$cnum);
if (!$hash) { return; }
+ my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
+
my ($items, %types, $other, @others);
my %classes = ( 'Problem' => '\.problem$',
'Exam' => '\.exam$',
@@ -76,12 +78,20 @@
'Instructor Info' => '/aboutme',
'Image' => '\.(jpg|gif|png|jpeg)',
);
-
+
foreach my $item (keys(%{ $hash })) {
if ($item !~ /^src_/) { next; }
my $src = $hash->{$item};
if ($src =~ /^\s*$/) { next; }
$items++;
+ }
+ my $cur_item=0;
+ my $total_tries=0;
+ foreach my $item (keys(%{ $hash })) {
+ if ($item !~ /^src_/) { next; }
+ my $src = $hash->{$item};
+ if ($src =~ /^\s*$/) { next; }
+ $cur_item++;
my $match;
foreach my $type (keys(%classes)) {
if ($src =~ /$classes{$type}/i) {
@@ -93,6 +103,27 @@
$other++;
push(@others,$src);
}
+ if ($src =~ /\.problem/) {
+ my ($id) = ($item=~/src_(.*)/);
+ my ($map_id,$res_id) = split(/\./,$id);
+ my $symb = &Apache::lonnet::encode_symb($hash->{'map_id_'.$map_id},
+ $res_id,$src);
+ my $tries;
+ foreach my $user (keys(%{ $classlist })) {
+ my ($uname,$udom) = split(':',$user);
+ my %grades =
+ &Apache::lonnet::restore($symb,$cdom.'_'.$cnum,$udom,$uname);
+ my @attempt_keys = grep(/^resource\.[^\.]+\.tries/,
+ (keys(%grades)));
+ foreach my $key (@attempt_keys) {
+ &log("$key");
+ $tries+=$grades{$key};
+ }
+ }
+ &status("$tries on ".&Apache::lonnet::gettitle($symb));
+ &status("$cur_item of $items");
+ $total_tries += $tries;
+ }
}
&log("Course has $items items.");
&increaselog();
@@ -148,12 +179,11 @@
$total_logins += $num_logins;
}
}
- &log("Section: $section (".$sections{$section}.")".
- " -- $active_users have logged in $total_logins times");
+ &log("Section: $section (".$sections{$section}.")".
+ " -- $active_users have logged in ".
+ ($active_users ? "$total_logins times" : q{}));
}
&decreaselog();
- foreach my $section (sort(keys(%sections))) {
-
}
my %login_cache;
@@ -240,4 +270,10 @@
print(" "x$level.$msg);
print $logfile (" "x$level.$msg);
}
+
+ sub status {
+ my $msg = join('',@_);
+ if ($msg !~ /\n/) { $msg .= "\n"; }
+ print(" "x$level.$msg);
+ }
}