[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework grades.pm
raeburn
raeburn at source.lon-capa.org
Wed Feb 26 21:41:39 EST 2014
raeburn Thu Feb 27 02:41:39 2014 EDT
Modified files: (Branch: version_2_11_X)
/loncom/homework grades.pm
Log:
- For 2.11
- Backport 1.711 (part), 1.712, 1.713, 1.715, 1.716, 1.717, 1.718, 1.719,
1.720, 1.721, 1.722.
-------------- next part --------------
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.596.2.12.2.27 loncom/homework/grades.pm:1.596.2.12.2.28
--- loncom/homework/grades.pm:1.596.2.12.2.27 Sat Jan 18 01:57:41 2014
+++ loncom/homework/grades.pm Thu Feb 27 02:41:38 2014
@@ -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 @@
my $grayFont = '<span class="LC_internal_info">';
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 @@
$bottomrow.'</tr></table></blockquote>';
} 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 @@
$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-<br />-g;
- return '<br /><br /><blockquote><tt>'.&keywords_highlight($answer).'</tt></blockquote>';
+ return '<br /><br /><blockquote><tt>'.&keywords_highlight(&HTML::Entities::encode($answer, '"<>&')).'</tt></blockquote>';
} elsif ( $response eq 'organic') {
- my $result='Smile representation: "<tt>'.$answer.'</tt>"';
+ my $result=&mt('Smile representation: [_1]',
+ '"<tt>'.&HTML::Entities::encode($answer, '"<>&').'</tt>"');
my $jme=$record->{$version."resource.$partid.$respid.molecule"};
$result.=&Apache::chemresponse::jme_img($jme,$answer,400);
return $result;
@@ -498,12 +503,14 @@
$result.='</ul>';
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 @@
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(<<SUBJAVASCRIPT);
<script type="text/javascript" language="javascript">
@@ -1684,25 +1700,34 @@
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=="<i>") {var syisel="checked"};
- if (kwstyle=="<b>") {var sybsel="checked"};
+ if (kwstyle=="") {var synsel="checked='checked'"};
+ if (kwstyle=="<i>") {var syisel="checked='checked'"};
+ if (kwstyle=="<b>") {var sybsel="checked='checked'"};
highlightCentral();
- highlightbody('red','red',redsel,'0','normal',sznsel,'','normal',synsel);
- highlightbody('green','green',grnsel,'+1','+1',sz1sel,'<i>','italic',syisel);
- highlightbody('blue','blue',blusel,'+2','+2',sz2sel,'<b>','bold',sybsel);
+ highlightbody('red',txtcol1,redsel,'0',txtsiz1,sznsel,'',txtsty1,synsel);
+ highlightbody('green',txtcol2,grnsel,'+1',txtsiz2,sz1sel,'<i>',txtsty2,syisel);
+ highlightbody('blue',txtcol3,blusel,'+2',txtsiz3,sz2sel,'<b>',txtsty3,sybsel);
highlightend();
return;
}
@@ -1720,31 +1745,29 @@
hDoc.$docopen;
hDoc.write('$start_page_highlight_central');
hDoc.write("<form action=\\"inactive\\" name=\\"hlCenter\\">");
- hDoc.write("<h3><span class=\\"LC_info\\"> $lt{'kehi'}<\\/span><\\/h3><br /><br />");
+ hDoc.write("<h1>$lt{'kehi'}<\\/h1>");
- hDoc.write('<table border="0" width="100%"><tr><td bgcolor="#777777">');
- hDoc.write('<table border="0" width="100%"><tr bgcolor="#DDFFFF">');
- hDoc.write("<td><b>$lt{'txtc'}<\\/b><\\/td><td><b>$lt{'font'}<\\/b><\\/td><td><b>$lt{'fnst'}<\\/td><\\/tr>");
+ hDoc.write('<table border="0" width="100%"><tr style="background-color:#A1D676">');
+ hDoc.write("<th>$lt{'txtc'}<\\/th><th>$lt{'font'}<\\/th><th>$lt{'fnst'}<\\/th><\\/tr>");
}
function highlightbody(clrval,clrtxt,clrsel,szval,sztxt,szsel,syval,sytxt,sysel) {
var hDoc = hwdWin.document;
- hDoc.write("<tr bgcolor=\\"#ffffdd\\">");
+ hDoc.write("<tr>");
hDoc.write("<td align=\\"left\\">");
- hDoc.write("<input name=\\"kwdclr\\" type=\\"radio\\" value=\\""+clrval+"\\" "+clrsel+"> "+clrtxt+"<\\/td>");
+ hDoc.write("<input name=\\"kwdclr\\" type=\\"radio\\" value=\\""+clrval+"\\" "+clrsel+" \\/> "+clrtxt+"<\\/td>");
hDoc.write("<td align=\\"left\\">");
- hDoc.write("<input name=\\"kwdsize\\" type=\\"radio\\" value=\\""+szval+"\\" "+szsel+"> "+sztxt+"<\\/td>");
+ hDoc.write("<input name=\\"kwdsize\\" type=\\"radio\\" value=\\""+szval+"\\" "+szsel+" \\/> "+sztxt+"<\\/td>");
hDoc.write("<td align=\\"left\\">");
- hDoc.write("<input name=\\"kwdstyle\\" type=\\"radio\\" value=\\""+syval+"\\" "+sysel+"> "+sytxt+"<\\/td>");
+ hDoc.write("<input name=\\"kwdstyle\\" type=\\"radio\\" value=\\""+syval+"\\" "+sysel+" \\/> "+sytxt+"<\\/td>");
hDoc.write("<\\/tr>");
}
function highlightend() {
var hDoc = hwdWin.document;
- hDoc.write("<\\/table>");
- hDoc.write("<\\/td><\\/tr><\\/table> ");
- hDoc.write("<input type=\\"button\\" value=\\"$lt{'save'}\\" onclick=\\"javascript:updateChoice(1)\\"> ");
- hDoc.write("<input type=\\"button\\" value=\\"$lt{'canc'}\\" onclick=\\"self.close()\\"><br /><br />");
+ hDoc.write("<\\/table><br \\/>");
+ hDoc.write("<input type=\\"button\\" value=\\"$lt{'save'}\\" onclick=\\"javascript:updateChoice(1)\\" \\/> ");
+ hDoc.write("<input type=\\"button\\" value=\\"$lt{'canc'}\\" onclick=\\"self.close()\\" \\/><br /><br />");
hDoc.write("<\\/form>");
hDoc.write('$end_page_highlight_central');
hDoc.close();
@@ -2019,9 +2042,12 @@
if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; }
if (!&canview($usec)) {
- $request->print('<span class="LC_warning">Unable to view requested student.('.
- $uname.':'.$udom.' in section '.$usec.' in course id '.
- $env{'request.course.id'}.')</span>');
+ $request->print(
+ '<span class="LC_warning">'.
+ &mt('Unable to view requested student.').
+ ' '.&mt('([_1] in section [_2] in course id [_3])',
+ $uname.':'.$udom,$usec,$env{'request.course.id'}).
+ '</span>');
$request->print(&show_grading_menu_form($symb));
return;
}
@@ -2127,6 +2153,7 @@
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 @@
#
# Print out the keyword options line
#
- $request->print(<<KEYWORDS);
- <b>$lt{'keyw'}:</b>
-<a href="javascript:keywords(document.SCORE);" target="_self">$lt{'list'}</a>
-<a href="#" onmousedown="javascript:getSel(); return false"
- class="page">$lt{'past'}</a>
-<a href="javascript:kwhighlight();" target="_self">$lt{'high'}</a><br /><br />
-KEYWORDS
+ $request->print(
+ '<div class="LC_columnSection">'
+ .'<fieldset><legend>'.$lt{'keyh'}.'</legend>'
+ .&Apache::lonhtmlcommon::funclist_from_array(
+ ['<a href="javascript:keywords(document.SCORE);" target="_self">'.$lt{'list'}.'</a>',
+ '<a href="#" onmousedown="javascript:getSel(); return false"
+ class="page">'.$lt{'past'}.'</a>',
+ '<a href="javascript:kwhighlight();" target="_self">'.$lt{'high'}.'</a>'],
+ {legend => $lt{'keyw'}})
+ .'</fieldset></div>'
+ );
+
#
# Load the other essays for similarity check
#
@@ -2603,8 +2635,10 @@
}
my ($partid,$foo) = split(/submission$/,$key);
my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?
- '<span class="LC_warning">Draft Copy</span> ' : '';
- push(@string, join(':', $key, $hide, $draft.$lasthash{$key}));
+ '<span class="LC_warning">'.&mt('Draft Copy').'</span> ' : '';
+ push(@string, join(':', $key, $hide, $draft.(
+ ref($lasthash{$key}) eq 'ARRAY' ?
+ join(',', @{$lasthash{$key}}) : $lasthash{$key}) ));
}
}
if (!@string) {
@@ -2632,16 +2666,20 @@
sub show_previous_task_version {
my ($request,$symb) = @_;
if ($symb eq '') {
- $request->print("Unable to handle ambiguous references.");
-
+ $request->print(
+ '<span class="LC_error">'.
+ &mt('Unable to handle ambiguous references.').
+ '</span>');
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('<span class="LC_warning">Unable to view previous version for requested student.('.
- $uname.':'.$udom.' in section '.$usec.' in course id '.
- $env{'request.course.id'}.')</span>');
+ $request->print('<span class="LC_warning">'.
+ &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'}.').
+ '</span>');
return;
}
my $mode = 'both';
@@ -2825,7 +2863,10 @@
next;
}
if ($errorflag eq 'not_allowed') {
- $request->print("<span class=\"LC_warning\">Not allowed to modify grades for $uname:$udom</span>");
+ $request->print(
+ '<span class="LC_error">'
+ .&mt('Not allowed to modify grades for [_1]',"$uname:$udom")
+ .'</span>');
$ctr++;
next;
}
@@ -4748,9 +4789,12 @@
&Apache::lonnet::clear_EXT_cache_status();
if (!&canview($usec)) {
- $request->print('<span class="LC_warning">'.&mt('Unable to view requested student. ([_1])',$env{'form.student'}).'</span>');
- $request->print(&show_grading_menu_form($symb));
- return;
+ $request->print('<span class="LC_warning">'.
+ &mt('Unable to view requested student. ([_1])',
+ $env{'form.student'}).
+ '</span>');
+ $request->print(&show_grading_menu_form($symb));
+ return;
}
my $result='<h3><span class="LC_info"> '.$env{'form.title'}.'</span></h3>';
$result.='<h3> '.&mt('Student: [_1]',&nameUserString(undef,$$fullname{$env{'form.student'}},$uname,$udom)).
@@ -6715,7 +6759,7 @@
$scantron_config{'CODEstart'} &&
$scantron_config{'CODElength'}) {
$CODElist=$env{'form.scantron_CODElist'};
- if ($env{'form.scantron_CODElist'} eq '') { $CODElist='<span class="LC_warning">None</span>'; }
+ if ($env{'form.scantron_CODElist'} eq '') { $CODElist='<span class="LC_warning">'.&mt('None').'</span>'; }
$CODElist=
'<tr><td><b>'.&mt('List of CODES to validate against:').'</b></td><td><tt>'.
$env{'form.scantron_CODElist'}.'</tt></td></tr>';
@@ -8344,7 +8388,7 @@
return &mt('The sequence to be graded contains response types which are handgraded.').'<p>'.
&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?','<br />').
'<label><input type="radio" name="scantron_lastbubblepoints" value="'.$bubbles_per_row.'" checked="checked" />'.&mt('[quant,_1,point]',$bubbles_per_row).'</label> '.&mt('or').' '.
- '<label><input type="radio" name="scantron_lastbubblepoints" value="0"/>0 points</label></p>';
+ '<label><input type="radio" name="scantron_lastbubblepoints" value="0" />'.&mt('0 points').'</label></p>';
}
return;
}
@@ -9021,7 +9065,7 @@
&Apache::lonnet::allowuploaded('/adm/grades',$skipped);
$r->print('
<p>
- '.&mt('[_1]Original[_2] file as uploaded by the scantron office.',
+ '.&mt('[_1]Original[_2] file as uploaded by bubblesheet scanning office.',
'<a href="'.$orig.'">','</a>').'
</p>
<p>
@@ -9197,14 +9241,14 @@
'<td>'.&mt('Bubblesheet').'</td><td>'.$showscandata.'</td><td rowspan="2">'.$last.'</td><td rowspan="2">'.$pid.'</td>'."\n".
'</tr>'."\n".
'<tr class="'.$css_class.'">'."\n".
-'<td>Submissions</td><td>'.$showrecord.'</td></tr>'."\n";
+'<td>'.&mt('Submissions').'</td><td>'.$showrecord.'</td></tr>'."\n";
$passed ++;
} else {
my $css_class = ($failed % 2)?'LC_odd_row':'LC_even_row';
$badstudents .= '<tr class="'.$css_class.'"><td>'.&mt('Bubblesheet').'</td><td><span class="LC_nobreak">'.$scandata{$pid}.'</span></td><td rowspan="2">'.$last.'</td><td rowspan="2">'.$pid.'</td>'."\n".
'</tr>'."\n".
'<tr class="'.$css_class.'">'."\n".
-'<td>Submissions</td><td><span class="LC_nobreak">'.$record{$pid}.'</span></td>'."\n".
+'<td>'.&mt('Submissions').'</td><td><span class="LC_nobreak">'.$record{$pid}.'</span></td>'."\n".
'</tr>'."\n";
$failed ++;
}
@@ -10546,11 +10590,11 @@
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.
More information about the LON-CAPA-cvs
mailing list