--- loncom/homework/grades.pm 2004/12/03 22:44:36 1.233 +++ loncom/homework/grades.pm 2005/02/07 17:07:58 1.242 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.233 2004/12/03 22:44:36 albertel Exp $ +# $Id: grades.pm,v 1.242 2005/02/07 17:07:58 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -973,6 +973,7 @@ sub sub_page_kw_js { my $iconpath = $request->dir_config('lonIconsURL'); &commonJSfunctions($request); my $docopen=&Apache::lonhtmlcommon::javascript_docopen(); + $docopen=~s/^document\.//; $request->print(<<SUBJAVASCRIPT); <script type="text/javascript" language="javascript"> @@ -1689,6 +1690,7 @@ KEYWORDS &Apache::lonnet::allowuploaded('/adm/grades',$file); $lastsubonly.='<br /><a href="'.$file.'" target="lonGRDs"><img src="'.&Apache::loncommon::icon($file).'" border=0"> '.$file.'</a>'; } + $lastsubonly.='<br />'; } $lastsubonly.='<b>Submitted Answer: </b>'. &cleanRecord($subval,$responsetype,$symb,$partid, @@ -3058,7 +3060,8 @@ sub getSymbMap { my $minder = 0; # Gather every sequence that has problems. - my @sequences = $navmap->retrieveResources(undef, sub { shift->is_map(); }, 1); + my @sequences = $navmap->retrieveResources(undef, sub { shift->is_map(); }, + 1,0,1); for my $sequence ($navmap->getById('0.0'), @sequences) { if ($navmap->hasResource($sequence, sub { shift->is_problem(); }, 0) ) { my $title = $minder.'.'.$sequence->compTitle(); @@ -3137,7 +3140,7 @@ sub displayPage { if($curRes == $iterator->BEGIN_MAP) { $depth++; } if($curRes == $iterator->END_MAP) { $depth--; } - if (ref($curRes) && $curRes->is_problem()) { + if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) { my $parts = $curRes->parts(); my $title = $curRes->compTitle(); my $symbx = $curRes->symb(); @@ -3794,25 +3797,49 @@ sub scantron_parse_scanline { my $currentquest=substr($questions,0,$$scantron_config{'Qlength'}); substr($questions,0,$$scantron_config{'Qlength'})=''; if (length($currentquest) < $$scantron_config{'Qlength'}) { next; } - my @array=split($$scantron_config{'Qon'},$currentquest,-1); - if (length($array[0]) eq $$scantron_config{'Qlength'}) { - $record{"scantron.$questnum.answer"}=''; - if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) { - push(@{$record{"scantron.missingerror"}},$questnum); - } + if ($$scantron_config{'Qon'} eq 'letter') { + if (!$currentquest || $currentquest eq $$scantron_config{'Qoff'} || + $currentquest !~ /^[A-Z]$/) { + $record{"scantron.$questnum.answer"}=''; + if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) { + push(@{$record{"scantron.missingerror"}},$questnum); + } + } else { + $record{"scantron.$questnum.answer"}=$currentquest; + } + } elsif ($$scantron_config{'Qon'} eq 'number') { + if (!$currentquest || $currentquest eq $$scantron_config{'Qoff'} || + $currentquest !~ /^\d$/) { + $record{"scantron.$questnum.answer"}=''; + if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) { + push(@{$record{"scantron.missingerror"}},$questnum); + } + } else { + $record{"scantron.$questnum.answer"}= + $alphabet[$currentquest-1]; + } } else { - $record{"scantron.$questnum.answer"}=$alphabet[length($array[0])]; + my @array=split($$scantron_config{'Qon'},$currentquest,-1); + if (length($array[0]) eq $$scantron_config{'Qlength'}) { + $record{"scantron.$questnum.answer"}=''; + if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) { + push(@{$record{"scantron.missingerror"}},$questnum); + } + } else { + $record{"scantron.$questnum.answer"}= + $alphabet[length($array[0])]; + } + if (scalar(@array) gt 2) { + push(@{$record{'scantron.doubleerror'}},$questnum); + my @ans=@array; + my $i=length($ans[0]);shift(@ans); + while ($#ans) { + $i+=length($ans[0])+1; + $record{"scantron.$questnum.answer"}.=$alphabet[$i]; + shift(@ans); + } + } } - if (scalar(@array) gt 2) { - push(@{$record{'scantron.doubleerror'}},$questnum); - my @ans=@array; - my $i=length($ans[0]);shift(@ans); - while ($#ans) { - $i+=length($ans[0])+1; - $record{"scantron.$questnum.answer"}.=$alphabet[$i]; - shift(@ans); - } - } } $record{'scantron.maxquest'}=$questnum; return \%record; @@ -3977,14 +4004,28 @@ sub scantron_do_warning { if (!$symb) {return '';} my $default_form_data=&defaultFormData($symb,$url); $r->print(&scantron_form_start().$default_form_data); - my $warning=&scantron_warning_screen('Validate Records'); - $r->print(<<STUFF); + if ( $ENV{'form.selectpage'} eq '' || + $ENV{'form.scantron_selectfile'} eq '' || + $ENV{'form.scantron_format'} eq '' ) { + $r->print("<p>You have forgetten to specify some information. Please go Back and try again.</p>"); + if ( $ENV{'form.selectpage'} eq '') { + $r->print('<p><font color="red">You have not selected a Sequence to grade</font></p>'); + } + if ( $ENV{'form.scantron_selectfile'} eq '') { + $r->print('<p><font color="red">You have not selected a file that contains the student\'s response data.</font></p>'); + } + if ( $ENV{'form.scantron_format'} eq '') { + $r->print('<p><font color="red">You have not selected a the format of the student\'s response data.</font></p>'); + } + } else { + my $warning=&scantron_warning_screen('Validate Records'); + $r->print(<<STUFF); $warning <input type="submit" name="submit" value="Validate Records" /> <input type="hidden" name="command" value="scantron_validate" /> -</form> STUFF - $r->print("<br />".&show_grading_menu_form($symb,$url)."</body></html>"); + } + $r->print("</form><br />".&show_grading_menu_form($symb,$url)."</body></html>"); return ''; } @@ -4285,6 +4326,12 @@ sub scantron_get_correction { $r->print(" in scanline $i <pre>". $line."</pre> \n"); } + my $message="<p>The ID on the form is <tt>". + $$scan_record{'scantron.ID'}."</tt><br />\n". + "The name on the paper is ". + $$scan_record{'scantron.LastName'}.",". + $$scan_record{'scantron.FirstName'}."</p>"; + $r->print('<input type="hidden" name="scantron_corrections" value="'.$error.'" />'."\n"); $r->print('<input type="hidden" name="scantron_line" value="'.$i.'" />'."\n"); if ($error =~ /ID$/) { @@ -4293,11 +4340,7 @@ sub scantron_get_correction { } elsif ($error eq 'duplicateID') { $r->print("The encoded ID has also been used by a previous paper $arg</p>\n"); } - $r->print("<p>The ID on the form is <tt>". - $$scan_record{'scantron.ID'}."</tt><br />\n"); - $r->print("The name on the paper is ". - $$scan_record{'scantron.LastName'}.",". - $$scan_record{'scantron.FirstName'}."</p>"); + $r->print($message); $r->print("<p>How should I handle this? <br /> \n"); $r->print("\n<ul><li> "); #FIXME it would be nice if this sent back the user ID and @@ -4317,11 +4360,7 @@ sub scantron_get_correction { } $r->print("<p>The CODE on the form is <tt>'". $$scan_record{'scantron.CODE'}."'</tt><br />\n"); - $r->print("<p>The ID on the form is <tt>". - $$scan_record{'scantron.ID'}."</tt><br />\n"); - $r->print("The name on the paper is ". - $$scan_record{'scantron.LastName'}.",". - $$scan_record{'scantron.FirstName'}."</p>"); + $r->print($message); $r->print("<p>How should I handle this? <br /> \n"); $r->print("\n<br /> "); my $i=0; @@ -4364,6 +4403,7 @@ ENDSCRIPT $r->print("<p>There have been multiple bubbles scanned for a some question(s)</p>\n"); $r->print('<input type="hidden" name="scantron_questions" value="'. join(',',@{$arg}).'" />'); + $r->print($message); $r->print("<p>Please indicate which bubble should be used for grading</p>"); foreach my $question (@{$arg}) { my $selected=$$scan_record{"scantron.$question.answer"}; @@ -4371,6 +4411,7 @@ ENDSCRIPT } } elsif ($error eq 'missingbubble') { $r->print("<p>There have been <b>no</b> bubbles scanned for some question(s)</p>\n"); + $r->print($message); $r->print("<p>Please indicate which bubble should be used for grading</p>"); $r->print("Some questions have no scanned bubbles\n"); $r->print('<input type="hidden" name="scantron_questions" value="'. @@ -4524,7 +4565,7 @@ sub scantron_get_maxbubble { my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); &Apache::lonnet::delenv('form.counter'); foreach my $resource (@resources) { - my $result=&Apache::lonnet::ssi($resource->src()); + my $result=&Apache::lonnet::ssi($resource->src().'?symb='.&Apache::lonnet::escape($resource->symb())); } &Apache::lonnet::delenv('scantron\.'); my $envfile=$ENV{'user.environment'}; @@ -4808,7 +4849,6 @@ DOWNLOAD # #------------------------------------------------------------------- - #-------------------------- Menu interface ------------------------- # #--- Show a Grading Menu button - Calls the next routine --- @@ -4861,6 +4901,7 @@ sub gradingmenu { if (!checkReceiptNo(formname,'notOK')) { return false;} formname.submit(); } + if (val < 7) formname.submit(); } function checkReceiptNo(formname,nospace) { @@ -4913,7 +4954,7 @@ GRADINGMENUJS ($saveSec eq $_ ? 'selected="on"':'').'>'.$_.'</option>'."\n"; } } - $result.= '<option value="all" '.($saveSec eq 'all' ? 'selected="on"' : ''). '>all</select> '; + $result.= '<option value="all" '.($saveSec eq 'all' ? 'selected="on"' : ''). '>all</option></select> '; $result.=&mt('Student Status').':</b>'.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,undef); @@ -4965,6 +5006,9 @@ GRADINGMENUJS '-<input type="text" name="receipt" size="4" onChange="javascript:checkReceiptNo(this.form,\'OK\')">'. '</td></tr>'."\n"; } + $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'. + '<input type="button" onClick="javascript:this.form.action=\'/adm/helper/resettimes.helper\';this.form.submit();'. + '" value="'.&mt('Manage').'" /> access times.</td></tr>'."\n"; $result.='</form></td></tr></table>'."\n". '</td></tr></table>'."\n".