--- loncom/homework/grades.pm 2005/09/12 20:27:25 1.283 +++ loncom/homework/grades.pm 2005/09/23 15:19:05 1.288 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.283 2005/09/12 20:27:25 albertel Exp $ +# $Id: grades.pm,v 1.288 2005/09/23 15:19:05 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1370,10 +1370,10 @@ sub gradeBox { my $ctr = 0; $result.='<table border="0"><tr>'."\n"; # display radio buttons in a nice table 10 across while ($ctr<=$wgt) { - $result.= '<td><nobr><input type="radio" name="RADVAL'.$counter.'_'.$partid.'" '. + $result.= '<td><nobr><label><input type="radio" name="RADVAL'.$counter.'_'.$partid.'" '. 'onclick="javascript:writeBox(this.form,\''.$counter.'_'.$partid.'\','. $ctr.')" value="'.$ctr.'" '. - ($score eq $ctr ? 'checked':'').' /> '.$ctr."</nobr></td>\n"; + ($score eq $ctr ? 'checked':'').' /> '.$ctr."</label></nobr></td>\n"; $result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : ''); $ctr++; } @@ -2332,7 +2332,7 @@ sub version_portfiles { } else { my $copy_result = &Apache::lonnet::finishuserfileupload($stuname,$domain,'copy', '/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]); - push(@v_portfiles, $answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]); + push(@v_portfiles, $directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]); &Apache::lonnet::mark_as_readonly($domain,$stuname, ['/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]], [$symb,$env{'request.course.id'},'graded']); @@ -2579,9 +2579,9 @@ sub viewgrades { $result.='<table border="0"><tr>'; my $ctr = 0; while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across - $result.= '<td><input type="radio" name="RADVAL_'.$partid.'" '. + $result.= '<td><label><input type="radio" name="RADVAL_'.$partid.'" '. 'onclick="javascript:writePoint(\''.$partid.'\','.$weight{$partid}. - ','.$ctr.')" />'.$ctr."</td>\n"; + ','.$ctr.')" />'.$ctr."</label></td>\n"; $result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : ''); $ctr++; } @@ -3365,13 +3365,13 @@ LISTJAVASCRIPT $result.='<input type="hidden" name="page" />'."\n". '<input type="hidden" name="title" />'."\n"; - $result.=' <b>View Problems Text: </b><input type="radio" name="vProb" value="no" checked="on" /> no '."\n". - '<input type="radio" name="vProb" value="yes" /> yes '."<br>\n"; + $result.=' <b>View Problems Text: </b><label><input type="radio" name="vProb" value="no" checked="on" /> no </label>'."\n". + '<label><input type="radio" name="vProb" value="yes" /> yes </label>'."<br />\n"; $result.=' <b>Submission Details: </b>'. - '<input type="radio" name="lastSub" value="none" /> none'."\n". - '<input type="radio" name="lastSub" value="datesub" checked /> by dates and submissions'."\n". - '<input type="radio" name="lastSub" value="all" /> all details'."\n"; + '<label><input type="radio" name="lastSub" value="none" /> none</label>'."\n". + '<label><input type="radio" name="lastSub" value="datesub" checked /> by dates and submissions</label>'."\n". + '<label><input type="radio" name="lastSub" value="all" /> all details</label>'."\n"; $result.='<input type="hidden" name="section" value="'.$getsec.'" />'."\n". '<input type="hidden" name="Status" value="'.$env{'form.Status'}.'" />'."\n". @@ -3399,8 +3399,8 @@ LISTJAVASCRIPT my ($uname,$udom) = split(/:/,$student); $studentTable.=($ptr%2 == 1 ? '<tr bgcolor="#ffffe6">' : '</td>'); $studentTable.='<td align="right">'.$ptr.' </td>'; - $studentTable.='<td> <input type="radio" name="student" value="'.$student.'" /> ' - .&nameUserString(undef,$$fullname{$student},$uname,$udom)."\n"; + $studentTable.='<td> <label><input type="radio" name="student" value="'.$student.'" /> ' + .&nameUserString(undef,$$fullname{$student},$uname,$udom)."</label>\n"; $studentTable.=($ptr%2 == 0 ? '</td></tr>' : ''); $ptr++; } @@ -3472,7 +3472,11 @@ sub displayPage { my $navmap = Apache::lonnavmaps::navmap->new(); my ($mapUrl, $id, $resUrl)=&Apache::lonnet::decode_symb($env{'form.page'}); my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps - + if (!$map) { + $request->print('<font color="red">Unable to view requested sequence. ('.$resUrl.')</font>'); + $request->print(&show_grading_menu_form($symb,$url)); + return; + } my $iterator = $navmap->getIterator($map->map_start(), $map->map_finish()); @@ -3678,7 +3682,12 @@ sub updateGradeByPage { my $navmap = Apache::lonnavmaps::navmap->new(); my ($mapUrl, $id, $resUrl) = &Apache::lonnet::decode_symb( $env{'form.page'}); my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps - + if (!$map) { + $request->print('<font color="red">Unable to grade requested sequence. ('.$resUrl.')</font>'); + my ($symb,$url)=&get_symb_and_url($request); + $request->print(&show_grading_menu_form($symb,$url)); + return; + } my $iterator = $navmap->getIterator($map->map_start(), $map->map_finish()); @@ -4324,7 +4333,7 @@ sub scantron_process_corrections { } } if ($err) { - $r->print("Unable to accept last correction, an error occurred :$errmsg:"); + $r->print("<font color='red'>Unable to accept last correction, an error occurred :$errmsg:</font>"); } else { &scantron_put_line($scanlines,$scan_data,$which,$line,$skip); &scantron_putfile($scanlines,$scan_data); @@ -4378,14 +4387,26 @@ sub check_for_error { sub scantron_warning_screen { my ($button_text)=@_; my $title=&Apache::lonnet::gettitle($env{'form.selectpage'}); + my %scantron_config=&get_scantron_config($env{'form.scantron_format'}); + my $CODElist="a"; + if ($scantron_config{'CODElocation'} && + $scantron_config{'CODEstart'} && + $scantron_config{'CODElength'}) { + $CODElist=$env{'form.scantron_CODElist'}; + if ($CODElist eq '') { $CODElist='<font color="red">None</font>'; } + $CODElist= + '<tr><td><b>List of CODES to validate against:</b></td><td><tt>'. + $CODElist.'</tt></td></tr>'; + } return (<<STUFF); <p> <font color="red">Please double check the information below before clicking on '$button_text'</font> </p> <table> -<tr><td><b>Sequence To be Graded:</b></td><td>$title</td></tr> +<tr><td><b>Sequence to be Graded:</b></td><td>$title</td></tr> <tr><td><b>Data File that will be used:</b></td><td><tt>$env{'form.scantron_selectfile'}</tt></td></tr> +$CODElist </table> </font> <br /> @@ -5378,10 +5399,10 @@ GRADINGMENUJS $result.='</td></tr>'; - $result.='<tr bgcolor="#ffffe6"valign="top"><td>'. + $result.='<tr bgcolor="#ffffe6"valign="top"><td><label>'. '<input type="radio" name="radioChoice" value="submission" '. ($saveCmd eq 'submission' ? 'checked' : '').'> '.'<b>'.&mt('Current Resource').':</b> '.&mt('For one or more students'). - ' <select name="submitonly">'. + '</label> <select name="submitonly">'. '<option value="yes" '. ($saveSub eq 'yes' ? 'selected="on"' : '').'>with submissions</option>'. '<option value="graded" '. @@ -5392,14 +5413,14 @@ GRADINGMENUJS ($saveSub eq 'all' ? 'selected="on"' : '').'>with any status</option></select></td></tr>'."\n"; $result.='<tr bgcolor="#ffffe6"valign="top"><td>'. - '<input type="radio" name="radioChoice" value="viewgrades" '. + '<label><input type="radio" name="radioChoice" value="viewgrades" '. ($saveCmd eq 'viewgrades' ? 'checked' : '').'> '. - '<b>Current Resource:</b> For all students in selected section or course</td></tr>'."\n"; + '<b>Current Resource:</b> For all students in selected section or course</label></td></tr>'."\n"; $result.='<tr bgcolor="#ffffe6" valign="top"><td>'. - '<input type="radio" name="radioChoice" value="pickStudentPage" '. + '<label><input type="radio" name="radioChoice" value="pickStudentPage" '. ($saveCmd eq 'pickStudentPage' ? 'checked' : '').'> '. - 'The <b>complete</b> set/page/sequence: For one student</td></tr>'."\n"; + 'The <b>complete</b> set/page/sequence: For one student</label></td></tr>'."\n"; $result.='<tr bgcolor="#ffffe6"><td><br />'. '<input type="button" onClick="javascript:checkChoice(this.form,\'2\');" value="Next->" />'. @@ -5437,10 +5458,32 @@ GRADINGMENUJS return $result; } +sub reset_perm { + undef(%perm); +} + +sub init_perm { + &reset_perm(); + if (!($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) { + if ($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { + $perm{'vgr_section'}=$env{'request.course.sec'}; + } else { + delete($perm{'vgr'}); + } + } + if (!($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}))) { + if ($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { + $perm{'mgr_section'}=$env{'request.course.sec'}; + } else { + delete($perm{'mgr'}); + } + } +} + sub handler { my $request=$_[0]; - undef(%perm); + &reset_perm(); if ($env{'browser.mathml'}) { &Apache::loncommon::content_type($request,'text/xml'); } else { @@ -5489,20 +5532,7 @@ sub handler { } } } else { - if (!($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) { - if ($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { - $perm{'vgr_section'}=$env{'request.course.sec'}; - } else { - delete($perm{'vgr'}); - } - } - if (!($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}))) { - if ($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { - $perm{'mgr_section'}=$env{'request.course.sec'}; - } else { - delete($perm{'mgr'}); - } - } + &init_perm(); if ($command eq 'submission' && $perm{'vgr'}) { ($env{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0)); } elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) {