--- loncom/homework/grades.pm 2003/03/24 21:03:54 1.76 +++ loncom/homework/grades.pm 2003/03/28 23:44:31 1.81 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.76 2003/03/24 21:03:54 ng Exp $ +# $Id: grades.pm,v 1.81 2003/03/28 23:44:31 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -125,8 +125,8 @@ sub getclasslist { my (undef,undef,$end,$start,$id,$section,$fullname,$status)= @{$classlist->{$_}}; # filter students according to status selected - if ($filterlist && $ENV{'form.saveStatus'} ne 'Any') { - if ($ENV{'form.saveStatus'} ne $status) { + if ($filterlist && $ENV{'form.status'} ne 'Any') { + if ($ENV{'form.status'} ne $status) { delete ($classlist->{$_}); next; } @@ -211,10 +211,7 @@ sub jscriptNform { $jscript.= '<form action="/adm/grades" method="post" name="onestudent">'."\n". '<input type="hidden" name="symb" value="'.$symb.'" />'."\n". '<input type="hidden" name="url" value="'.$url.'" />'."\n". - '<input type="hidden" name="saveCmd" value="'.$ENV{'form.saveCmd'}.'" />'."\n". - '<input type="hidden" name="saveSec" value="'.$ENV{'form.saveSec'}.'" />'."\n". - '<input type="hidden" name="saveSub" value="'.$ENV{'form.saveSub'}.'" />'."\n". - '<input type="hidden" name="saveStatus" value="'.$ENV{'form.saveStatus'}.'" />'."\n". + '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n". '<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n". '<input type="hidden" name="command" value="submission" />'."\n". '<input type="hidden" name="student" value="" />'."\n". @@ -301,7 +298,7 @@ sub listStudents { '<td><b>Type: </b>'.$responsetype.'</td>'. '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>'; } - $result.='</table>'; + $result.='</table>'."\n"; my $viewgrade = $ENV{'form.handgrade'} eq 'yes' ? 'View/Grade' : 'View'; $ENV{'form.probTitle'} = $ENV{'form.probTitle'} eq '' ? @@ -346,8 +343,8 @@ LISTJAVASCRIPT my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked'; my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n". - ' <b>View Problem: </b><input type="radio" name="vProb" value="no" /> no '."\n". - '<input type="radio" name="vProb" value="yes" checked /> one student '."\n". + ' <b>View Problem: </b><input type="radio" name="vProb" value="no" checked /> no '."\n". + '<input type="radio" name="vProb" value="yes" /> one student '."\n". '<input type="radio" name="vProb" value="all" /> all students <br />'."\n". ' <b>Submissions: </b>'."\n"; if ($ENV{'form.handgrade'} eq 'yes') { @@ -361,10 +358,7 @@ LISTJAVASCRIPT '<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="showgrading" value="'.$ENV{'form.showgrading'}.'" /><br />'."\n". - '<input type="hidden" name="saveCmd" value="'.$ENV{'form.saveCmd'}.'" />'."\n". - '<input type="hidden" name="saveSec" value="'.$ENV{'form.saveSec'}.'" />'."\n". - '<input type="hidden" name="saveSub" value="'.$ENV{'form.saveSub'}.'" />'."\n". - '<input type="hidden" name="saveStatus" value="'.$ENV{'form.saveStatus'}.'" />'."\n". + '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n". '<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n". '<input type="hidden" name="url" value="'.$url.'" />'."\n". '<input type="hidden" name="symb" value="'.$symb.'" />'."\n". @@ -634,6 +628,7 @@ SUBJAVASCRIPT #--- javascript for essay type problem -- sub sub_page_kw_js { my $request = shift; + my $iconpath = $request->dir_config('lonIconsURL'); $request->print(<<SUBJAVASCRIPT); <script type="text/javascript" language="javascript"> @@ -681,6 +676,12 @@ sub sub_page_kw_js { } //====================== Script for composing message ============== + // preload images + img1 = new Image(); + img1.src = "$iconpath/mailbkgrd.gif"; + img2 = new Image(); + img2.src = "$iconpath/mailto.gif"; + function msgCenter(msgform,usrctr,fullname) { var Nmsg = msgform.savemsgN.value; savedMsgHeader(Nmsg,usrctr,fullname); @@ -735,17 +736,26 @@ sub sub_page_kw_js { pDoc.write(" if (document.msgcenter.subchk.checked) {"); pDoc.write(" msgchk = \\"msgsub,\\";"); pDoc.write(" }"); - pDoc.write( "for (var i=1; i<=nmsg; i++) {"); + pDoc.write(" var includemsg = 0;"); + pDoc.write(" for (var i=1; i<=nmsg; i++) {"); pDoc.write(" var opnmsg = eval(\\"opener.document.SCORE.savemsg\\"+i);"); pDoc.write(" var frmmsg = eval(\\"document.msgcenter.msg\\"+i);"); pDoc.write(" opnmsg.value = frmmsg.value;"); pDoc.write(" var chkbox = eval(\\"document.msgcenter.msgn\\"+i);"); pDoc.write(" if (chkbox.checked) {"); pDoc.write(" msgchk += \\"savemsg\\"+i+\\",\\";"); + pDoc.write(" includemsg = 1;"); pDoc.write(" }"); pDoc.write(" }"); pDoc.write(" if (document.msgcenter.newmsgchk.checked) {"); pDoc.write(" msgchk += \\"newmsg\\"+usrctr;"); + pDoc.write(" includemsg = 1;"); + pDoc.write(" }"); + pDoc.write(" imgformname = eval(\\"opener.document.SCORE.mailicon\\"+usrctr);"); + pDoc.write(" if (includemsg) {"); + pDoc.write(" imgformname.src = \\"$iconpath/mailto.gif\\";"); + pDoc.write(" } else {"); + pDoc.write(" imgformname.src = \\"$iconpath/mailbkgrd.gif\\";"); pDoc.write(" }"); pDoc.write(" var includemsg = eval(\\"opener.document.SCORE.includemsg\\"+usrctr);"); pDoc.write(" includemsg.value = msgchk;"); @@ -1036,10 +1046,7 @@ sub submission { $request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n". '<input type="hidden" name="command" value="handgrade" />'."\n". - '<input type="hidden" name="saveCmd" value="'.$ENV{'form.saveCmd'}.'" />'."\n". - '<input type="hidden" name="saveSec" value="'.$ENV{'form.saveSec'}.'" />'."\n". - '<input type="hidden" name="saveSub" value="'.$ENV{'form.saveSub'}.'" />'."\n". - '<input type="hidden" name="saveStatus" value="'.$ENV{'form.saveStatus'}.'" />'."\n". + '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n". '<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n". '<input type="hidden" name="refresh" value="off" />'."\n". '<input type="hidden" name="symb" value="'.$symb.'" />'."\n". @@ -1063,7 +1070,9 @@ sub submission { my ($cts,$prnmsg) = (1,''); while ($cts <= $ENV{'form.savemsgN'}) { $prnmsg.='<input type="hidden" name="savemsg'.$cts.'" value="'. - ($keyhash{$symb.'_savemsg'.$cts} eq '' ? $ENV{'form.savemsg'.$cts} : $keyhash{$symb.'_savemsg'.$cts}). + ($keyhash{$symb.'_savemsg'.$cts} eq '' ? + &Apache::lonfeedback::clear_out_html($ENV{'form.savemsg'.$cts}) : + &Apache::lonfeedback::clear_out_html($keyhash{$symb.'_savemsg'.$cts})). '" />'."\n"; $cts++; } @@ -1104,7 +1113,7 @@ KEYWORDS my ($classlist,$fullname); if ($ENV{'form.handgrade'} eq 'yes') { my @col_list; - ($classlist,undef,$fullname) = &getclasslist('all',$ENV{'form.showgrading'} eq 'yes' ? '1' : '0'); + ($classlist,undef,$fullname) = &getclasslist('all','0'); for (keys (%$handgrade)) { my $ncol = &Apache::lonnet::EXT('resource.'.$_. '.maxcollaborators', @@ -1112,20 +1121,26 @@ KEYWORDS next if ($ncol <= 0); s/\_/\./g; next if ($record{'resource.'.$_.'.collaborators'} eq ''); - my (@collaborators) = split(/,?\s+/, + my (@colList) = split(/,?\s+/, $record{'resource.'.$_.'.collaborators'}); + my @collaborators = (); + foreach (@colList) { #pre-filter list - throw out submitter + my ($co_name,$co_dom) = split /\@|:/,$_; + $co_dom = $udom if (! defined($co_dom)); + next if ($co_name eq $uname && $co_dom eq $udom); + push @collaborators, $_; + } my (@badcollaborators); if (scalar(@collaborators) != 0) { $result.='<b>Collaborators: </b>'; foreach my $collaborator (@collaborators) { my ($co_name,$co_dom) = split /\@|:/,$collaborator; $co_dom = $udom if (! defined($co_dom)); - next if ($co_name eq $uname && $co_dom eq $udom); # Doing this grep allows 'fuzzy' specification - my @Matches = grep /^$co_name:$co_dom/i, + my @Matches = grep /^$co_name:$co_dom$/i, keys %$classlist; - if (! scalar(@Matches)) { - push @badcollaborators,$collaborator; + if (! scalar(@Matches)) { + push @badcollaborators,':'.$collaborator.':'; next; } push @col_list, @Matches; @@ -1145,7 +1160,7 @@ KEYWORDS $result .= 'invalid collaborators'; } $result .= ': '.join(', ',@badcollaborators); - + $result .= '</td></tr></table>'; } if (scalar(@collaborators > $ncol)) { $result .= '<table border="0"><tr bgcolor="#ffbbbb"><td>'; @@ -1238,7 +1253,9 @@ KEYWORDS $result.='<tr><td bgcolor="#ffffff">'."\n". ' <a href="javascript:msgCenter(document.SCORE,'.$counter. ',\''.$msgfor.'\')"; TARGET=_self>'. - 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a>'. + 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a> '. + '<img src="'.$request->dir_config('lonIconsURL'). + '/mailbkgrd.gif" width="14" height="10" name="mailicon'.$counter.'" />'."\n". '<br /> (Message will be sent when you click on Save & Next below.)'."\n" if ($ENV{'form.handgrade'} eq 'yes'); $request->print($result); @@ -1352,12 +1369,11 @@ sub processHandGrade { my $ctr = 0; while ($ctr < $ngrade) { my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr}); - my ($errorflag) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr); + my ($errorflag,$pts,$wgt) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr); if ($errorflag eq 'no_score') { $ctr++; next; } - my $includemsg = $ENV{'form.includemsg'.$ctr}; my ($subject,$message,$msgstatus) = ('','',''); if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) { @@ -1366,7 +1382,11 @@ sub processHandGrade { foreach (@msgnum) { $message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne ''); } - #$message =~ s/\s+/ /g; + $message =&Apache::lonfeedback::clear_out_html($message); + $message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt; + $message.=" for <a href=\"". + &Apache::lonnet::clutter($url). + "?symb=$symb\">$ENV{'form.probTitle'}</a>"; $msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom, $ENV{'form.msgsub'},$message); } @@ -1504,8 +1524,9 @@ sub processHandGrade { #---- Save the score and award for each student, if changed sub saveHandGrade { my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter) = @_; - my %record=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname); - my %newrecord; + my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname); + my %newrecord = (); + my ($pts,$wgt) = ('',''); foreach (split(/:/,$ENV{'form.partlist'.$newflg})) { if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') { if ($record{'resource.'.$_.'.solved'} ne 'excused') { @@ -1515,11 +1536,11 @@ sub saveHandGrade { } } } else { - my $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? - $ENV{'form.GD_BOX'.$newflg.'_'.$_} : - $ENV{'form.RADVAL'.$newflg.'_'.$_}); + $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? + $ENV{'form.GD_BOX'.$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 : + $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 : $ENV{'form.WGT'.$newflg.'_'.$_}; my $partial= $pts/$wgt; $newrecord{'resource.'.$_.'.awarded'} = $partial @@ -1542,7 +1563,7 @@ sub saveHandGrade { &Apache::lonnet::cstore(\%newrecord,$symb, $ENV{'request.course.id'},$domain,$stuname); } - return ''; + return '',$pts,$wgt; } #-------------------------------------------------------------------------------------- @@ -1738,10 +1759,7 @@ sub viewgrades { '<input type="hidden" name="url" value="'.$url.'" />'."\n". '<input type="hidden" name="command" value="editgrades" />'."\n". '<input type="hidden" name="section" value="'.$ENV{'form.section'}.'" />'."\n". - '<input type="hidden" name="saveCmd" value="'.$ENV{'form.saveCmd'}.'" />'."\n". - '<input type="hidden" name="saveSec" value="'.$ENV{'form.saveSec'}.'" />'."\n". - '<input type="hidden" name="saveSub" value="'.$ENV{'form.saveSub'}.'" />'."\n". - '<input type="hidden" name="saveStatus" value="'.$ENV{'form.saveStatus'}.'" />'."\n". + '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n". '<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n"; $result.='<h3>Assign Common Grade To '; @@ -2158,10 +2176,7 @@ to this page if the data selected is ins value="$ENV{'form.upfile_associate'}" /> <input type="hidden" name="symb" value="$symb" /> <input type="hidden" name="url" value="$url" /> -<input type="hidden" name="saveCmd" value="$ENV{'form.saveCmd'}" /> -<input type="hidden" name="saveSec" value="$ENV{'form.saveSec'}" /> -<input type="hidden" name="saveSub" value="$ENV{'form.saveSub'}" /> -<input type="hidden" name="saveStatus" value="$ENV{'form.saveStatus'}" /> +<input type="hidden" name="saveState" value="$ENV{'form.saveState'}" /> <input type="hidden" name="probTitle" value="$ENV{'form.probTitle'}" /> <input type="hidden" name="command" value="csvuploadassign" /> <hr /> @@ -2355,7 +2370,7 @@ LISTJAVASCRIPT 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.='<form action="/adm/grades" method="post" name="displayPage">'."\n"; $result.=' <b>Problems from:</b> <select name="selectpage">'."\n"; my ($titles,$symbx) = &getSymbMap($request); my ($curpage,$type,$mapId) = ($symb =~ /(.*?\.(page|sequence))___(\d+)___/); @@ -2389,13 +2404,10 @@ LISTJAVASCRIPT $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="saveCmd" value="'.$ENV{'form.saveCmd'}.'" />'."\n". - '<input type="hidden" name="saveSec" value="'.$ENV{'form.saveSec'}.'" />'."\n". - '<input type="hidden" name="saveSub" value="'.$ENV{'form.saveSub'}.'" />'."\n". - '<input type="hidden" name="saveStatus" value="'.$ENV{'form.saveStatus'}.'" />'."\n"; + '<input type="hidden" name="symb" value="'.$symb.'" />'."\n". + '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."<br />\n"; - $result.='<br /> <input type="button" '. + $result.=' <input type="button" '. 'onClick="javascript:checkPickOne(this.form);"value="Submit" /><br />'."\n"; $request->print($result); @@ -2433,8 +2445,7 @@ LISTJAVASCRIPT sub getSymbMap { my ($request) = @_; - my $navmap = Apache::lonnavmaps::navmap-> new($request, - $ENV{'request.course.fn'}.'.db', + 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 @@ -2509,8 +2520,7 @@ sub displayPage { &sub_page_js($request); $request->print($result); - my $navmap = Apache::lonnavmaps::navmap-> new($request, - $ENV{'request.course.fn'}.'.db', + 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 @@ -2525,10 +2535,7 @@ sub displayPage { '<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="saveCmd" value="'.$ENV{'form.saveCmd'}.'" />'."\n". - '<input type="hidden" name="saveSec" value="'.$ENV{'form.saveSec'}.'" />'."\n". - '<input type="hidden" name="saveSub" value="'.$ENV{'form.saveSub'}.'" />'."\n". - '<input type="hidden" name="saveStatus" value="'.$ENV{'form.saveStatus'}.'" />'."\n"; + '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n"; my $checkIcon = '<img src="'.$request->dir_config('lonIconsURL'). '/check.gif" height="16" border="0" />'; @@ -2560,8 +2567,8 @@ sub displayPage { } else { my $companswer = &Apache::loncommon::get_student_answers( $symbx,$uname,$udom,$ENV{'request.course.id'}); - $companswer=~s|<form(.*?)>||g; - $companswer=~s|</form>||g; + $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>'); @@ -2590,13 +2597,16 @@ sub displayPage { my @displaySub = (); foreach my $partid (@{$parts}) { my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys; - next if ($record{"$version:resource.$partid.award"} eq 'APPROX_ANS' && - $record{"$version:resource.$partid.solved"} eq ''); + next if ($record{"$version:resource.$partid.solved"} eq ''); +# next if ($record{"$version:resource.$partid.award"} eq 'APPROX_ANS' && +# $record{"$version:resource.$partid.solved"} eq ''); $displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ? - '<b>Part:</b> '.$partid.' <b>Submission:</b> ' - .$record{$version.':'.$matchKey[0]}.'<br />' : ''; + '<b>Part '.$partid.' '. + ($record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' : + 'Trial '.$record{"$version:resource.$partid.tries"}).'</b> '. + $record{$version.':'.$matchKey[0]}.'<br />' : ''; $displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ? - '<b>Part:</b> '.$partid.' '. + '<b>Part '.$partid.'</b> '. $record{"$version:resource.$partid.award"}.'/'. $record{"$version:resource.$partid.solved"}.'<br />' : ''; $displaySub[2].=(exists $record{"$version:resource.$partid.regrader"}) ? @@ -2667,8 +2677,7 @@ sub updateGradeByPage { $request->print($result); - my $navmap = Apache::lonnavmaps::navmap-> new($request, - $ENV{'request.course.fn'}.'.db', + 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 @@ -2770,6 +2779,15 @@ sub updateGradeByPage { # #------ start of section for handling grading by page/sequence --------- +sub defaultFormData { + my ($symb,$url)=@_; + return ' + <input type="hidden" name="symb" value="'.$symb.'" />'."\n". + '<input type="hidden" name="url" value="'.$url.'" />'."\n". + '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n". + '<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n"; +} + sub getSequenceDropDown { my ($request,$symb)=@_; my $result='<select name="selectpage">'."\n"; @@ -2787,17 +2805,33 @@ sub getSequenceDropDown { return $result; } +sub scantron_uploads { + if (!-e $Apache::lonnet::perlvar{'lonScansDir'}) { return ''}; + my $result= '<select name="scantron_selectfile">'; + opendir(DIR,$Apache::lonnet::perlvar{'lonScansDir'}); + my @files=sort(readdir(DIR)); + foreach my $filename (@files) { + if ($filename eq '.' or $filename eq '..') { next; } + $result.="<option>$filename</option>\n"; + } + closedir(DIR); + $result.="</select>"; + return $result; +} + sub scantron_selectphase { my ($r) = @_; my ($symb,$url)=&get_symb_and_url($r); if (!$symb) {return '';} my $sequence_selector=&getSequenceDropDown($r,$symb); + my $default_form_data=&defaultFormData($symb,$url); + my $grading_menu_button=&show_grading_menu_form($symb,$url); + my $file_selector=&scantron_uploads(); my $result; $result.= <<SCANTRONFORM; <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload"> - <input type="hidden" name="symb" value="$symb" /> - <input type="hidden" name="url" value="$url" /> <input type="hidden" name="command" value="scantron_configphase" /> + $default_form_data <table width="100%" border="0"> <tr> <td bgcolor="#777777"> @@ -2814,12 +2848,7 @@ sub scantron_selectphase { </tr> <tr bgcolor="#ffffe6"> <td> - <!-- FIXME I need to present a list of files from a specfic directory that has been configured, or any existing delay queues --> - Filename of scoring office file: - <select name="selectfile"> - <option value="filname1">filename1</option> - <option value="filname2">filename2</option> - </select> + Filename of scoring office file: $file_selector </td> </tr> </table> @@ -2828,6 +2857,7 @@ sub scantron_selectphase { </table> <input type="submit" value="Submit" /> </form> +$grading_menu_button SCANTRONFORM return $result; @@ -2835,12 +2865,44 @@ SCANTRONFORM sub scantron_configphase { my ($r) = @_; - my $sequence=$ENV{'form.selectpage'}; + my (undef,undef,$sequence)=split(/___/,$ENV{'form.selectpage'}); my $result; - $result.="got page $sequence"; - $Apache::lonxml::debug=1; - &Apache::lonhomework::showhash(%ENV); - $Apache::lonxml::debug=0; + my ($symb,$url)=&get_symb_and_url($r); + if (!$symb) {return '';} + my $default_form_data=&defaultFormData($symb,$url); + my $grading_menu_button=&show_grading_menu_form($symb,$url); + my $file_selector; + $result.= <<SCANTRONFORM; +<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload"> + <input type="hidden" name="command" value="scantron_configphase" /> + $default_form_data + <table width="100%" border="0"> + <tr> + <td bgcolor="#777777"> + <table width="100%" border="0"> + <tr bgcolor="#e6ffff"> + <td> + <b>Select a format for the data file.</b> + </td> + </tr> + <tr bgcolor="#ffffe6"> + <td> + Format of data file: + </td> + </tr> + <tr bgcolor="#ffffe6"> + <td> + Filename of scoring office file: $file_selector + </td> + </tr> + </table> + </td> + </tr> + </table> + <input type="submit" value="Submit" /> +</form> +$grading_menu_button +SCANTRONFORM #FIXME Needs to present some lines from the file and allow the instructor to specify which columns represent what data, possibly have some nice defaults setup, probably should do a pass through all problems for a student to get an idea of how many questions there are, and homw many lines we'll have, return $result; } @@ -2878,16 +2940,24 @@ sub show_grading_menu_form { my $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="saveCmd" value="'.$ENV{'form.saveCmd'}.'" />'."\n". - '<input type="hidden" name="saveSec" value="'.$ENV{'form.saveSec'}.'" />'."\n". - '<input type="hidden" name="saveSub" value="'.$ENV{'form.saveSub'}.'" />'."\n". - '<input type="hidden" name="saveStatus" value="'.$ENV{'form.saveStatus'}.'" />'."\n". + '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n". '<input type="hidden" name="command" value="gradingmenu" />'."\n". '<input type="submit" name="submit" value="Grading Menu" />'."\n". '</form>'."\n"; return $result; } +# -- Retrieve choices for grading form +sub savedState { + my %savedState = (); + if ($ENV{'form.saveState'}) { + foreach (split(/:/,$ENV{'form.saveState'})) { + my ($key,$value) = split(/=/,$_,2); + $savedState{$key} = $value; + } + } + return \%savedState; +} #--- Displays the main menu page ------- sub gradingmenu { @@ -2895,19 +2965,13 @@ sub gradingmenu { my ($symb,$url)=&get_symb_and_url($request); if (!$symb) {return '';} my $probTitle = &Apache::lonnet::gettitle($symb); - my $saveCmd = ($ENV{'form.saveCmd'} eq '' ? 'pickStudentPage' : $ENV{'form.saveCmd'}); - my $saveSec = ($ENV{'form.saveSec'} eq '' ? 'all' : $ENV{'form.saveSec'}); - my $saveSub = ($ENV{'form.saveSub'} eq '' ? 'yes' : $ENV{'form.saveSub'}); - my $saveStatus = ($ENV{'form.saveStatus'} eq '' ? 'Active' : $ENV{'form.saveStatus'}); $request->print(<<GRADINGMENUJS); <script type="text/javascript" language="javascript"> function checkChoice(formname) { var cmd = formname.command; - formname.saveCmd.value = radioSelection(cmd); - formname.saveSec.value = pullDownSelection(formname.section); - formname.saveSub.value = radioSelection(formname.submitonly); - formname.saveStatus.value = pullDownSelection(formname.status); + formname.saveState.value = "saveCmd="+radioSelection(cmd)+":saveSec="+pullDownSelection(formname.section)+ + ":saveSub="+radioSelection(formname.submitonly)+":saveStatus="+pullDownSelection(formname.status); if (cmd[0].checked || cmd[1].checked || cmd[2].checked || cmd[4].checked) formname.submit(); if (cmd[3].checked) browseAndUpload(); @@ -2974,7 +3038,10 @@ sub gradingmenu { lDoc.write(" alert(\\"Please use the browse button to select a file from your local directory.\\");"); lDoc.write(" return false;"); lDoc.write(" }"); + lDoc.write(" var openformname = opener.document.gradingMenu;"); + lDoc.write(" formname.saveState.value = \\"saveCmd=\\"+opener.radioSelection(openformname.command)+\\":saveSec=\\"+opener.pullDownSelection(openformname.section)+\\":saveSub=\\"+opener.radioSelection(openformname.submitonly)+\\":saveStatus=\\"+opener.pullDownSelection(openformname.status);"); lDoc.write(" document.gradesupload.submit();"); + lDoc.write(" if (navigator.appName !=\\"Netscape\\") {self.close()};"); lDoc.write(" setTimeout('self.close()',750)"); lDoc.write("}"); @@ -2986,13 +3053,10 @@ sub gradingmenu { lDoc.write("<input type=\\"hidden\\" name=\\"symb\\" value=\\"$symb\\">"); lDoc.write("<input type=\\"hidden\\" name=\\"url\\" value=\\"$url\\">"); lDoc.write("<input type=\\"hidden\\" name=\\"probTitle\\" value=\\"$probTitle\\">"); - lDoc.write("<input type=\\"hidden\\" name=\\"saveCmd\\" value=\\"csvupload\\">"); - lDoc.write("<input type=\\"hidden\\" name=\\"saveSec\\" value=\\"$saveSec\\">"); - lDoc.write("<input type=\\"hidden\\" name=\\"saveSub\\" value=\\"$saveSub\\">"); - lDoc.write("<input type=\\"hidden\\" name=\\"saveStatus\\" value=\\"$saveStatus\\">"); + lDoc.write("<input type=\\"hidden\\" name=\\"saveState\\" value=\\"\\">"); lDoc.write("<input type=\\"hidden\\" name=\\"command\\" value=\\"csvuploadmap\\">"); - lDoc.write("<font color=\\"green\\" size=+1><b>Specify a file containing the class scores for problem - $probTitle</b></font><br><br>"); + lDoc.write("<font color=\\"green\\" size=+1> <b>Specify a file containing the class scores for problem - $probTitle</b></font><br><br>"); lDoc.write("<table border=0 width=100%><tr><td bgcolor=\\"#777777\\">"); lDoc.write("<table border=0 width=100%><tr bgcolor=\\"#ddffff\\">"); @@ -3030,6 +3094,11 @@ GRADINGMENUJS $result.='</table>'."\n"; my (undef,$sections) = &getclasslist('all','0'); + my $savedState = &savedState(); + my $saveCmd = ($$savedState{'saveCmd'} eq '' ? 'pickStudentPage' : $$savedState{'saveCmd'}); + my $saveSec = ($$savedState{'saveSec'} eq '' ? 'all' : $$savedState{'saveSec'}); + my $saveSub = ($$savedState{'saveSub'} eq '' ? 'yes' : $$savedState{'saveSub'}); + my $saveStatus = ($$savedState{'saveStatus'} eq '' ? 'Active' : $$savedState{'saveStatus'}); $result.='<form action="/adm/grades" method="post" name="gradingMenu">'."\n". '<input type="hidden" name="symb" value="'.$symb.'" />'."\n". @@ -3037,10 +3106,7 @@ GRADINGMENUJS '<input type="hidden" name="response" value="'.$resptype.'" />'."\n". '<input type="hidden" name="handgrade" value="'.$hdgrade.'" />'."\n". '<input type="hidden" name="probTitle" value="'.$probTitle.'" />'."\n". - '<input type="hidden" name="saveCmd" value="" />'."\n". - '<input type="hidden" name="saveSec" value="" />'."\n". - '<input type="hidden" name="saveSub" value="" />'."\n". - '<input type="hidden" name="saveStatus" value="" />'."\n". + '<input type="hidden" name="saveState" value="" />'."\n". '<input type="hidden" name="showgrading" value="yes" />'."\n"; $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n". @@ -3075,7 +3141,8 @@ GRADINGMENUJS 'Upload scores from file</td></tr>'."\n"; $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'. - '<input type="radio" name="command" value="scantron_selectphase" /> '. + '<input type="radio" name="command" value="scantron_selectphase" '. + ($saveCmd eq 'scantron_selectphase' ? 'checked="on"' : '').' /> '. 'Grade scantron forms</td></tr>'."\n"; if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) {