--- loncom/homework/grades.pm 2011/10/17 12:41:34 1.662 +++ loncom/homework/grades.pm 2013/08/28 04:25:14 1.704 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.662 2011/10/17 12:41:34 raeburn Exp $ +# $Id: grades.pm,v 1.704 2013/08/28 04:25:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -54,6 +54,7 @@ use POSIX qw(floor); my %perm=(); +my %old_essays=(); # These variables are used to recover from ssi errors @@ -202,6 +203,7 @@ sub get_display_part { sub reset_caches { &reset_analyze_cache(); &reset_perm(); + &reset_old_essays(); } { @@ -681,7 +683,11 @@ sub compute_points { # sub most_similar { - my ($uname,$udom,$uessay,$old_essays)=@_; + my ($uname,$udom,$symb,$uessay)=@_; + + unless ($symb) { return ''; } + + unless (ref($old_essays{$symb}) eq 'HASH') { return ''; } # ignore spaces and punctuation @@ -698,11 +704,11 @@ sub most_similar { my $scrsid=''; my $sessay=''; # go through all essays ... - foreach my $tkey (keys(%$old_essays)) { + foreach my $tkey (keys(%{$old_essays{$symb}})) { my ($tname,$tdom,$tcrsid)=map {&unescape($_)} (split(/\./,$tkey)); # ... except the same student next if (($tname eq $uname) && ($tdom eq $udom)); - my $tessay=$old_essays->{$tkey}; + my $tessay=$old_essays{$symb}{$tkey}; $tessay=~s/\W+/ /gs; # String similarity gives up if not even limit my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit); @@ -712,7 +718,7 @@ sub most_similar { $sname=$tname; $sdom=$tdom; $scrsid=$tcrsid; - $sessay=$old_essays->{$tkey}; + $sessay=$old_essays{$symb}{$tkey}; } } if ($limit>0.6) { @@ -730,7 +736,7 @@ sub most_similar { sub initialverifyreceipt { my ($request,$symb) = @_; &commonJSfunctions($request); - return '
'. &keywords_highlight($oessay). '
' + .&mt('Unable to accept last correction, an error occurred: [_1]', + $errmsg) + .'
@@ -6234,9 +6586,9 @@ sub scantron_warning_screen { '.&mt('Sequence to be Graded:').''.$title.' '.&mt('Data File that will be used:').''.$env{'form.scantron_selectfile'}.' -'.$CODElist.' +'.$CODElist.$lastbubblepoints.' - '.&mt('If this information is correct, please click on \'[_1]\'.',&mt($button_text)).' + '.&mt("If this information is correct, please click on '[_1]'.",&mt($button_text)).' '.&mt('If something is incorrect, please return to [_1]Grade/Manage/Review Bubblesheets[_2] to start over.','','').' @@ -6272,8 +6624,9 @@ sub scantron_do_warning { } } else { my $warning=&scantron_warning_screen('Grading: Validate Records',$symb); + my $bubbledbyhand=&hand_bubble_option(); $r->print(' -'.$warning.' +'.$warning.$bubbledbyhand.' '); @@ -6315,9 +6668,11 @@ SCANTRONFORM ''."\n"; $chunk .= ''."\n"; + $chunk .= + ''."\n"; $result .= $chunk; $line++; - } + } return $result; } @@ -6338,7 +6693,7 @@ sub scantron_validate_file { if (!$symb) {return '';} my $default_form_data=&defaultFormData($symb); - # do the detection of only doing skipped records first befroe we delete + # do the detection of only doing skipped records first before we delete # them when doing the corrections reset if ($env{'form.scantron_options_redo'} ne 'redo_skipped_ready') { &reset_skipping_status(); @@ -6369,6 +6724,9 @@ sub scantron_validate_file { return ''; } my $result=&scantron_form_start($max_bubble).$default_form_data; + if ($env{'form.scantron_lastbubblepoints'} ne '') { + $result .= ''; + } $r->print($result); my @validate_phases=( 'sequence', @@ -6386,6 +6744,7 @@ sub scantron_validate_file { while (!$stop && $currentphase < scalar(@validate_phases)) { $r->print(&mt('Validating '.$validate_phases[$currentphase]).''); $r->rflush(); + my $which="scantron_validate_".$validate_phases[$currentphase]; { no strict 'refs'; @@ -6794,7 +7153,13 @@ sub scantron_validate_sequence { my @resources= $navmap->retrieveResources($map,\&scantron_filter_not_exam,1,0); if (@resources) { - $r->print("".&mt('Some resources in the sequence currently are not set to exam mode. Grading these resources currently may not work correctly.').""); + $r->print( + '' + .&mt('Some resources in the sequence currently are not set to' + .' bubblesheet exam mode. Grading these resources currently may not' + .' work correctly.') + .'' + ); return (1,$currentphase); } } @@ -6875,7 +7240,8 @@ sub scantron_validate_ID { sub scantron_get_correction { - my ($r,$i,$scan_record,$scan_config,$line,$error,$arg)=@_; + my ($r,$i,$scan_record,$scan_config,$line,$error,$arg, + $randomorder,$randompick,$respnumlookup,$startline)=@_; #FIXME in the case of a duplicated ID the previous line, probably need #to show both the current line and the previous one and allow skipping #the previous one or the current one @@ -6899,7 +7265,7 @@ sub scantron_get_correction { .&mt('The ID on the form is [_1]', "$$scan_record{'scantron.ID'}") .'' - .&mt('The name on the paper is [_2], [_3]', + .&mt('The name on the paper is [_1], [_2]', $$scan_record{'scantron.LastName'}, $$scan_record{'scantron.FirstName'}) .'
'.&mt('If this information is correct, please click on \'[_1]\'.',&mt($button_text)).' +
'.&mt("If this information is correct, please click on '[_1]'.",&mt($button_text)).' '.&mt('If something is incorrect, please return to [_1]Grade/Manage/Review Bubblesheets[_2] to start over.','','').'
".&mt('Some resources in the sequence currently are not set to exam mode. Grading these resources currently may not work correctly.')."
' + .&mt('Some resources in the sequence currently are not set to' + .' bubblesheet exam mode. Grading these resources currently may not' + .' work correctly.') + .'
".&mt("Please indicate which bubble should be used for grading")."
'. + &mt('If you have already graded these by bubbling sheets to indicate points awarded, [_1]what point value is assigned to a filled last bubble in each row?',''). + ''.&mt('[quant,_1,point]',$bubbles_per_row).' '.&mt('or').' '. + '0 points
- '.&mt('The requested file name was invalid.').' + '.&mt('The requested filename was invalid.').'
'.&mt('Exact matches for [quant,_1,student].',$passed).''.&mt('Discrepancies detected for [quant,_1,student].',$failed).'
' + .&mt('Exact matches for [_1][quant,_2,student][_3].','',$passed,'') + .'' + .&mt('Discrepancies detected for [_1][quant,_2,student][_3].','',$failed,'') + .'