--- loncom/homework/grades.pm 2003/07/17 22:08:25 1.118 +++ loncom/homework/grades.pm 2003/07/19 15:11:27 1.120 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.118 2003/07/17 22:08:25 ng Exp $ +# $Id: grades.pm,v 1.120 2003/07/19 15:11:27 ng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -140,7 +140,6 @@ sub showResourceInfo { #--- Currently filters option response type only. sub cleanRecord { my ($answer,$response) = @_; - $answer =~ s|^
||; if ($response eq 'option') { my (@IDs,@ans); foreach (split(/\&/,&Apache::lonnet::unescape($answer))) { @@ -471,8 +470,7 @@ LISTJAVASCRIPT $request->print($result); my $checkhdgrade = ($ENV{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked' : ''; - my $checklastsub = ($ENV{'form.handgrade'} eq 'no') ? 'checked' : ''; - $checklastsub = 'checked' if ($checkhdgrade eq '' && $checklastsub eq ''); + my $checklastsub = $checkhdgrade eq '' ? 'checked' : ''; my $gradeTable='
'."\n". ' View Problem Text: no '."\n". ' one student '."\n". @@ -709,9 +707,10 @@ sub sub_page_js { } function checkSolved(formname,id) { - if (eval("formname.solved"+id+".value") == "correct_by_student") { + if (eval("formname.solved"+id+".value") == "correct_by_student" && formname.overRideScore.value == 'no') { var reply = confirm("This problem has been graded correct by the computer. Do you want to change the score?"); if (!reply) {return "noupdate";} + formname.overRideScore.value = 'yes'; } return "update"; } @@ -749,6 +748,14 @@ sub sub_page_js { formname.submit(); } +//======= Process request to show the grading page from SUBM, CHART buttons + function gradeStudent(formname,ptr) { + formname.gradeOpt.value = 'Grade Student'; + formname.showgrading.value = "yes"; + formname.studentNo.value = ptr; + formname.submit(); + } + //======= Check that a score is assigned for all the problems (page/sequence grading only) ========= function checkSubmitPage(formname,total) { noscore = new Array(100); @@ -1033,16 +1040,6 @@ sub sub_page_kw_js { hDoc.write(" self.close()"); hDoc.write("}"); -/* hDoc.write("function radioSelection(radioButton) {"); - hDoc.write(" var selection=null;"); - hDoc.write(" for (var i=0; i"); @@ -1172,6 +1169,7 @@ sub submission { (my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; my ($uname,$udom) = ($ENV{'form.student'},$ENV{'form.userdom'}); + $udom = ($udom eq '' ? $ENV{'user.domain'} : $udom); #has form.userdom changed for a student? my $usec = &Apache::lonnet::getsection($udom,$uname,$ENV{'request.course.id'}); $ENV{'form.fullname'} = &get_fullname ($uname,$udom) if $ENV{'form.fullname'} eq ''; @@ -1185,6 +1183,7 @@ sub submission { return; } + $ENV{'form.lastSub'} = ($ENV{'form.lastSub'} eq '' ? 'all' : $ENV{'form.lastSub'}); my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : ''); # header info @@ -1229,12 +1228,17 @@ sub submission { $ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0'; } + my $overRideScore = $ENV{'form.overRideScore'} eq '' ? 'no' : $ENV{'form.overRideScore'}; $request->print(''."\n". ''."\n". ''."\n". + ''."\n". + ''."\n". ''."\n". ''."\n". + ''."\n". + ''."\n". ''."\n". ''."\n". ''."\n". @@ -1290,7 +1294,6 @@ KEYWORDS $request->print('


') if ($counter > 0); $request->print(&show_problem($request,$symb,$uname,$udom,1,1)); } - my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname); my ($partlist,$handgrade) = &response_type($url); @@ -1377,8 +1380,7 @@ KEYWORDS $$fullname{$ENV{'form.'.$uname.':'.$udom.':submitted_by'}}.''; $request->print($submitby); } else { - my ($string,$timestamp)= - &get_last_submission (%record); + my ($string,$timestamp)= &get_last_submission (\%record); my $lastsubonly=''. ($$timestamp eq '' ? '' : 'Date Submitted: '. $$timestamp)."\n"; @@ -1416,9 +1418,11 @@ KEYWORDS '"> File uploaded by student '. 'Like all files provided by users, '. 'this file may contain virusses
':''). - 'Submitted Answer: '.($responsetype eq 'essay' ? '
' : ''). + 'Submitted Answer: '.($responsetype =~ /^(essay|option)$/ ? + '
' : ''). &cleanRecord(&keywords_highlight($subval),$responsetype). - ($responsetype eq 'essay' ? '

' : '

').$similar."\n" + ($responsetype =~ /^(essay|option)$/ ? '

' : + '

').$similar."\n" if ($ENV{'form.lastSub'} eq 'lastonly' || ($ENV{'form.lastSub'} eq 'hdgrade' && $$handgrade{$part} =~ /:yes$/)); @@ -1436,23 +1440,27 @@ KEYWORDS $last,'.submission', 'Apache::grades::keywords_highlight')); } + + $result=''."\n". + ''."\n". + ''."\n"; + $request->print($result); # return if view submission with no grading option if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) { -# if (!&canmodify($usec)) { - $request->print(''."\n"); - $request->print(&show_grading_menu_form($symb,$url)) + my $toGrade.='  '."\n"; + $toGrade.=''."\n"; + $toGrade.=&show_grading_menu_form($symb,$url) if (($ENV{'form.command'} eq 'submission') || ($ENV{'form.command'} eq 'processGroup' && $counter == $total)); + $request = print($toGrade); return; } # essay grading options if ($ENV{'form.handgrade'} eq 'yes') { - $result=''."\n". - ''."\n". - ''."\n"; my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'}); my $msgfor = $givenn.' '.$lastname; if (scalar(@col_fullnames) > 0) { @@ -1461,15 +1469,15 @@ KEYWORDS } $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript # $result.=''."\n". - $result.=' '. 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'  '. ''."\n". '
 (Message will be sent when you click on Save & Next below.)'."\n" if ($ENV{'form.handgrade'} eq 'yes'); - $request->print($result); } + $request->print($result); my %seen = (); my @partlist; @@ -1494,28 +1502,23 @@ KEYWORDS # print end of form if ($counter == $total) { - my $endform='
'. - ''."\n"; -# if ($ENV{'form.handgrade'} eq 'yes') { - $endform.='  '."\n"; - my $ntstu =''."\n"; - my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1'); - $ntstu =~ s/