--- loncom/homework/grades.pm 2002/07/03 21:05:33 1.35 +++ 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.35 2002/07/03 21:05:33 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 @@ -351,7 +353,7 @@ sub submission { my ($request,$counter,$total) = @_; if ($counter == 0) { - $request->print(<print(< function updateRadio(radioButton,formtextbox,formsel,wgt) { var pts = formtextbox.value; @@ -400,30 +402,236 @@ sub submission { function keywords(keyform) { var keywds = keyform.value; - var nret = prompt("Keywords list, separate by a space or comma. Add/delete to list if desired.",keywds); + var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keywds); if (nret==null) return; keyform.value = nret; return; } - function addmsg(msgform) { - var msg = msgform.value; - var nret = prompt("Enter the message you wish to send to the student.",msg); +//===================== Script to add keyword(s) ================== + function getSel() { + if (document.getSelection) txt = document.getSelection(); + else if (document.selection) txt = document.selection.createRange().text; + else return; + var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," "); + if (cleantxt=="") { + alert("Select a word or group of words from document and then click this link."); + return; + } + var nret = prompt("Add selection to keyword list?",cleantxt); if (nret==null) return; - msgform.value = nret; + var curlist = document.SCORE.keywords.value; + document.SCORE.keywords.value = curlist+" "+nret; return; } - function savedmsg(msgform) { - var Nmsg = msgform.value; - var nret = prompt("Number of saved messages = ",Nmsg); - if (nret==null) return; - msgform.value = nret; +//====================== Script for composing message ============== + function msgCenter(msgform,usrctr,fullname) { + var Nmsg = msgform.savemsgN.value; + savedMsgHeader(Nmsg,usrctr,fullname); + var subject = msgform.msgsub.value; + 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,shwsel); + } + newmsg = eval("document.SCORE.newmsg"+usrctr+".value"); + shwsel = ""; + re = /newmsg/; + if (re.test(msgchk)) { shwsel = "checked" } + newMsg(newmsg,shwsel); + msgTail(); + return; + } + +function savedMsgHeader(Nmsg,usrctr,fullname) { + var height = 30*Nmsg+250; + var scrollbar = "no"; + if (height > 600) { + 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"); + + pWin.document.write(" -JAVASCRIPT +SUBJAVASCRIPT } (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 ''; } @@ -433,14 +641,14 @@ JAVASCRIPT 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

'); + $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'}); @@ -454,59 +662,75 @@ JAVASCRIPT $result.='
'; $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"); + ' 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(<Grading Options -Keywords list    -Add a message    -Saved messages

Keyword Options  +Keyword List    +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: '. - ($ENV{'form.fullname'} ne '' ? $ENV{'form.fullname'} : &get_fullname($uname,$udom)). + 'Fullname: '.$fullname. 'Domain: '.$udom.'
Collaborators: '; foreach (@collaborators) { @@ -517,28 +741,41 @@ KEYWORDS '" value="'.(join ':',@collaborators).'" />'."\n"; } } - $result.='
Resource: '.$url.'
'."\n"; + $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.='
Points'; - my $ctr = 0; + my $ctr = 0; $result.=''; # display radio buttons in a nice table with 10 across while ($ctr<=$wgt) { $result.= '\n"; + $result.="  \n"; + $result.='Compose Message'."\n"; } } $result.='
partial'."\n"; $optsel =~ s/
'; $request->print($result); -# -# print end of form + + # print end of form if ($counter == $total) { my $endform.='
'; my $ntstu ='