--- loncom/homework/inputtags.pm 2005/11/10 22:19:27 1.179 +++ loncom/homework/inputtags.pm 2005/11/21 22:45:13 1.184 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.179 2005/11/10 22:19:27 albertel Exp $ +# $Id: inputtags.pm,v 1.184 2005/11/21 22:45:13 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -388,7 +388,8 @@ sub checkstatus { sub valid_award { my ($award) =@_; - foreach my $possibleaward ('MISSING_ANSWER', 'ERROR', 'NO_RESPONSE', + foreach my $possibleaward ('EXTRA_ANSWER','MISSING_ANSWER', 'ERROR', + 'NO_RESPONSE', 'TOO_LONG', 'UNIT_INVALID_INSTRUCTOR', 'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT', @@ -403,7 +404,7 @@ sub valid_award { } sub finalizeawards { - my ($awardref,$msgref)=@_; + my ($awardref,$msgref,$nameref,$reverse)=@_; my $result=undef; my $award; my $msg; @@ -419,15 +420,19 @@ sub finalizeawards { if ($blankcount == ($#$awardref + 1)) { $result = 'NO_RESPONSE'; } } if (defined($result)) { return ($result,$msg); } - foreach my $possibleaward ('MISSING_ANSWER', 'ERROR', 'NO_RESPONSE', - 'TOO_LONG', 'UNIT_INVALID_INSTRUCTOR', - 'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE', - 'UNIT_FAIL', 'NO_UNIT', - 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', - 'BAD_FORMULA', 'SIG_FAIL', 'INCORRECT', - 'MISORDERED_RANK', 'INVALID_FILETYPE', - 'DRAFT', 'SUBMITTED', 'ASSIGNED_SCORE', - 'APPROX_ANS', 'EXACT_ANS','COMMA_FAIL') { + + # these awards are ordered from most important error through best correct + + my @awards = ('EXTRA_ANSWER', 'MISSING_ANSWER', 'ERROR', 'NO_RESPONSE', + 'TOO_LONG', + 'UNIT_INVALID_INSTRUCTOR', 'UNIT_INVALID_STUDENT', + 'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT', + 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', + 'COMMA_FAIL', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK', + 'INVALID_FILETYPE', 'DRAFT', 'SUBMITTED', 'ASSIGNED_SCORE', + 'APPROX_ANS', 'EXACT_ANS'); + if ($reverse) { @awards=reverse(@awards); } + foreach my $possibleaward (@awards) { ($result,$msg)=&checkstatus($possibleaward,$awardref,$msgref); if (defined($result)) { return ($result,$msg); } } @@ -448,6 +453,14 @@ sub decideoutput { 'no_message' => '#fffff', ); + my $part = $Apache::inputtags::part; + my $handgrade = + ('yes' eq lc(&Apache::lonnet::EXT("resource.$part.handgrade"))); + + my $computer = ($handgrade)? '' + : " ".&mt("Computer's answer now shown above."); + &Apache::lonxml::debug("handgrade has :$handgrade:"); + if ($previous) { $previousmsg=&mt('You have entered that answer before'); } if ($solved =~ /^correct/) { @@ -469,7 +482,7 @@ sub decideoutput { $message = '\textbf{'.$message.'}'; } else { $message = "".$message.""; - $message.=" ".&mt("Computer's answer now shown above."); + $message.= $computer; } $added_computer_text=1; unless ($env{'course.'. @@ -501,7 +514,7 @@ sub decideoutput { $message = '\textbf{'.&mt('You are correct.').'}'; } else { $message = "".&mt('You are correct.').""; - $message.=" ".&mt("Computer's answer now shown above."); + $message.= $computer; } $added_computer_text=1; unless ($env{'course.'. @@ -519,6 +532,10 @@ sub decideoutput { $message = ''; $bgcolor=$possiblecolors{'no_feedback'}; $button=1; + } elsif ($award eq 'EXTRA_ANSWER') { + $message = &mt('Some extra items were submitted.'); + $bgcolor=$possiblecolors{'not_charged_try'}; + $button = 1; } elsif ($award eq 'MISSING_ANSWER') { $message = &mt('Some items were not submitted.'); $bgcolor=$possiblecolors{'not_charged_try'}; @@ -617,7 +634,7 @@ sub decideoutput { } if ($Apache::inputtags::status[-1] eq 'SHOW_ANSWER' && !$added_computer_text && $target ne 'tex') { - $message.=" ".&mt("Computer's answer now shown above."); + $message.= $computer; $added_computer_text=1; } return ($button,$bgcolor,$message,$previousmsg); @@ -773,6 +790,9 @@ sub setgradedata { return ''; } $Apache::lonhomework::results{"resource.$id.award"} = $award; + if ($award eq 'SUBMITTED') { + &Apache::response::add_to_gradingqueue(); + } } sub grade { @@ -829,8 +849,11 @@ sub gradestatus { my $status = $Apache::inputtags::status['-1']; &Apache::lonxml::debug("gradestatus has :$status:"); - if ( $status ne 'CLOSED' && $status ne 'UNAVAILABLE' && - $status ne 'INVALID_ACCESS') { + if ( $status ne 'CLOSED' + && $status ne 'UNAVAILABLE' + && $status ne 'INVALID_ACCESS' + && $status ne 'NEEDS_CHECKIN' + && $status ne 'NOT_IN_A_SLOT') { my $award = $Apache::lonhomework::history{"resource.$id.award"}; my $awarded = $Apache::lonhomework::history{"resource.$id.awarded"}; my $solved = $Apache::lonhomework::history{"resource.$id.solved"};