--- loncom/homework/inputtags.pm 2003/04/30 13:44:30 1.97 +++ loncom/homework/inputtags.pm 2003/05/23 07:04:44 1.102 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.97 2003/04/30 13:44:30 sakharuk Exp $ +# $Id: inputtags.pm,v 1.102 2003/05/23 07:04:44 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,7 +33,7 @@ use strict; use Apache::loncommon; BEGIN { - &Apache::lonxml::register('Apache::inputtags',('textfield','textline')); + &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline')); } @@ -160,14 +160,14 @@ sub start_textline { my $result = ""; if ($target eq 'web') { $Apache::lonxml::evaluate--; + my $partid=$Apache::inputtags::part; + my $id=$Apache::inputtags::response[-1]; if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval); my $maxlength; if ($size eq '') { $size=20; } else { if ($size < 20) { $maxlength=$size; } } - my $partid=$Apache::inputtags::part; - my $id=$Apache::inputtags::response[-1]; my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"}); if ($Apache::lonhomework::type ne 'exam') { $result= ''; + } + } + } elsif ($target eq 'edit') { + $result=&Apache::edit::tag_start($target,$token); + $result.=&Apache::edit::end_table; + } + return $result; +} + +sub end_hiddenline { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; + if ($target eq 'web') { $Apache::lonxml::evaluate++; } + elsif ($target eq 'edit') { return ('','no'); } + return ""; +} + sub finalizeawards { my $result=''; my $award; @@ -223,7 +251,9 @@ sub finalizeawards { if ($result eq '' ) { foreach $award (@_) { if ($award eq 'NO_RESPONSE') {$result='NO_RESPONSE'; last;} } } - + if ($result eq '' ) { + foreach $award (@_) { if ($award eq 'TOO_LONG') {$result='TOO_LONG'; last;}} + } if ($result eq '' ) { foreach $award (@_) { if ($award eq 'UNIT_FAIL' || @@ -308,6 +338,12 @@ sub decideoutput { } elsif ($award eq 'MISSING_ANSWER') { $message = 'Some parts were not submitted'; $button = 1; + } elsif ($award eq 'ERROR') { + $message = 'An error occured while trying to grade answer.'; + $button = 1; + } elsif ($award eq 'TOO_LONG') { + $message = "The submitted answer was too long."; + $button=1; } elsif ($award eq 'WANTED_NUMERIC') { $message = "This question expects a numeric answer"; $button=1; @@ -350,8 +386,8 @@ sub decideoutput { } else { $message = "Unknown message: $award"; $button=1; - } - if (lc($Apache::lonhomework::problemstatus) ne 'yes') { + } + if (lc($Apache::lonhomework::problemstatus) eq 'no') { $message = "Answer Submitted"; $button=1; } @@ -376,7 +412,8 @@ sub setgradedata { $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award; return ''; } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~ - /^correct/ || $Apache::lonhomework::scantronmode) { + /^correct/ || $Apache::lonhomework::scantronmode || + lc($Apache::lonhomework::problemstatus) eq 'no') { #handle assignment of tries and solved status my $solvemsg; if ($Apache::lonhomework::scantronmode) { @@ -428,13 +465,19 @@ sub setgradedata { } else { $Apache::lonhomework::results{"resource.$id.solved"} = 'incorrect_attempted'; + if (lc($Apache::lonhomework::problemstatus) eq 'no') { + $Apache::lonhomework::results{"resource.$id.tries"} = + $Apache::lonhomework::history{"resource.$id.tries"} + 1; + } } # check if this was a previous submission if it was delete the # unneeded data and update the previously_used attribute if ( $previously_used eq 'PREVIOUSLY_USED') { - delete($Apache::lonhomework::results{"resource.$id.tries"}); - $Apache::lonhomework::results{"resource.$id.previous"} = '1'; + if (lc($Apache::lonhomework::problemstatus) ne 'no') { + delete($Apache::lonhomework::results{"resource.$id.tries"}); + $Apache::lonhomework::results{"resource.$id.previous"} = '1'; + } } elsif ( $previously_used eq 'PREVIOUSLY_LAST') { #delete all data as they student didn't do anything, but save #the list of collaborators.