--- loncom/homework/inputtags.pm 2000/11/28 19:15:48 1.8 +++ loncom/homework/inputtags.pm 2000/12/01 00:44:48 1.9 @@ -10,9 +10,9 @@ sub BEGIN { sub initialize_inputtags { - $Apache::inputtags::curvalue=0; @Apache::inputtags::input=(); @Apache::inputtags::response=(); + @Apache::inputtags::responselist=(); @Apache::inputtags::answergroup=(); $Apache::inputtags::part=''; %Apache::inputtags::params=(); @@ -66,6 +66,7 @@ sub start_answergroup { sub end_answergroup { my ($target,$token,$parstack,$parser,$safeeval)=@_; + return ''; # has ben deprecated my $args =''; if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } my $id = &Apache::run::run("{$args;".'return $id}',$safeeval); @@ -95,6 +96,73 @@ sub end_datasubmission { } } +sub finalizeawards { + my $result=''; + my $award; + if ($#_ == '-1') { $result = "NO_RESPONSE"; } + foreach $award (@_) { if ($award eq '') {$result='MISSING_ANSWER'; last;}} + if ($result eq '' ) { + foreach $award (@_) { + if ($award eq 'UNIT_FAIL' || + $award eq 'NO_UNIT' || + $award eq 'UNIT_NOTNEEDED') { + $result=$award; last; + } + } + } + &Apache::lonxml::debug("1 $result"); + if ($result eq '' ) { + foreach $award (@_) { + if ($award eq 'WANTED_NUMERIC' || + $award eq 'BAD_FORMULA') {$result=$award; last;} + } + } + &Apache::lonxml::debug("2 $result"); + if ($result eq '' ) { + foreach $award (@_) { if ($award eq 'SIG_FAIL') {$result=$award; last;} } + } + &Apache::lonxml::debug("3 $result"); + if ($result eq '' ) { + foreach $award (@_) { if ($award eq 'INCORRECT') {$result=$award; last;} } + } + &Apache::lonxml::debug("4 $result"); + if ($result eq '' ) { + foreach $award (@_) { if ($award eq 'APPROX_ANS') {$result=$award; last;} } + } + &Apache::lonxml::debug("5 $result"); + if ($result eq '' ) { $result='EXACT_ANS'; } + &Apache::lonxml::debug("6 $result"); + return $result +} + +sub grade { + my ($target) = @_; + my $id = $Apache::inputtags::part; + my $result=''; + my $button=''; + my $showbutton='1'; + my $usedtry='1'; + my $response=''; + if ( $target == 'web' ) { + if ( defined $ENV{'form.submit'}) { + my @awards = (); + foreach $response (@Apache::inputtags::responselist) { + my $value=$Apache::lonhomework::results{"response.awarddetail.$id.$response"}; + if ( $value ne '' ) { + &Apache::lonxml::debug("keep ing $value from $response for $id"); + push (@awards,$value); + } else { + &Apache::lonxml::debug("skipping $value from $response for $id"); + } + } + my $finalaward = &finalizeawards(@awards); + &Apache::lonxml::debug("final award $finalaward"); + } + if ($showbutton > 0) { $result.=$button } + } + return $result; +} + 1; __END__