[LON-CAPA-cvs] cvs: loncom /homework grades.pm
raeburn
raeburn at source.lon-capa.org
Sun Dec 9 20:13:09 EST 2012
raeburn Mon Dec 10 01:13:09 2012 EDT
Modified files:
/loncom/homework grades.pm
Log:
- Bubblesheet grading CODEd exams -- randomorder for folder being graded
now supported.
- If randomorder parameter set, seed used for ordering of resources is
set in lonnet::rndseed() based on CODE.
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.676 loncom/homework/grades.pm:1.677
--- loncom/homework/grades.pm:1.676 Fri Nov 9 15:31:42 2012
+++ loncom/homework/grades.pm Mon Dec 10 01:13:08 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.676 2012/11/09 15:31:42 goltermann Exp $
+# $Id: grades.pm,v 1.677 2012/12/10 01:13:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7914,15 +7914,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;
@@ -8006,10 +8012,38 @@
'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 && $scancode) {
+ unless (ref($ordered{$scancode}) eq 'ARRAY') {
+ $env{'form.CODE'} = $scancode;
+ my $actual_seq =
+ &Apache::lonprintout::master_seq_to_person_seq($sequence,
+ \@master_seq,
+ $user,$scancode);
+ if (ref($actual_seq) eq 'ARRAY') {
+ @{$ordered{$scancode}} =
+ map { $symb_to_resource{$_}; } @{$actual_seq};
+ }
+ delete($env{'form.CODE'});
+ }
+ if (ref($ordered{$scancode}) eq 'ARRAY') {
+ @mapresources = @{$ordered{$scancode}};
+ }
+ }
my (%partids_by_symb,$res_error);
- foreach my $resource (@resources) {
+ foreach my $resource (@mapresources) {
my $ressymb;
if (ref($resource)) {
$ressymb = $resource->symb();
@@ -8041,16 +8075,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>");
@@ -8067,7 +8093,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'},
@@ -8078,7 +8104,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>");
@@ -8089,7 +8115,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'},
@@ -8165,8 +8191,7 @@
}
sub grade_student_bubbles {
- my ($r,$uname,$udom,$scan_record,$scancode,$resources,$parts,$bubbles_per_row) = @_;
-# Walk folder as student here to get resources in order student sees.
+ my ($r,$uname,$udom,$scan_record,$scancode,$resources,$parts,$bubbles_per_row) = @_;
if (ref($resources) eq 'ARRAY') {
my $count = 0;
foreach my $resource (@{$resources}) {
@@ -8470,11 +8495,14 @@
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);
&graders_resources_pass(\@resources,\%grader_partids_by_symb,
\%grader_randomlists_by_symb,$bubbles_per_row);
-
my ($uname,$udom);
my (%scandata,%lastname,%bylast);
$r->print('
@@ -8528,8 +8556,31 @@
chomp($scandata{$pid});
$scandata{$pid} =~ s/\r$//;
($username,$domain)=split(/:/,$uname);
+
+ my ($scancode,%ordered);
+ 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 && $scancode) {
+ unless (ref($ordered{$scancode}) eq 'ARRAY') {
+ $env{'form.CODE'} = $scancode;
+ $ordered{$scancode} =
+ &Apache::lonprintout::master_seq_to_person_seq($sequence,
+ \@resources,
+ $uname,$scancode);
+ delete($env{'form.CODE'});
+ }
+ if (ref($ordered{$scancode}) eq 'ARRAY') {
+ @mapresources = @{$ordered{$scancode}};
+ }
+ }
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