[LON-CAPA-cvs] cvs: modules /albertel course_info.pl
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 27 Jun 2007 01:21:55 -0000
albertel Tue Jun 26 21:21:55 2007 EDT
Modified files:
/modules/albertel course_info.pl
Log:
- trying to make the try count code faster
Index: modules/albertel/course_info.pl
diff -u modules/albertel/course_info.pl:1.10 modules/albertel/course_info.pl:1.11
--- modules/albertel/course_info.pl:1.10 Tue Jun 26 19:57:25 2007
+++ modules/albertel/course_info.pl Tue Jun 26 21:21:53 2007
@@ -25,7 +25,7 @@
"domain=s" => \$domain,
"domainskip=s" => \$domain_skip,
"skiptries" => \$skip_tries,
- "help" => \$help,);
+ "help" => \$help);
if ($help) {
print <<END;
@@ -63,13 +63,13 @@
&logfile("output/$year/$year.$dom.info");
&log("\n\n$dom\n");
&increaselog();
- if ($since <100) {
- $since = time()-$since;
- } else {
- $since = 1;
+ my $search_since = 1;
+ if ($since) {
+ $search_since = time()-$since;
}
my %courses =
- &Apache::lonnet::courseiddump($dom,'.',$since,'.','.','.',1,\@hostids,'.',1);
+ &Apache::lonnet::courseiddump($dom,'.',$search_since,'.','.',
+ '.',1,\@hostids,'.',1);
my $course_count=0;
foreach my $key (sort
{
@@ -141,6 +141,7 @@
'External' => '/wrapper/ext/',
'Instructor Info' => '/aboutme',
'Image' => '\.(jpg|gif|png|jpeg)',
+ 'Movie' => '\.(mpg|mpeg|avi|mov$',
);
foreach my $item (keys(%{ $hash })) {
@@ -151,6 +152,8 @@
}
my $cur_item=0;
my $total_tries=0;
+ my $do_tries=0;
+ my %tries_on;
foreach my $item (keys(%{ $hash })) {
if ($item !~ /^src_/) { next; }
my $src = $hash->{$item};
@@ -168,24 +171,35 @@
push(@others,$src);
}
if ($src =~ /\.(problem|exam|survey)/) {
+ $do_tries = !$skip_tries;
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);
+ $tries_on{$symb}=0;
+ &status(0," did ".&Apache::lonnet::gettitle($symb));
+ }
+ &status(1,"$cur_item of $items ($total_tries)");
+ }
+ my $cur_user=0;
+ my $total_users = scalar(keys(%{ $classlist }));
+ if ($do_tries) {
+ foreach my $user (keys(%{ $classlist })) {
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)));
+ $cur_user++;
+ my ($uname,$udom) = split(':',$user);
+ my %info =&Apache::lonnet::currentdump($cdom.'_'.$cnum,$udom,$uname);
+ foreach my $symb (keys(%info)) {
+ next if (!exists($tries_on{$symb}));
+ my @attempt_keys =
+ grep(/^resource\.[^\.]+\.tries/,(keys(%{ $info{$symb} })));
foreach my $key (@attempt_keys) {
- $tries+=$grades{$key};
+ $tries+=$info{$symb}{$key};
}
}
- &status(0,"$tries on ".&Apache::lonnet::gettitle($symb));
+ &status(0,"$tries by $user ");
$total_tries += $tries;
- &status(1,"$cur_item of $items ($total_tries)");
+ &status(1,"$cur_user of $total_users ($total_tries)");
}
}
&status(0);
@@ -234,7 +248,7 @@
my $startcol = &Apache::loncoursedata::CL_START();
my $endcol = &Apache::loncoursedata::CL_END();
&log("Total \# of students: ".scalar(keys(%{ $classlist })));
- &log("Section list: ".join(', ',keys(%sections)));
+ &log("Section list: ".join(', ',sort(keys(%sections))));
&increaselog();
foreach my $section (sort(keys(%sections))) {
my $cl_section = $section;
@@ -244,7 +258,7 @@
&status(1," user $section ");
&status(0," user $user ");
if ($classlist->{$user}[$seccol] ne $cl_section) { next; }
- &status(1," user $section ");
+ &status(1," section $section ");
&status(0," user $user ");
my $act_key;
if ($classlist->{$user}[$startcol]) {