('.
+ &mt('Compose message to student'.(scalar(@$col_fullnames) >= 1 ? 's' : '')).' ('.
&mt('incl. grades').' )'.
- ' dir_config('lonIconsURL').
'/mailbkgrd.gif" width="14" height="10" name="mailicon'.$counter.'" />'."\n".
' ('.
&mt('Message will be sent when you click on Save & Next below.').")\n";
@@ -2598,10 +2627,187 @@ sub keywords_highlight {
return $string;
}
+# For Tasks provide a mechanism to display previous version for one specific student
+
+sub show_previous_task_version {
+ my ($request,$symb) = @_;
+ if ($symb eq '') {
+ $request->print("Unable to handle ambiguous references.");
+
+ return '';
+ }
+ my ($uname,$udom) = ($env{'form.student'},$env{'form.userdom'});
+ my $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'});
+ if (!&canview($usec)) {
+ $request->print('Unable to view previous version for requested student.('.
+ $uname.':'.$udom.' in section '.$usec.' in course id '.
+ $env{'request.course.id'}.') ');
+ return;
+ }
+ my $mode = 'both';
+ my $isTask = ($symb =~/\.task$/);
+ if ($isTask) {
+ if ($env{'form.previousversion'} =~ /^\d+$/) {
+ if ($env{'form.fullname'} eq '') {
+ $env{'form.fullname'} =
+ &Apache::loncommon::plainname($uname,$udom,'lastname');
+ }
+ my $probtitle=&Apache::lonnet::gettitle($symb);
+ $request->print("\n\n".
+ ''.
+ '
'.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).
+ ' '."\n");
+ &Apache::lonxml::clear_problem_counter();
+ $request->print(&show_problem($request,$symb,$uname,$udom,1,1,$mode,
+ {'previousversion' => $env{'form.previousversion'} }));
+ $request->print("\n");
+ }
+ }
+ return;
+}
+
+sub choose_task_version_form {
+ my ($symb,$uname,$udom,$nomenu) = @_;
+ my $isTask = ($symb =~/\.task$/);
+ my ($current,$version,$result,$js,$displayed,$rowtitle);
+ if ($isTask) {
+ my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
+ $udom,$uname);
+ if (($record{'resource.0.version'} eq '') ||
+ ($record{'resource.0.version'} < 2)) {
+ return ($record{'resource.0.version'},
+ $record{'resource.0.version'},$result,$js);
+ } else {
+ $current = $record{'resource.0.version'};
+ }
+ if ($env{'form.previousversion'}) {
+ $displayed = $env{'form.previousversion'};
+ $rowtitle = &mt('Choose another version:')
+ } else {
+ $displayed = $current;
+ $rowtitle = &mt('Show earlier version:');
+ }
+ $result = '';
+ my $list;
+ my $numversions = 0;
+ for (my $i=1; $i<=$record{'resource.0.version'}; $i++) {
+ if ($i == $current) {
+ if (!$env{'form.previousversion'} || $nomenu) {
+ next;
+ } else {
+ $list .= '
'.&mt('Current').' '."\n";
+ $numversions ++;
+ }
+ } elsif (defined($record{'resource.'.$i.'.0.status'})) {
+ unless ($i == $env{'form.previousversion'}) {
+ $numversions ++;
+ }
+ $list .= '
'.$i.' '."\n";
+ }
+ }
+ if ($numversions) {
+ $symb = &HTML::Entities::encode($symb,'<>"&');
+ $result .=
+ '
';
+ $js = &previous_display_javascript($nomenu,$current);
+ } elsif ($displayed && $nomenu) {
+ $result .= '
'.&mt('Close window').' ';
+ } else {
+ $result .= &mt('No previous versions to show for this student');
+ }
+ $result .= '
';
+ }
+ return ($current,$displayed,$result,$js);
+}
+
+sub previous_display_javascript {
+ my ($nomenu,$current) = @_;
+ my $js = <<"JSONE";
+
+ENDJS
+
+}
+
#--- Called from submission routine
sub processHandGrade {
my ($request) = shift;
- my $symb = &get_symb($request);
+ my ($symb) = &get_symb($request);
my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb);
my $button = $env{'form.gradeOpt'};
my $ngrade = $env{'form.NCT'};
@@ -3010,7 +3216,7 @@ sub handback_files {
&Apache::lonnet::dirlist($portfolio_root.$portfolio_path,
$domain,$stuname,$getpropath);
my $version = &get_next_version($answer_name,$answer_ext,$dir_list);
- # fix file name
+ # fix filename
my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/);
my $result=&Apache::lonnet::finishuserfileupload($stuname,$domain,
$newflg.'_'.$part_resp.'_returndoc'.$counter,
@@ -3030,7 +3236,7 @@ sub handback_files {
$file_msg.=''.$save_file_name." ";
}
- $request->print(' '.&mt('[_1] will be the uploaded file name [_2]',''.$fname.' ',''.$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$counter}.' '));
+ $request->print(' '.&mt('[_1] will be the uploaded filename [_2]',''.$fname.' ',''.$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$counter}.' '));
}
}
}
@@ -3436,7 +3642,7 @@ sub viewgrades {
&Apache::lonnet::clear_EXT_cache_status();
my $result=''.&mt('Manual Grading').' ';
- $result.=''.&mt('Current Resource: [_1]',$env{'form.probTitle'}).' '."\n";
+ $result.=''.&mt('Current Resource').': '.$env{'form.probTitle'}.' '."\n";
#view individual student submission form - called using Javascript viewOneStudent
$result.=&jscriptNform($symb);
@@ -3499,8 +3705,9 @@ sub viewgrades {
$partid.'" size="4" '.'onchange="javascript:writePoint(\''.
$partid.'\','.$weight{$partid}.',\'textval\')" /> /'.
$weight{$partid}.' '.&mt('(problem weight)').''."\n";
- $line.= ''.&mt('Grade Status').': '.&mt('Grade Status').': '.
+ ' '.
' '.
''.&mt('excused').' '.
@@ -3547,8 +3754,8 @@ sub viewgrades {
my $display_part=&get_display_part($partid,$symb);
if ($display =~ /^Partial Credit Factor/) {
$result.=''.
- &mt('Score Part: [_1] (weight = [_2])',
- $display_part,$weight{$partid}).' '."\n";
+ &mt('Score Part: [_1][_2](weight = [_3])',
+ $display_part,' ',$weight{$partid}).''."\n";
next;
} else {
@@ -3669,11 +3876,11 @@ sub viewstudentgrade {
sub editgrades {
my ($request) = @_;
- my $symb=&get_symb($request);
+ my ($symb)=&get_symb($request);
my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section'));
my $title=''.&mt('Current Grade Status').' ';
- $title.=''.&mt('Current Resource: [_1]',$env{'form.probTitle'}).' '."\n";
- $title.=''.&mt('Section: [_1]',$section_display).' '."\n";
+ $title.=''.&mt('Current Resource').': '.$env{'form.probTitle'}.' '."\n";
+ $title.=''.&mt('Section:').' '.$section_display.' '."\n";
my $result= &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
@@ -4058,11 +4265,12 @@ sub csvupload_fields {
sub csvuploadmap_footer {
my ($request,$i,$keyfields) =@_;
+ my $buttontext = &mt('Assign Grades');
$request->print(<
-
+
ENDPICK
}
@@ -4206,7 +4414,7 @@ ENDPICK
}
# FIXME do a check for any duplicated user ids...
# FIXME do a check for any invalid user ids?...
- $request->print('
+ $request->print('
'."\n");
$request->print(&show_grading_menu_form($symb));
return '';
@@ -4614,8 +4822,8 @@ sub displayPage {
&Apache::loncommon::start_data_table_row().
''.$prob.
(scalar(@{$parts}) == 1 ? ''
- : ' ('.&mt('[_1]parts)',
- scalar(@{$parts}).' ')
+ : ' ('.&mt('[_1]parts',
+ scalar(@{$parts}).' ').')'
).
' ';
$studentTable.='';
@@ -4697,6 +4905,7 @@ sub displaySubByDates {
&Apache::loncommon::start_data_table_header_row().
' '.&mt('Date/Time').' '.
($isCODE?''.&mt('CODE').' ':'').
+ ($isTask?''.&mt('Version').' ':'').
''.&mt('Submission').' '.
''.&mt('Status').' '.
&Apache::loncommon::end_data_table_header_row();
@@ -4717,7 +4926,9 @@ sub displaySubByDates {
if (exists($$record{$version.':resource.0.version'})) {
$interaction = $$record{$version.':resource.0.version'};
}
-
+ if ($isTask && $env{'form.previousversion'}) {
+ next unless ($interaction == $env{'form.previousversion'});
+ }
my $where = ($isTask ? "$version:resource.$interaction"
: "$version:resource");
$studentTable.=&Apache::loncommon::start_data_table_row().
@@ -4725,6 +4936,9 @@ sub displaySubByDates {
if ($isCODE) {
$studentTable.=''.$record->{$version.':resource.CODE'}.' ';
}
+ if ($isTask) {
+ $studentTable.=''.$interaction.' ';
+ }
my @versionKeys = split(/\:/,$$record{$version.':keys'});
my @displaySub = ();
foreach my $partid (@{$parts}) {
@@ -4744,7 +4958,7 @@ sub displaySubByDates {
my ($responseId)= ($isTask ? ($matchKey=~ /^resource\.(.*?)\.\Q$partid\E\.award$/)
: ($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/));
- $displaySub[0].='';
$displaySub[0].=''.&mt('Part: [_1]',$display_part).' '
.' '
.'('.&mt('Response ID: [_1]',$responseId).')'
@@ -5016,7 +5230,7 @@ like.
Next each scanline is checked for any errors of either 'missing
bubbles' (it's an error because it may have been mis-scanned
because too light bubbling), 'double bubble' (each bubble line should
-have no more that one letter picked), invalid or duplicated CODE,
+have no more than one letter picked), invalid or duplicated CODE,
invalid student/employee ID
If the CODE option is used that determines the randomization of the
@@ -5106,6 +5320,11 @@ my %subdivided_bubble_lines; # no.
my %responsetype_per_response; # responsetype for each response
+my %masterseq_id_responsenum; # src_id (e.g., 12.3_0.11 etc.) for each
+ # numbered response. Needed when randomorder
+ # or randompick are in use. Key is ID, value
+ # is response number.
+
# Save and restore the bubble lines array to the form env.
@@ -5119,12 +5338,17 @@ sub save_bubble_lines {
$env{"form.scantron.responsetype.$line"} =
$responsetype_per_response{$line};
}
+ foreach my $resid (keys(%masterseq_id_responsenum)) {
+ my $line = $masterseq_id_responsenum{$resid};
+ $env{"form.scantron.residpart.$line"} = $resid;
+ }
}
sub restore_bubble_lines {
my $line = 0;
%bubble_lines_per_response = ();
+ %masterseq_id_responsenum = ();
while ($env{"form.scantron.bubblelines.$line"}) {
my $value = $env{"form.scantron.bubblelines.$line"};
$bubble_lines_per_response{$line} = $value;
@@ -5134,28 +5358,12 @@ sub restore_bubble_lines {
$env{"form.scantron.sub_bubblelines.$line"};
$responsetype_per_response{$line} =
$env{"form.scantron.responsetype.$line"};
+ my $id = $env{"form.scantron.residpart.$line"};
+ $masterseq_id_responsenum{$id} = $line;
$line++;
}
}
-# Given the parsed scanline, get the response for
-# 'answer' number n:
-
-sub get_response_bubbles {
- my ($parsed_line, $response) = @_;
-
- my $bubble_line = $first_bubble_line{$response-1} +1;
- my $bubble_lines= $bubble_lines_per_response{$response-1};
-
- my $selected = "";
-
- for (my $bline = 0; $bline < $bubble_lines; $bline++) {
- $selected .= $$parsed_line{"scantron.$bubble_line.answer"}.":";
- $bubble_line++;
- }
- return $selected;
-}
-
=pod
=item scantron_filenames
@@ -5485,7 +5693,7 @@ sub scantron_selectphase {
&Apache::lonpickcode::code_list($r,2);
- $r->print(' ");
&ssi_print_error($r);
@@ -7987,27 +8528,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 +8575,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 +8631,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 +8653,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 +8729,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 +8762,9 @@ sub scantron_upload_scantron_data {
'domainid',
'coursename',$dom);
my $syllabuslink = ''.&mt('Syllabus').' '.
- (' 'x2).&mt('(shows course personnel)');
- my $default_form_data=&defaultFormData(&get_symb($r,1));
+ (' 'x2).&mt('(shows course personnel)');
+ my ($symb) = &get_symb($r,1);
+ my $default_form_data=&defaultFormData($symb);
my $nofile_alert = &mt('Please use the browse button to select a file from your local directory.');
my $nocourseid_alert = &mt("Please use the 'Select Course' link to open a separate window where you can search for a course to which a file can be uploaded.");
$r->print('
@@ -8342,17 +8969,18 @@ sub valid_file {
sub scantron_download_scantron_data {
my ($r)=@_;
- my $default_form_data=&defaultFormData(&get_symb($r,1));
+ my ($symb) = &get_symb($r,1);
+ my $default_form_data=&defaultFormData($symb);
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
my $file=$env{'form.scantron_selectfile'};
if (! &valid_file($file)) {
$r->print('
- '.&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 +9003,7 @@ sub scantron_download_scantron_data {
'',' ').'
');
- $r->print(&show_grading_menu_form(&get_symb($r,1)));
+ $r->print(&show_grading_menu_form($symb));
return '';
}
@@ -8393,6 +9021,7 @@ sub checkscantron_results {
my %record;
my %scantron_config =
&Apache::grades::get_scantron_config($env{'form.scantron_format'});
+ my $bubbles_per_row = &bubblesheet_bubbles_per_row(\%scantron_config);
my ($scanlines,$scan_data)=&Apache::grades::scantron_getfile();
my $classlist=&Apache::loncoursedata::get_classlist();
my %idmap=&Apache::grades::username_to_idmap($classlist);
@@ -8402,10 +9031,20 @@ sub checkscantron_results {
return '';
}
my $map=$navmap->getResourceByUrl($sequence);
+ my ($randomorder,$randompick,@master_seq,%symb_to_resource,%grader_partids_by_symb,
+ %grader_randomlists_by_symb,%orderedforcode);
+ if (ref($map)) {
+ $randomorder=$map->randomorder();
+ $randompick=$map->randompick();
+ }
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 $nav_error = &get_master_seq(\@resources,\@master_seq,\%symb_to_resource);
+ if ($nav_error) {
+ $r->print(&navmap_errormsg());
+ return '';
+ }
+ &graders_resources_pass(\@resources,\%grader_partids_by_symb,
+ \%grader_randomlists_by_symb,$bubbles_per_row);
my ($uname,$udom);
my (%scandata,%lastname,%bylast);
$r->print('
@@ -8414,12 +9053,9 @@ sub checkscantron_results {
my @delayqueue;
my %completedstudents;
- my $count=&Apache::grades::get_todo_count($scanlines,$scan_data);
- my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Bubblesheet/Submissions Comparison Status',
- 'Progress of Bubblesheet Data/Submission Records Comparison',$count,
- 'inline',undef,'checkscantron');
- my ($username,$domain,$started);
- my $nav_error;
+ my $count=&get_todo_count($scanlines,$scan_data);
+ my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,$count);
+ my ($username,$domain,$started,%ordered);
&scantron_get_maxbubble(\$nav_error,\%scantron_config); # Need the bubble lines array to parse.
if ($nav_error) {
$r->print(&navmap_errormsg());
@@ -8444,8 +9080,8 @@ sub checkscantron_results {
my $scan_record=
&Apache::grades::scantron_parse_scanline($line,$i,\%scantron_config,
$scan_data);
- unless ($uname=&Apache::grades::scantron_find_student($scan_record,$scan_data,
- \%idmap,$i)) {
+ unless ($uname=&scantron_find_student($scan_record,$scan_data,
+ \%idmap,$i)) {
&Apache::grades::scantron_add_delay(\@delayqueue,$line,
'Unable to find a student that matches',1);
next;
@@ -8458,13 +9094,40 @@ sub checkscantron_results {
my $pid = $scan_record->{'scantron.ID'};
$lastname{$pid} = $scan_record->{'scantron.LastName'};
push(@{$bylast{$lastname{$pid}}},$pid);
+ 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;
my $lastpos = $env{'form.scantron_maxbubble'}*$scantron_config{'Qlength'};
+ my %respnumlookup=();
+ my %startline=();
+ if ($randomorder || $randompick) {
+ @mapresources =
+ &users_order($user,$scancode,$sequence,\@master_seq,\%symb_to_resource,
+ \%orderedforcode);
+ my $total = &get_respnum_lookups($sequence,$scan_data,\%idmap,$line,
+ $scan_record,\@master_seq,\%symb_to_resource,
+ \%grader_partids_by_symb,\%orderedforcode,
+ \%respnumlookup,\%startline);
+ if ($randompick && $total) {
+ $lastpos = $total*$scantron_config{'Qlength'};
+ }
+ }
$scandata{$pid} = substr($line,$scantron_config{'Qstart'}-1,$lastpos);
chomp($scandata{$pid});
$scandata{$pid} =~ s/\r$//;
- ($username,$domain)=split(/:/,$uname);
+
my $counter = -1;
- foreach my $resource (@resources) {
+ foreach my $resource (@mapresources) {
my $parts;
my $ressymb = $resource->symb();
if ((exists($grader_randomlists_by_symb{$ressymb})) ||
@@ -8479,7 +9142,9 @@ sub checkscantron_results {
($counter,my $recording) =
&verify_scantron_grading($resource,$domain,$username,$cid,$counter,
$scandata{$pid},$parts,
- \%scantron_config,\%lettdig,$numletts);
+ \%scantron_config,\%lettdig,$numletts,
+ $randomorder,$randompick,
+ \%respnumlookup,\%startline);
$record{$pid} .= $recording;
}
}
@@ -8525,7 +9190,11 @@ sub checkscantron_results {
$env{'form.scantron_maxbubble'}).
''
);
- $r->print(''.&mt('Exact matches for [quant,_1,student] .',$passed).' '.&mt('Discrepancies detected for [quant,_1,student] .',$failed).'
');
+ $r->print(''
+ .&mt('Exact matches for [_1][quant,_2,student][_3].','',$passed,' ')
+ .' '
+ .&mt('Discrepancies detected for [_1][quant,_2,student][_3].','',$failed,' ')
+ .'
');
if ($passed) {
$r->print(&mt('Students with exact correspondence between bubblesheet data and submissions are as follows:').' ');
$r->print(&Apache::loncommon::start_data_table()."\n".
@@ -8551,7 +9220,8 @@ sub checkscantron_results {
sub verify_scantron_grading {
my ($resource,$domain,$username,$cid,$counter,$scandata,$partids,
- $scantron_config,$lettdig,$numletts) = @_;
+ $scantron_config,$lettdig,$numletts,$randomorder,$randompick,
+ $respnumlookup,$startline) = @_;
my ($record,%expected,%startpos);
return ($counter,$record) if (!ref($resource));
return ($counter,$record) if (!$resource->is_problem());
@@ -8560,15 +9230,21 @@ sub verify_scantron_grading {
foreach my $part_id (@{$partids}) {
$counter ++;
$expected{$part_id} = 0;
- if ($env{"form.scantron.sub_bubblelines.$counter"}) {
- my @sub_lines = split(/,/,$env{"form.scantron.sub_bubblelines.$counter"});
+ my $respnum = $counter;
+ if ($randomorder || $randompick) {
+ $respnum = $respnumlookup->{$counter};
+ $startpos{$part_id} = $startline->{$counter} + 1;
+ } else {
+ $startpos{$part_id} = $env{"form.scantron.first_bubble_line.$counter"};
+ }
+ if ($env{"form.scantron.sub_bubblelines.$respnum"}) {
+ my @sub_lines = split(/,/,$env{"form.scantron.sub_bubblelines.$respnum"});
foreach my $item (@sub_lines) {
$expected{$part_id} += $item;
}
} else {
- $expected{$part_id} = $env{"form.scantron.bubblelines.$counter"};
+ $expected{$part_id} = $env{"form.scantron.bubblelines.$respnum"};
}
- $startpos{$part_id} = $env{"form.scantron.first_bubble_line.$counter"};
}
if ($symb) {
my %recorded;
@@ -8664,7 +9340,7 @@ sub verify_scantron_grading {
return ($counter,$record);
}
-sub letter_to_digits {
+sub letter_to_digits {
my %lettdig = (
A => 1,
B => 2,
@@ -8711,6 +9387,13 @@ sub savedState {
return \%savedState;
}
+#--- Href with symb and command ---
+
+sub href_symb_cmd {
+ my ($symb,$cmd)=@_;
+ return '/adm/grades?symb='.&HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb),'<>&"').'&command='.$cmd;
+}
+
sub grading_menu {
my ($request) = @_;
my ($symb)=&get_symb($request);
@@ -9018,6 +9701,21 @@ sub init_perm {
}
}
+sub init_old_essays {
+ my ($symb,$apath,$adom,$aname) = @_;
+ if ($symb ne '') {
+ my %essays = &Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
+ if (keys(%essays) > 0) {
+ $old_essays{$symb} = \%essays;
+ }
+ }
+ return;
+}
+
+sub reset_old_essays {
+ undef(%old_essays);
+}
+
sub gather_clicker_ids {
my %clicker_ids;
@@ -9119,7 +9817,8 @@ sub process_clicker {
my $pincorrect=&mt("Percentage points for incorrect solution");
my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype',
{'iclicker' => 'i>clicker',
- 'interwrite' => 'interwrite PRS'});
+ 'interwrite' => 'interwrite PRS',
+ 'turning' => 'Turning Technologies'});
$symb = &Apache::lonenc::check_encrypt($symb);
$result.=<
@@ -9292,6 +9991,9 @@ ENDHEADER
if ($env{'form.upfiletype'} eq 'interwrite') {
($errormsg,$number)=&interwrite_eval(\@questiontitles,\%responses);
}
+ if ($env{'form.upfiletype'} eq 'turning') {
+ ($errormsg,$number)=&turning_eval(\@questiontitles,\%responses);
+ }
$result.=' '.&mt('Found [_1] question(s)',$number).' '.
' '.
&mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses',
@@ -9346,7 +10048,7 @@ ENDHEADER
&mt('Found [_1] registered and [_2] unregistered clickers.',$student_count,$unknown_count);
if (($env{'form.gradingmechanism'} ne 'attendance') && ($env{'form.gradingmechanism'} ne 'given')) {
if ($correct_count==0) {
- $errormsg.="Found no correct answers answers for grading!";
+ $errormsg.="Found no correct answers for grading!";
} elsif ($correct_count>1) {
$result.=''.&mt("Found [_1] entries for grading!",$correct_count).' ';
}
@@ -9423,6 +10125,31 @@ sub interwrite_eval {
return ($errormsg,$number);
}
+sub turning_eval {
+ my ($questiontitles,$responses)=@_;
+ my $number=0;
+ my $errormsg='';
+ foreach my $line (split(/[\n\r]/,$env{'form.upfile'})) {
+ my %components=&Apache::loncommon::record_sep($line);
+ my @entries=map {$components{$_}} (sort(keys(%components)));
+ if ($#entries>$number) { $number=$#entries; }
+ my $id=$entries[0];
+ my @idresponses;
+ $id=~s/^[\#0]+//;
+ unless ($id) { next; }
+ for (my $idx=1;$idx<=$#entries;$idx++) {
+ $entries[$idx]=~s/\,/\;/g;
+ $entries[$idx]=~s/[^a-zA-Z0-9\.\*\-\+\;]+//g;
+ push(@idresponses,$entries[$idx]);
+ }
+ $$responses{$id}=join(',',@idresponses);
+ }
+ for (my $i=1; $i<=$number; $i++) {
+ $$questiontitles[$i]=&mt('Question [_1]',$i);
+ }
+ return ($errormsg,$number);
+}
+
sub assign_clicker_grades {
my ($r)=@_;
my ($symb)=&get_symb($r);
@@ -9496,7 +10223,7 @@ sub assign_clicker_grades {
if ($user) {
if ($users{$user}) {
$result.=''.
- &mt("More than one entry found for [_1] !",$user).
+ &mt('More than one entry found for [_1]!',''.$user.' ').
' ';
}
$users{$user}=1;
@@ -9564,6 +10291,19 @@ sub navmap_errormsg {
'';
}
+sub startpage {
+ my ($r,$symb,$crumbs,$onlyfolderflag,$nodisplayflag,$stuvcurrent,$stuvdisp,$nomenu,$js) = @_;
+ if ($nomenu) {
+ $r->print(&Apache::loncommon::start_page("Student's Version",$js,{'only_body' => '1'}));
+ } else {
+ $r->print(&Apache::loncommon::start_page('Grading',$js,
+ {'bread_crumbs' => $crumbs}));
+ }
+ unless ($nodisplayflag) {
+ $r->print(&Apache::lonhtmlcommon::resource_info_box($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp));
+ }
+}
+
sub handler {
my $request=$_[0];
&reset_caches();
@@ -9585,7 +10325,7 @@ sub handler {
$ssi_error = 0;
my $brcrum = [{href=>"/adm/grades",text=>"Grading"}];
my $start_page = &Apache::loncommon::start_page('Grading',undef,
- {'bread_crumbs' => $brcrum});
+ {'bread_crumbs' => $brcrum});
if ($symb eq '' && $command eq '') {
if ($env{'user.adv'}) {
&Apache::loncommon::content_type($request,'text/html');
@@ -9618,6 +10358,7 @@ sub handler {
&init_perm();
if (!%perm) {
$request->internal_redirect('/adm/quickgrades');
+ return OK;
} else {
&Apache::loncommon::content_type($request,'text/html');
$request->send_http_header;
@@ -9638,9 +10379,33 @@ sub handler {
}
&Apache::loncommon::content_type($request,'text/html');
$request->send_http_header;
- $request->print($start_page);
+ unless ((($command eq 'submission' || $command eq 'versionsub')) && ($perm{'vgr'})) {
+ $request->print($start_page);
+ }
if ($command eq 'submission' && $perm{'vgr'}) {
+ my ($stuvcurrent,$stuvdisp,$versionform,$js);
+ if (($env{'form.student'} ne '') && ($env{'form.userdom'} ne '')) {
+ ($stuvcurrent,$stuvdisp,$versionform,$js) =
+ &choose_task_version_form($symb,$env{'form.student'},
+ $env{'form.userdom'});
+ }
+ &startpage($request,$symb,[{href=>"", text=>"Student Submissions"}],undef,undef,$stuvcurrent,$stuvdisp,undef,$js);
+ if ($versionform) {
+ $request->print($versionform);
+ }
+ $request->print(' ');
($env{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0));
+ } elsif ($command eq 'versionsub' && $perm{'vgr'}) {
+ my ($stuvcurrent,$stuvdisp,$versionform,$js) =
+ &choose_task_version_form($symb,$env{'form.student'},
+ $env{'form.userdom'},
+ $env{'form.inhibitmenu'});
+ &startpage($request,$symb,[{href=>"", text=>"Previous Student Version"}],undef,undef,$stuvcurrent,$stuvdisp,$env{'form.inhibitmenu'},$js);
+ if ($versionform) {
+ $request->print($versionform);
+ }
+ $request->print(' ');
+ $request->print(&show_previous_task_version($request,$symb));
} elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) {
&pickStudentPage($request);
} elsif ($command eq 'displayPage' && $perm{'vgr'}) {
@@ -9811,6 +10576,16 @@ ssi_with_retries()
- missingbubble - array ref of the bubble lines that have missing
bubble errors
+ $randomorder - True if exam folder has randomorder set
+ $randompick - True if exam folder has randompick set
+ $respnumlookup - Reference to HASH mapping question numbers in bubble lines
+ for current line to question number used for same question
+ in "Master Seqence" (as seen by Course Coordinator).
+ $startline - Reference to hash where key is question number (0 is first)
+ and value is number of first bubble line for current student
+ or code-based randompick and/or randomorder.
+
+
=item scantron_get_maxbubble() :
Arguments:
@@ -9831,7 +10606,7 @@ ssi_with_retries()
$env{'form.scantron.bubble_lines.n'},
$env{'form.scantron.first_bubble_line.n'} and
$env{"form.scantron.sub_bubblelines.n"}
- which are the total number of bubble, lines, the number of bubble
+ which are the total number of bubble lines, the number of bubble
lines for response n and number of the first bubble line for response n,
and a comma separated list of numbers of bubble lines for sub-questions
(for optionresponse, matchresponse, and rankresponse items), for response n.