--- loncom/homework/grades.pm 2014/01/18 01:57:41 1.596.2.12.2.27 +++ loncom/homework/grades.pm 2014/02/27 02:41:38 1.596.2.12.2.28 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.596.2.12.2.27 2014/01/18 01:57:41 raeburn Exp $ +# $Id: grades.pm,v 1.596.2.12.2.28 2014/02/27 02:41:38 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -391,6 +391,8 @@ sub cleanRecord { my $grayFont = ''; if ($response =~ /^(option|rank)$/) { my %answer=&Apache::lonnet::str2hash($answer); + my @answer = %answer; + %answer = map {&HTML::Entities::encode($_, '"<>&')} @answer; my %grading=&Apache::lonnet::str2hash($record->{$version."resource.$partid.$respid.submissiongrading"}); my ($toprow,$bottomrow); foreach my $foil (@$order) { @@ -407,6 +409,8 @@ sub cleanRecord { $bottomrow.''; } elsif ($response eq 'match') { my %answer=&Apache::lonnet::str2hash($answer); + my @answer = %answer; + %answer = map {&HTML::Entities::encode($_, '"<>&')} @answer; my %grading=&Apache::lonnet::str2hash($record->{$version."resource.$partid.$respid.submissiongrading"}); my @items=&Apache::lonnet::str2array($record->{$version."resource.$partid.$respid.submissionitems"}); my ($toprow,$middlerow,$bottomrow); @@ -462,9 +466,10 @@ sub cleanRecord { $env{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob. } $answer =~ s-\n-
-g; - return '

'.&keywords_highlight($answer).'
'; + return '

'.&keywords_highlight(&HTML::Entities::encode($answer, '"<>&')).'
'; } elsif ( $response eq 'organic') { - my $result='Smile representation: "'.$answer.'"'; + my $result=&mt('Smile representation: [_1]', + '"'.&HTML::Entities::encode($answer, '"<>&').'"'); my $jme=$record->{$version."resource.$partid.$respid.molecule"}; $result.=&Apache::chemresponse::jme_img($jme,$answer,400); return $result; @@ -498,12 +503,14 @@ sub cleanRecord { $result.=''; return $result; } - } elsif ( $response =~ m/(?:numerical|formula)/) { + } elsif ( $response =~ m/(?:numerical|formula|custom)/) { + # Respect multiple input fields, see Bug #5409 $answer = &Apache::loncommon::format_previous_attempt_value('submission', $answer); + return $answer; } - return $answer; + return &HTML::Entities::encode($answer, '"<>&'); } #-- A couple of common js functions @@ -1519,6 +1526,15 @@ INNERJS txtc => 'Text Color', font => 'Font Size', fnst => 'Font Style', + col1 => 'red', + col2 => 'green', + col3 => 'blue', + siz1 => 'normal', + siz2 => '+1', + siz3 => '+2', + sty1 => 'normal', + sty2 => 'italic', + sty3 => 'bold', ); $request->print(< @@ -1684,25 +1700,34 @@ INNERJS var redsel = ""; var grnsel = ""; var blusel = ""; - if (kwclr=="red") {var redsel="checked"}; - if (kwclr=="green") {var grnsel="checked"}; - if (kwclr=="blue") {var blusel="checked"}; + var txtcol1 = "$lt{'col1'}"; + var txtcol2 = "$lt{'col2'}"; + var txtcol3 = "$lt{'col3'}"; + var txtsiz1 = "$lt{'siz1'}"; + var txtsiz2 = "$lt{'siz2'}"; + var txtsiz3 = "$lt{'siz3'}"; + var txtsty1 = "$lt{'sty1'}"; + var txtsty2 = "$lt{'sty2'}"; + var txtsty3 = "$lt{'sty3'}"; + if (kwclr=="red") {var redsel="checked='checked'"}; + if (kwclr=="green") {var grnsel="checked='checked'"}; + if (kwclr=="blue") {var blusel="checked='checked'"}; var sznsel = ""; var sz1sel = ""; var sz2sel = ""; - if (kwsize=="0") {var sznsel="checked"}; - if (kwsize=="+1") {var sz1sel="checked"}; - if (kwsize=="+2") {var sz2sel="checked"}; + if (kwsize=="0") {var sznsel="checked='checked'"}; + if (kwsize=="+1") {var sz1sel="checked='checked'"}; + if (kwsize=="+2") {var sz2sel="checked='checked'"}; var synsel = ""; var syisel = ""; var sybsel = ""; - if (kwstyle=="") {var synsel="checked"}; - if (kwstyle=="") {var syisel="checked"}; - if (kwstyle=="") {var sybsel="checked"}; + if (kwstyle=="") {var synsel="checked='checked'"}; + if (kwstyle=="") {var syisel="checked='checked'"}; + if (kwstyle=="") {var sybsel="checked='checked'"}; highlightCentral(); - highlightbody('red','red',redsel,'0','normal',sznsel,'','normal',synsel); - highlightbody('green','green',grnsel,'+1','+1',sz1sel,'','italic',syisel); - highlightbody('blue','blue',blusel,'+2','+2',sz2sel,'','bold',sybsel); + highlightbody('red',txtcol1,redsel,'0',txtsiz1,sznsel,'',txtsty1,synsel); + highlightbody('green',txtcol2,grnsel,'+1',txtsiz2,sz1sel,'',txtsty2,syisel); + highlightbody('blue',txtcol3,blusel,'+2',txtsiz3,sz2sel,'',txtsty3,sybsel); highlightend(); return; } @@ -1720,31 +1745,29 @@ INNERJS hDoc.$docopen; hDoc.write('$start_page_highlight_central'); hDoc.write("
"); - hDoc.write("

 $lt{'kehi'}<\\/span><\\/h3>

