version 1.61, 2002/11/27 15:54:24
|
version 1.71, 2003/03/11 19:32:02
|
Line 31
|
Line 31
|
# 8/20 Gerd Kortemeyer |
# 8/20 Gerd Kortemeyer |
# Year 2002 |
# Year 2002 |
# June-August H.K. Ng |
# June-August H.K. Ng |
|
# Year 2003 |
|
# February, March H.K. Ng |
# |
# |
|
|
package Apache::grades; |
package Apache::grades; |
Line 39 use Apache::style;
|
Line 41 use Apache::style;
|
use Apache::lonxml; |
use Apache::lonxml; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon; |
use Apache::loncommon; |
|
use Apache::lonnavmaps; |
use Apache::lonhomework; |
use Apache::lonhomework; |
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use Apache::lonmsg qw(:user_normal_msg); |
use Apache::lonmsg qw(:user_normal_msg); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
|
|
# ----- These first few routines are general use routines.----- |
# ----- These first few routines are general use routines.---- |
# |
# |
# --- Retrieve the parts that matches stores_\d+ from the metadata file.--- |
# --- Retrieve the parts that matches stores_\d+ from the metadata file.--- |
sub getpartlist { |
sub getpartlist { |
Line 234 sub verifyreceipt {
|
Line 237 sub verifyreceipt {
|
|
|
my $title.='<h3><font color="#339933">Verifying Submission Receipt '. |
my $title.='<h3><font color="#339933">Verifying Submission Receipt '. |
$receipt.'</h3></font>'."\n". |
$receipt.'</h3></font>'."\n". |
'<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br><br>'."\n"; |
'<font size=+1><b>Problem: </b>'. |
|
&Apache::lonnet::metadata($ENV{'form.url'},'title').'</font><br><br>'."\n"; |
|
|
my ($string,$contents,$matches) = ('','',0); |
my ($string,$contents,$matches) = ('','',0); |
my (undef,undef,$fullname) = &getclasslist('all','0'); |
my (undef,undef,$fullname) = &getclasslist('all','0'); |
Line 269 sub verifyreceipt {
|
Line 273 sub verifyreceipt {
|
return $string.&show_grading_menu_form($symb,$url); |
return $string.&show_grading_menu_form($symb,$url); |
} |
} |
|
|
|
# |
|
# Pick student and page/sequence for manual grading |
|
|
|
|
#--- This is called by a number of programs. |
#--- This is called by a number of programs. |
#--- Called from the Grading Menu - View/Grade an individual student |
#--- Called from the Grading Menu - View/Grade an individual student |
#--- Also called directly when one clicks on the subm button |
#--- Also called directly when one clicks on the subm button |
Line 293 sub listStudents {
|
Line 301 sub listStudents {
|
} |
} |
$result.='</table>'; |
$result.='</table>'; |
|
|
my $viewgrade; |
my $viewgrade = $ENV{'form.handgrade'} eq 'yes' ? 'View/Grade' : 'View'; |
if ($ENV{'form.handgrade'} eq 'yes') { |
|
$viewgrade = 'View/Grade'; |
|
} else { |
|
$viewgrade = 'View'; |
|
} |
|
|
|
$result='<h3><font color="#339933"> '. |
$result='<h3><font color="#339933"> '. |
$viewgrade. |
$viewgrade. |
' Submissions for a Student or a Group of Students</font></h3>'. |
' Submissions for a Student or a Group of Students</font></h3>'. |
'<table border="0"><tr><td colspan=3><font size=+1>'. |
'<table border="0"><tr><td colspan=3><font size=+1>'. |
'<b>Resource: </b>'.$url.'</font></td></tr>'.$result; |
'<b>Problem: </b>'.&Apache::lonnet::metadata($url,'title').'</font></td></tr>'.$result; |
|
|
$request->print(<<LISTJAVASCRIPT); |
$request->print(<<LISTJAVASCRIPT); |
<script type="text/javascript" language="javascript"> |
<script type="text/javascript" language="javascript"> |
Line 453 sub sub_page_js {
|
Line 456 sub sub_page_js {
|
my $request = shift; |
my $request = shift; |
$request->print(<<SUBJAVASCRIPT); |
$request->print(<<SUBJAVASCRIPT); |
<script type="text/javascript" language="javascript"> |
<script type="text/javascript" language="javascript"> |
function updateRadio(radioButton,formtextbox,formsel,scores,weight) { |
function updateRadio(formname,id,weight) { |
var pts = formtextbox.value; |
var gradeBox = eval("formname.GD_BOX"+id); |
var resetbox =false; |
var radioButton = eval("formname.RADVAL"+id); |
if (isNaN(pts) || pts < 0) { |
var pts = checkSolved(formname,id) == 'update' ? gradeBox.value : weight; |
alert("A number equal or greater than 0 is expected. Entered value = "+pts); |
gradeBox.value = pts; |
for (var i=0; i<radioButton.length; i++) { |
var resetbox = false; |
if (radioButton[i].checked) { |
if (isNaN(pts) || pts < 0) { |
formtextbox.value = i; |
alert("A number equal or greater than 0 is expected. Entered value = "+pts); |
resetbox = true; |
for (var i=0; i<radioButton.length; i++) { |
} |
if (radioButton[i].checked) { |
|
gradeBox.value = i; |
|
resetbox = true; |
|
} |
|
} |
|
if (!resetbox) { |
|
formtextbox.value = ""; |
|
} |
|
return; |
} |
} |
if (!resetbox) { |
|
formtextbox.value = ""; |
if (pts > weight) { |
|
var resp = confirm("You entered a value ("+pts+ |
|
") greater than the weight for the part. Accept?"); |
|
if (resp == false) { |
|
gradeBox.value = ""; |
|
return; |
|
} |
} |
} |
return; |
|
} |
|
|
|
if (pts > weight) { |
for (var i=0; i<radioButton.length; i++) { |
var resp = confirm("You entered a value ("+pts+ |
radioButton[i].checked=false; |
") greater than the weight for the part. Accept?"); |
if (pts == i && pts != "") { |
if (resp == false) { |
radioButton[i].checked=true; |
formtextbox.value = ""; |
} |
return; |
} |
} |
updateSelect(formname,id); |
|
var stores = eval("formname.stores"+id); |
|
stores.value = "0"; |
} |
} |
|
|
for (var i=0; i<radioButton.length; i++) { |
function writeBox(formname,id,pts,weight) { |
radioButton[i].checked=false; |
var gradeBox = eval("formname.GD_BOX"+id); |
if (pts == i) { |
if (checkSolved(formname,id) == 'update') { |
radioButton[i].checked=true; |
gradeBox.value = pts; |
|
} else { |
|
gradeBox.value = weight; |
|
var radioButton = eval("formname.RADVAL"+id); |
|
for (var i=0; i<radioButton.length; i++) { |
|
radioButton[i].checked=false; |
|
if (i == weight) { |
|
radioButton[i].checked=true; |
|
} |
|
} |
} |
} |
|
var stores = eval("formname.stores"+id); |
|
stores.value = "0"; |
|
updateSelect(formname,id); |
|
return; |
} |
} |
updateSelect(formsel); |
|
scores.value = "0"; |
|
} |
|
|
|
function writeBox(formrad,formsel,pts,scores) { |
function clearRadBox(formname,id) { |
formrad.value = pts; |
if (checkSolved(formname,id) == 'noupdate') { |
scores.value = "0"; |
updateSelect(formname,id); |
updateSelect(formsel,pts); |
return; |
return; |
} |
} |
gradeSelect = eval("formname.GD_SEL"+id); |
|
for (var i=0; i<gradeSelect.length; i++) { |
|
if (gradeSelect[i].selected) { |
|
var selectx=i; |
|
} |
|
} |
|
var stores = eval("formname.stores"+id); |
|
if (selectx == stores.value) { return }; |
|
var gradeBox = eval("formname.GD_BOX"+id); |
|
gradeBox.value = ""; |
|
var radioButton = eval("formname.RADVAL"+id); |
|
for (var i=0; i<radioButton.length; i++) { |
|
radioButton[i].checked=false; |
|
} |
|
stores.value = selectx; |
|
} |
|
|
function clearRadBox(radioButton,formbox,formsel,scores) { |
function checkSolved(formname,id) { |
for (var i=0; i<formsel.length; i++) { |
if (eval("formname.solved"+id+".value") == "correct_by_student") { |
if (formsel[i].selected) { |
alert("This problem has been graded correct by the computer. The score cannot be changed."); |
var selectx=i; |
return "noupdate"; |
} |
} |
|
return "update"; |
} |
} |
if (selectx == scores.value) { return }; |
|
formbox.value = ""; |
function updateSelect(formname,id) { |
for (var i=0; i<radioButton.length; i++) { |
var gradeSelect = eval("formname.GD_SEL"+id); |
radioButton[i].checked=false; |
gradeSelect[0].selected = true; |
|
return; |
} |
} |
scores.value = selectx; |
|
} |
|
|
|
function updateSelect(formsel) { |
//=========== Check that a point is assigned for all the parts (essay grading only) ============ |
formsel[0].selected = true; |
function checksubmit(formname,val,total,parttot) { |
return; |
document.SCORE.gradeOpt.value = val; |
} |
if (val == "Save & Next") { |
|
for (i=0;i<=total;i++) { |
|
for (j=0;j<parttot;j++) { |
|
var partid = eval("formname.partid"+i+"_"+j+".value"); |
|
var selopt = eval("formname.GD_SEL"+i+"_"+partid); |
|
if (selopt[0].selected) { |
|
var points = eval("formname.GD_BOX"+i+"_"+partid+".value"); |
|
if (points == "") { |
|
var name = eval("formname.name"+i+".value"); |
|
var resp = confirm("You did not assign a score for "+name+", part "+partid+". Continue?"); |
|
if (resp == false) { |
|
eval("formname.GD_BOX"+i+"_"+partid+".focus()"); |
|
return false; |
|
} |
|
} |
|
} |
|
|
|
} |
|
} |
|
|
|
} |
|
formname.submit(); |
|
} |
|
|
//=================== Check that a point is assigned for all the parts ============== |
//======= Check that a score is assigned for all the problems (page/sequence grading only) ========= |
function checksubmit(val,total,parttot) { |
function checkSubmitPage(formname,total) { |
document.SCORE.gradeOpt.value = val; |
noscore = new Array(100); |
if (val == "Save & Next") { |
var ptr = 0; |
for (i=0;i<=total;i++) { |
for (i=1;i<total;i++) { |
for (j=0;j<parttot;j++) { |
var partid = eval("formname.q_"+i+".value"); |
var partid = eval("document.SCORE.partid"+i+"_"+j+".value"); |
var selopt = eval("formname.GD_SEL"+i+"_"+partid); |
var selopt = eval("document.SCORE.GD_SEL"+i+"_"+partid); |
if (selopt[0].selected) { |
if (selopt[0].selected) { |
var points = eval("formname.GD_BOX"+i+"_"+partid+".value"); |
var points = eval("document.SCORE.GD_BOX"+i+"_"+partid+".value"); |
var status = eval("formname.solved"+i+"_"+partid+".value"); |
if (points == "") { |
if (points == "" && status != "correct_by_student") { |
var name = eval("document.SCORE.name"+i+".value"); |
noscore[ptr] = i; |
alert("Please assign a score for "+name+", part "+partid+"."); |
ptr++; |
return false; |
} |
} |
} |
} |
} |
|
if (ptr != 0) { |
|
var sense = ptr == 1 ? ": " : "s: "; |
|
var prolist = ""; |
|
if (ptr == 1) { |
|
prolist = noscore[0]; |
|
} else { |
|
var i = 0; |
|
while (i < ptr-1) { |
|
prolist += noscore[i]+", "; |
|
i++; |
|
} |
|
prolist += "and "+noscore[i]; |
|
} |
|
var resp = confirm("You did not assign any score for the following problem"+sense+prolist+". Continue?"); |
|
if (resp == false) { |
|
return false; |
|
} |
|
} |
|
|
} |
formname.submit(); |
} |
} |
|
</script> |
|
SUBJAVASCRIPT |
|
} |
|
|
} |
#--- javascript for essay type problem -- |
document.SCORE.submit(); |
sub sub_page_kw_js { |
} |
my $request = shift; |
|
$request->print(<<SUBJAVASCRIPT); |
|
<script type="text/javascript" language="javascript"> |
|
|
//===================== Show list of keywords ==================== |
//===================== Show list of keywords ==================== |
function keywords(keyform) { |
function keywords(keyform) { |
Line 672 sub sub_page_js {
|
Line 759 sub sub_page_js {
|
pWin.document.write("<tr bgcolor=\\"#ffffdd\\">"); |
pWin.document.write("<tr bgcolor=\\"#ffffdd\\">"); |
pWin.document.write("<td>Subject</td>"); |
pWin.document.write("<td>Subject</td>"); |
pWin.document.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"></td>"); |
pWin.document.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"></td>"); |
pWin.document.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+" \\"size=\\"60\\" maxlength=\\"80\\"></td></tr>"); |
pWin.document.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+"\\"size=\\"60\\" maxlength=\\"80\\"></td></tr>"); |
} |
} |
|
|
function displaySavedMsg(ctr,msg,shwsel) { |
function displaySavedMsg(ctr,msg,shwsel) { |
pWin.document.write("<tr bgcolor=\\"#ffffdd\\">"); |
pWin.document.write("<tr bgcolor=\\"#ffffdd\\">"); |
pWin.document.write("<td align=\\"center\\">"+ctr+"</td>"); |
pWin.document.write("<td align=\\"center\\">"+ctr+"</td>"); |
pWin.document.write("<td align=\\"center\\"><input name=\\"msgn"+ctr+"\\" type=\\"checkbox\\"" +shwsel+"></td>"); |
pWin.document.write("<td align=\\"center\\"><input name=\\"msgn"+ctr+"\\" type=\\"checkbox\\"" +shwsel+"></td>"); |
pWin.document.write("<td><input name=\\"msg"+ctr+"\\" type=\\"text\\" value=\\""+msg+" \\" size=\\"60\\" maxlength=\\"80\\"></td></tr>"); |
pWin.document.write("<td><input name=\\"msg"+ctr+"\\" type=\\"text\\" value=\\""+msg+"\\" size=\\"60\\" maxlength=\\"80\\"></td></tr>"); |
} |
} |
|
|
function newMsg(newmsg,shwsel) { |
function newMsg(newmsg,shwsel) { |
pWin.document.write("<tr bgcolor=\\"#ffffdd\\">"); |
pWin.document.write("<tr bgcolor=\\"#ffffdd\\">"); |
pWin.document.write("<td align=\\"center\\">New</td>"); |
pWin.document.write("<td align=\\"center\\">New</td>"); |
pWin.document.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"></td>"); |
pWin.document.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"></td>"); |
pWin.document.write("<td><input name=\\"newmsg\\" type=\\"text\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" value=\\""+newmsg+" \\" size=\\"60\\" maxlength=\\"80\\"></td></tr>"); |
pWin.document.write("<td><input name=\\"newmsg\\" type=\\"text\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" value=\\""+newmsg+"\\" size=\\"60\\" maxlength=\\"80\\"></td></tr>"); |
} |
} |
|
|
function msgTail() { |
function msgTail() { |
Line 795 function displaySavedMsg(ctr,msg,shwsel)
|
Line 882 function displaySavedMsg(ctr,msg,shwsel)
|
SUBJAVASCRIPT |
SUBJAVASCRIPT |
} |
} |
|
|
|
#--- displays the grading box, used in essay type problem and grading by page/sequence |
|
sub gradeBox { |
|
my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_; |
|
|
|
my $checkIcon = '<img src="'.$request->dir_config('lonIconsURL'). |
|
'/check.gif" height="16" border="0" />'; |
|
|
|
my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname); |
|
my $wgtmsg = ($wgt > 0 ? '(problem weight)' : |
|
'<font color="red">problem weight assigned by computer</font>'); |
|
$wgt = ($wgt > 0 ? $wgt : '1'); |
|
my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ? |
|
'' : $$record{'resource.'.$partid.'.awarded'}*$wgt); |
|
my $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />'."\n"; |
|
|
|
$result.='<table border="0"><tr><td>'. |
|
'<b>Part </b>'.$partid.' <b>Points: </b></td><td>'."\n"; |
|
|
|
my $ctr = 0; |
|
$result.='<table border="0"><tr>'."\n"; # display radio buttons in a nice table 10 across |
|
while ($ctr<=$wgt) { |
|
$result.= '<td><input type="radio" name="RADVAL'.$counter.'_'.$partid.'" '. |
|
'onclick="javascript:writeBox(this.form,\''.$counter.'_'.$partid.'\','. |
|
$ctr.','.$wgt.')" value="'.$ctr.'" '. |
|
($score eq $ctr ? 'checked':'').' /> '.$ctr."</td>\n"; |
|
$result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : ''); |
|
$ctr++; |
|
} |
|
$result.='</tr></table>'; |
|
|
|
$result.='</td><td> <b>or</b> </td>'."\n"; |
|
$result.='<td><input type="text" name="GD_BOX'.$counter.'_'.$partid.'"'. |
|
($score ne ''? ' value = "'.$score.'"':'').' size="4" '. |
|
'onChange="javascript:updateRadio(this.form,\''.$counter.'_'.$partid.'\','. |
|
$wgt.')" /></td>'."\n"; |
|
$result.='<td>/'.$wgt.' '.$wgtmsg. |
|
($$record{'resource.'.$partid.'.solved'} eq 'correct_by_student' ? ' '.$checkIcon : ''). |
|
' </td><td>'."\n"; |
|
|
|
$result.='<select name="GD_SEL'.$counter.'_'.$partid.'" '. |
|
'onChange="javascript:clearRadBox(this.form,\''.$counter.'_'.$partid.'\')" >'."\n"; |
|
if ($$record{'resource.'.$partid.'.solved'} eq 'excused') { |
|
$result.='<option> </option>'. |
|
'<option selected="on">excused</option></select>'."\n"; |
|
} else { |
|
$result.='<option selected="on"> </option>'. |
|
'<option>excused</option></select>'."\n"; |
|
} |
|
$result.="  \n"; |
|
$result.='<input type="hidden" name="stores'.$counter.'_'.$partid.'" value="" />'."\n". |
|
'<input type="hidden" name="oldpts'.$counter.'_'.$partid.'" value="'.$score.'" />'."\n". |
|
'<input type="hidden" name="solved'.$counter.'_'.$partid.'" value="'. |
|
$$record{'resource.'.$partid.'.solved'}.'" />'."\n"; |
|
$result.='</td></tr></table>'."\n"; |
|
return $result; |
|
} |
|
|
sub show_problem { |
sub show_problem { |
my ($request,$symb,$uname,$udom,$removeform) = @_; |
my ($request,$symb,$uname,$udom,$removeform,$viewon) = @_; |
my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom, |
my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom, |
$ENV{'request.course.id'}); |
$ENV{'request.course.id'}); |
if ($removeform) { |
if ($removeform) { |
Line 813 sub show_problem {
|
Line 956 sub show_problem {
|
$rendered=~s|name="submit"|name="would_have_been_submit"|g; |
$rendered=~s|name="submit"|name="would_have_been_submit"|g; |
} |
} |
my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">'; |
my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">'; |
$result.='<table border="0" width="100%"><tr><td bgcolor="#e6ffff">'; |
$result.='<table border="0" width="100%">'; |
$result.='<b> View of the problem - '.$ENV{'form.fullname'}. |
$result.='<tr><td bgcolor="#e6ffff"><b> View of the problem - '.$ENV{'form.fullname'}. |
'</b></td></tr><tr><td bgcolor="#ffffff">'.$rendered.'<br />'; |
'</b></td></tr>' if ($viewon); |
|
$result.='<tr><td bgcolor="#ffffff">'.$rendered.'<br />'; |
$result.='<b>Correct answer:</b><br />'.$companswer; |
$result.='<b>Correct answer:</b><br />'.$companswer; |
$result.='</td></tr></table>'; |
$result.='</td></tr></table>'; |
$result.='</td></tr></table><br />'; |
$result.='</td></tr></table><br />'; |
$request->print($result); |
return $result; |
|
# $request->print($result); |
} |
} |
|
|
# --------------------------- show submissions of a student, option to grade |
# --------------------------- show submissions of a student, option to grade |
Line 841 sub submission {
|
Line 986 sub submission {
|
# header info |
# header info |
if ($counter == 0) { |
if ($counter == 0) { |
&sub_page_js($request); |
&sub_page_js($request); |
|
&sub_page_kw_js($request); |
$request->print('<h3> <font color="#339933">Submission Record</font></h3>'."\n". |
$request->print('<h3> <font color="#339933">Submission Record</font></h3>'."\n". |
'<font size=+1> <b>Resource: </b>'.$url.'</font>'."\n"); |
'<font size=+1> <b>Problem: </b>'. |
|
&Apache::lonnet::metadata($url,'title').'</font>'."\n"); |
|
|
# option to display problem, only once else it cause problems |
# option to display problem, only once else it cause problems |
# with the form later since the problem has a form. |
# with the form later since the problem has a form. |
if ($ENV{'form.vProb'} eq 'yes') { |
if ($ENV{'form.vProb'} eq 'yes' or !$ENV{'form.vProb'}) { |
&show_problem($request,$symb,$uname,$udom,0); |
$request->print(&show_problem($request,$symb,$uname,$udom,0,1)); |
} |
} |
|
|
# kwclr is the only variable that is guaranteed to be non blank |
# kwclr is the only variable that is guaranteed to be non blank |
Line 911 KEYWORDS
|
Line 1058 KEYWORDS
|
} |
} |
|
|
if ($ENV{'form.vProb'} eq 'all') { |
if ($ENV{'form.vProb'} eq 'all') { |
$request->print('<br /><br /><br />'); |
$request->print('<br /><br /><br />') if ($counter > 0); |
&show_problem($request,$symb,$uname,$udom,1); |
$request->print(&show_problem($request,$symb,$uname,$udom,1,1)); |
} |
} |
|
|
my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname); |
my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname); |
Line 1008 KEYWORDS
|
Line 1155 KEYWORDS
|
} else { |
} else { |
my ($string,$timestamp)= |
my ($string,$timestamp)= |
&get_last_submission (%record); |
&get_last_submission (%record); |
my $lastsubonly.=''. |
my $lastsubonly=''. |
($$timestamp eq '' ? '' : '<b>Date Submitted:</b> '. |
($$timestamp eq '' ? '' : '<b>Date Submitted:</b> '. |
$$timestamp).''; |
$$timestamp).''; |
if ($$timestamp eq '') { |
if ($$timestamp eq '') { |
Line 1021 KEYWORDS
|
Line 1168 KEYWORDS
|
my ($ressub,$subval) = split(/:/,$_,2); |
my ($ressub,$subval) = split(/:/,$_,2); |
$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '. |
$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '. |
$partid.'</b> <font color="#999999">( ID '.$respid. |
$partid.'</b> <font color="#999999">( ID '.$respid. |
' )</font> <b>Answer: </b>'. |
' )</font> '. |
|
($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 />':''). |
|
'<b>Answer: </b>'. |
&keywords_highlight($subval).'</td></tr>'."\n" |
&keywords_highlight($subval).'</td></tr>'."\n" |
if ($ENV{'form.lastSub'} eq 'lastonly' || |
if ($ENV{'form.lastSub'} eq 'lastonly' || |
($ENV{'form.lastSub'} eq 'hdgrade' && |
($ENV{'form.lastSub'} eq 'hdgrade' && |
Line 1073 KEYWORDS
|
Line 1225 KEYWORDS
|
$seen{$partid}++; |
$seen{$partid}++; |
next if ($$handgrade{$_} =~ /:no$/); |
next if ($$handgrade{$_} =~ /:no$/); |
push @partlist,$partid; |
push @partlist,$partid; |
my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname); |
|
my $wgtmsg = ($wgt > 0 ? '(problem weight)' : |
|
'<font color="red">problem weight assigned by computer</font>'); |
|
$wgt = ($wgt > 0 ? $wgt : '1'); |
|
my $score = ($record{'resource.'.$partid.'.awarded'} eq '' ? |
|
'' : $record{'resource.'.$partid.'.awarded'}*$wgt); |
|
$result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />'; |
|
$result.='<table border="0"><tr><td><b>Part </b>'.$partid.' <b>Points: </b></td><td>'; |
|
|
|
my $ctr = 0; |
$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record)); |
$result.='<table border="0"><tr>'; # display radio buttons in a nice table 10 across |
|
while ($ctr<=$wgt) { |
|
$result.= '<td><input type="radio" name="RADVAL'.$counter.'_'.$partid.'" '. |
|
'onclick="javascript:writeBox(this.form.GD_BOX'.$counter.'_'.$partid. |
|
',this.form.GD_SEL'.$counter.'_'.$partid.','.$ctr. |
|
',this.form.stores'.$counter.'_'.$partid.')" '. |
|
($score eq $ctr ? 'checked':'').' /> '.$ctr."</td>\n"; |
|
$result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : ''); |
|
$ctr++; |
|
} |
|
$result.='</tr></table>'; |
|
|
|
$result.='</td><td> <b>or</b> </td>'; |
# $request->print($result); |
$result.='<td><input type="text" name="GD_BOX'.$counter.'_'.$partid.'"'. |
|
($score ne ''? ' value = "'.$score.'"':'').' size="4" '. |
|
'onChange="javascript:updateRadio(this.form.RADVAL'.$counter.'_'.$partid. |
|
',this.form.GD_BOX'.$counter.'_'.$partid. |
|
',this.form.GD_SEL'.$counter.'_'.$partid. |
|
',this.form.stores'.$counter.'_'.$partid. |
|
','.$wgt.')" /></td>'."\n"; |
|
$result.='<td>/'.$wgt.' '.$wgtmsg.' </td><td>'; |
|
|
|
$result.='<select name="GD_SEL'.$counter.'_'.$partid.'" '. |
|
'onChange="javascript:clearRadBox(this.form.RADVAL'.$counter.'_'.$partid. |
|
',this.form.GD_BOX'.$counter.'_'.$partid. |
|
',this.form.GD_SEL'.$counter.'_'.$partid. |
|
',this.form.stores'.$counter.'_'.$partid.')" >'."\n"; |
|
if ($record{'resource.'.$partid.'.solved'} eq 'excused') { |
|
$result.='<option> </option>'. |
|
'<option selected="on">excused</option></select>'; |
|
} else { |
|
$result.='<option selected="on"> </option>'. |
|
'<option>excused</option></select>'; |
|
} |
|
$result.="  \n"; |
|
$result.='<input type="hidden" name="stores'.$counter.'_'.$partid.'" value="0" />'; |
|
$result.='</td></tr></table>'."\n"; |
|
$request->print($result); |
|
} |
} |
$result='<input type="hidden" name="partlist'.$counter. |
$result='<input type="hidden" name="partlist'.$counter. |
'" value="'.(join ":",@partlist).'" />'."\n"; |
'" value="'.(join ":",@partlist).'" />'."\n"; |
Line 1138 KEYWORDS
|
Line 1246 KEYWORDS
|
'<input type="hidden" name="gradeOpt" value="" />'."\n"; |
'<input type="hidden" name="gradeOpt" value="" />'."\n"; |
if ($ENV{'form.handgrade'} eq 'yes') { |
if ($ENV{'form.handgrade'} eq 'yes') { |
$endform.='<input type="button" value="Save & Next" '. |
$endform.='<input type="button" value="Save & Next" '. |
'onClick="javascript:checksubmit(\'Save & Next\','. |
'onClick="javascript:checksubmit(this.form,\'Save & Next\','. |
$total.','.scalar(@partlist).');" TARGET=_self> '."\n"; |
$total.','.scalar(@partlist).');" TARGET=_self> '."\n"; |
my $ntstu ='<select name="NTSTU">'. |
my $ntstu ='<select name="NTSTU">'. |
'<option>1</option><option>2</option>'. |
'<option>1</option><option>2</option>'. |
Line 1151 KEYWORDS
|
Line 1259 KEYWORDS
|
$endform.='<input type="hidden" name="NTSTU" value="1" />'."\n"; |
$endform.='<input type="hidden" name="NTSTU" value="1" />'."\n"; |
} |
} |
$endform.='<input type="button" value="Next" '. |
$endform.='<input type="button" value="Next" '. |
'onClick="javascript:checksubmit(\'Next\');" TARGET=_self> '."\n". |
'onClick="javascript:checksubmit(this.form,\'Next\');" TARGET=_self> '."\n". |
'<input type="button" value="Previous" '. |
'<input type="button" value="Previous" '. |
'onClick="javascript:checksubmit(\'Previous\');" TARGET=_self> '; |
'onClick="javascript:checksubmit(this.form,\'Previous\');" TARGET=_self> '; |
$endform.='(Next and Previous do not save the scores.)'."\n" |
$endform.='(Next and Previous do not save the scores.)'."\n" |
if ($ENV{'form.handgrade'} eq 'yes'); |
if ($ENV{'form.handgrade'} eq 'yes'); |
$endform.='</td><tr></table></form>'; |
$endform.='</td><tr></table></form>'; |
Line 1223 sub processHandGrade {
|
Line 1331 sub processHandGrade {
|
while ($ctr < $ngrade) { |
while ($ctr < $ngrade) { |
my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr}); |
my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr}); |
my ($errorflag) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr); |
my ($errorflag) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr); |
|
if ($errorflag eq 'no_score') { |
|
$ctr++; |
|
next; |
|
} |
|
|
my $includemsg = $ENV{'form.includemsg'.$ctr}; |
my $includemsg = $ENV{'form.includemsg'.$ctr}; |
my ($subject,$message,$msgstatus) = ('','',''); |
my ($subject,$message,$msgstatus) = ('','',''); |
if ($includemsg =~ /savemsg|new$ctr/) { |
if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) { |
$subject = $ENV{'form.msgsub'} if ($includemsg =~ /^msgsub/); |
$subject = $ENV{'form.msgsub'} if ($includemsg =~ /^msgsub/); |
my (@msgnum) = split(/,/,$includemsg); |
my (@msgnum) = split(/,/,$includemsg); |
foreach (@msgnum) { |
foreach (@msgnum) { |
Line 1386 sub saveHandGrade {
|
Line 1498 sub saveHandGrade {
|
my $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? |
my $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? |
$ENV{'form.GD_BOX'.$newflg.'_'.$_} : |
$ENV{'form.GD_BOX'.$newflg.'_'.$_} : |
$ENV{'form.RADVAL'.$newflg.'_'.$_}); |
$ENV{'form.RADVAL'.$newflg.'_'.$_}); |
|
return 'no_score' if ($pts eq '' && $ENV{'form.GD_SEL'.$newflg.'_'.$_} eq ''); |
my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 : |
my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 : |
$ENV{'form.WGT'.$newflg.'_'.$_}; |
$ENV{'form.WGT'.$newflg.'_'.$_}; |
my $partial= $pts/$wgt; |
my $partial= $pts/$wgt; |
Line 1594 sub viewgrades {
|
Line 1707 sub viewgrades {
|
my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'}); |
my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'}); |
my $result='<h3><font color="#339933">Manual Grading</font></h3>'; |
my $result='<h3><font color="#339933">Manual Grading</font></h3>'; |
|
|
$result.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font>'."\n"; |
$result.='<font size=+1><b>Problem: </b>'.&Apache::lonnet::metadata($ENV{'form.url'},'title') |
|
.'</font>'."\n"; |
|
|
#view individual student submission form - called using Javascript viewOneStudent |
#view individual student submission form - called using Javascript viewOneStudent |
$result.=&jscriptNform($url,$symb); |
$result.=&jscriptNform($url,$symb); |
Line 1725 sub viewstudentgrade {
|
Line 1839 sub viewstudentgrade {
|
'<a href="javascript:viewOneStudent(\''.$uname.'\',\''.$udom. |
'<a href="javascript:viewOneStudent(\''.$uname.'\',\''.$udom. |
'\')"; TARGET=_self>'.$fullname.'</a>'. |
'\')"; TARGET=_self>'.$fullname.'</a>'. |
'</td><td>'.$uname.'</td><td align="middle">'.$udom.'</td>'."\n"; |
'</td><td>'.$uname.'</td><td align="middle">'.$udom.'</td>'."\n"; |
foreach my $part (@$parts) { |
foreach my $apart (@$parts) { |
my ($part,$type) = &split_part_type($part); |
my ($part,$type) = &split_part_type($apart); |
my $score=$record{"resource.$part.$type"}; |
my $score=$record{"resource.$part.$type"}; |
if ($type eq 'awarded') { |
if ($type eq 'awarded') { |
my $pts = $score eq '' ? '' : $score*$$weight{$part}; |
my $pts = $score eq '' ? '' : $score*$$weight{$part}; |
Line 1770 sub editgrades {
|
Line 1884 sub editgrades {
|
my $symb=$ENV{'form.symb'}; |
my $symb=$ENV{'form.symb'}; |
my $url =$ENV{'form.url'}; |
my $url =$ENV{'form.url'}; |
my $title='<h3><font color="#339933">Current Grade Status</font></h3>'; |
my $title='<h3><font color="#339933">Current Grade Status</font></h3>'; |
$title.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br />'."\n"; |
$title.='<font size=+1><b>Problem: </b>'. |
|
&Apache::lonnet::metadata($ENV{'form.url'},'title').'</font><br />'."\n"; |
$title.='<font size=+1><b>Section: </b>'.$ENV{'form.section'}.'</font>'."\n"; |
$title.='<font size=+1><b>Section: </b>'.$ENV{'form.section'}.'</font>'."\n"; |
$title.= &show_grading_menu_form ($symb,$url); |
$title.= &show_grading_menu_form ($symb,$url); |
my $result= '<table border="0"><tr><td bgcolor="#777777">'."\n"; |
my $result= '<table border="0"><tr><td bgcolor="#777777">'."\n"; |
Line 1994 sub csvuploadmap_header {
|
Line 2109 sub csvuploadmap_header {
|
} |
} |
|
|
my $result='<table border="0">'; |
my $result='<table border="0">'; |
$result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>'; |
$result.='<tr><td colspan=3><font size=+1><b>Problem: </b>'.&Apache::lonnet::metadata($url,'title') |
|
.'</font></td></tr>'; |
my ($partlist,$handgrade) = &response_type($url); |
my ($partlist,$handgrade) = &response_type($url); |
my ($resptype,$hdgrade)=('','no'); |
my ($resptype,$hdgrade)=('','no'); |
for (sort keys(%$handgrade)) { |
for (sort keys(%$handgrade)) { |
Line 2178 sub gradingmenu {
|
Line 2294 sub gradingmenu {
|
if (!$symb) {return '';} |
if (!$symb) {return '';} |
my $result='<h3> <font color="#339933">Select a Grading Method</font></h3>'; |
my $result='<h3> <font color="#339933">Select a Grading Method</font></h3>'; |
$result.='<table border="0">'; |
$result.='<table border="0">'; |
$result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>'; |
$result.='<tr><td colspan=3><font size=+1><b>Problem: </b>'. |
|
&Apache::lonnet::metadata($ENV{'form.url'},'title').'</font></td></tr>'; |
my ($partlist,$handgrade) = &response_type($url); |
my ($partlist,$handgrade) = &response_type($url); |
my ($resptype,$hdgrade)=('','no'); |
my ($resptype,$hdgrade)=('','no'); |
for (sort keys(%$handgrade)) { |
for (sort keys(%$handgrade)) { |
Line 2193 sub gradingmenu {
|
Line 2310 sub gradingmenu {
|
$result.=&view_edit_entire_class_form($symb,$url).'<br />'; |
$result.=&view_edit_entire_class_form($symb,$url).'<br />'; |
$result.=&upcsvScores_form($symb,$url).'<br />'; |
$result.=&upcsvScores_form($symb,$url).'<br />'; |
$result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).'<br />'; |
$result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).'<br />'; |
|
$result.=&gradeByPage_form($symb,$url,$resptype,$hdgrade).'<br />'; |
$result.=&verifyReceipt_form($symb,$url) |
$result.=&verifyReceipt_form($symb,$url) |
if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)); |
if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)); |
|
|
Line 2264 sub viewGradeaStu_form {
|
Line 2382 sub viewGradeaStu_form {
|
my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n"; |
my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n"; |
$result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n"; |
$result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n"; |
$result.=' <b>'; |
$result.=' <b>'; |
if ($handgrade eq 'yes') { |
$result.=($handgrade eq 'yes' ? 'View/Grade' : 'View').' an Individual Student\'s Submission</b></td></tr>'."\n"; |
$result.="View/Grade "; |
|
} else { |
|
$result.="View "; |
|
} |
|
$result.='an Individual Student\'s Submission</b></td></tr>'."\n"; |
|
$result.='<tr bgcolor=#ffffe6><td>'."\n"; |
$result.='<tr bgcolor=#ffffe6><td>'."\n"; |
$result.='<form action="/adm/grades" method="post">'."\n". |
$result.='<form action="/adm/grades" method="post">'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
Line 2305 sub viewGradeaStu_form {
|
Line 2418 sub viewGradeaStu_form {
|
return $result; |
return $result; |
} |
} |
|
|
|
#--- Handgrading problems by page/sequence for each student --- |
|
sub gradeByPage_form { |
|
my ($symb,$url,$response,$handgrade) = @_; |
|
my ($classlist,$sections) = &getclasslist('all','0'); |
|
my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n"; |
|
$result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n"; |
|
$result.=' <b>'; |
|
$result.='Handgrade an Individual Student\'s by Page/Sequence</b></td></tr>'."\n"; |
|
$result.='<tr bgcolor=#ffffe6><td>'."\n"; |
|
$result.='<form action="/adm/grades" method="post">'."\n". |
|
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
|
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
|
'<input type="hidden" name="response" value="'.$response.'" />'."\n". |
|
'<input type="hidden" name="handgrade" value="'.$handgrade.'" />'."\n". |
|
'<input type="hidden" name="showgrading" value="yes" />'."\n". |
|
'<input type="hidden" name="command" value="pickStudentPage" />'."\n"; |
|
|
|
$result.=' <b>Select section:</b> <select name="section">'."\n"; |
|
if (ref($sections)) { |
|
foreach (sort (@$sections)) {$result.='<option>'.$_.'</option>'."\n";} |
|
} |
|
$result.= '<option selected="on">all</select>'."\n"; |
|
|
|
$result.='<br /> <input type="button" onClick="submit();" value="'; |
|
$result.='View/Grade'.'" />'."\n".'</form>'."\n"; |
|
$result.='</td></tr></table>'."\n"; |
|
$result.='</td></tr></table>'."\n"; |
|
return $result; |
|
} |
|
|
|
sub pickStudentPage { |
|
my ($request) = shift; |
|
|
|
$request->print(<<LISTJAVASCRIPT); |
|
<script type="text/javascript" language="javascript"> |
|
|
|
function checkPickOne(formname) { |
|
var user = radioSelection(formname.student); |
|
if (user == null) { |
|
alert("Please select the student you wish to grade."); |
|
return; |
|
} |
|
var ptr = pullDownSelection(formname.selectpage); |
|
formname.page.value = eval("formname.page"+ptr+".value"); |
|
formname.title.value = eval("formname.title"+ptr+".value"); |
|
formname.submit(); |
|
} |
|
|
|
function radioSelection(radioButton) { |
|
var selection=null; |
|
for (var i=0; i<radioButton.length; i++) { |
|
if (radioButton[i].checked) { |
|
selection=radioButton[i].value; |
|
return selection; |
|
} |
|
} |
|
return selection; |
|
} |
|
|
|
function pullDownSelection(selectOne) { |
|
var selection=null; |
|
for (var i=0; i<selectOne.length; i++) { |
|
if (selectOne[i].selected) { |
|
selection=selectOne[i].value; |
|
return selection; |
|
} |
|
} |
|
} |
|
</script> |
|
LISTJAVASCRIPT |
|
|
|
my ($symb,$url) = &get_symb_and_url(); |
|
my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"}; |
|
my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"}; |
|
my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'}; |
|
|
|
my $result='<h3><font color="#339933"> '. |
|
'Manual Grading by Page or Sequence</font></h3>'; |
|
|
|
$result.='<form action="/adm/grades" method="post" name="displayPage">'."<br>\n"; |
|
$result.=' <b>Problems from:</b> <select name="selectpage">'."\n"; |
|
my ($titles,$symbx) = &getSymbMap(); |
|
my ($curpage,$type,$mapId) = ($symb =~ /(.*?\.(page|sequence))___(\d+)___/); |
|
my $ctr=0; |
|
foreach (@$titles) { |
|
my ($minder,$showtitle) = ($_ =~ /(\d+)\.(.*)/); |
|
$result.='<option value="'.$ctr.'" '. |
|
($$symbx{$_} =~ /$curpage$/ ? 'selected="on"' : ''). |
|
'>'.$showtitle.'</option>'."\n"; |
|
$ctr++; |
|
} |
|
$result.= '</select>'."<br>\n"; |
|
$ctr=0; |
|
foreach (@$titles) { |
|
my ($minder,$showtitle) = ($_ =~ /(\d+)\.(.*)/); |
|
$result.='<input type="hidden" name="page'.$ctr.'" value="'.$$symbx{$_}.'" />'."\n"; |
|
$result.='<input type="hidden" name="title'.$ctr.'" value="'.$showtitle.'" />'."\n"; |
|
$ctr++; |
|
} |
|
$result.='<input type="hidden" name="page" />'."\n"; |
|
$result.='<input type="hidden" name="title" />'."\n"; |
|
|
|
$result.=' <b>View Problems: </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>'. |
|
'<input type="radio" name="lastSub" value="none" /> none'."\n". |
|
'<input type="radio" name="lastSub" value="datesub" checked /> dates and submissions'."\n". |
|
'<input type="radio" name="lastSub" value="all" /> all details'."\n"; |
|
$result.='<input type="hidden" name="section" value="'.$getsec.'" />'."\n". |
|
'<input type="hidden" name="command" value="displayPage" />'."\n". |
|
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
|
'<input type="hidden" name="symb" value="'.$symb.'" />'."<br><br>\n"; |
|
$request->print($result); |
|
|
|
my $studentTable.=' <b>Select a Student you wish to grade</b><br>'. |
|
'<table border="0"><tr><td bgcolor="#777777">'. |
|
'<table border="0"><tr bgcolor="#e6ffff">'. |
|
'<td><b> Fullname <font color="#999999">(username)</font></b></td>'. |
|
'<td><b> Fullname <font color="#999999">(username)</font></b></td>'. |
|
'<td><b> Fullname <font color="#999999">(username)</font></b></td>'. |
|
'<td><b> Fullname <font color="#999999">(username)</font></b></td></tr>'; |
|
|
|
my (undef,undef,$fullname) = &getclasslist($getsec,'0'); |
|
my $ptr = 1; |
|
foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) { |
|
my ($uname,$udom) = split(/:/,$student); |
|
$studentTable.=($ptr%4 == 1 ? '<tr bgcolor="#ffffe6"><td>' : '</td><td>'); |
|
$studentTable.='<input type="radio" name="student" value="'.$student.'" /> '.$$fullname{$student}. |
|
'<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font>'."\n"; |
|
$studentTable.=($ptr%4 == 0 ? '</td></tr>' : ''); |
|
$ptr++; |
|
} |
|
$studentTable.='</td><td> </td><td> </td><td> ' if ($ptr%4 == 2); |
|
$studentTable.='</td><td> </td><td> ' if ($ptr%4 == 3); |
|
$studentTable.='</td><td> ' if ($ptr%4 == 0); |
|
$studentTable.='</td></tr></table></td></tr></table>'."\n"; |
|
$studentTable.='<br /> <input type="button" '. |
|
'onClick="javascript:checkPickOne(this.form);"value="Submit" /></form>'."\n"; |
|
|
|
$studentTable.=&show_grading_menu_form($symb,$url); |
|
$request->print($studentTable); |
|
|
|
return ''; |
|
} |
|
|
|
sub getSymbMap { |
|
my $navmap = Apache::lonnavmaps::navmap-> new( |
|
$ENV{'request.course.fn'}.'.db', |
|
$ENV{'request.course.fn'}.'_parms.db',1, 1); |
|
|
|
my $res = $navmap->firstResource(); # temp resource to access constants |
|
$navmap->init(); |
|
|
|
# End navmap using boilerplate |
|
|
|
my $iterator = $navmap->getIterator(undef, undef, undef, 1); |
|
my $depth = 1; |
|
$iterator->next(); # ignore first BEGIN_MAP |
|
my $curRes = $iterator->next(); |
|
|
|
my %symbx = (); |
|
my @titles = (); |
|
my $minder=0; |
|
while ($depth > 0) { |
|
if ($curRes == $iterator->BEGIN_MAP()) {$depth++;} |
|
if ($curRes == $iterator->END_MAP()) { $depth--; } |
|
|
|
if (ref($curRes) && $curRes->is_map()) { |
|
my ($mapUrl, $id, $resUrl) = split(/___/, $curRes->symb()); # check map contains at least one problem |
|
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps |
|
|
|
my $mapiterator = $navmap->getIterator($map->map_start(), |
|
$map->map_finish()); |
|
|
|
my $mapdepth = 1; |
|
my $countProblems = 0; |
|
$mapiterator->next(); # skip the first BEGIN_MAP |
|
my $mapcurRes = $mapiterator->next(); # for "current resource" |
|
my $ctr=0; |
|
while ($mapdepth > 0 && $ctr < 100) { |
|
if($mapcurRes == $mapiterator->BEGIN_MAP) { $mapdepth++; } |
|
if($mapcurRes == $mapiterator->END_MAP) { $mapdepth++; } |
|
|
|
if (ref($mapcurRes) && $mapcurRes->is_problem() && !$mapcurRes->randomout) { |
|
$countProblems++; |
|
} |
|
$ctr++; |
|
} |
|
if ($countProblems > 0) { |
|
my $title = $curRes->compTitle(); |
|
push @titles,$minder.'.'.$title; # minder, just in case two titles are identical |
|
$symbx{$minder.'.'.$title} = $curRes->symb(); |
|
$minder++; |
|
} |
|
} |
|
$curRes = $iterator->next(); |
|
} |
|
|
|
$navmap->untieHashes(); |
|
return \@titles,\%symbx; |
|
} |
|
|
|
sub displayPage { |
|
my ($request) = shift; |
|
|
|
my ($symb,$url) = &get_symb_and_url(); |
|
my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"}; |
|
my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"}; |
|
my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'}; |
|
my $pageTitle = $ENV{'form.page'}; |
|
my (undef,undef,$fullname) = &getclasslist($getsec,'0'); |
|
my ($uname,$udom) = split(/:/,$ENV{'form.student'}); |
|
|
|
my $result='<h3><font color="#339933"> '.$ENV{'form.title'}.'</font></h3>'; |
|
$result.='<h3> Student: '.$$fullname{$ENV{'form.student'}}. |
|
'<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font></h3>'."\n"; |
|
|
|
&sub_page_js($request); |
|
$request->print($result); |
|
|
|
my $navmap = Apache::lonnavmaps::navmap-> new( |
|
$ENV{'request.course.fn'}.'.db', |
|
$ENV{'request.course.fn'}.'_parms.db',1, 1); |
|
my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'}); |
|
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps |
|
|
|
my $iterator = $navmap->getIterator($map->map_start(), |
|
$map->map_finish()); |
|
|
|
my $studentTable='<form action="/adm/grades" method="post" name="gradePage">'."\n". |
|
'<input type="hidden" name="command" value="gradeByPage" />'."\n". |
|
'<input type="hidden" name="student" value="'.$ENV{'form.student'}.'" />'."\n". |
|
'<input type="hidden" name="page" value="'.$pageTitle.'" />'."\n". |
|
'<input type="hidden" name="title" value="'.$ENV{'form.title'}.'" />'."\n". |
|
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
|
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n"; |
|
|
|
my $checkIcon = '<img src="'.$request->dir_config('lonIconsURL'). |
|
'/check.gif" height="16" border="0" />'; |
|
|
|
$studentTable.=' <b>Note:</b> A problem graded correct ('.$checkIcon. |
|
') by the computer cannot be changed.'."\n". |
|
'<table border="0"><tr><td bgcolor="#777777">'. |
|
'<table border="0"><tr bgcolor="#e6ffff">'. |
|
'<td align="center"><b> No </b></td>'. |
|
'<td><b> '.($ENV{'form.vProb'} eq 'no' ? 'Title' : 'Problem View').'/Grade</b></td></tr>'; |
|
|
|
my ($depth,$ctr,$question) = (1,0,1); |
|
$iterator->next(); # skip the first BEGIN_MAP |
|
my $curRes = $iterator->next(); # for "current resource" |
|
while ($depth > 0 && $ctr < 100) { # ctr, just in case it never gets out of loop |
|
if($curRes == $iterator->BEGIN_MAP) { $depth++; } |
|
if($curRes == $iterator->END_MAP) { $depth++; } |
|
|
|
if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) { |
|
my $parts = $curRes->parts(); |
|
if (scalar(@{$parts}) > 1) { shift @{$parts}; } |
|
my $title = $curRes->compTitle(); |
|
my $symbx = $curRes->symb(); |
|
$studentTable.='<tr bgcolor="#ffffe6"><td align="center" valign="top" >'.$question. |
|
(scalar(@{$parts}) == 1 ? '' : '<br>('.scalar(@{$parts}).' parts)').'</td>'; |
|
$studentTable.='<td valign="top">'; |
|
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'}); |
|
$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/<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 />'; |
|
} else { |
|
$studentTable.='<table border="0" width="100%"><tr><td bgcolor="#777777">'. |
|
'<table border="0" width="100%"><tr bgcolor="#e6ffff">'. |
|
'<td><b>Date/Time</b></td>'. |
|
'<td><b>Submission</b></td>'. |
|
'<td><b>Status </b></td></tr>'; |
|
my ($version); |
|
for ($version=1;$version<=$record{'version'};$version++) { |
|
my $timestamp = scalar(localtime($record{$version.':timestamp'})); |
|
$studentTable.='<tr bgcolor="#ffffff" valign="top"><td>'.$timestamp.'</td>'; |
|
my @versionKeys = split(/\:/,$record{$version.':keys'}); |
|
my @displaySub = (); |
|
foreach my $partid (@{$parts}) { |
|
my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys; |
|
$displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ? |
|
'<b>Part:</b> '.$partid.' <b>Submission:</b> ' |
|
.$record{$version.':'.$matchKey[0]}.'<br />' : ''; |
|
$displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ? |
|
'<b>Part:</b> '.$partid.' '. |
|
$record{"$version:resource.$partid.award"}.'/'. |
|
$record{"$version:resource.$partid.solved"}.'<br />' : ''; |
|
} |
|
$displaySub[1].=(exists $record{"$version:resource.regrader"}) ? |
|
'Manually graded by '.$record{"$version:resource.regrader"} : ''; |
|
$studentTable.='<td>'.$displaySub[0].' </td><td>'.$displaySub[1].' </td></tr>'; |
|
} |
|
$studentTable.='</table></td></tr></table>'; |
|
} |
|
} elsif ($ENV{'form.lastSub'} eq 'all') { |
|
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : ''); |
|
$studentTable.=&Apache::loncommon::get_previous_attempt($symbx,$uname,$udom, |
|
$ENV{'request.course.id'}, |
|
'','.submission'); |
|
|
|
} |
|
|
|
foreach my $partid (@{$parts}) { |
|
$studentTable.=&gradeBox($request,$symbx,$uname,$udom,$question,$partid,\%record); |
|
$studentTable.='<input type="hidden" name="q_'.$question.'" value="'.$partid.'" />'."\n"; |
|
$question++; |
|
} |
|
$studentTable.='</td></tr>'; |
|
|
|
} |
|
$curRes = $iterator->next(); |
|
$ctr++; |
|
} |
|
$navmap->init(); |
|
|
|
$studentTable.='</td></tr></table></td></tr></table>'."\n". |
|
' <input type="button" value="Save" '. |
|
'onClick="javascript:checkSubmitPage(this.form,'.$question.');" TARGET=_self />'. |
|
'</form>'."\n"; |
|
$studentTable.=&show_grading_menu_form($symb,$url); |
|
$request->print($studentTable); |
|
|
|
return ''; |
|
} |
|
|
|
sub updateGradeByPage { |
|
my ($request) = shift; |
|
|
|
my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"}; |
|
my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"}; |
|
my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'}; |
|
my $pageTitle = $ENV{'form.page'}; |
|
my (undef,undef,$fullname) = &getclasslist($getsec,'0'); |
|
my ($uname,$udom) = split(/:/,$ENV{'form.student'}); |
|
|
|
my $result='<h3><font color="#339933"> '.$ENV{'form.title'}.'</font></h3>'; |
|
$result.='<h3> Student: '.$$fullname{$ENV{'form.student'}}. |
|
'<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font></h3>'."\n"; |
|
|
|
$request->print($result); |
|
|
|
my $navmap = Apache::lonnavmaps::navmap-> new( |
|
$ENV{'request.course.fn'}.'.db', |
|
$ENV{'request.course.fn'}.'_parms.db',1, 1); |
|
my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'}); |
|
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps |
|
|
|
my $iterator = $navmap->getIterator($map->map_start(), |
|
$map->map_finish()); |
|
|
|
my $studentTable='<table border="0"><tr><td bgcolor="#777777">'. |
|
'<table border="0"><tr bgcolor="#e6ffff">'. |
|
'<td align="center"><b> No </b></td>'. |
|
'<td><b> Title </b></td>'. |
|
'<td><b> Previous Score </b></td>'. |
|
'<td><b> New Score </b></td></tr>'; |
|
|
|
$iterator->next(); # skip the first BEGIN_MAP |
|
my $curRes = $iterator->next(); # for "current resource" |
|
my ($depth,$ctr,$question,$changeflag)= (1,0,1,0); |
|
while ($depth > 0 && $ctr < 100) { # ctr, just in case it never gets out of loop |
|
if($curRes == $iterator->BEGIN_MAP) { $depth++; } |
|
if($curRes == $iterator->END_MAP) { $depth++; } |
|
|
|
if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) { |
|
my $parts = $curRes->parts(); |
|
if (scalar(@{$parts}) > 1) { shift @{$parts}; } |
|
my $title = $curRes->compTitle(); |
|
my $symbx = $curRes->symb(); |
|
$studentTable.='<tr bgcolor="#ffffe6"><td align="center" valign="top" >'.$question. |
|
(scalar(@{$parts}) == 1 ? '' : '<br>('.scalar(@{$parts}).' parts)').'</td>'; |
|
$studentTable.='<td valign="top"> <b>'.$title.'</b> </td>'; |
|
|
|
my %newrecord=(); |
|
my @displayPts=(); |
|
foreach my $partid (@{$parts}) { |
|
my $newpts = $ENV{'form.GD_BOX'.$question.'_'.$partid}; |
|
my $oldpts = $ENV{'form.oldpts'.$question.'_'.$partid}; |
|
|
|
my $wgt = $ENV{'form.WGT'.$question.'_'.$partid} != 0 ? |
|
$ENV{'form.WGT'.$question.'_'.$partid} : 1; |
|
my $partial = $newpts/$wgt; |
|
my $score; |
|
if ($partial > 0) { |
|
$score = 'correct_by_override'; |
|
} elsif ($partial == 0) { |
|
$score = 'incorrect_by_override'; |
|
} |
|
if ($ENV{'form.GD_SEL'.$question.'_'.$partid} eq 'excused') { |
|
$partial = ''; |
|
$score = 'excused'; |
|
} |
|
my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid}; |
|
$displayPts[0].=' <b>Part</b> '.$partid.' = '. |
|
(($oldstatus eq 'excused') ? 'excused' : $oldpts). |
|
' <br>'; |
|
$displayPts[1].=' <b>Part</b> '.$partid.' = '. |
|
($oldstatus eq 'correct_by_student' ? $oldpts : |
|
(($score eq 'excused') ? 'excused' : $newpts)). |
|
' <br>'; |
|
|
|
$question++; |
|
if (($oldstatus eq 'correct_by_student') || |
|
($newpts eq $oldpts && $score eq $oldstatus)) |
|
{ |
|
next; |
|
} |
|
$newrecord{'resource.'.$partid.'.awarded'} = $partial if $partial ne ''; |
|
$newrecord{'resource.'.$partid.'.solved'} = $score; |
|
|
|
$changeflag++; |
|
} |
|
if (scalar(keys(%newrecord)) > 0) { |
|
$newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; |
|
&Apache::lonnet::cstore(\%newrecord,$symbx,$ENV{'request.course.id'}, |
|
$udom,$uname); |
|
} |
|
$studentTable.='<td valign="top">'.$displayPts[0].'</td>'. |
|
'<td valign="top">'.$displayPts[1].'</td>'. |
|
'</tr>'; |
|
|
|
} |
|
$curRes = $iterator->next(); |
|
$ctr++; |
|
} |
|
$navmap->init(); |
|
|
|
$studentTable.='</td></tr></table></td></tr></table>'; |
|
$studentTable.=($changeflag == 0 ? 'No score was changed or updated.' : |
|
'The scores were changed for '. |
|
$changeflag.' problem'.($changeflag == 1 ? '.' : 's.')); |
|
$studentTable.=&show_grading_menu_form($ENV{'form.symb'},$ENV{'form.url'}); |
|
$request->print($studentTable); |
|
|
|
return ''; |
|
} |
|
|
|
|
#--- Form to input a receipt number --- |
#--- Form to input a receipt number --- |
sub verifyReceipt_form { |
sub verifyReceipt_form { |
my ($symb,$url) = @_; |
my ($symb,$url) = @_; |
Line 2392 sub handler {
|
Line 2960 sub handler {
|
} else { |
} else { |
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}); |
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}); |
if ($command eq 'submission') { |
if ($command eq 'submission') { |
&listStudents($request) if ($ENV{'form.student'} eq ''); |
($ENV{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0)); |
&submission($request,0,0) if ($ENV{'form.student'} ne ''); |
# if ($command eq 'submission') { |
|
# &listStudents($request) if ($ENV{'form.student'} eq ''); |
|
# &submission($request,0,0) if ($ENV{'form.student'} ne ''); |
|
} elsif ($command eq 'pickStudentPage') { |
|
&pickStudentPage($request); |
|
} elsif ($command eq 'displayPage') { |
|
&displayPage($request); |
|
} elsif ($command eq 'gradeByPage') { |
|
&updateGradeByPage($request); |
} elsif ($command eq 'processGroup') { |
} elsif ($command eq 'processGroup') { |
&processGroup($request); |
&processGroup($request); |
} elsif ($command eq 'gradingmenu') { |
} elsif ($command eq 'gradingmenu') { |