[LON-CAPA-cvs] cvs: loncom /homework grades.pm structuretags.pm
raeburn
raeburn@source.lon-capa.org
Mon, 09 Mar 2009 21:24:12 -0000
This is a MIME encoded message
--raeburn1236633852
Content-Type: text/plain
raeburn Mon Mar 9 21:24:12 2009 EDT
Modified files:
/loncom/homework grades.pm structuretags.pm
Log:
Efficiency changes.
- Scantron grading and Standalone verification.
- Eliminate calls to &scantron_partids_tograde() to get responseIDs for each student if the resource does not contain randomlist.
- Use partIDs/responseIDs retrieved (once) for current grader.
- Additional hash to cache.
%analyze_cache_formkeys - additional form items used when record stored in %analyze_cache for a given key.
- Additional arg for &get_analyze().
$add_to_hash - can be a ref to a HASH of additional form items to include in the ssi call.
- &scantron_partids_tograde() includes 'check_parts_withrandomlist' as additional arg
- so structuretags::start_randomlist() will add parts to $Apache::lonhomework::analyze{'parts_withrandomlist'} an arrayref if the resource contains a randomlist.
--raeburn1236633852
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090309212412.txt"
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.556 loncom/homework/grades.pm:1.557
--- loncom/homework/grades.pm:1.556 Mon Mar 9 01:58:48 2009
+++ loncom/homework/grades.pm Mon Mar 9 21:24:12 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.556 2009/03/09 01:58:48 weissno Exp $
+# $Id: grades.pm,v 1.557 2009/03/09 21:24:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -234,28 +234,54 @@
{
my %analyze_cache;
+ my %analyze_cache_formkeys;
sub reset_analyze_cache {
undef(%analyze_cache);
+ undef(%analyze_cache_formkeys);
}
sub get_analyze {
- my ($symb,$uname,$udom,$no_increment)=@_;
+ my ($symb,$uname,$udom,$no_increment,$add_to_hash)=@_;
my $key = "$symb\0$uname\0$udom";
- return $analyze_cache{$key} if (exists($analyze_cache{$key}));
+ if (exists($analyze_cache{$key})) {
+ my $getupdate = 0;
+ if (ref($add_to_hash) eq 'HASH') {
+ foreach my $item (keys(%{$add_to_hash})) {
+ if (ref($analyze_cache_formkeys{$key}) eq 'HASH') {
+ if (!exists($analyze_cache_formkeys{$key}{$item})) {
+ $getupdate = 1;
+ last;
+ }
+ } else {
+ $getupdate = 1;
+ }
+ }
+ }
+ if (!$getupdate) {
+ return $analyze_cache{$key};
+ }
+ }
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
$url=&Apache::lonnet::clutter($url);
- my $subresult=&ssi_with_retries($url, $ssi_retries,
- ('grade_target' => 'analyze',
- 'grade_domain' => $udom,
- 'grade_symb' => $symb,
- 'grade_courseid' =>
- $env{'request.course.id'},
- 'grade_username' => $uname,
- 'grade_noincrement' => $no_increment));
+ my %form = ('grade_target' => 'analyze',
+ 'grade_domain' => $udom,
+ 'grade_symb' => $symb,
+ 'grade_courseid' => $env{'request.course.id'},
+ 'grade_username' => $uname,
+ 'grade_noincrement' => $no_increment);
+ if (ref($add_to_hash)) {
+ %form = (%form,%{$add_to_hash});
+ }
+ my $subresult=&ssi_with_retries($url, $ssi_retries,%form);
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2);
my %analyze=&Apache::lonnet::str2hash($subresult);
+ if (ref($add_to_hash) eq 'HASH') {
+ $analyze_cache_formkeys{$key} = $add_to_hash;
+ } else {
+ $analyze_cache_formkeys{$key} = {};
+ }
return $analyze_cache{$key} = \%analyze;
}
@@ -279,11 +305,15 @@
}
sub scantron_partids_tograde {
- my ($resource,$cid,$uname,$udom) = @_;
+ my ($resource,$cid,$uname,$udom,$check_for_randomlist) = @_;
my (%analysis,@parts);
if (ref($resource)) {
my $symb = $resource->symb();
- my $analyze = &get_analyze($symb,$uname,$udom);
+ my $add_to_form;
+ if ($check_for_randomlist) {
+ $add_to_form = { 'check_parts_withrandomlist' => 1,};
+ }
+ my $analyze = &get_analyze($symb,$uname,$udom,undef,$add_to_form);
if (ref($analyze) eq 'HASH') {
%analysis = %{$analyze};
}
@@ -5157,6 +5187,10 @@
'<td> '.$format_selector.' </td>'."\n".
&Apache::loncommon::end_data_table_row()."\n".
&Apache::loncommon::start_data_table_row()."\n".
+ '<td> '.&mt('Options').' </td>'."\n".
+ '<td> <label><input type="checkbox" name="scantron_options_hidden" value="ignore_hidden"/> '.&mt('Skip hidden resources').'</label></td>'.
+ &Apache::loncommon::end_data_table_row()."\n".
+ &Apache::loncommon::start_data_table_row()."\n".
'<td colspan="2">'."\n".
'<input type="hidden" name="command" value="checksubmissions" />'."\n".
'<input type="submit" value="'.&mt('Review Scantron Data and Submission Records').'" />'."\n".
@@ -7258,8 +7292,8 @@
&Apache::lonxml::clear_problem_counter();
- my $uname = $env{'form.student'};
- my $udom = $env{'form.userdom'};
+ my $uname = $env{'user.name'};
+ my $udom = $env{'user.domain'};
my $cid = $env{'request.course.id'};
my $total_lines = 0;
%bubble_lines_per_response = ();
@@ -7404,7 +7438,23 @@
my $navmap=Apache::lonnavmaps::navmap->new();
my $map=$navmap->getResourceByUrl($sequence);
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
-# $r->print("geto ".scalar(@resources)."<br />");
+ my (%grader_partids_by_symb,%grader_randomlists_by_symb);
+ &graders_resources_pass(\@resources,\%grader_partids_by_symb,
+ \%grader_randomlists_by_symb);
+ foreach my $resource (@resources) {
+ my $ressymb = $resource->symb();
+ my ($analysis,$parts) =
+ &scantron_partids_tograde($resource,$env{'request.course.id'},
+ $env{'user.name'},$env{'user.domain'},1);
+ $grader_partids_by_symb{$ressymb} = $parts;
+ if (ref($analysis) eq 'HASH') {
+ if (ref($analysis->{'parts_withrandomlist'}) eq 'ARRAY') {
+ $grader_randomlists_by_symb{$ressymb} =
+ $analysis->{'parts_withrandomlist'};
+ }
+ }
+ }
+
my ($uname,$udom);
my $result= <<SCANTRONFORM;
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload">
@@ -7472,8 +7522,14 @@
my %partids_by_symb;
foreach my $resource (@resources) {
my $ressymb = $resource->symb();
- my ($analysis,$parts) =
- &scantron_partids_tograde($resource,$env{'request.course.id'},$uname,$udom); $partids_by_symb{$ressymb} = $parts;
+ if ((exists($grader_randomlists_by_symb{$ressymb})) ||
+ (ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) {
+ my ($analysis,$parts) =
+ &scantron_partids_tograde($resource,$env{'request.course.id'},$uname,$udom);
+ $partids_by_symb{$ressymb} = $parts;
+ } else {
+ $partids_by_symb{$ressymb} = $grader_partids_by_symb{$ressymb};
+ }
}
&Apache::lonxml::clear_problem_counter();
@@ -7584,6 +7640,27 @@
return '';
}
+sub graders_resources_pass {
+ my ($resources,$grader_partids_by_symb,$grader_randomlists_by_symb) = @_;
+ if ((ref($resources) eq 'ARRAY') && (ref($grader_partids_by_symb)) &&
+ (ref($grader_randomlists_by_symb) eq 'HASH')) {
+ foreach my $resource (@{$resources}) {
+ my $ressymb = $resource->symb();
+ my ($analysis,$parts) =
+ &scantron_partids_tograde($resource,$env{'request.course.id'},
+ $env{'user.name'},$env{'user.domain'},1);
+ $grader_partids_by_symb->{$ressymb} = $parts;
+ if (ref($analysis) eq 'HASH') {
+ if (ref($analysis->{'parts_withrandomlist'}) eq 'ARRAY') {
+ $grader_randomlists_by_symb->{$ressymb} =
+ $analysis->{'parts_withrandomlist'};
+ }
+ }
+ }
+ }
+ return;
+}
+
sub grade_student_bubbles {
my ($r,$uname,$udom,$scan_record,$scancode,$resources,$parts) = @_;
if (ref($resources) eq 'ARRAY') {
@@ -7782,7 +7859,10 @@
my %idmap=&Apache::grades::username_to_idmap($classlist);
my $navmap=Apache::lonnavmaps::navmap->new();
my $map=$navmap->getResourceByUrl($sequence);
- my @resources=$navmap->retrieveResources($map,undef,1,0);
+ my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
+ my (%grader_partids_by_symb,%grader_randomlists_by_symb);
+ &graders_resources_pass(\@resources,\%grader_partids_by_symb, \%grader_randomlists_by_symb);
+
my ($uname,$udom);
my (%scandata,%lastname,%bylast);
$r->print('
@@ -7797,7 +7877,7 @@
'inline',undef,'checkscantron');
my ($username,$domain,$started);
- &Apache::grades::scantron_get_maxbubble(); # Need the bubble lines array to parse.
+ &scantron_get_maxbubble(); # Need the bubble lines array to parse.
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,
'Processing first student');
@@ -7838,9 +7918,15 @@
($username,$domain)=split(/:/,$uname);
my $counter = -1;
foreach my $resource (@resources) {
+ my $parts;
my $ressymb = $resource->symb();
- my ($analysis,$parts) =
- &scantron_partids_tograde($resource,$env{'request.course.id'},$username,$domain);
+ if ((exists($grader_randomlists_by_symb{$ressymb})) ||
+ (ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) {
+ (my $analysis,$parts) =
+ &scantron_partids_tograde($resource,$env{'request.course.id'},$username,$domain);
+ } else {
+ $parts = $grader_partids_by_symb{$ressymb};
+ }
($counter,my $recording) =
&verify_scantron_grading($resource,$domain,$username,$cid,$counter,
$scandata{$pid},$parts,
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.438 loncom/homework/structuretags.pm:1.439
--- loncom/homework/structuretags.pm:1.438 Thu Dec 11 11:02:21 2008
+++ loncom/homework/structuretags.pm Mon Mar 9 21:24:12 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.438 2008/12/11 11:02:21 bisitz Exp $
+# $Id: structuretags.pm,v 1.439 2009/03/09 21:24:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1599,6 +1599,20 @@
my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval);
$showarg--;
if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; }
+ if (($target eq 'analyze') && ($env{'form.check_parts_withrandomlist'})) {
+ my @currlist;
+ my $part = $Apache::inputtags::part;
+ if ($part ne '') {
+ if (ref($Apache::lonhomework::analyze{'parts_withrandomlist'}) eq 'ARRAY') {
+ my @currlist = @{$Apache::lonhomework::analyze{'parts_withrandomlist'}};
+ if (!(grep(/^\Q$part\E$/,@currlist))) {
+ push(@{$Apache::lonhomework::analyze{'parts_withrandomlist'}},$part);
+ }
+ } else {
+ push(@{$Apache::lonhomework::analyze{'parts_withrandomlist'}},$part);
+ }
+ }
+ }
for(0 .. $show) {
$bodytext .= "$randomlist[ $idx_arr[$_] ]";
}
--raeburn1236633852--