--- loncom/homework/grades.pm 2002/07/07 20:08:45 1.36 +++ loncom/homework/grades.pm 2002/07/08 21:18:54 1.37 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.36 2002/07/07 20:08:45 ng Exp $ +# $Id: grades.pm,v 1.37 2002/07/08 21:18:54 ng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -136,9 +136,11 @@ sub listStudents {  Resource: $ENV{'form.url'}

 View Options
 View Problem: no - yes -   Submissions: last - all + yes
Submissions: + last sub only + last sub & parts info + all details @@ -428,13 +430,26 @@ sub submission { var Nmsg = msgform.savemsgN.value; savedMsgHeader(Nmsg,usrctr,fullname); var subject = msgform.msgsub.value; - displaySubject(subject); + var rtrchk = eval("document.SCORE.includemsg"+usrctr); + var msgchk = rtrchk.value; +// alert("checked=>"+msgchk); + re = /msgsub/; + var shwsel = ""; + if (re.test(msgchk)) { shwsel = "checked" } + displaySubject(subject,shwsel); for (var i=1; i<=Nmsg; i++) { + var testpt = "savemsg"+i+","; + re = /testpt/; + shwsel = ""; + if (re.test(msgchk)) { shwsel = "checked" } var message = eval("document.SCORE.savemsg"+i+".value"); - displaySavedMsg(i,message); + displaySavedMsg(i,message,shwsel); } newmsg = eval("document.SCORE.newmsg"+usrctr+".value"); - newMsg(newmsg); + shwsel = ""; + re = /newmsg/; + if (re.test(msgchk)) { shwsel = "checked" } + newMsg(newmsg,shwsel); msgTail(); return; } @@ -446,6 +461,8 @@ function savedMsgHeader(Nmsg,usrctr,full height = 600; scrollbar = "yes"; } +/* if (window.pWin) + window.pWin.close(); */ pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',width=600,height='+height); pWin.document.write(""); pWin.document.write("Message Central"); @@ -460,7 +477,7 @@ function savedMsgHeader(Nmsg,usrctr,full pWin.document.write(" var msgchk = \\"\\";"); pWin.document.write(" if (document.msgcenter.subchk.checked) {"); - pWin.document.write(" msgchk = \\"subject,\\";"); + pWin.document.write(" msgchk = \\"msgsub,\\";"); pWin.document.write(" }"); pWin.document.write( "for (var i=1; i<=nmsg; i++) {"); pWin.document.write(" var opnmsg = eval(\\"opener.document.SCORE.savemsg\\"+i);"); @@ -468,15 +485,16 @@ function savedMsgHeader(Nmsg,usrctr,full pWin.document.write(" opnmsg.value = frmmsg.value;"); pWin.document.write(" var chkbox = eval(\\"document.msgcenter.msgn\\"+i);"); pWin.document.write(" if (chkbox.checked) {"); - pWin.document.write(" msgchk += i+\\",\\";"); + pWin.document.write(" msgchk += \\"savemsg\\"+i+\\",\\";"); pWin.document.write(" }"); pWin.document.write(" }"); pWin.document.write(" if (document.msgcenter.newmsgchk.checked) {"); - pWin.document.write(" msgchk += \\"new\\";"); + pWin.document.write(" msgchk += \\"newmsg\\"+usrctr;"); pWin.document.write(" }"); pWin.document.write(" var includemsg = eval(\\"opener.document.SCORE.includemsg\\"+usrctr);"); pWin.document.write(" includemsg.value = msgchk;"); +// pWin.document.write(" alert(\\"slected=\\"+msgchk)"); pWin.document.write(" self.close()"); pWin.document.write("}"); @@ -494,24 +512,24 @@ function savedMsgHeader(Nmsg,usrctr,full pWin.document.write(""); pWin.document.write(""); } - function displaySubject(msg) { + function displaySubject(msg,shwsel) { pWin.document.write(""); pWin.document.write(""); - pWin.document.write(""); + pWin.document.write(""); pWin.document.write(""); } -function displaySavedMsg(ctr,msg) { +function displaySavedMsg(ctr,msg,shwsel) { pWin.document.write(""); pWin.document.write(""); - pWin.document.write(""); + pWin.document.write(""); pWin.document.write(""); } -function newMsg(newmsg) { +function newMsg(newmsg,shwsel) { pWin.document.write(""); pWin.document.write(""); - pWin.document.write(""); + pWin.document.write(""); pWin.document.write(""); } @@ -623,15 +641,14 @@ SUBJAVASCRIPT 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 ''; } my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : ''); -# -# header info + + # header info if ($counter == 0) { $request->print('

 Submission Record

'. ' Resource: '.$url.''); } -# -# option to display problem, only once else it cause problems with the form later since the problem has a form. + # option to display problem, only once else it cause problems with the form later since the problem has a form. if ($ENV{'form.vProb'} eq 'yes' && $counter == 0) { my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom, $ENV{'request.course.id'}); @@ -645,65 +662,75 @@ SUBJAVASCRIPT $result.='
TypeIncludeMessage
Subject
"+ctr+"
New

'; $request->print($result); } -# -# beginning of form + + # beginning of form if ($counter == 0) { - my %keyhash = &Apache::lonnet::get - ('nohist_handgrade',[$symb.'_keywords'], + my %keyhash = &Apache::lonnet::dump('nohist_handgrade', $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'}; + # if the handgrade db has never being initialized then set some default values + if ($keyhash{$symb.'_handgrade'} eq '') { + $keyhash{$symb.'_keywords'} = ''; + $keyhash{$symb.'_subject'} = &Apache::lonnet::metadata($url,'title'); + $keyhash{$loginuser.'_kwclr'} = $keyhash{$loginuser.'_kwclr'} eq '' ? 'red' : $keyhash{$loginuser.'_kwclr'}; + $keyhash{$loginuser.'_kwsize'} = $keyhash{$loginuser.'_kwsize'} eq '' ? '0' : $keyhash{$loginuser.'_kwsize'}; + $keyhash{$loginuser.'_kwstyle'} = $keyhash{$loginuser.'_kwstyle'} eq '' ? '' : $keyhash{$loginuser.'_kwstyle'}; + $keyhash{$symb.'_savemsgN'} = '0'; + } $request->print(''."\n". ''."\n". ''."\n". ''."\n". - ''."\n". + ''."\n". ''."\n". ''."\n". ''."\n". ''."\n". ''."\n". ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". ''."\n"); + ' value="'.($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : $total+1).'" />'."\n"); + + my ($cts,$prnmsg) = (1,''); + while ($cts <= $keyhash{$symb.'_savemsgN'}) { + $prnmsg.=''."\n"; + $cts++; + } + $request->print($prnmsg); if ($ENV{'form.handgrade'} eq 'yes') { $request->print(<Keyword Options  Keyword List    Paste Selection to Keyword list (requires N4+ and IE5+)    + CLASS="page">Paste Selection to Keyword list    Keyword Highlight Attribute

