version 1.51, 2002/09/20 23:46:41
|
version 1.73, 2003/03/17 19:08:50
|
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::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 51 sub getpartlist {
|
Line 55 sub getpartlist {
|
my @parts =(); |
my @parts =(); |
my (@metakeys) = split(/,/,&Apache::lonnet::metadata($url,'keys')); |
my (@metakeys) = split(/,/,&Apache::lonnet::metadata($url,'keys')); |
foreach my $key (@metakeys) { |
foreach my $key (@metakeys) { |
if ( $key =~ m/stores_([0-9]+)_.*/) { |
if ( $key =~ m/stores_(\w+)_.*/) { |
push(@parts,$key); |
push(@parts,$key); |
} |
} |
} |
} |
Line 72 sub get_symb_and_url {
|
Line 76 sub get_symb_and_url {
|
sub get_fullname { |
sub get_fullname { |
my ($uname,$udom) = @_; |
my ($uname,$udom) = @_; |
my %name=&Apache::lonnet::get('environment', ['lastname','generation', |
my %name=&Apache::lonnet::get('environment', ['lastname','generation', |
'firstname','middlename'],$udom,$uname); |
'firstname','middlename'], |
|
$udom,$uname); |
my $fullname; |
my $fullname; |
my ($tmp) = keys(%name); |
my ($tmp) = keys(%name); |
if ($tmp !~ /^(con_lost|error|no_such_host)/i) { |
if ($tmp !~ /^(con_lost|error|no_such_host)/i) { |
$fullname=$name{'lastname'}.$name{'generation'}; |
$fullname = &Apache::loncoursedata::ProcessFullName |
if ($fullname =~ /[^\s]+/) { $fullname.=', '; } |
(@name{qw/lastname generation firstname middlename/}); |
$fullname.=$name{'firstname'}.' '.$name{'middlename'}; |
} else { |
|
&Apache::lonnet::logthis('grades.pm: no name data for '.$uname. |
|
'@'.$udom.':'.$tmp); |
} |
} |
return $fullname; |
return $fullname; |
} |
} |
Line 91 sub response_type {
|
Line 98 sub response_type {
|
my %seen = (); |
my %seen = (); |
my (@partlist,%handgrade); |
my (@partlist,%handgrade); |
foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) { |
foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) { |
if (/^\w+response_\d+.*/) { |
if (/^\w+response_\w+.*/) { |
my ($responsetype,$part) = split(/_/,$_,2); |
my ($responsetype,$part) = split(/_/,$_,2); |
my ($partid,$respid) = split(/_/,$part); |
my ($partid,$respid) = split(/_/,$part); |
$handgrade{$part} = $responsetype.':'.($allkeys =~ /parameter_$part\_handgrade/ ? 'yes' : 'no'); |
$handgrade{$part} = $responsetype.':'.($allkeys =~ /parameter_$part\_handgrade/ ? 'yes' : 'no'); |
Line 107 sub response_type {
|
Line 114 sub response_type {
|
#--- section, ids and fullnames for each user. |
#--- section, ids and fullnames for each user. |
sub getclasslist { |
sub getclasslist { |
my ($getsec,$hideexpired) = @_; |
my ($getsec,$hideexpired) = @_; |
my $now = time; |
my $classlist=&Apache::loncoursedata::get_classlist(); |
my %classlist=&Apache::lonnet::dump('classlist', |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); |
|
my ($tmp) = keys(%classlist); |
|
# Bail out if we were unable to get the classlist |
# Bail out if we were unable to get the classlist |
return if ($tmp =~ /^(con_lost|error|no_such_host)/i); |
return if (! defined($classlist)); |
|
# |
# codes to check for fields in the classlist |
my %sections; |
# should contain end:start:id:section:fullname |
my %fullnames; |
for (keys %classlist) { |
foreach (keys(%$classlist)) { |
my (@fields) = split(/:/,$classlist{$_}); |
# the following undefs are for 'domain', and 'username' respectively. |
%classlist = &reformat_classlist(\%classlist) if (scalar(@fields) <= 2); |
my (undef,undef,$end,$start,$id,$section,$fullname,$status)= |
last; |
@{$classlist->{$_}}; |
} |
|
|
|
my (@holdsec,@sections,%allids,%stusec,%fullname); |
|
foreach (keys(%classlist)) { |
|
my ($end,$start,$id,$section,$fullname)=split(/:/,$classlist{$_}); |
|
# still a student? |
# still a student? |
if (($hideexpired) && ($end) && ($end < $now)) { |
if (($hideexpired) && ($status ne 'Active')) { |
next; |
delete ($classlist->{$_}); |
} |
next; |
|
} |
$section = ($section ne '' ? $section : 'no'); |
$section = ($section ne '' ? $section : 'no'); |
push @holdsec,$section; |
|
if ($getsec eq 'all' || $getsec eq $section) { |
if ($getsec eq 'all' || $getsec eq $section) { |
push (@{ $classlist{$getsec} }, $_); |
$sections{$section}++; |
$allids{$_} =$id; |
$fullnames{$_}=$fullname; |
$stusec{$_} =$section; |
} else { |
$fullname{$_}=$fullname; |
delete($classlist->{$_}); |
} |
} |
} |
} |
my %seen = (); |
my %seen = (); |
foreach my $item (@holdsec) { |
my @sections = sort(keys(%sections)); |
push (@sections, $item) unless $seen{$item}++; |
return ($classlist,\@sections,\%fullnames); |
} |
|
return (\%classlist,\@sections,\%allids,\%stusec,\%fullname); |
|
} |
|
|
|
# add id, section and fullname to the classlist.db |
|
# done to maintain backward compatibility with older versions |
|
sub reformat_classlist { |
|
my ($classlist) = shift; |
|
foreach (sort keys(%$classlist)) { |
|
my ($unam,$udom) = split(/:/); |
|
my $section = &Apache::lonnet::usection($udom,$unam,$ENV{'request.course.id'}); |
|
my $fullname = &get_fullname ($unam,$udom); |
|
my %userid = &Apache::lonnet::idrget($udom,($unam)); |
|
$$classlist{$_} = $$classlist{$_}.':'.$userid{$unam}.':'.$section.':'.$fullname; |
|
} |
|
my $putresult = &Apache::lonnet::put |
|
('classlist',\%$classlist, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); |
|
|
|
return %$classlist; |
|
} |
} |
|
|
#find user domain |
#find user domain |
Line 232 sub jscriptNform {
|
Line 209 sub jscriptNform {
|
$jscript.= '<form action="/adm/grades" method="post" name="onestudent">'."\n". |
$jscript.= '<form action="/adm/grades" method="post" name="onestudent">'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
|
'<input type="hidden" name="lastCmd" value="'.$ENV{'form.lastCmd'}.'" />'."\n". |
|
'<input type="hidden" name="lastSec" value="'.$ENV{'form.lastSec'}.'" />'."\n". |
|
'<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n". |
'<input type="hidden" name="command" value="submission" />'."\n". |
'<input type="hidden" name="command" value="submission" />'."\n". |
'<input type="hidden" name="student" value="" />'."\n". |
'<input type="hidden" name="student" value="" />'."\n". |
'<input type="hidden" name="userdom" value="" />'."\n". |
'<input type="hidden" name="userdom" value="" />'."\n". |
Line 260 sub verifyreceipt {
|
Line 240 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>'.$ENV{'form.probTitle'}.'</font><br><br>'."\n"; |
|
|
my ($string,$contents,$matches) = ('','',0); |
my ($string,$contents,$matches) = ('','',0); |
my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0'); |
my (undef,undef,$fullname) = &getclasslist('all','0'); |
|
|
foreach (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) { |
foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) { |
my ($uname,$udom)=split(/\:/); |
my ($uname,$udom)=split(/\:/); |
if ($receipt eq |
if ($receipt eq |
&Apache::lonnet::ireceipt($uname,$udom,$courseid,$symb)) { |
&Apache::lonnet::ireceipt($uname,$udom,$courseid,$symb)) { |
Line 302 sub verifyreceipt {
|
Line 282 sub verifyreceipt {
|
sub listStudents { |
sub listStudents { |
my ($request) = shift; |
my ($request) = shift; |
|
|
my ($symb,$url) = &get_symb_and_url(); |
my ($symb,$url) = &get_symb_and_url($request); |
my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"}; |
my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"}; |
my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"}; |
my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"}; |
my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'}; |
my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'}; |
Line 319 sub listStudents {
|
Line 299 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>'.$ENV{'form.probTitle'}.'</font></td></tr>'.$result; |
|
|
$request->print(<<LISTJAVASCRIPT); |
$request->print(<<LISTJAVASCRIPT); |
<script type="text/javascript" language="javascript"> |
<script type="text/javascript" language="javascript"> |
Line 365 LISTJAVASCRIPT
|
Line 340 LISTJAVASCRIPT
|
my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked'; |
my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked'; |
|
|
my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n". |
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: </b><input type="radio" name="vProb" value="no" /> no '."\n". |
'<input type="radio" name="vProb" value="yes"> yes <br />'."\n". |
'<input type="radio" name="vProb" value="yes" checked /> one student '."\n". |
|
'<input type="radio" name="vProb" value="all" /> all students <br />'."\n". |
' <b>Submissions: </b>'."\n"; |
' <b>Submissions: </b>'."\n"; |
if ($ENV{'form.handgrade'} eq 'yes') { |
if ($ENV{'form.handgrade'} eq 'yes') { |
$gradeTable.='<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> handgrade only'."\n"; |
$gradeTable.='<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> handgrade only'."\n"; |
Line 379 LISTJAVASCRIPT
|
Line 355 LISTJAVASCRIPT
|
'<input type="hidden" name="response" value="'.$ENV{'form.response'}.'" />'."\n". |
'<input type="hidden" name="response" value="'.$ENV{'form.response'}.'" />'."\n". |
'<input type="hidden" name="handgrade" value="'.$ENV{'form.handgrade'}.'" /><br />'."\n". |
'<input type="hidden" name="handgrade" value="'.$ENV{'form.handgrade'}.'" /><br />'."\n". |
'<input type="hidden" name="showgrading" value="'.$ENV{'form.showgrading'}.'" /><br />'."\n". |
'<input type="hidden" name="showgrading" value="'.$ENV{'form.showgrading'}.'" /><br />'."\n". |
|
'<input type="hidden" name="lastCmd" value="'.$ENV{'form.lastCmd'}.'" />'."\n". |
|
'<input type="hidden" name="lastSec" value="'.$ENV{'form.lastSec'}.'" />'."\n". |
|
'<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'To '.lc($viewgrade).' a submission, click on the check box next to the student\'s name. Then '."\n". |
'To '.lc($viewgrade).' a submission, click on the check box next to the student\'s name. Then '."\n". |
Line 389 LISTJAVASCRIPT
|
Line 368 LISTJAVASCRIPT
|
'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n". |
'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n". |
'value="'.$viewgrade.'" />'."\n"; |
'value="'.$viewgrade.'" />'."\n"; |
|
|
my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($getsec,'0'); |
my (undef,undef,$fullname) = &getclasslist($getsec,'0'); |
|
|
$gradeTable.='<table border="0"><tr><td bgcolor="#777777">'. |
$gradeTable.='<table border="0"><tr><td bgcolor="#777777">'. |
'<table border="0"><tr bgcolor="#e6ffff">'. |
'<table border="0"><tr bgcolor="#e6ffff">'. |
Line 401 LISTJAVASCRIPT
|
Line 380 LISTJAVASCRIPT
|
$gradeTable.='</tr>'."\n"; |
$gradeTable.='</tr>'."\n"; |
|
|
my $ctr = 0; |
my $ctr = 0; |
foreach my $student (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) { |
foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) { |
my ($uname,$udom) = split(/:/,$student); |
my ($uname,$udom) = split(/:/,$student); |
my (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist); |
my (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist); |
my $statusflg = ''; |
my $statusflg = ''; |
Line 478 sub sub_page_js {
|
Line 457 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 oldpts = eval("formname.oldpts"+id+".value"); |
alert("A number equal or greater than 0 is expected. Entered value = "+pts); |
var pts = checkSolved(formname,id) == 'update' ? gradeBox.value : oldpts; |
for (var i=0; i<radioButton.length; i++) { |
gradeBox.value = pts; |
if (radioButton[i].checked) { |
var resetbox = false; |
formtextbox.value = i; |
if (isNaN(pts) || pts < 0) { |
resetbox = true; |
alert("A number equal or greater than 0 is expected. Entered value = "+pts); |
} |
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) { |
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 { |
|
var oldpts = eval("formname.oldpts"+id+".value"); |
|
gradeBox.value = oldpts; |
|
var radioButton = eval("formname.RADVAL"+id); |
|
for (var i=0; i<radioButton.length; i++) { |
|
radioButton[i].checked=false; |
|
if (i == oldpts) { |
|
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 637 sub sub_page_js {
|
Line 702 sub sub_page_js {
|
} |
} |
|
|
function savedMsgHeader(Nmsg,usrctr,fullname) { |
function savedMsgHeader(Nmsg,usrctr,fullname) { |
var height = 30*Nmsg+250; |
var height = 50*Nmsg+250; |
var scrollbar = "no"; |
var scrollbar = "no"; |
if (height > 600) { |
if (height > 600) { |
height = 600; |
height = 600; |
Line 697 sub sub_page_js {
|
Line 762 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><textarea name=\\"msg"+ctr+"\\" cols=\\"60\\" rows=\\"3\\">"+msg+"</textarea></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><textarea name=\\"newmsg\\" cols=\\"60\\" rows=\\"3\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" >"+newmsg+"</textarea></td></tr>"); |
} |
} |
|
|
function msgTail() { |
function msgTail() { |
Line 809 function displaySavedMsg(ctr,msg,shwsel)
|
Line 874 function displaySavedMsg(ctr,msg,shwsel)
|
function highlightend() { |
function highlightend() { |
hwdWin.document.write("</table>"); |
hwdWin.document.write("</table>"); |
hwdWin.document.write("</td></tr></table> "); |
hwdWin.document.write("</td></tr></table> "); |
// hwdWin.document.write("<input type=\\"button\\" value=\\"Save\\" onClick=\\"javascript:updateChoice(0)\\"> "); |
|
hwdWin.document.write("<input type=\\"button\\" value=\\"Save\\" onClick=\\"javascript:updateChoice(1)\\"> "); |
hwdWin.document.write("<input type=\\"button\\" value=\\"Save\\" onClick=\\"javascript:updateChoice(1)\\"> "); |
hwdWin.document.write("<input type=\\"button\\" value=\\"Cancel\\" onClick=\\"self.close()\\"><br><br>"); |
hwdWin.document.write("<input type=\\"button\\" value=\\"Cancel\\" onClick=\\"self.close()\\"><br><br>"); |
hwdWin.document.write("</form>"); |
hwdWin.document.write("</form>"); |
Line 820 function displaySavedMsg(ctr,msg,shwsel)
|
Line 884 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.')" 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 { |
|
my ($request,$symb,$uname,$udom,$removeform,$viewon) = @_; |
|
my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom, |
|
$ENV{'request.course.id'}); |
|
if ($removeform) { |
|
$rendered=~s|<form(.*?)>||g; |
|
$rendered=~s|</form>||g; |
|
$rendered=~s|name="submit"|name="would_have_been_submit"|g; |
|
} |
|
my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom, |
|
$ENV{'request.course.id'}); |
|
if ($removeform) { |
|
$companswer=~s|<form(.*?)>||g; |
|
$companswer=~s|</form>||g; |
|
$rendered=~s|name="submit"|name="would_have_been_submit"|g; |
|
} |
|
my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">'; |
|
$result.='<table border="0" width="100%">'; |
|
$result.='<tr><td bgcolor="#e6ffff"><b> View of the problem - '.$ENV{'form.fullname'}. |
|
'</b></td></tr>' if ($viewon); |
|
$result.='<tr><td bgcolor="#ffffff">'.$rendered.'<br />'; |
|
$result.='<b>Correct answer:</b><br />'.$companswer; |
|
$result.='</td></tr></table>'; |
|
$result.='</td></tr></table><br />'; |
|
return $result; |
|
} |
|
|
# --------------------------- show submissions of a student, option to grade |
# --------------------------- show submissions of a student, option to grade |
sub submission { |
sub submission { |
my ($request,$counter,$total) = @_; |
my ($request,$counter,$total) = @_; |
|
|
(my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; |
(my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; |
# if ($ENV{'form.student'} eq '') { &moreinfo($request,'Need student login id'); return ''; } |
|
my ($uname,$udom) = ($ENV{'form.student'},$ENV{'form.userdom'}); |
my ($uname,$udom) = ($ENV{'form.student'},$ENV{'form.userdom'}); |
($uname,$udom) = &finduser($uname) if $udom eq ''; |
($uname,$udom) = &finduser($uname) if $udom eq ''; |
$ENV{'form.fullname'} = &get_fullname ($uname,$udom) if $ENV{'form.fullname'} eq ''; |
$ENV{'form.fullname'} = &get_fullname ($uname,$udom) if $ENV{'form.fullname'} eq ''; |
# if ($uname eq '') { &moreinfo($request,'Unable to find student'); return ''; } |
|
|
|
my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url))); |
my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url))); |
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; } |
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; } |
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : ''); |
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : ''); |
$ENV{'form.vProb'} = $ENV{'form.vProb'} ne '' ? $ENV{'form.vProb'} : 'yes'; |
|
my ($classlist,$seclist,$ids,$stusec,$fullname); |
|
|
|
# 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>'.$ENV{'form.probTitle'}.'</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'}) { |
my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom, |
$request->print(&show_problem($request,$symb,$uname,$udom,0,1)); |
$ENV{'request.course.id'}); |
|
my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom, |
|
$ENV{'request.course.id'}); |
|
my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">'; |
|
$result.='<table border="0" width="100%"><tr><td bgcolor="#e6ffff">'; |
|
$result.='<b> View of the problem - '.$ENV{'form.fullname'}. |
|
'</b></td></tr><tr><td bgcolor="#ffffff">'.$rendered.'<br />'; |
|
$result.='<b>Correct answer:</b><br />'.$companswer; |
|
$result.='</td></tr></table>'; |
|
$result.='</td></tr></table><br />'; |
|
$request->print($result); |
|
} |
} |
|
|
# 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 875 sub submission {
|
Line 1008 sub submission {
|
$ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0'; |
$ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0'; |
$ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : ''; |
$ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : ''; |
$ENV{'form.msgsub'} = $keyhash{$symb.'_subject'} ne '' ? |
$ENV{'form.msgsub'} = $keyhash{$symb.'_subject'} ne '' ? |
$keyhash{$symb.'_subject'} : &Apache::lonnet::metadata($url,'title'); |
$keyhash{$symb.'_subject'} : $ENV{'form.probTitle'}; |
$ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0'; |
$ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0'; |
|
|
} |
} |
|
|
$request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n". |
$request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n". |
'<input type="hidden" name="command" value="handgrade" />'."\n". |
'<input type="hidden" name="command" value="handgrade" />'."\n". |
|
'<input type="hidden" name="lastCmd" value="'.$ENV{'form.lastCmd'}.'" />'."\n". |
|
'<input type="hidden" name="lastSec" value="'.$ENV{'form.lastSec'}.'" />'."\n". |
|
'<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n". |
'<input type="hidden" name="refresh" value="off" />'."\n". |
'<input type="hidden" name="refresh" value="off" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
Line 921 KEYWORDS
|
Line 1057 KEYWORDS
|
} |
} |
} |
} |
|
|
|
if ($ENV{'form.vProb'} eq 'all') { |
|
$request->print('<br /><br /><br />') if ($counter > 0); |
|
$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); |
my ($partlist,$handgrade) = &response_type($url); |
my ($partlist,$handgrade) = &response_type($url); |
|
|
Line 937 KEYWORDS
|
Line 1078 KEYWORDS
|
|
|
# If this is handgraded, then check for collaborators |
# If this is handgraded, then check for collaborators |
my @col_fullnames; |
my @col_fullnames; |
|
my ($classlist,$fullname); |
if ($ENV{'form.handgrade'} eq 'yes') { |
if ($ENV{'form.handgrade'} eq 'yes') { |
my @col_list; |
my @col_list; |
($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0'); |
($classlist,undef,$fullname) = &getclasslist('all','0'); |
for (keys (%$handgrade)) { |
for (keys (%$handgrade)) { |
my $ncol = &Apache::lonnet::EXT('resource.'.$_. |
my $ncol = &Apache::lonnet::EXT('resource.'.$_. |
'.maxcollaborators',$symb,$udom,$uname); |
'.maxcollaborators', |
if ($ncol > 0) { |
$symb,$udom,$uname); |
s/\_/\./g; |
next if ($ncol <= 0); |
if ($record{'resource.'.$_.'.collaborators'} ne '') { |
s/\_/\./g; |
my (@collaborators) = split(/,?\s+/, |
next if ($record{'resource.'.$_.'.collaborators'} eq ''); |
$record{'resource.'.$_.'.collaborators'}); |
my (@collaborators) = split(/,?\s+/, |
my (@badcollaborators); |
$record{'resource.'.$_.'.collaborators'}); |
if (scalar(@collaborators) != 0) { |
my (@badcollaborators); |
$result.='<b>Collaborators: </b>'; |
if (scalar(@collaborators) != 0) { |
foreach my $collaborator (@collaborators) { |
$result.='<b>Collaborators: </b>'; |
$collaborator = $collaborator =~ /\@|:/ ? |
foreach my $collaborator (@collaborators) { |
(split(/@|:/,$collaborator))[0] : $collaborator; |
my ($co_name,$co_dom) = split /\@|:/,$collaborator; |
next if ($collaborator eq $uname); |
$co_dom = $udom if (! defined($co_dom)); |
if (!grep /^$collaborator:/i,keys %$classlist) { |
next if ($co_name eq $uname && $co_dom eq $udom); |
push @badcollaborators,$collaborator; |
# Doing this grep allows 'fuzzy' specification |
next; |
my @Matches = grep /^$co_name:$co_dom/i, |
} |
keys %$classlist; |
push @col_list, $collaborator; |
if (! scalar(@Matches)) { |
my ($lastname,$givenn) = split(/,/,$$fullname{$collaborator.':'.$udom}); |
push @badcollaborators,$collaborator; |
push @col_fullnames, $givenn.' '.$lastname; |
next; |
$result.=$$fullname{$collaborator.':'.$udom}.' '; |
} |
} |
push @col_list, @Matches; |
$result.='<br />'."\n"; |
foreach (@Matches) { |
$result.='<table border="0"><tr bgcolor="#ffbbbb"><td>'. |
my ($lastname,$givenn) = split(/,/,$$fullname{$_}); |
'This student has submitted '. |
push @col_fullnames, $givenn.' '.$lastname; |
(scalar (@badcollaborators) > 1 ? '' : 'an'). |
$result.=$$fullname{$_}.' '; |
' invalid collaborator'.(scalar (@badcollaborators) > 1 ? 's. ' : '. '). |
} |
(join ', ',@badcollaborators).'</td></tr></table>' |
} |
if (scalar(@badcollaborators) > 0); |
$result.='<br />'."\n"; |
|
if (scalar(@badcollaborators) > 0) { |
$result.='<table border="0"><tr bgcolor="#ffbbbb"><td>'. |
$result.='<table border="0"><tr bgcolor="#ffbbbb"><td>'; |
'This student has submitted too many collaborators. Maximum is '. |
$result.='This student has submitted '; |
$ncol.'.</td></tr></table>' if (scalar(@collaborators) > $ncol); |
if (scalar(@badcollaborators) == 1) { |
$result.='<input type="hidden" name="collaborator'.$counter. |
$result .= 'an invalid collaborator'; |
'" value="'.(join ':',@col_list).'" />'."\n"; |
} else { |
} |
$result .= 'invalid collaborators'; |
} |
} |
} |
$result .= ': '.join(', ',@badcollaborators); |
|
|
|
} |
|
if (scalar(@collaborators > $ncol)) { |
|
$result .= '<table border="0"><tr bgcolor="#ffbbbb"><td>'; |
|
$result .= 'This student has sumbitted too many '. |
|
'collaborators. Maximum is '.$ncol; |
|
$result .= '</td></tr></table>'; |
|
} |
|
$result.='<input type="hidden" name="collaborator'.$counter. |
|
'" value="'.(join ':',@col_list).'" />'."\n"; |
|
} |
} |
} |
} |
} |
$request->print($result."\n"); |
$request->print($result."\n"); |
Line 1002 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 1015 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 1037 KEYWORDS
|
Line 1195 KEYWORDS
|
# return if view submission with no grading option |
# return if view submission with no grading option |
if ($ENV{'form.showgrading'} eq '') { |
if ($ENV{'form.showgrading'} eq '') { |
$request->print('</td></tr></table></td></tr></table></form>'."\n"); |
$request->print('</td></tr></table></td></tr></table></form>'."\n"); |
|
$request->print(&show_grading_menu_form($symb,$url)) |
|
if (($ENV{'form.command'} eq 'submission') || |
|
($ENV{'form.command'} eq 'processGroup' && $counter == $total)); |
return; |
return; |
} |
} |
|
|
Line 1067 KEYWORDS
|
Line 1228 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; |
|
$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(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record)); |
$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". |
|
'<option selected="on"> </option>'. |
|
'<option>excused</option></select>'."  \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 1126 KEYWORDS
|
Line 1247 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 1139 KEYWORDS
|
Line 1260 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 1161 sub get_last_submission {
|
Line 1282 sub get_last_submission {
|
for ($version=1;$version<=$returnhash{'version'};$version++) { |
for ($version=1;$version<=$returnhash{'version'};$version++) { |
foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) { |
foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) { |
$lasthash{$_}=$returnhash{$version.':'.$_}; |
$lasthash{$_}=$returnhash{$version.':'.$_}; |
if ($returnhash{$version.':'.$_} =~ /(SUBMITTED|DRAFT)$/) { |
|
$timestamp = scalar(localtime($returnhash{$version.':timestamp'})); |
$timestamp = scalar(localtime($returnhash{$version.':timestamp'})); |
} |
|
} |
} |
} |
} |
foreach ((keys %lasthash)) { |
foreach ((keys %lasthash)) { |
Line 1187 sub keywords_highlight {
|
Line 1306 sub keywords_highlight {
|
(my $styleoff = $styleon) =~ s/\</\<\//; |
(my $styleoff = $styleon) =~ s/\</\<\//; |
my @keylist = split(/[,\s+]/,$ENV{'form.keywords'}); |
my @keylist = split(/[,\s+]/,$ENV{'form.keywords'}); |
foreach (@keylist) { |
foreach (@keylist) { |
$string =~ s/\b$_(\b|\.)/\<font color\=$ENV{'form.kwclr'} $size\>$styleon$_$styleoff\<\/font\>/gi; |
$string =~ s/\b\Q$_\E(\b|\.)/\<font color\=$ENV{'form.kwclr'} $size\>$styleon$_$styleoff\<\/font\>/gi; |
} |
} |
|
# This is not really the right place to do this, but I cannot find a |
|
# better one at this time. So here we go - the m in the s:::mg causes |
|
# ^ to match the beginning of a new line. So we replace(???) the beginning |
|
# of the line with <br /> to make things formatted a little better. |
|
$string =~ s:^:<br />:mg; |
return $string; |
return $string; |
} |
} |
|
|
Line 1206 sub processHandGrade {
|
Line 1330 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) { |
$message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne ''); |
$message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne ''); |
} |
} |
$message =~ s/\s+/ /g; |
#$message =~ s/\s+/ /g; |
$msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom, |
$msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom, |
$ENV{'form.msgsub'},$message); |
$ENV{'form.msgsub'},$message); |
} |
} |
Line 1297 sub processHandGrade {
|
Line 1425 sub processHandGrade {
|
$laststu = $firststu if ($ctr > $ngrade); |
$laststu = $firststu if ($ctr > $ngrade); |
} |
} |
|
|
my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0'); |
my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0'); |
my (@parsedlist,@nextlist); |
my (@parsedlist,@nextlist); |
my ($nextflg) = 0; |
my ($nextflg) = 0; |
foreach (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) { |
foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) { |
if ($nextflg == 1 && $button =~ /Next$/) { |
if ($nextflg == 1 && $button =~ /Next$/) { |
push @parsedlist,$_; |
push @parsedlist,$_; |
} |
} |
Line 1337 sub processHandGrade {
|
Line 1465 sub processHandGrade {
|
$ENV{'form.student'} = $uname; |
$ENV{'form.student'} = $uname; |
$ENV{'form.userdom'} = $udom; |
$ENV{'form.userdom'} = $udom; |
$ENV{'form.fullname'} = $$fullname{$_}; |
$ENV{'form.fullname'} = $$fullname{$_}; |
# $ENV{'form.'.$_.':submitted_by'} = $submitter; |
|
# print "submitter=$ENV{'form.'.$_.':submitted_by'}= $submitter:<br>"; |
|
&submission($request,$ctr,$total); |
&submission($request,$ctr,$total); |
$ctr++; |
$ctr++; |
} |
} |
Line 1359 sub saveHandGrade {
|
Line 1485 sub saveHandGrade {
|
my %newrecord; |
my %newrecord; |
foreach (split(/:/,$ENV{'form.partlist'.$newflg})) { |
foreach (split(/:/,$ENV{'form.partlist'.$newflg})) { |
if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') { |
if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') { |
$newrecord{'resource.'.$_.'.solved'} = 'excused' |
if ($record{'resource.'.$_.'.solved'} ne 'excused') { |
if ($record{'resource.'.$_.'.solved'} ne 'excused'); |
$newrecord{'resource.'.$_.'.solved'} = 'excused'; |
|
if (exists($record{'resource.'.$_.'.awarded'})) { |
|
$newrecord{'resource.'.$_.'.awarded'} = ''; |
|
} |
|
} |
} else { |
} else { |
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 1380 sub saveHandGrade {
|
Line 1511 sub saveHandGrade {
|
} |
} |
$newrecord{'resource.'.$_.'.submitted_by'} = $submitter |
$newrecord{'resource.'.$_.'.submitted_by'} = $submitter |
if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter)); |
if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter)); |
|
$newrecord{'resource.'.$_.'regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; |
} |
} |
} |
} |
|
|
if (scalar(keys(%newrecord)) > 0) { |
if (scalar(keys(%newrecord)) > 0) { |
$newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; |
|
&Apache::lonnet::cstore(\%newrecord,$symb, |
&Apache::lonnet::cstore(\%newrecord,$symb, |
$ENV{'request.course.id'},$domain,$stuname); |
$ENV{'request.course.id'},$domain,$stuname); |
} |
} |
Line 1441 sub viewgrades_js {
|
Line 1572 sub viewgrades_js {
|
for (i=0;i<document.classgrade.total.value;i++) { |
for (i=0;i<document.classgrade.total.value;i++) { |
var user = eval("document.classgrade.ctr"+i+".value"); |
var user = eval("document.classgrade.ctr"+i+".value"); |
var scorename = eval("document.classgrade.GD_"+user+ |
var scorename = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_aw"); |
"_"+partid+"_awarded"); |
var saveval = eval("document.classgrade.GD_"+user+ |
var saveval = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_sv_s.value"); |
"_"+partid+"_solved_s.value"); |
var selname = eval("document.classgrade.GD_"+user+"_"+partid+"_sv"); |
var selname = eval("document.classgrade.GD_"+user+"_"+partid+"_solved"); |
if (saveval != "correct") { |
if (saveval != "correct") { |
scorename.value = point; |
scorename.value = point; |
if (selname[0].selected != true) { |
if (selname[0].selected != true) { |
Line 1470 sub viewgrades_js {
|
Line 1601 sub viewgrades_js {
|
for (i=0;i<document.classgrade.total.value;i++) { |
for (i=0;i<document.classgrade.total.value;i++) { |
var user = eval("document.classgrade.ctr"+i+".value"); |
var user = eval("document.classgrade.ctr"+i+".value"); |
var scorename = eval("document.classgrade.GD_"+user+ |
var scorename = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_aw"); |
"_"+partid+"_awarded"); |
var saveval = eval("document.classgrade.GD_"+user+ |
var saveval = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_sv_s.value"); |
"_"+partid+"_solved_s.value"); |
var selname = eval("document.classgrade.GD_"+user+ |
var selname = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_sv"); |
"_"+partid+"_solved"); |
if (saveval != "correct") { |
if (saveval != "correct") { |
scorename.value = ""; |
scorename.value = ""; |
selname[1].selected = true; |
selname[1].selected = true; |
Line 1484 sub viewgrades_js {
|
Line 1615 sub viewgrades_js {
|
for (i=0;i<document.classgrade.total.value;i++) { |
for (i=0;i<document.classgrade.total.value;i++) { |
var user = eval("document.classgrade.ctr"+i+".value"); |
var user = eval("document.classgrade.ctr"+i+".value"); |
var scorename = eval("document.classgrade.GD_"+user+ |
var scorename = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_aw"); |
"_"+partid+"_awarded"); |
var saveval = eval("document.classgrade.GD_"+user+ |
var saveval = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_sv_s.value"); |
"_"+partid+"_solved_s.value"); |
var selname = eval("document.classgrade.GD_"+user+ |
var selname = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_sv"); |
"_"+partid+"_solved"); |
if (saveval != "correct") { |
if (saveval != "correct") { |
scorename.value = eval("document.classgrade.GD_"+user+ |
scorename.value = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_aw_s.value");; |
"_"+partid+"_awarded_s.value");; |
selname[0].selected = true; |
selname[0].selected = true; |
} |
} |
} |
} |
Line 1499 sub viewgrades_js {
|
Line 1630 sub viewgrades_js {
|
} |
} |
|
|
function changeSelect(partid,user) { |
function changeSelect(partid,user) { |
var selval = eval("document.classgrade.GD_"+user+'_'+partid+"_sv"); |
var selval = eval("document.classgrade.GD_"+user+'_'+partid+"_solved"); |
var textbox = eval("document.classgrade.GD_"+user+'_'+partid+"_aw"); |
var textbox = eval("document.classgrade.GD_"+user+'_'+partid+"_awarded"); |
var point = textbox.value; |
var point = textbox.value; |
var weight = eval("document.classgrade.weight_"+partid+".value"); |
var weight = eval("document.classgrade.weight_"+partid+".value"); |
|
|
Line 1521 sub viewgrades_js {
|
Line 1652 sub viewgrades_js {
|
} |
} |
|
|
function changeOneScore(partid,user) { |
function changeOneScore(partid,user) { |
var selval = eval("document.classgrade.GD_"+user+'_'+partid+"_sv"); |
var selval = eval("document.classgrade.GD_"+user+'_'+partid+"_solved"); |
if (selval[1].selected) { |
if (selval[1].selected) { |
var boxval = eval("document.classgrade.GD_"+user+'_'+partid+"_aw"); |
var boxval = eval("document.classgrade.GD_"+user+'_'+partid+"_awarded"); |
boxval.value = ""; |
boxval.value = ""; |
} |
} |
} |
} |
Line 1544 sub viewgrades_js {
|
Line 1675 sub viewgrades_js {
|
for (i=0;i<document.classgrade.total.value;i++) { |
for (i=0;i<document.classgrade.total.value;i++) { |
var user = eval("document.classgrade.ctr"+i+".value"); |
var user = eval("document.classgrade.ctr"+i+".value"); |
var resetscore = eval("document.classgrade.GD_"+user+ |
var resetscore = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_aw"); |
"_"+partid+"_awarded"); |
resetscore.value = eval("document.classgrade.GD_"+user+ |
resetscore.value = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_aw_s.value"); |
"_"+partid+"_awarded_s.value"); |
|
|
var saveselval = eval("document.classgrade.GD_"+user+ |
var saveselval = eval("document.classgrade.GD_"+user+ |
"_"+partid+"_sv_s.value"); |
"_"+partid+"_solved_s.value"); |
|
|
var selname = eval("document.classgrade.GD_"+user+"_"+partid+"_sv"); |
var selname = eval("document.classgrade.GD_"+user+"_"+partid+"_solved"); |
if (saveselval == "excused") { |
if (saveselval == "excused") { |
if (selname[1].selected == false) { selname[1].selected = true;} |
if (selname[1].selected == false) { selname[1].selected = true;} |
} else { |
} else { |
Line 1573 sub viewgrades {
|
Line 1704 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>'.$ENV{'form.probTitle'}.'</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 1583 sub viewgrades {
|
Line 1714 sub viewgrades {
|
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
'<input type="hidden" name="command" value="editgrades" />'."\n". |
'<input type="hidden" name="command" value="editgrades" />'."\n". |
'<input type="hidden" name="section" value="'.$ENV{'form.section'}.'" />'."\n"; |
'<input type="hidden" name="section" value="'.$ENV{'form.section'}.'" />'."\n". |
$result.='To assign the same score for all the students use the radio buttons or '. |
'<input type="hidden" name="lastCmd" value="'.$ENV{'form.lastCmd'}.'" />'."\n". |
'text box below. To assign scores individually fill in the score boxes for '. |
'<input type="hidden" name="lastSec" value="'.$ENV{'form.lastSec'}.'" />'."\n". |
'each student in the table below. <font color="red">A part that has already '. |
'<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n"; |
'been graded does not get changed using the radio buttons or text box. '. |
|
'If needed, it has to be changed individually.</font>'; |
$result.='<h3>Assign Common Grade To '; |
|
if ($ENV{'form.section'} eq 'all') { |
|
$result.='Class </h3>'; |
|
} elsif ($ENV{'form.section'} eq 'no') { |
|
$result.='Students in no Section </h3>'; |
|
} else { |
|
$result.='Students in Section '.$ENV{'form.section'}.'</h3>'; |
|
} |
|
$result.= '<table border=0><tr><td bgcolor="#777777">'."\n". |
|
'<table border=0><tr bgcolor="#ffffdd"><td>'; |
#radio buttons/text box for assigning points for a section or class. |
#radio buttons/text box for assigning points for a section or class. |
#handles different parts of a problem |
#handles different parts of a problem |
my ($partlist,$handgrade) = &response_type($ENV{'form.url'}); |
my ($partlist,$handgrade) = &response_type($ENV{'form.url'}); |
Line 1598 sub viewgrades {
|
Line 1737 sub viewgrades {
|
$result.='<table border="0">'; |
$result.='<table border="0">'; |
my %seen = (); |
my %seen = (); |
for (sort keys(%$handgrade)) { |
for (sort keys(%$handgrade)) { |
my ($partid,$respid) = split (/_/); |
my ($partid,$respid) = split (/_/,$_,2); |
next if $seen{$partid}; |
next if $seen{$partid}; |
$seen{$partid}++; |
$seen{$partid}++; |
my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_}); |
my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_}); |
Line 1614 sub viewgrades {
|
Line 1753 sub viewgrades {
|
my $ctr = 0; |
my $ctr = 0; |
while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across |
while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across |
$result.= '<td><input type="radio" name="RADVAL_'.$partid.'" '. |
$result.= '<td><input type="radio" name="RADVAL_'.$partid.'" '. |
'onclick="javascript:writePoint('.$partid.','.$weight{$partid}. |
'onclick="javascript:writePoint(\''.$partid.'\','.$weight{$partid}. |
','.$ctr.')" />'.$ctr."</td>\n"; |
','.$ctr.')" />'.$ctr."</td>\n"; |
$result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : ''); |
$result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : ''); |
$ctr++; |
$ctr++; |
} |
} |
$result.='</tr></table>'; |
$result.='</tr></table>'; |
$result.= '</td><td><b> or </b><input type="text" name="TEXTVAL_'. |
$result.= '</td><td><b> or </b><input type="text" name="TEXTVAL_'. |
$partid.'" size="4" '. |
$partid.'" size="4" '.'onChange="javascript:writePoint(\''. |
'onChange="javascript:writePoint('.$partid.','.$weight{$partid}. |
$partid.'\','.$weight{$partid}.',\'textval\')" /> /'. |
',\'textval\')" /> /'. |
|
$weight{$partid}.' (problem weight)</td>'."\n"; |
$weight{$partid}.' (problem weight)</td>'."\n"; |
$result.= '</td><td><select name="SELVAL_'.$partid.'"'. |
$result.= '</td><td><select name="SELVAL_'.$partid.'"'. |
'onChange="javascript:writeRadText('.$partid.','.$weight{$partid}.')" /> '. |
'onChange="javascript:writeRadText(\''.$partid.'\','. |
|
$weight{$partid}.')"> '. |
'<option selected="on"> </option>'. |
'<option selected="on"> </option>'. |
'<option>excused</option></select></td></tr>'."\n"; |
'<option>excused</option></select></td></tr>'."\n"; |
$ctsparts++; |
$ctsparts++; |
} |
} |
$result.='</table><input type="hidden" name="totalparts" value="'.$ctsparts.'" />'; |
$result.='</table>'.'</td></tr></table>'.'</td></tr></table>'."\n". |
|
'<input type="hidden" name="totalparts" value="'.$ctsparts.'" />'; |
$result.='<input type="button" value="Reset" '. |
$result.='<input type="button" value="Reset" '. |
'onClick="javascript:resetEntry('.$ctsparts.');" TARGET=_self> '; |
'onClick="javascript:resetEntry('.$ctsparts.');" TARGET=_self> '; |
$result.='<input type="button" value="Submit Changes" '. |
$result.='<input type="button" value="Submit Changes" '. |
Line 1639 sub viewgrades {
|
Line 1779 sub viewgrades {
|
|
|
#table listing all the students in a section/class |
#table listing all the students in a section/class |
#header of table |
#header of table |
|
$result.= '<h3>Assign Grade to Specific Students in '; |
|
if ($ENV{'form.section'} eq 'all') { |
|
$result.='the Class </h3>'; |
|
} elsif ($ENV{'form.section'} eq 'no') { |
|
$result.='no Section </h3>'; |
|
} else { |
|
$result.='Section '.$ENV{'form.section'}.'</h3>'; |
|
} |
$result.= '<table border=0><tr><td bgcolor="#777777">'."\n". |
$result.= '<table border=0><tr><td bgcolor="#777777">'."\n". |
'<table border=0><tr bgcolor="#deffff">'. |
'<table border=0><tr bgcolor="#deffff">'. |
'<td><b>Fullname</b></td><td><b>Username</b></td><td><b>Domain</b></td>'."\n"; |
'<td><b>Fullname</b></td><td><b>Username</b></td><td><b>Domain</b></td>'."\n"; |
my (@parts) = sort(&getpartlist($url)); |
my (@parts) = sort(&getpartlist($url)); |
foreach my $part (@parts) { |
foreach my $part (@parts) { |
my $display=&Apache::lonnet::metadata($url,$part.'.display'); |
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) { $display = &Apache::lonnet::metadata($url,$part.'.name'); } |
if ($display =~ /^Partial Credit Factor/) { |
if ($display =~ /^Partial Credit Factor/) { |
$_ = $display; |
my ($partid) = &split_part_type($part); |
my ($partid) = /.*?(\d+).*/; |
$result.='<td><b>Score Part '.$partid.'<br />(weight = '. |
$result.='<td><b>Score Part '.$partid.'<br>(weight = '. |
|
$weight{$partid}.')</b></td>'."\n"; |
$weight{$partid}.')</b></td>'."\n"; |
next; |
next; |
} |
} |
$display =~ s/Problem Status/Grade Status<br>/; |
$display =~ s|Problem Status|Grade Status<br />|; |
$result.='<td><b>'.$display.'</b></td>'."\n"; |
$result.='<td><b>'.$display.'</b></td>'."\n"; |
} |
} |
$result.='</tr>'; |
$result.='</tr>'; |
|
|
#get info for each student |
#get info for each student |
#list all the students - with points and grade status |
#list all the students - with points and grade status |
my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0'); |
my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0'); |
my $ctr = 0; |
my $ctr = 0; |
foreach (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) { |
foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) { |
my ($uname,$udom) = split(/:/); |
my ($uname,$udom) = split(/:/); |
$result.='<input type="hidden" name="ctr'.$ctr.'" value="'.$uname.'" />'."\n"; |
$result.='<input type="hidden" name="ctr'.$ctr.'" value="'.$uname.'" />'."\n"; |
$result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'}, |
$result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'}, |
Line 1687 sub viewstudentgrade {
|
Line 1833 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 ($temp,$part,$type)=split(/_/,$part); |
my ($part,$type) = &split_part_type($apart); |
my $score=$record{"resource.$part.$type"}; |
my $score=$record{"resource.$part.$type"}; |
next if $type eq 'tries'; |
|
if ($type eq 'awarded') { |
if ($type eq 'awarded') { |
my $pts = $score eq '' ? '' : $score*$$weight{$part}; |
my $pts = $score eq '' ? '' : $score*$$weight{$part}; |
$result.='<input type="hidden" name="'. |
$result.='<input type="hidden" name="'. |
'GD_'.$uname.'_'.$part.'_aw_s" value="'.$pts.'" />'."\n"; |
'GD_'.$uname.'_'.$part.'_awarded_s" value="'.$pts.'" />'."\n"; |
$result.='<td align="middle"><input type="text" name="'. |
$result.='<td align="middle"><input type="text" name="'. |
'GD_'.$uname.'_'.$part.'_aw" '. |
'GD_'.$uname.'_'.$part.'_awarded" '. |
'onChange="javascript:changeSelect('.$part.',\''.$uname. |
'onChange="javascript:changeSelect(\''.$part.'\',\''.$uname. |
'\')" value="'.$pts.'" size="4" /></td>'."\n"; |
'\')" value="'.$pts.'" size="4" /></td>'."\n"; |
} elsif ($type eq 'solved') { |
} elsif ($type eq 'solved') { |
my ($status,$foo)=split(/_/,$score,2); |
my ($status,$foo)=split(/_/,$score,2); |
$status = 'nothing' if ($status eq ''); |
$status = 'nothing' if ($status eq ''); |
$result.='<input type="hidden" name="'. |
$result.='<input type="hidden" name="'.'GD_'.$uname.'_'. |
'GD_'.$uname.'_'.$part.'_sv_s" value="'.$status.'" />'."\n"; |
$part.'_solved_s" value="'.$status.'" />'."\n"; |
$result.='<td align="middle"><select name="'. |
$result.='<td align="middle"><select name="'. |
'GD_'.$uname.'_'.$part.'_sv" '. |
'GD_'.$uname.'_'.$part.'_solved" '. |
'onChange="javascript:changeOneScore('.$part.',\''.$uname.'\')" >'."\n"; |
'onChange="javascript:changeOneScore(\''.$part.'\',\''.$uname.'\')" >'."\n"; |
my $optsel = '<option selected="on"> </option><option>excused</option>'."\n"; |
my $optsel = '<option selected="on"> </option><option>excused</option>'."\n"; |
$optsel = '<option> </option><option selected="on">excused</option>'."\n" |
$optsel = '<option> </option><option selected="on">excused</option>'."\n" |
if ($status eq 'excused'); |
if ($status eq 'excused'); |
$result.=$optsel; |
$result.=$optsel; |
$result.="</select></td>\n"; |
$result.="</select></td>\n"; |
|
} else { |
|
$result.='<input type="hidden" name="'. |
|
'GD_'.$uname.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'. |
|
"\n"; |
|
$result.='<td align="middle"><input type="text" name="'. |
|
'GD_'.$uname.'_'.$part.'_'.$type.'" '. |
|
'value="'.$score.'" size="4" /></td>'."\n"; |
} |
} |
} |
} |
$result.='</tr>'; |
$result.='</tr>'; |
Line 1726 sub editgrades {
|
Line 1878 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>'.$ENV{'form.probTitle'}.'</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); |
|
my $result= '<table border="0"><tr><td bgcolor="#777777">'."\n"; |
my $result= '<table border="0"><tr><td bgcolor="#777777">'."\n"; |
$result.= '<table border="0"><tr bgcolor="#deffff">'. |
$result.= '<table border="0"><tr bgcolor="#deffff">'. |
'<td rowspan=2><b>Username</b></td><td rowspan=2><b>Fullname</b></td>'."\n"; |
'<td rowspan=2><b>Username</b></td><td rowspan=2><b>Fullname</b></td>'."\n"; |
Line 1740 sub editgrades {
|
Line 1891 sub editgrades {
|
'ungraded' =>'ungraded_attempted', |
'ungraded' =>'ungraded_attempted', |
'nothing' => '', |
'nothing' => '', |
); |
); |
my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0'); |
my ($classlist,undef,$fullname) = &getclasslist($ENV{'form.section'},'0'); |
|
|
my (@partid); |
my (@partid); |
my %weight = (); |
my %weight = (); |
|
my %columns = (); |
my ($i,$ctr,$count,$rec_update) = (0,0,0,0); |
my ($i,$ctr,$count,$rec_update) = (0,0,0,0); |
|
|
|
my (@parts) = sort(&getpartlist($url)); |
|
my $header; |
while ($ctr < $ENV{'form.totalparts'}) { |
while ($ctr < $ENV{'form.totalparts'}) { |
my $partid = $ENV{'form.partid_'.$ctr}; |
my $partid = $ENV{'form.partid_'.$ctr}; |
push @partid,$partid; |
push @partid,$partid; |
$weight{$partid} = $ENV{'form.weight_'.$partid}; |
$weight{$partid} = $ENV{'form.weight_'.$partid}; |
$ctr++; |
$ctr++; |
$result .= '<td colspan = 2 align="center"><b>Part '.$partid. |
|
'</b> (Weight = '.$weight{$partid}.')</td>'; |
|
} |
} |
$result .= '</tr><tr bgcolor="#deffff">'; |
foreach my $partid (@partid) { |
foreach (@partid) { |
$header .= '<td align="center"> <b>Old Score</b> </td>'. |
$result .= '<td align="center"> <b>Old Score</b> </td>'. |
|
'<td align="center"> <b>New Score</b> </td>'; |
'<td align="center"> <b>New Score</b> </td>'; |
|
$columns{$partid}=2; |
|
foreach my $stores (@parts) { |
|
my ($part,$type) = &split_part_type($stores); |
|
if ($part !~ m/^\Q$partid\E/) { next;} |
|
if ($type eq 'awarded' || $type eq 'solved') { next; } |
|
my $display=&Apache::lonnet::metadata($url,$stores.'.display'); |
|
$display =~ s/\[Part: (\w)+\]//; |
|
$header .= '<td align="center"> <b>Old</b> '.$display.' </td>'. |
|
'<td align="center"> <b>New</b> '.$display.' </td>'; |
|
$columns{$partid}+=2; |
|
} |
} |
} |
|
foreach my $partid (@partid) { |
|
$result .= '<td colspan="'.$columns{$partid}. |
|
'" align="center"><b>Part '.$partid. |
|
'</b> (Weight = '.$weight{$partid}.')</td>'; |
|
|
|
} |
|
$result .= '</tr><tr bgcolor="#deffff">'; |
|
$result .= $header; |
$result .= '</tr>'."\n"; |
$result .= '</tr>'."\n"; |
|
|
for ($i=0; $i<$ENV{'form.total'}; $i++) { |
for ($i=0; $i<$ENV{'form.total'}; $i++) { |
Line 1765 sub editgrades {
|
Line 1936 sub editgrades {
|
my %newrecord; |
my %newrecord; |
my $updateflag = 0; |
my $updateflag = 0; |
my @userdom = grep /^$user:/,keys %$classlist; |
my @userdom = grep /^$user:/,keys %$classlist; |
my ($foo,$udom) = split(/:/,$userdom[0]); |
my (undef,$udom) = split(/:/,$userdom[0]); |
|
|
$result .= '<tr bgcolor="#ffffde"><td>'.$user.' </td><td>'. |
$result .= '<tr bgcolor="#ffffde"><td>'.$user.' </td><td>'. |
$$fullname{$userdom[0]}.' </td>'; |
$$fullname{$userdom[0]}.' </td>'; |
|
|
foreach (@partid) { |
foreach (@partid) { |
my $old_aw = $ENV{'form.GD_'.$user.'_'.$_.'_aw_s'}; |
my $old_aw = $ENV{'form.GD_'.$user.'_'.$_.'_awarded_s'}; |
my $old_part = $old_aw eq '' ? '' : $old_aw/$weight{$_}; |
my $old_part_pcr = $old_aw/($weight{$_} ne '0' ? $weight{$_}:1); |
my $old_score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_sv_s'}}; |
my $old_part = $old_aw eq '' ? '' : $old_part_pcr; |
|
my $old_score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_solved_s'}}; |
my $awarded = $ENV{'form.GD_'.$user.'_'.$_.'_aw'}; |
|
my $partial = $awarded eq '' ? '' : $awarded/$weight{$_}; |
my $awarded = $ENV{'form.GD_'.$user.'_'.$_.'_awarded'}; |
|
my $pcr = $awarded/($weight{$_} ne '0' ? $weight{$_} : 1); |
|
my $partial = $awarded eq '' ? '' : $pcr; |
my $score; |
my $score; |
if ($partial eq '') { |
if ($partial eq '') { |
$score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_sv_s'}}; |
$score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_solved_s'}}; |
} elsif ($partial > 0) { |
} elsif ($partial > 0) { |
$score = 'correct_by_override'; |
$score = 'correct_by_override'; |
} elsif ($partial == 0) { |
} elsif ($partial == 0) { |
$score = 'incorrect_by_override'; |
$score = 'incorrect_by_override'; |
} |
} |
$score = 'excused' if (($ENV{'form.GD_'.$user.'_'.$_.'_sv'} eq 'excused') && |
$score = 'excused' if (($ENV{'form.GD_'.$user.'_'.$_.'_solved'} eq 'excused') && |
($score ne 'excused')); |
($score ne 'excused')); |
$result .= '<td align="center">'.$old_aw.' </td>'. |
$result .= '<td align="center">'.$old_aw.' </td>'. |
'<td align="center">'.$awarded. |
'<td align="center">'.$awarded. |
($score eq 'excused' ? $score : '').' </td>'; |
($score eq 'excused' ? $score : '').' </td>'; |
|
|
next if ($old_part eq $partial && $old_score eq $score); |
if (!($old_part eq $partial && $old_score eq $score)) { |
|
$updateflag = 1; |
$updateflag = 1; |
$newrecord{'resource.'.$_.'.awarded'} = $partial if $partial ne ''; |
$newrecord{'resource.'.$_.'.awarded'} = $partial if $partial ne ''; |
$newrecord{'resource.'.$_.'.solved'} = $score; |
$newrecord{'resource.'.$_.'.solved'} = $score; |
$rec_update++; |
$rec_update++; |
} |
|
|
|
my $partid=$_; |
|
foreach my $stores (@parts) { |
|
my ($part,$type) = &split_part_type($stores); |
|
if ($part !~ m/^\Q$partid\E/) { next;} |
|
if ($type eq 'awarded' || $type eq 'solved') { next; } |
|
my $old_aw = $ENV{'form.GD_'.$user.'_'.$part.'_'.$type.'_s'}; |
|
my $awarded = $ENV{'form.GD_'.$user.'_'.$part.'_'.$type}; |
|
if ($awarded ne '' && $awarded ne $old_aw) { |
|
$newrecord{'resource.'.$part.'.'.$type}= $awarded; |
|
$newrecord{'resource.'.$part.'regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; |
|
$updateflag=1; |
|
} |
|
$result .= '<td align="center">'.$old_aw.' </td>'. |
|
'<td align="center">'.$awarded.' </td>'; |
|
} |
} |
} |
$result .= '</tr>'."\n"; |
$result .= '</tr>'."\n"; |
if ($updateflag) { |
if ($updateflag) { |
$count++; |
$count++; |
$newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; |
|
&Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'}, |
&Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'}, |
$udom,$user); |
$udom,$user); |
} |
} |
} |
} |
$result .= '</table></td></tr></table>'."\n"; |
$result .= '</table></td></tr></table>'."\n". |
|
&show_grading_menu_form ($symb,$url); |
my $msg = '<b>Number of records updated = '.$rec_update. |
my $msg = '<b>Number of records updated = '.$rec_update. |
' for '.$count.' student'.($count <= 1 ? '' : 's').'.</b><br />'. |
' for '.$count.' student'.($count <= 1 ? '' : 's').'.</b><br />'. |
'<b>Total number of students = '.$ENV{'form.total'}.'</b><br />'; |
'<b>Total number of students = '.$ENV{'form.total'}.'</b><br />'; |
return $title.$msg.$result; |
return $title.$msg.$result; |
} |
} |
|
|
|
sub split_part_type { |
|
my ($partstr) = @_; |
|
my ($temp,@allparts)=split(/_/,$partstr); |
|
my $type=pop(@allparts); |
|
my $part=join('.',@allparts); |
|
return ($part,$type); |
|
} |
|
|
#------------- end of section for handling grading by section/class --------- |
#------------- end of section for handling grading by section/class --------- |
# |
# |
#---------------------------------------------------------------------------- |
#---------------------------------------------------------------------------- |
Line 1821 sub editgrades {
|
Line 2018 sub editgrades {
|
# |
# |
#-------------------------- Next few routines handles grading by csv upload |
#-------------------------- Next few routines handles grading by csv upload |
# |
# |
|
#--- Menu to upload a csv scores --- |
|
sub upcsvScores_form { |
|
my ($request) = shift; |
|
my ($symb,$url)=&get_symb_and_url($request); |
|
if (!$symb) {return '';} |
|
my $result =<<CSVFORMJS; |
|
<script type="text/javascript" language="javascript"> |
|
function checkUpload(formname) { |
|
if (formname.upfile.value == "") { |
|
alert("Please use the browse button to select a file from your local directory."); |
|
return false; |
|
} |
|
formname.submit(); |
|
if (navigator.appName !="Netscape") {self.close()}; //if netscape if appears to close before submit!!! |
|
// any suggestion how to get around this?? |
|
} |
|
</script> |
|
CSVFORMJS |
|
$ENV{'form.probTitle'} = &Apache::lonnet::metadata($url,'title'); |
|
$result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n"; |
|
$result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n"; |
|
$result.=' <b>Specify a file containing the class scores for problem - '.$ENV{'form.probTitle'}. |
|
'.</b></td></tr>'."\n"; |
|
$result.='<tr bgcolor=#ffffe6><td>'."\n"; |
|
my $upfile_select=&Apache::loncommon::upfile_select_html(); |
|
$result.=<<ENDUPFORM; |
|
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload" target="LONcatInfo"> |
|
<input type="hidden" name="symb" value="$symb" /> |
|
<input type="hidden" name="url" value="$url" /> |
|
<input type="hidden" name="command" value="csvuploadmap" /> |
|
<input type="hidden" name="probTitle" value="$ENV{'form.probTitle'}" /> |
|
$upfile_select |
|
<br /><input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Scores" /> |
|
<input type="button" value="Cancel" onClick="self.close()"> |
|
|
|
</form> |
|
ENDUPFORM |
|
$result.='</td></tr></table>'."\n"; |
|
$result.='</td></tr></table>'."\n"; |
|
return $result; |
|
} |
|
|
#--- Javascript to handle csv upload |
#--- Javascript to handle csv upload |
sub csvupload_javascript_reverse_associate { |
sub csvupload_javascript_reverse_associate { |
return(<<ENDPICK); |
return(<<ENDPICK); |
Line 1905 sub csvuploadmap_header {
|
Line 2144 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>'.$ENV{'form.probTitle'}.'</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 1936 to this page if the data selected is ins
|
Line 2175 to this page if the data selected is ins
|
value="$ENV{'form.upfile_associate'}" /> |
value="$ENV{'form.upfile_associate'}" /> |
<input type="hidden" name="symb" value="$symb" /> |
<input type="hidden" name="symb" value="$symb" /> |
<input type="hidden" name="url" value="$url" /> |
<input type="hidden" name="url" value="$url" /> |
|
<input type="hidden" name="lastCmd" value="$ENV{'form.lastCmd'}" /> |
|
<input type="hidden" name="lastSec" value="$ENV{'form.lastSec'}" /> |
|
<input type="hidden" name="probTitle" value="$ENV{'form.probTitle'}" /> |
<input type="hidden" name="command" value="csvuploadassign" /> |
<input type="hidden" name="command" value="csvuploadassign" /> |
<hr /> |
<hr /> |
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
Line 1976 sub csvuploadmap {
|
Line 2218 sub csvuploadmap {
|
my ($request)= @_; |
my ($request)= @_; |
my ($symb,$url)=&get_symb_and_url($request); |
my ($symb,$url)=&get_symb_and_url($request); |
if (!$symb) {return '';} |
if (!$symb) {return '';} |
|
|
my $datatoken; |
my $datatoken; |
if (!$ENV{'form.datatoken'}) { |
if (!$ENV{'form.datatoken'}) { |
$datatoken=&Apache::loncommon::upfile_store($request); |
$datatoken=&Apache::loncommon::upfile_store($request); |
Line 2004 sub csvuploadmap {
|
Line 2247 sub csvuploadmap {
|
} |
} |
} |
} |
&csvuploadmap_footer($request,$i,$keyfields); |
&csvuploadmap_footer($request,$i,$keyfields); |
|
$request->print(&show_grading_menu_form($symb,$url)); |
|
|
return ''; |
return ''; |
} |
} |
|
|
Line 2067 sub csvuploadassign {
|
Line 2312 sub csvuploadassign {
|
#------------- end of section for handling csv file upload --------- |
#------------- end of section for handling csv file upload --------- |
# |
# |
#------------------------------------------------------------------- |
#------------------------------------------------------------------- |
|
# |
|
#-------------- Next few routines handles grading by page/sequence |
|
# |
|
#--- Select a page/sequence and a student to grade |
|
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) { |
|
return radioButton[i].value; |
|
} |
|
} |
|
return selection; |
|
} |
|
|
|
function pullDownSelection(selectOne) { |
|
var selection=null; |
|
for (var i=0; i<selectOne.length; i++) { |
|
if (selectOne[i].selected) { |
|
return selectOne[i].value; |
|
} |
|
} |
|
} |
|
</script> |
|
LISTJAVASCRIPT |
|
|
|
my ($symb,$url) = &get_symb_and_url($request); |
|
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". |
|
'<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". |
|
'<input type="hidden" name="lastCmd" value="'.$ENV{'form.lastCmd'}.'" />'."\n". |
|
'<input type="hidden" name="lastSec" value="'.$ENV{'form.lastSec'}.'" />'."\n"; |
|
|
|
$result.='<br /> <input type="button" '. |
|
'onClick="javascript:checkPickOne(this.form);"value="Submit" /><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; |
|
} |
|
|
|
# |
|
#--- Displays a page/sequence w/wo problems, w/wo submissions |
|
sub displayPage { |
|
my ($request) = shift; |
|
|
|
my ($symb,$url) = &get_symb_and_url($request); |
|
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". |
|
'<input type="hidden" name="lastCmd" value="'.$ENV{'form.lastCmd'}.'" />'."\n". |
|
'<input type="hidden" name="lastSec" value="'.$ENV{'form.lastSec'}.'" />'."\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(); |
|
$parts = &temp_parts_fix($parts); # remove line when lonnavmap is fixed |
|
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[2].=(exists $record{"$version:resource.$partid.regrader"}) ? |
|
$record{"$version:resource.$partid.regrader"}.' (<b>Part:</b> '.$partid.')' : ''; |
|
} |
|
$displaySub[2].=(exists $record{"$version:resource.regrader"}) ? |
|
$record{"$version:resource.regrader"} : ''; |
|
$studentTable.='<td>'.$displaySub[0].' </td><td>'.$displaySub[1]. |
|
($displaySub[2] eq '' ? '' : 'Manually graded by '.$displaySub[2]).' </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++; |
|
} |
|
|
|
$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 temp_parts_fix { #remove sub once lonnavmap is fixed |
|
my $parts = shift; |
|
my %seen = (); |
|
my @correctParts = (); |
|
foreach (@{$parts}) { |
|
next if ($seen{$_} > 0); |
|
$seen{$_}++; |
|
push @correctParts,$_; |
|
} |
|
return \@correctParts; |
|
} |
|
|
|
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(); |
|
$parts = &temp_parts_fix($parts); # remove line when lonnavmap is fixed |
|
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; |
|
$newrecord{'resource.'.$partid.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; |
|
|
|
$changeflag++; |
|
} |
|
if (scalar(keys(%newrecord)) > 0) { |
|
&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++; |
|
} |
|
|
|
$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 ''; |
|
} |
|
|
|
#-------- end of section for handling grading by page/sequence --------- |
|
# |
|
#------------------------------------------------------------------- |
|
|
#-------------------------- Menu interface ------------------------- |
#-------------------------- Menu interface ------------------------- |
# |
# |
Line 2076 sub show_grading_menu_form {
|
Line 2775 sub show_grading_menu_form {
|
my $result.='<form action="/adm/grades" method="post">'."\n". |
my $result.='<form action="/adm/grades" method="post">'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
|
'<input type="hidden" name="lastCmd" value="'.$ENV{'form.lastCmd'}.'" />'."\n". |
|
'<input type="hidden" name="lastSec" value="'.$ENV{'form.lastSec'}.'" />'."\n". |
'<input type="hidden" name="command" value="gradingmenu" />'."\n". |
'<input type="hidden" name="command" value="gradingmenu" />'."\n". |
'<input type="submit" name="submit" value="Grading Menu" />'."\n". |
'<input type="submit" name="submit" value="Grading Menu" />'."\n". |
'</form>'."\n"; |
'</form>'."\n"; |
Line 2087 sub gradingmenu {
|
Line 2788 sub gradingmenu {
|
my ($request) = @_; |
my ($request) = @_; |
my ($symb,$url)=&get_symb_and_url($request); |
my ($symb,$url)=&get_symb_and_url($request); |
if (!$symb) {return '';} |
if (!$symb) {return '';} |
my $result='<h3> <font color="#339933">Select a Grading Method</font></h3>'; |
|
$result.='<table border="0">'; |
$request->print(<<GRADINGMENUJS); |
$result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>'; |
<script type="text/javascript" language="javascript"> |
|
function checkChoice(formname) { |
|
var cmd = formname.command; |
|
formname.lastCmd.value = radioSelection(formname.command); |
|
formname.lastSec.value = pullDownSelection(formname.section); |
|
if (cmd[0].checked || cmd[1].checked || cmd[2].checked) { |
|
formname.submit(); |
|
} |
|
|
|
if (cmd[3].checked) { |
|
var url = "/adm/grades?command=csvform&symb="+formname.symb.value+"&url="+formname.url.value; |
|
var options = "width=620,height=340,screenx=70,screeny=75,"; |
|
options += "resizable=no,scrollbars=no,status=no,"; |
|
options += "menubar=no,toolbar=no,location=no,directories=no"; |
|
var newWin = window.open(url, "CSVFile", options); |
|
newWin.focus(); |
|
} |
|
|
|
if (cmd[4].checked) { |
|
if (!checkReceiptNo(formname,'notOK')) { return false;} |
|
formname.submit(); |
|
} |
|
} |
|
|
|
function checkReceiptNo(formname,nospace) { |
|
var receiptNo = formname.receipt.value; |
|
var checkOpt = false; |
|
if (nospace == "OK" && isNaN(receiptNo)) {checkOpt = true;} |
|
if (nospace == "notOK" && (isNaN(receiptNo) || receiptNo == "")) {checkOpt = true;} |
|
if (checkOpt) { |
|
alert("Please enter a receipt number given by a student in the receipt box."); |
|
formname.receipt.value = ""; |
|
formname.receipt.focus(); |
|
return false; |
|
} |
|
formname.command[4].checked = true; |
|
return true; |
|
} |
|
|
|
function radioSelection(radioButton) { |
|
var selection=null; |
|
for (var i=0; i<radioButton.length; i++) { |
|
if (radioButton[i].checked) { |
|
return radioButton[i].value; |
|
} |
|
} |
|
return selection; |
|
} |
|
|
|
function pullDownSelection(selectOne) { |
|
var selection=""; |
|
for (var i=0; i<selectOne.length; i++) { |
|
if (selectOne[i].selected) { |
|
return selectOne[i].value; |
|
} |
|
} |
|
} |
|
</script> |
|
GRADINGMENUJS |
|
|
|
my $probTitle = &Apache::lonnet::metadata($ENV{'form.url'},'title'); |
|
my $result='<h3> <font color="#339933">Manual Grading/View Submission</font></h3>'. |
|
'<table border="0">'. |
|
'<tr><td colspan=3><font size=+1><b>Problem: </b>'.$probTitle.'</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 2101 sub gradingmenu {
|
Line 2865 sub gradingmenu {
|
'<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>'; |
'<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>'; |
} |
} |
$result.='</table>'; |
$result.='</table>'; |
$result.=&view_edit_entire_class_form($symb,$url).'<br />'; |
|
$result.=&upcsvScores_form($symb,$url).'<br />'; |
|
$result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).'<br />'; |
|
$result.=&verifyReceipt_form($symb,$url) |
|
if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)); |
|
|
|
return $result; |
|
} |
|
|
|
#--- Menu for grading a section or the whole class --- |
|
sub view_edit_entire_class_form { |
|
my ($symb,$url)=@_; |
|
my ($classlist,$sections) = &getclasslist('all','0'); |
my ($classlist,$sections) = &getclasslist('all','0'); |
my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n"; |
my $lastCmd = ($ENV{'form.lastCmd'} eq '' ? 'pickStudentPage' : $ENV{'form.lastCmd'}); |
$result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n"; |
my $lastSec = ($ENV{'form.lastSec'} eq '' ? 'all' : $ENV{'form.lastSec'}); |
$result.=' <b>Grade Entire Class</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="command" value="viewgrades" />'."\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>'."<br />\n"; |
|
$result.=' <input type="button" onClick="submit();" value="Grade" /></form>'."\n"; |
|
$result.='</td></tr></table>'."\n"; |
|
$result.='</td></tr></table>'."\n"; |
|
return $result; |
|
} |
|
|
|
#--- Menu to upload a csv scores --- |
$result.='<form action="/adm/grades" method="post" name="gradingMenu">'."\n". |
sub upcsvScores_form { |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
my ($symb,$url) = @_; |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
if (!$symb) {return '';} |
'<input type="hidden" name="response" value="'.$resptype.'" />'."\n". |
my $result = '<script type="text/javascript" language="javascript">'."\n". |
'<input type="hidden" name="handgrade" value="'.$hdgrade.'" />'."\n". |
' function checkUpload(formname) {'."\n". |
'<input type="hidden" name="probTitle" value="'.$probTitle.'" />'."\n". |
' if (formname.upfile.value == "") {'."\n". |
'<input type="hidden" name="lastCmd" value="" />'."\n". |
' alert("Please use the browse button to select a file from your local directory.");'."\n". |
'<input type="hidden" name="lastSec" value="" />'."\n". |
' return false;'."\n". |
'<input type="hidden" name="showgrading" value="yes" />'."\n"; |
' }'."\n". |
|
' formname.submit();'."\n". |
$result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n". |
' }'."\n". |
'<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n". |
'</script>'."\n"; |
' <b>Select a Grading/Viewing Option</b></td></tr>'."\n". |
|
'<tr bgcolor=#ffffe6><td>'."\n"; |
$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>'. |
$result.=' <b>Specify a file containing the class scores for above resource</b></td></tr>'."\n"; |
'<tr bgcolor="#ffffe6" valign="top"><td colspan="2">'. |
$result.='<tr bgcolor=#ffffe6><td>'."\n"; |
'<input type="radio" name="command" value="pickStudentPage" '. |
my $upfile_select=&Apache::loncommon::upfile_select_html(); |
($lastCmd eq 'pickStudentPage' ? 'checked' : '').'> '. |
$result.=<<ENDUPFORM; |
'Handgrade/View Submission for a student by page/sequence</td></tr>'."\n". |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload"> |
|
<input type="hidden" name="symb" value="$symb" /> |
'<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'. |
<input type="hidden" name="url" value="$url" /> |
'<input type="radio" name="command" value="viewgrades" '. |
<input type="hidden" name="command" value="csvuploadmap" /> |
($lastCmd eq 'viewgrades' ? 'checked' : '').'> '. |
$upfile_select |
'Grade by section or class</td></tr>'."\n". |
<br /> <input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Grades" /> |
|
</form> |
'<tr bgcolor="#ffffe6"valign="top"><td><input type="radio" name="command" value="submission" '. |
ENDUPFORM |
($lastCmd eq 'submission' ? 'checked' : '').'> '. |
$result.='</td></tr></table>'."\n"; |
($hdgrade eq 'yes' ? 'View/Grade essay response of' : 'View'). |
$result.='</td></tr></table>'."\n"; |
' an individual student </td>'."\n". |
return $result; |
'<td>--> For students who has: '. |
} |
'<input type="radio" name="submitonly" value="yes" checked> submitted'. |
|
'<input type="radio" name="submitonly" value="all"> everybody</td></tr>'."\n". |
|
|
#--- Handgrading problems --- |
'<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'. |
sub viewGradeaStu_form { |
'<input type="radio" name="command" value="csvupload" '. |
my ($symb,$url,$response,$handgrade) = @_; |
($lastCmd eq 'csvupload' ? 'checked' : '').'> '. |
my ($classlist,$sections) = &getclasslist('all','0'); |
'Upload scores from file</td></tr>'."\n"; |
my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n"; |
|
$result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n"; |
if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) { |
$result.=' <b>'; |
$result.='<tr bgcolor="#ffffe6"valign="top"><td>'. |
if ($handgrade eq 'yes') { |
'<input type="radio" name="command" value="verify" onSelect="javascript:this.form.receipt.focus()" '. |
$result.="View/Grade "; |
($lastCmd eq 'verify' ? 'checked' : '').'> '. |
} else { |
'Verify a submission receipt issued by this server</td>'. |
$result.="View "; |
'<td>--> Receipt no: '.unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}). |
} |
'-<input type="text" name="receipt" size="4" onChange="javascript:checkReceiptNo(this.form,\'OK\')">'. |
$result.='an Individual Student\'s Submission</b></td></tr>'."\n"; |
'</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="submission" />'."\n"; |
|
|
|
$result.=' <b>Select section:</b> <select name="section">'."\n"; |
$result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2"><br />'."\n". |
|
' Select section:</b> <select name="section">'."\n"; |
if (ref($sections)) { |
if (ref($sections)) { |
foreach (sort (@$sections)) {$result.='<option>'.$_.'</option>'."\n";} |
foreach (sort (@$sections)) {$result.='<option value="'.$_.'" '. |
|
($lastSec eq $_ ? 'selected="on"' : '').'>'.$_.'</option>'."\n";} |
} |
} |
$result.= '<option selected="on">all</select>'."\n"; |
$result.= '<option value="all" '.($lastSec eq 'all' ? 'selected="on"' : ''). '>all</select> '. |
$result.=' <b>Display students who has: </b>'. |
'<font color="red">(Applies to the first three options only.)</font>'."\n"; |
'<input type="radio" name="submitonly" value="yes" checked> submitted'. |
|
'<input type="radio" name="submitonly" value="all"> everybody <br />'; |
|
if (ref($sections)) { |
if (ref($sections)) { |
$result.=' (Section "no" implies the students were not assigned a section.)<br />' |
$result.=' (Section "no" implies the students were not assigned a section.)<br />' |
if (grep /no/,@$sections); |
if (grep /no/,@$sections); |
} |
} |
|
$result.='</td></tr>'; |
|
|
|
$result.='<tr bgcolor="#ffffe6"><td colspan="2"><br />'. |
$result.='<br /> <input type="button" onClick="submit();" value="'; |
'<input type="button" onClick="javascript:checkChoice(this.form);" value="View/Grade" />'."\n". |
if ($handgrade eq 'yes') { |
'</form></td></tr></table>'."\n". |
$result.="View/Grade"; |
'</td></tr></table>'."\n". |
} else { |
'</td></tr></table>'."\n"; |
$result.="View"; |
|
} |
|
$result.='" />'."\n".'</form>'."\n"; |
|
$result.='</td></tr></table>'."\n"; |
|
$result.='</td></tr></table>'."\n"; |
|
return $result; |
|
} |
|
|
|
#--- Form to input a receipt number --- |
|
sub verifyReceipt_form { |
|
my ($symb,$url) = @_; |
|
my $result = '<script type="text/javascript" language="javascript">'."\n". |
|
' function checkEntry(formname) {'."\n". |
|
' var receipt = formname.receipt.value;'."\n". |
|
' if (isNaN(receipt) || receipt == "") {'."\n". |
|
' alert("Please enter a receipt number given by a student in the box.");'."\n". |
|
' return false;'."\n". |
|
' }'."\n". |
|
' formname.submit();'."\n". |
|
' }'."\n". |
|
'</script>'."\n"; |
|
|
|
my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}); |
|
|
|
$result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n"; |
|
$result.='<table width=100% border=0><tr><td bgcolor=#e6ffff>'."\n"; |
|
$result.=' <b>Verify a Submission Receipt Issued by this Server</td></tr>'."\n"; |
|
$result.='<tr bgcolor=#ffffe6><td>'."\n"; |
|
$result.='<form action="/adm/grades" method="post" name="verifyform">'."\n"; |
|
$result.=' <tt>'.$hostver.'-<input type="text" name="receipt" size="4"></tt><br />'."\n"; |
|
$result.=' <input type="button" onClick="javascript:checkEntry(this.form);"'. |
|
' value="Verify Receipt">'."\n"; |
|
$result.='<input type="hidden" name="command" value="verify">'."\n"; |
|
if ($ENV{'form.url'}) { |
|
$result.='<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />'; |
|
} |
|
if ($ENV{'form.symb'}) { |
|
$result.='<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />'; |
|
} |
|
$result.='</form>'; |
|
$result.='</td></tr></table>'."\n"; |
|
$result.='</td></tr></table>'."\n"; |
|
return $result; |
return $result; |
} |
} |
|
|
Line 2303 sub handler {
|
Line 2991 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 ''); |
} 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') { |
Line 2317 sub handler {
|
Line 3010 sub handler {
|
$request->print(&editgrades($request)); |
$request->print(&editgrades($request)); |
} elsif ($command eq 'verify') { |
} elsif ($command eq 'verify') { |
$request->print(&verifyreceipt($request)); |
$request->print(&verifyreceipt($request)); |
|
} elsif ($command eq 'csvform') { |
|
$request->print(&upcsvScores_form($request)); |
} elsif ($command eq 'csvupload') { |
} elsif ($command eq 'csvupload') { |
$request->print(&csvupload($request)); |
$request->print(&csvupload($request)); |
} elsif ($command eq 'viewclasslist') { |
} elsif ($command eq 'viewclasslist') { |