");
&ssi_print_error($r);
@@ -7987,27 +8522,43 @@ SCANTRONFORM
return ''; # Why return ''? Beats me.
}
+ if (($scancode) && ($randomorder || $randompick)) {
+ my $parmresult =
+ &Apache::lonparmset::storeparm_by_symb($symb,
+ '0_examcode',2,$scancode,
+ 'string_examcode',$uname,
+ $udom);
+ }
$completedstudents{$uname}={'line'=>$line};
if ($env{'form.verifyrecord'}) {
my $lastpos = $env{'form.scantron_maxbubble'}*$scantron_config{'Qlength'};
+ if ($randompick) {
+ if ($total) {
+ $lastpos = $total*$scantron_config{'Qlength'};
+ }
+ }
+
my $studentdata = substr($line,$scantron_config{'Qstart'}-1,$lastpos);
chomp($studentdata);
$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'},
$counter,$studentdata,$partids_by_symb{$ressymb},
- \%scantron_config,\%lettdig,$numletts);
+ \%scantron_config,\%lettdig,$numletts,$randomorder,
+ $randompick,\%respnumlookup,\%startline);
$studentrecord .= $recording;
}
if ($studentrecord ne $studentdata) {
&Apache::lonxml::clear_problem_counter();
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode,
- \@resources,\%partids_by_symb,
- $bubbles_per_row) eq 'ssi_error') {
+ \@mapresources,\%partids_by_symb,
+ $bubbles_per_row,$randomorder,$randompick,
+ \%respnumlookup,\%startline)
+ eq 'ssi_error') {
$ssi_error = 0; # So end of handler error message does not trigger.
$r->print("");
&ssi_print_error($r);
@@ -8018,12 +8569,14 @@ SCANTRONFORM
}
$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'},
$counter,$studentdata,$partids_by_symb{$ressymb},
- \%scantron_config,\%lettdig,$numletts);
+ \%scantron_config,\%lettdig,$numletts,
+ $randomorder,$randompick,\%respnumlookup,
+ \%startline);
$studentrecord .= $recording;
}
if ($studentrecord ne $studentdata) {
@@ -8072,7 +8625,8 @@ SCANTRONFORM
}
sub graders_resources_pass {
- my ($resources,$grader_partids_by_symb,$grader_randomlists_by_symb) = @_;
+ my ($resources,$grader_partids_by_symb,$grader_randomlists_by_symb,
+ $bubbles_per_row) = @_;
if ((ref($resources) eq 'ARRAY') && (ref($grader_partids_by_symb)) &&
(ref($grader_randomlists_by_symb) eq 'HASH')) {
foreach my $resource (@{$resources}) {
@@ -8093,8 +8647,67 @@ sub graders_resources_pass {
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 and/or randompick 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,$symb_to_resource,$orderedforcode) = @_;
+ my @mapresources;
+ unless ((ref($master_seq) eq 'ARRAY') && (ref($symb_to_resource) eq 'HASH')) {
+ return @mapresources;
+ }
+ if ($scancode) {
+ if ((ref($orderedforcode) eq 'HASH') && (ref($orderedforcode->{$scancode}) eq 'ARRAY')) {
+ @mapresources = @{$orderedforcode->{$scancode}};
+ } else {
+ $env{'form.CODE'} = $scancode;
+ my $actual_seq =
+ &Apache::lonprintout::master_seq_to_person_seq($mapurl,
+ $master_seq,
+ $user,$scancode,1);
+ if (ref($actual_seq) eq 'ARRAY') {
+ @mapresources = map { $symb_to_resource->{$_}; } @{$actual_seq};
+ if (ref($orderedforcode) eq 'HASH') {
+ if (@mapresources > 0) {
+ $orderedforcode->{$scancode} = \@mapresources;
+ }
+ }
+ }
+ delete($env{'form.CODE'});
+ }
+ } else {
+ my $actual_seq =
+ &Apache::lonprintout::master_seq_to_person_seq($mapurl,
+ $master_seq,
+ $user,undef,1);
+ 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) = @_;
+ my ($r,$uname,$udom,$scan_record,$scancode,$resources,$parts,$bubbles_per_row,
+ $randomorder,$randompick,$respnumlookup,$startline) = @_;
+ my $uselookup = 0;
+ if (($randomorder || $randompick) && (ref($respnumlookup) eq 'HASH') &&
+ (ref($startline) eq 'HASH')) {
+ $uselookup = 1;
+ }
+
if (ref($resources) eq 'ARRAY') {
my $count = 0;
foreach my $resource (@{$resources}) {
@@ -8110,11 +8723,18 @@ sub grade_student_bubbles {
if ($bubbles_per_row ne '') {
$form{'bubbles_per_row'} = $bubbles_per_row;
}
+ if ($env{'form.scantron_lastbubblepoints'} ne '') {
+ $form{'scantron_lastbubblepoints'} = $env{'form.scantron_lastbubblepoints'};
+ }
if (ref($parts) eq 'HASH') {
if (ref($parts->{$ressymb}) eq 'ARRAY') {
foreach my $part (@{$parts->{$ressymb}}) {
- $form{'scantron_questnum_start.'.$part} =
- 1+$env{'form.scantron.first_bubble_line.'.$count};
+ if ($uselookup) {
+ $form{'scantron_questnum_start.'.$part} = $startline->{$count} + 1;
+ } else {
+ $form{'scantron_questnum_start.'.$part} =
+ 1+$env{'form.scantron.first_bubble_line.'.$count};
+ }
$count++;
}
}
@@ -8136,8 +8756,9 @@ sub scantron_upload_scantron_data {
'domainid',
'coursename',$dom);
my $syllabuslink = '
- '.&mt('The requested file name was invalid.').'
+ '.&mt('The requested filename was invalid.').'
');
- $r->print(&show_grading_menu_form(&get_symb($r,1)));
+ $r->print(&show_grading_menu_form($symb));
return;
}
my $orig='/uploaded/'.$cdom.'/'.$cname.'/scantron_orig_'.$file;
@@ -8375,7 +8997,7 @@ sub scantron_download_scantron_data {
'