"); + hDoc.write("

$lt{'kehi'}<\\/h1>"); - hDoc.write('
'); - hDoc.write(''); - hDoc.write("
$lt{'txtc'}<\\/b><\\/td>$lt{'font'}<\\/b><\\/td>$lt{'fnst'}<\\/td><\\/tr>"); + hDoc.write(''); + hDoc.write(""); + hDoc.write(""); hDoc.write("'; @@ -8344,7 +8388,7 @@ sub hand_bubble_option { return &mt('The sequence to be graded contains response types which are handgraded.').'

'. &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('or').' '. - '

'; + '

'; } return; } @@ -9021,7 +9065,7 @@ sub scantron_download_scantron_data { &Apache::lonnet::allowuploaded('/adm/grades',$skipped); $r->print('

- '.&mt('[_1]Original[_2] file as uploaded by the scantron office.', + '.&mt('[_1]Original[_2] file as uploaded by bubblesheet scanning office.', '','').'

@@ -9197,14 +9241,14 @@ sub checkscantron_results { '

'."\n". ''."\n". ''."\n". -''."\n"; +''."\n"; $passed ++; } else { my $css_class = ($failed % 2)?'LC_odd_row':'LC_even_row'; $badstudents .= ''."\n". ''."\n". ''."\n". -''."\n". +''."\n". ''."\n"; $failed ++; } @@ -10546,11 +10590,11 @@ At least the logic that drives this has ssi_with_retries - Does the server side include of a resource. if the ssi call returns an error we'll retry it up to the number of times requested by the caller. - If we still have a proble, no text is appended to the + If we still have a problem, no text is appended to the output and we set some global variables. to indicate to the caller an SSI error occurred. All of this is supposed to deal with the issues described - in LonCAPA BZ 5631 see: + in LON-CAPA BZ 5631 see: http://bugs.lon-capa.org/show_bug.cgi?id=5631 by informing the user that this happened.
$lt{'txtc'}<\\/th>$lt{'font'}<\\/th>$lt{'fnst'}<\\/th><\\/tr>"); } function highlightbody(clrval,clrtxt,clrsel,szval,sztxt,szsel,syval,sytxt,sysel) { var hDoc = hwdWin.document; - hDoc.write("
"); - hDoc.write(" "+clrtxt+"<\\/td>"); + hDoc.write(" "+clrtxt+"<\\/td>"); hDoc.write(""); - hDoc.write(" "+sztxt+"<\\/td>"); + hDoc.write(" "+sztxt+"<\\/td>"); hDoc.write(""); - hDoc.write(" "+sytxt+"<\\/td>"); + hDoc.write(" "+sytxt+"<\\/td>"); hDoc.write("<\\/tr>"); } function highlightend() { var hDoc = hwdWin.document; - hDoc.write("<\\/table>"); - hDoc.write("<\\/td><\\/tr><\\/table> "); - hDoc.write("  "); - hDoc.write("

"); + hDoc.write("<\\/table>
"); + hDoc.write("  "); + hDoc.write("

"); hDoc.write("<\\/form>"); hDoc.write('$end_page_highlight_central'); hDoc.close(); @@ -2019,9 +2042,12 @@ sub submission { if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; } if (!&canview($usec)) { - $request->print('Unable to view requested student.('. - $uname.':'.$udom.' in section '.$usec.' in course id '. - $env{'request.course.id'}.')'); + $request->print( + ''. + &mt('Unable to view requested student.'). + ' '.&mt('([_1] in section [_2] in course id [_3])', + $uname.':'.$udom,$usec,$env{'request.course.id'}). + ''); $request->print(&show_grading_menu_form($symb)); return; } @@ -2127,6 +2153,7 @@ sub submission { if ($env{'form.handgrade'} eq 'yes' && $env{'form.showgrading'} eq 'yes') { my %lt = &Apache::lonlocal::texthash( + keyh => 'Keyword Highlighting for Essays', keyw => 'Keyword Options', list => 'List', past => 'Paste Selection to List', @@ -2135,13 +2162,18 @@ sub submission { # # Print out the keyword options line # - $request->print(<$lt{'keyw'}:  -$lt{'list'}    -$lt{'past'}    -$lt{'high'}

-KEYWORDS + $request->print( + '
' + .'
'.$lt{'keyh'}.'' + .&Apache::lonhtmlcommon::funclist_from_array( + [''.$lt{'list'}.'', + ''.$lt{'past'}.'', + ''.$lt{'high'}.''], + {legend => $lt{'keyw'}}) + .'
' + ); + # # Load the other essays for similarity check # @@ -2603,8 +2635,10 @@ sub get_last_submission { } my ($partid,$foo) = split(/submission$/,$key); my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ? - 'Draft Copy ' : ''; - push(@string, join(':', $key, $hide, $draft.$lasthash{$key})); + ''.&mt('Draft Copy').' ' : ''; + push(@string, join(':', $key, $hide, $draft.( + ref($lasthash{$key}) eq 'ARRAY' ? + join(',', @{$lasthash{$key}}) : $lasthash{$key}) )); } } if (!@string) { @@ -2632,16 +2666,20 @@ sub keywords_highlight { sub show_previous_task_version { my ($request,$symb) = @_; if ($symb eq '') { - $request->print("Unable to handle ambiguous references."); - + $request->print( + ''. + &mt('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'}.')'); + $request->print(''. + &mt('Unable to view previous version for requested student.'). + ' '.&mt('([_1] in section [_2] in course id [_3])', + $uname.':'.$udom,$usec,$env{'request.course.id'}.'). + ''); return; } my $mode = 'both'; @@ -2825,7 +2863,10 @@ sub processHandGrade { next; } if ($errorflag eq 'not_allowed') { - $request->print("Not allowed to modify grades for $uname:$udom"); + $request->print( + '' + .&mt('Not allowed to modify grades for [_1]',"$uname:$udom") + .''); $ctr++; next; } @@ -4748,9 +4789,12 @@ sub displayPage { &Apache::lonnet::clear_EXT_cache_status(); if (!&canview($usec)) { - $request->print(''.&mt('Unable to view requested student. ([_1])',$env{'form.student'}).''); - $request->print(&show_grading_menu_form($symb)); - return; + $request->print(''. + &mt('Unable to view requested student. ([_1])', + $env{'form.student'}). + ''); + $request->print(&show_grading_menu_form($symb)); + return; } my $result='

 '.$env{'form.title'}.'

'; $result.='

 '.&mt('Student: [_1]',&nameUserString(undef,$$fullname{$env{'form.student'}},$uname,$udom)). @@ -6715,7 +6759,7 @@ sub scantron_warning_screen { $scantron_config{'CODEstart'} && $scantron_config{'CODElength'}) { $CODElist=$env{'form.scantron_CODElist'}; - if ($env{'form.scantron_CODElist'} eq '') { $CODElist='None'; } + if ($env{'form.scantron_CODElist'} eq '') { $CODElist=''.&mt('None').''; } $CODElist= '

'.&mt('List of CODES to validate against:').''. $env{'form.scantron_CODElist'}.'
'.&mt('Bubblesheet').''.$showscandata.''.$last.''.$pid.'
Submissions'.$showrecord.'
'.&mt('Submissions').''.$showrecord.'
'.&mt('Bubblesheet').''.$scandata{$pid}.''.$last.''.$pid.'
Submissions'.$record{$pid}.''.&mt('Submissions').''.$record{$pid}.'