KEYWORDS } } -# -# Student info + # Student info $request->print(($counter == 0 ? '' : '


')); my $fullname = ($ENV{'form.fullname'} ne '' ? $ENV{'form.fullname'} : &get_fullname($uname,$udom)); my $result.=''; if ($ENV{'form.handgrade'} eq 'yes') { - my $subonly = &get_last_submission($symb,$uname,$udom,$ENV{'request.course.id'}); +# my $subonly = &get_last_submission($symb,$uname,$udom,$ENV{'request.course.id'}); my ($classlist) = &getclasslist('all','0'); my @collaborators; - foreach ( sort(@{ $$classlist{'all'} }) ) { - my ($sname,$sdom) = split(/:/); - push @collaborators,$sname if (grep /\b$sname(\b|\.)/i,$subonly); - } - push @collaborators,'leede','carlandmm','freyniks'; # as a test to display collaborators. +# foreach ( sort(@{ $$classlist{'all'} }) ) { +# my ($sname,$sdom) = split(/:/); +# push @collaborators,$sname if (grep /\b$sname(\b|\.)/i,$subonly); +# } +# push @collaborators,'leede','carlandmm','freyniks'; # as a test to display collaborators. if (scalar(@collaborators) != 0) { $result.='
Username: '.$uname. 'Fullname: '.$fullname. -# ($ENV{'form.fullname'} ne '' ? $ENV{'form.fullname'} : &get_fullname($uname,$udom)). 'Domain: '.$udom.'
Collaborators: '; foreach (@collaborators) { @@ -716,28 +743,39 @@ KEYWORDS } $result.='
'."\n"; $request->print($result); -# -# print student answer - $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom, - $ENV{'request.course.id'},$last, - '.submission','Apache::grades::keywords_highlight')); -# -# + + # print student answer + if ($ENV{'form.lastSub'} eq 'lastonly') { + my ($string,$timestamp)=&get_last_submission ($symb,$uname,$udom,$ENV{'request.course.id'}); + $string=&keywords_highlight($string); + my $lastsubonly='
'; + $lastsubonly.=''; + $lastsubonly.=''; + $lastsubonly.='
Last Submission Only'. + ($timestamp eq '' ? '' : '    Date Submitted: '.$timestamp).'
'; + $lastsubonly.=$string; + $lastsubonly.='
'."\n"; + $request->print($lastsubonly); + } else { + $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom, + $ENV{'request.course.id'},$last, + '.submission','Apache::grades::keywords_highlight')); + } + my $wgt = &Apache::lonnet::EXT('resource.partid.weight',$symb,$udom,$uname); my $wgtmsg = ($wgt > 0 ? '(problem weight)' : 'problem weight assigned by computer'); $wgt = ($wgt > 0 ? $wgt : '1'); my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname); my $score = ($record{'resource.0.awarded'} eq '' ? '' : $record{'resource.0.awarded'}*$wgt); -# -# display grading options + # display grading options $result=''. ''."\n"; - $result.=''."\n". - $result.=''."\n". + $result.=''."\n"; + $result.=''."\n"; $result.='
Points'; - my $ctr = 0; + my $ctr = 0; $result.=''; # display radio buttons in a nice table with 10 across while ($ctr<=$wgt) { $result.= '
print($result); -# -# print end of form + + # print end of form if ($counter == $total) { my $endform.='
'; my $ntstu ='