[LON-CAPA-cvs] cvs: loncom /homework grades.pm
ng
lon-capa-cvs@mail.lon-capa.org
Tue, 15 Jul 2003 20:59:53 -0000
This is a MIME encoded message
--ng1058302793
Content-Type: text/plain
ng Tue Jul 15 16:59:53 2003 EDT
Modified files:
/loncom/homework grades.pm
Log:
change the main menu
get rid of number of attempts column(s) for grading by section/course
started work to allow grading for a given resource regardless whether it
is an essay response type problem.
--ng1058302793
Content-Type: text/plain
Content-Disposition: attachment; filename="ng-20030715165953.txt"
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.115 loncom/homework/grades.pm:1.116
--- loncom/homework/grades.pm:1.115 Mon Jul 14 12:11:19 2003
+++ loncom/homework/grades.pm Tue Jul 15 16:59:53 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.115 2003/07/14 16:11:19 ng Exp $
+# $Id: grades.pm,v 1.116 2003/07/15 20:59:53 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -418,7 +418,7 @@
my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked';
my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n".
- ' <b>View Problem: </b><input type="radio" name="vProb" value="no" checked /> no '."\n".
+ ' <b>View Problem Text: </b><input type="radio" name="vProb" value="no" checked /> no '."\n".
'<input type="radio" name="vProb" value="yes" /> one student '."\n".
'<input type="radio" name="vProb" value="all" /> all students <br />'."\n".
' <b>Submissions: </b>'."\n";
@@ -1114,7 +1114,8 @@
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
if (!&canview($usec)) {
- $request->print('<font color="red">Unable to view requested student.('.$uname.$udom.$usec.$ENV{'request.course.id'}.')</font>');
+ $request->print('<font color="red">Unable to view requested student.('.
+ $uname.$udom.$usec.$ENV{'request.course.id'}.')</font>');
$request->print(&show_grading_menu_form($symb,$url));
return;
}
@@ -1226,12 +1227,13 @@
'<table border="0" width=100%><tr bgcolor="#edffff"><td>'."\n";
$result.='<b>Fullname: </b>'.$ENV{'form.fullname'}.
- '<font color="#999999"> Username: '.$uname.'</font>'.
- '<font color="#999999"> Domain: '.$udom.'</font><br />'."\n";
+ '<font color="#999999"> Username: '.$uname.
+ ($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').'</font><br />'."\n";
+# '<font color="#999999"> Domain: '.$udom.'</font><br />'."\n";
$result.='<input type="hidden" name="name'.$counter.
'" value="'.$ENV{'form.fullname'}.'" />'."\n";
- # If this is handgraded, then check for collaborators
+ # If this is an essay-response part(handgraded), then check for collaborators
my @col_fullnames;
my ($classlist,$fullname);
if ($ENV{'form.handgrade'} eq 'yes') {
@@ -1321,7 +1323,8 @@
my ($oname,$odom,$ocrsid,$oessay,$osim)=&most_similar($uname,$udom,$subval);
if ($osim) {
$osim=int($osim*100.0);
- $similar='<hr /><h3><font color="#FF0000">Essay is '.$osim.'% similar to an essay by '.&Apache::loncommon::plainname($oname,$odom).
+ $similar='<hr /><h3><font color="#FF0000">Essay is '.$osim.
+ '% similar to an essay by '.&Apache::loncommon::plainname($oname,$odom).
'</font></h3><blockquote><i>'.
&keywords_highlight($oessay).'</i></blockquote><hr />';
}
@@ -1331,7 +1334,9 @@
($record{"resource.$partid.$respid.uploadedurl"}?
'<a href="'.
&Apache::lonnet::tokenwrapper($record{"resource.$partid.$respid.uploadedurl"}).
- '"><img src="/adm/lonIcons/unknown.gif" border=0"> File uploaded by student</a> <font color="red" size="1">Like all files provided by users, this file may contain virusses</font><br />':'').
+ '"><img src="/adm/lonIcons/unknown.gif" border=0"> File uploaded by student</a> '.
+ '<font color="red" size="1">Like all files provided by users, '.
+ 'this file may contain virusses</font><br />':'').
'<b>Answer: </b><blockquote>'.
&keywords_highlight($subval).'</blockquote><br /> '.$similar.'</td></tr>'."\n"
if ($ENV{'form.lastSub'} eq 'lastonly' ||
@@ -1352,7 +1357,8 @@
}
# return if view submission with no grading option
- if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) {
+# if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) {
+ if (!&canmodify($usec)) {
$request->print('</td></tr></table></td></tr></table></form>'."\n");
$request->print(&show_grading_menu_form($symb,$url))
if (($ENV{'form.command'} eq 'submission') ||
@@ -1388,7 +1394,7 @@
my ($partid,$respid) = split(/_/);
next if ($seen{$partid} > 0);
$seen{$partid}++;
- next if ($$handgrade{$_} =~ /:no$/);
+# next if ($$handgrade{$_} =~ /:no$/);
push @partlist,$partid;
$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
@@ -1977,6 +1983,7 @@
my (@parts) = sort(&getpartlist($url));
foreach my $part (@parts) {
my $display=&Apache::lonnet::metadata($url,$part.'.display');
+ next if ($display =~ /Number of Attempts/);
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
if ($display =~ /^Partial Credit Factor/) {
my ($partid) = &split_part_type($part);
@@ -2007,7 +2014,8 @@
'onClick="javascript:submit();" TARGET=_self /></form>'."\n";
if (scalar(%$fullname) eq 0) {
my $colspan=3+scalar(@parts);
- $result='<font color="red">There are no students in section "'.$ENV{'form.section'}.'" with enrollment status "'.$ENV{'form.Status'}.'" to modify or grade.</font>';
+ $result='<font color="red">There are no students in section "'.$ENV{'form.section'}.
+ '" with enrollment status "'.$ENV{'form.Status'}.'" to modify or grade.</font>';
}
$result.=&show_grading_menu_form($symb,$url);
return $result;
@@ -2047,13 +2055,13 @@
if ($status eq 'excused');
$result.=$optsel;
$result.="</select></td>\n";
- } else {
- $result.='<input type="hidden" name="'.
- 'GD_'.$student.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'.
- "\n";
- $result.='<td align="middle"><input type="text" name="'.
- 'GD_'.$student.'_'.$part.'_'.$type.'" '.
- 'value="'.$score.'" size="4" /></td>'."\n";
+# } else {
+# $result.='<input type="hidden" name="'.
+# 'GD_'.$student.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'.
+# "\n";
+# $result.='<td align="middle"><input type="text" name="'.
+# 'GD_'.$student.'_'.$part.'_'.$type.'" '.
+# 'value="'.$score.'" size="4" /></td>'."\n";
}
}
$result.='</tr>';
@@ -2607,7 +2615,7 @@
$result.='<input type="hidden" name="page" />'."\n".
'<input type="hidden" name="title" />'."\n";
- $result.=' <b>View Problems: </b><input type="radio" name="vProb" value="no" checked /> no '."\n".
+ $result.=' <b>View Problems Text: </b><input type="radio" name="vProb" value="no" checked /> no '."\n".
'<input type="radio" name="vProb" value="yes" /> yes '."<br>\n";
$result.=' <b>Submission Details: </b>'.
@@ -2781,21 +2789,18 @@
if ($ENV{'form.vProb'} eq 'yes') {
$studentTable.=&show_problem($request,$symbx,$uname,$udom,1);
} else {
- my $companswer = &Apache::loncommon::get_student_answers(
- $symbx,$uname,$udom,$ENV{'request.course.id'});
+ my $companswer = &Apache::loncommon::get_student_answers($symbx,$uname,$udom,$ENV{'request.course.id'});
$companswer =~ s|<form(.*?)>||g;
$companswer =~ s|</form>||g;
-
# while ($companswer =~ /(<a href\=\"javascript:newWindow.*?Script Vars<\/a>)/s) { #<a href="javascript:newWindow</a>
-# $request->print('match='.$1.'<br>');
-# $companswer =~ s/$1/ /s;
+# $companswer =~ s/$1/ /ms;
+# $request->print('match='.$1."<br>\n");
# }
-# $companswer =~ s/<table border=\"1\">/<table border=\"0\">/g;
+# $companswer =~ s|<table border=\"1\">|<table border=\"0\">|g;
$studentTable.=' <b>'.$title.'</b> <br> <b>Correct answer:</b><br>'.$companswer;
}
my %record = &Apache::lonnet::restore($symbx,$ENV{'request.course.id'},$udom,$uname);
-
if ($ENV{'form.lastSub'} eq 'datesub') {
if ($record{'version'} eq '') {
$studentTable.='<br /> <font color="red">No recorded submission for this problem</font><br />';
@@ -2805,6 +2810,10 @@
'<td><b>Date/Time</b></td>'.
'<td><b>Submission</b></td>'.
'<td><b>Status </b></td></tr>';
+ my %responseType = ();
+ foreach my $partid (@{$parts}) {
+ $responseType{$partid} = $curRes->responseType($partid);
+ }
my ($version);
for ($version=1;$version<=$record{'version'};$version++) {
my $timestamp = scalar(localtime($record{$version.':timestamp'}));
@@ -2812,16 +2821,13 @@
my @versionKeys = split(/\:/,$record{$version.':keys'});
my @displaySub = ();
foreach my $partid (@{$parts}) {
- my $responseType = $curRes->responseType($partid);
my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys;
next if ($record{"$version:resource.$partid.solved"} eq '');
-# next if ($record{"$version:resource.$partid.award"} eq 'APPROX_ANS' &&
-# $record{"$version:resource.$partid.solved"} eq '');
$displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ?
- '<b>Part '.$partid.' Type:'.$responseType.':endtype'.
+ '<b>Part '.$partid.' '.
($record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' :
'Trial '.$record{"$version:resource.$partid.tries"}).'</b> '.
- $record{$version.':'.$matchKey[0]}.'<br />' : '';
+ &cleanRecord($record{$version.':'.$matchKey[0]},$responseType{$partid}).'<br />' : '';
$displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ?
'<b>Part '.$partid.'</b> '.
$record{"$version:resource.$partid.award"}.'/'.
@@ -2868,6 +2874,26 @@
return '';
}
+sub cleanRecord {
+ my ($answer,$response) = @_;
+ if ($response eq 'option') {
+ my (@IDs,@ans);
+ foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {
+ my ($optionID,$ans) = split(/=/);
+ push @IDs,$optionID.'</font>';
+ push @ans,$ans;
+ }
+ my $grayFont = '<font color="#999999">';
+ return '<table border="1">'.
+ '<tr valign="top"><td>Answer</td><td>'.
+ (join '</td><td>',@ans).'</td></tr>'.
+ '<tr><td>'.$grayFont.'Option ID</font></td><td>'.$grayFont.
+ (join '</td><td>'.$grayFont,@IDs).'</font></td></tr>'.
+ '</table>';
+ }
+ return $answer;
+}
+
sub updateGradeByPage {
my ($request) = shift;
@@ -3335,12 +3361,17 @@
$request->print(<<GRADINGMENUJS);
<script type="text/javascript" language="javascript">
- function checkChoice(formname) {
- var cmd = formname.command;
- formname.saveState.value = "saveCmd="+radioSelection(cmd)+":saveSec="+pullDownSelection(formname.section)+
+ function checkChoice(formname,val,cmdx) {
+ if (val <= 2) {
+ var cmd = radioSelection(formname.radioChoice);
+ } else {
+ cmd = cmdx;
+ }
+ formname.command.value = cmd;
+ formname.saveState.value = "saveCmd="+cmd+":saveSec="+pullDownSelection(formname.section)+
":saveSub="+radioSelection(formname.submitonly)+":saveStatus="+pullDownSelection(formname.Status);
- if (cmd[0].checked || cmd[1].checked || cmd[2].checked || cmd[3].checked || cmd[4].checked) formname.submit();
- if (cmd[5].checked) {
+ if (val < 5) formname.submit();
+ if (val == 5) {
if (!checkReceiptNo(formname,'notOK')) { return false;}
formname.submit();
}
@@ -3357,7 +3388,6 @@
formname.receipt.focus();
return false;
}
- formname.command[5].checked = true;
return true;
}
@@ -3401,8 +3431,8 @@
$resptype = $responsetype;
$hdgrade = $handgrade if ($handgrade eq 'yes');
$result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.
- '<td><b>Type: </b>'.$responsetype.'</td>'.
- '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
+ '<td><b>Type: </b>'.$responsetype.'</td></tr>';
+# '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
}
$result.='</table>'."\n";
@@ -3419,75 +3449,75 @@
'<input type="hidden" name="response" value="'.$resptype.'" />'."\n".
'<input type="hidden" name="handgrade" value="'.$hdgrade.'" />'."\n".
'<input type="hidden" name="probTitle" value="'.$probTitle.'" />'."\n".
+ '<input type="hidden" name="command" value="" />'."\n".
'<input type="hidden" name="saveState" value="" />'."\n".
'<input type="hidden" name="showgrading" value="yes" />'."\n";
- $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n".
- '<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n".
+ $result.='<table width="100%" border=0><tr><td bgcolor=#777777>'."\n".
+ '<table width=100% border=0><tr bgcolor="#e6ffff"><td colspan="2">'."\n".
' <b>Select a Grading/Viewing Option</b></td></tr>'."\n".
- '<tr bgcolor=#ffffe6><td>'."\n";
+ '<tr bgcolor="#ffffe6" valign="top"><td>'."\n";
+
+ $result.='<table width="100%" border=0>';
+ $result.='<tr bgcolor="#ffffe6" valign="top"><td>'."\n".
+ ' Section: <select name="section">'."\n";
+ if (ref($sections)) {
+ foreach (sort (@$sections)) {$result.='<option value="'.$_.'" '.
+ ($saveSec eq $_ ? 'selected="on"' : '').'>'.$_.'</option>'."\n";}
+ }
+ $result.= '<option value="all" '.($saveSec eq 'all' ? 'selected="on"' : ''). '>all</select> ';
+
+ $result.='Student Status:</b>'.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,undef);
- $result.='<table width=100% border=0>'.
- '<tr bgcolor="#ffffe6" valign="top"><td colspan="2">'.
- '<input type="radio" name="command" value="pickStudentPage" '.
+ if (ref($sections)) {
+ $result.=' (Section "no" implies the students were not assigned a section.)<br />'
+ if (grep /no/,@$sections);
+ }
+ $result.='</td></tr>';
+
+ $result.='<tr bgcolor="#ffffe6" valign="top"><td>'.
+ '<input type="radio" name="radioChoice" value="pickStudentPage" '.
($saveCmd eq 'pickStudentPage' ? 'checked' : '').'> '.
- 'Handgrade/View Submission for a student by page/sequence</td></tr>'."\n".
+ 'One student for whole page/sequence/folder</td></tr>'."\n";
- '<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
- '<input type="radio" name="command" value="viewgrades" '.
+ $result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
+ '<input type="radio" name="radioChoice" value="viewgrades" '.
($saveCmd eq 'viewgrades' ? 'checked' : '').'> '.
- 'Grade by section or class</td></tr>'."\n".
+ 'All students in section/course for current resource</td></tr>'."\n";
- '<tr bgcolor="#ffffe6"valign="top"><td><input type="radio" name="command" value="submission" '.
- ($saveCmd eq 'submission' ? 'checked' : '').'> '.
- ($hdgrade eq 'yes' ? 'View/Grade essay response of' : 'View').
- ' an individual student </td>'."\n".
- '<td>--> For students who has: '.
+ $result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
+ '<input type="radio" name="radioChoice" value="submission" '.
+ ($saveCmd eq 'submission' ? 'checked' : '').'> '.'One or more students for current resource'.
+ '<br /> -->For students who has: '.
'<input type="radio" name="submitonly" value="yes" '.
($saveSub eq 'yes' ? 'checked' : '').' /> submitted'.
'<input type="radio" name="submitonly" value="all" '.
- ($saveSub eq 'all' ? 'checked' : '').' /> everybody</td></tr>'."\n".
+ ($saveSub eq 'all' ? 'checked' : '').' /> everybody</td></tr>'."\n";
- '<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
- '<input type="radio" name="command" value="csvform" '.
- ($saveCmd eq 'csvform' ? 'checked' : '').'> '.
- 'Upload scores from file</td></tr>'."\n";
+ $result.='<tr bgcolor="#ffffe6"><td><br />'.
+ '<input type="button" onClick="javascript:checkChoice(this.form,\'2\');" value="View/Grade/Regrade" />'.
+ '</td></tr></table>'."\n";
+
+ $result.='</td><td valign="top">';
+
+ $result.='<table width="100%" border=0>';
+ $result.='<tr bgcolor="#ffffe6"><td>'.
+ '<input type="button" onClick="javascript:checkChoice(this.form,\'3\',\'csvform\');" value="Upload" />'.
+ ' scores from file </td></tr>'."\n";
$result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
- '<input type="radio" name="command" value="scantron_selectphase" '.
- ($saveCmd eq 'scantron_selectphase' ? 'checked="on"' : '').' /> '.
- 'Grade scantron forms</td></tr>'."\n";
+ '<input type="button" onClick="javascript:checkChoice(this.form,\'4\',\'scantron_selectphase\');'.
+ '" value="Grade" /> scantron forms</td></tr>'."\n";
if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) {
$result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
- '<input type="radio" name="command" value="verify" onChecked="javascript:this.form.receipt.focus()" '.
- ($saveCmd eq 'verify' ? 'checked' : '').'> '.
- 'Verify a submission receipt issued by this server</td>'.
- '<td>--> Receipt no: '.unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}).
+ '<input type="button" onClick="javascript:checkChoice(this.form,\'5\',\'verify\');" value="Verify" />'.
+ ' submission Receipt no: '.unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}).
'-<input type="text" name="receipt" size="4" onChange="javascript:checkReceiptNo(this.form,\'OK\')">'.
'</td></tr>'."\n";
}
- $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2"><br />'."\n".
- ' Select section: <select name="section">'."\n";
- if (ref($sections)) {
- foreach (sort (@$sections)) {$result.='<option value="'.$_.'" '.
- ($saveSec eq $_ ? 'selected="on"' : '').'>'.$_.'</option>'."\n";}
- }
- $result.= '<option value="all" '.($saveSec eq 'all' ? 'selected="on"' : ''). '>all</select> ';
-
- $result.='Student Status:</b>'.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,undef);
- $result.=' <font color="red">(Applies to the first three options only.)</font>'."\n";
-
- if (ref($sections)) {
- $result.=' (Section "no" implies the students were not assigned a section.)<br />'
- if (grep /no/,@$sections);
- }
- $result.='</td></tr>';
-
- $result.='<tr bgcolor="#ffffe6"><td colspan="2"><br />'.
- '<input type="button" onClick="javascript:checkChoice(this.form);" value="View/Grade" />'."\n".
- '</form></td></tr></table>'."\n".
+ $result.='</form></td></tr></table>'."\n".
'</td></tr></table>'."\n".
'</td></tr></table>'."\n";
return $result;
--ng1058302793--