[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework grades.pm
raeburn
raeburn at source.lon-capa.org
Mon Dec 10 10:00:08 EST 2012
raeburn Mon Dec 10 15:00:08 2012 EDT
Modified files: (Branch: version_2_11_X)
/loncom/homework grades.pm
Log:
- For 2.11
- Backport 1.677, 1.678.
-------------- next part --------------
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.596.2.12.2.10 loncom/homework/grades.pm:1.596.2.12.2.11
--- loncom/homework/grades.pm:1.596.2.12.2.10 Mon Dec 10 13:28:54 2012
+++ loncom/homework/grades.pm Mon Dec 10 15:00:08 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.596.2.12.2.10 2012/12/10 13:28:54 raeburn Exp $
+# $Id: grades.pm,v 1.596.2.12.2.11 2012/12/10 15:00:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -8090,15 +8090,21 @@
return '';
}
my $map=$navmap->getResourceByUrl($sequence);
+ my $randomorder;
+ if (ref($map)) {
+ $randomorder = $map->randomorder();
+ }
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
- my (%grader_partids_by_symb,%grader_randomlists_by_symb);
+ my (%grader_partids_by_symb,%grader_randomlists_by_symb,%ordered);
&graders_resources_pass(\@resources,\%grader_partids_by_symb,
\%grader_randomlists_by_symb,$bubbles_per_row);
- my $resource_error;
+ my ($resource_error,%symb_to_resource, at master_seq);
foreach my $resource (@resources) {
my $ressymb;
if (ref($resource)) {
$ressymb = $resource->symb();
+ push(@master_seq,$ressymb);
+ $symb_to_resource{$ressymb} = $resource;
} else {
$resource_error = 1;
last;
@@ -8185,10 +8191,26 @@
'Student '.$uname.' has multiple sheets',2);
next;
}
+ my $usec = $classlist->{$uname}->[&Apache::loncoursedata::CL_SECTION];
+ my $user = $uname.':'.$usec;
($uname,$udom)=split(/:/,$uname);
+ my $scancode;
+ if ((exists($scan_record->{'scantron.CODE'})) &&
+ (&Apache::lonnet::validCODE($scan_record->{'scantron.CODE'}))) {
+ $scancode = $scan_record->{'scantron.CODE'};
+ } else {
+ $scancode = '';
+ }
+
+ my @mapresources = @resources;
+ if ($randomorder) {
+ @mapresources =
+ &users_order($user,$scancode,$sequence,\@master_seq,\%ordered,
+ \%symb_to_resource);
+ }
my (%partids_by_symb,$res_error);
- foreach my $resource (@resources) {
+ foreach my $resource (@mapresources) {
my $ressymb;
if (ref($resource)) {
$ressymb = $resource->symb();
@@ -8220,16 +8242,8 @@
&scantron_putfile($scanlines,$scan_data);
}
- my $scancode;
- if ((exists($scan_record->{'scantron.CODE'})) &&
- (&Apache::lonnet::validCODE($scan_record->{'scantron.CODE'}))) {
- $scancode = $scan_record->{'scantron.CODE'};
- } else {
- $scancode = '';
- }
-
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode,
- \@resources,\%partids_by_symb,
+ \@mapresources,\%partids_by_symb,
$bubbles_per_row) eq 'ssi_error') {
$ssi_error = 0; # So end of handler error message does not trigger.
$r->print("</form>");
@@ -8247,7 +8261,7 @@
$studentdata =~ s/\r$//;
my $studentrecord = '';
my $counter = -1;
- foreach my $resource (@resources) {
+ foreach my $resource (@mapresources) {
my $ressymb = $resource->symb();
($counter,my $recording) =
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'},
@@ -8258,7 +8272,7 @@
if ($studentrecord ne $studentdata) {
&Apache::lonxml::clear_problem_counter();
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode,
- \@resources,\%partids_by_symb,
+ \@mapresources,\%partids_by_symb,
$bubbles_per_row) eq 'ssi_error') {
$ssi_error = 0; # So end of handler error message does not trigger.
$r->print("</form>");
@@ -8270,7 +8284,7 @@
}
$counter = -1;
$studentrecord = '';
- foreach my $resource (@resources) {
+ foreach my $resource (@mapresources) {
my $ressymb = $resource->symb();
($counter,my $recording) =
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'},
@@ -8346,6 +8360,53 @@
return;
}
+=pod
+
+=item users_order
+
+ Returns array of resources in current map, ordered based on either CODE,
+ if this is a CODEd exam, or based on student's identity if this is a
+ "NAMEd" exam.
+
+ Should be used when randomorder applied when the corresponding exam was
+ printed, prior to students completing bubblesheets for the version of the
+ exam the student received.
+
+=cut
+
+sub users_order {
+ my ($user,$scancode,$mapurl,$master_seq,$ordered,$symb_to_resource) = @_;
+ my @mapresources;
+ unless ((ref($ordered) eq 'HASH') && (ref($symb_to_resource) eq 'HASH')) {
+ return @mapresources;
+ }
+ if (($scancode) && (ref($ordered->{$scancode}) eq 'ARRAY')) {
+ @mapresources = @{$ordered->{$scancode}};
+ } elsif ($scancode) {
+ $env{'form.CODE'} = $scancode;
+ my $actual_seq =
+ &Apache::lonprintout::master_seq_to_person_seq($mapurl,
+ $master_seq,
+ $user,$scancode);
+ if (ref($actual_seq) eq 'ARRAY') {
+ @{$ordered->{$scancode}} =
+ map { $symb_to_resource->{$_}; } @{$actual_seq};
+ @mapresources = @{$ordered->{$scancode}};
+ }
+ delete($env{'form.CODE'});
+ } else {
+ my $actual_seq =
+ &Apache::lonprintout::master_seq_to_person_seq($mapurl,
+ $master_seq,
+ $user);
+ if (ref($actual_seq) eq 'ARRAY') {
+ @mapresources =
+ map { $symb_to_resource->{$_}; } @{$actual_seq};
+ }
+ }
+ return @mapresources;
+}
+
sub grade_student_bubbles {
my ($r,$uname,$udom,$scan_record,$scancode,$resources,$parts,$bubbles_per_row) = @_;
if (ref($resources) eq 'ARRAY') {
@@ -8661,11 +8722,21 @@
return '';
}
my $map=$navmap->getResourceByUrl($sequence);
+ my ($randomorder, at master_seq,%symb_to_resource);
+ if (ref($map)) {
+ $randomorder=$map->randomorder();
+ }
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
+ foreach my $resource (@resources) {
+ if (ref($resource)) {
+ my $ressymb = $resource->symb();
+ push(@master_seq,$ressymb);
+ $symb_to_resource{$ressymb} = $resource;
+ }
+ }
my (%grader_partids_by_symb,%grader_randomlists_by_symb);
&graders_resources_pass(\@resources,\%grader_partids_by_symb,
\%grader_randomlists_by_symb,$bubbles_per_row);
-
my ($uname,$udom);
my (%scandata,%lastname,%bylast);
$r->print('
@@ -8676,7 +8747,7 @@
my $count=&Apache::grades::get_todo_count($scanlines,$scan_data);
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,$count);
- my ($username,$domain,$started);
+ my ($username,$domain,$started,%ordered);
my $nav_error;
&scantron_get_maxbubble(\$nav_error,\%scantron_config); # Need the bubble lines array to parse.
if ($nav_error) {
@@ -8720,9 +8791,26 @@
$scandata{$pid} = substr($line,$scantron_config{'Qstart'}-1,$lastpos);
chomp($scandata{$pid});
$scandata{$pid} =~ s/\r$//;
+ my $usec = $classlist->{$uname}->[&Apache::loncoursedata::CL_SECTION];
+ my $user = $uname.':'.$usec;
($username,$domain)=split(/:/,$uname);
+
+ my $scancode;
+ if ((exists($scan_record->{'scantron.CODE'})) &&
+ (&Apache::lonnet::validCODE($scan_record->{'scantron.CODE'}))) {
+ $scancode = $scan_record->{'scantron.CODE'};
+ } else {
+ $scancode = '';
+ }
+
+ my @mapresources = @resources;
+ if ($randomorder) {
+ @mapresources =
+ &users_order($user,$scancode,$sequence,\@master_seq,\%ordered,
+ \%symb_to_resource);
+ }
my $counter = -1;
- foreach my $resource (@resources) {
+ foreach my $resource (@mapresources) {
my $parts;
my $ressymb = $resource->symb();
if ((exists($grader_randomlists_by_symb{$ressymb})) ||
More information about the LON-CAPA-cvs
mailing list