--- loncom/homework/hint.pm 2003/04/08 02:21:13 1.39 +++ loncom/homework/hint.pm 2003/05/09 20:44:54 1.42 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # implements the tags that control the hints # -# $Id: hint.pm,v 1.39 2003/04/08 02:21:13 albertel Exp $ +# $Id: hint.pm,v 1.42 2003/05/09 20:44:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,18 +50,10 @@ sub start_hintgroup { my $hinttries=&Apache::lonnet::EXT("resource.$id.hinttries"); if ( $hinttries eq '') { $hinttries = 1; } &Apache::lonxml::debug("found :$id:$numtries:$hinttries:"); - if ($Apache::lonhomework::type ne 'exam') { - if ( $numtries < $hinttries ) { - $skiptoend='1'; - } else { - $result='
'; - } - } else { - &Apache::lonxml::startredirection; - } - if ($skiptoend) { + if ( $numtries < $hinttries ) { &Apache::lonxml::get_all_text("/hintgroup",$parser); } + &Apache::lonxml::startredirection; } elsif ($target eq 'tex') { $result .= '\keephidden{'; } @@ -80,12 +72,11 @@ sub end_hintgroup { my $hinttries=&Apache::lonnet::EXT("resource.$id.hinttries"); if ( $hinttries eq '') { $hinttries = 1; } &Apache::lonxml::debug("found :$id:$numtries:$hinttries:"); - if ($Apache::lonhomework::type ne 'exam') { - if ( $numtries >= $hinttries ) { - $result='
'; - } - } else { - &Apache::lonxml::endredirection; + my $hinttext=&Apache::lonxml::endredirection; + if ($Apache::lonhomework::type ne 'exam' && + $numtries >= $hinttries && $hinttext =~/\S/) { + $result='
'. + $hinttext.'
'; } } elsif ($target eq 'edit') { $result.=&Apache::edit::end_table(); @@ -357,13 +348,25 @@ sub end_radiobuttonhint { my $response = $Apache::lonhomework::history{ "resource.$part_id.submission"}; ($response)=&Apache::lonnet::str2hash($response); - if ($answer[0] eq 'foil' && $response eq $answer[1]) { - push (@Apache::hint::which,$name); + &Apache::lonxml::debug("response is $response"); + + if ($answer[0] eq 'foil') { + shift(@answer); + foreach my $answer (@answer) { + if ($response eq $answer) { + push (@Apache::hint::which,$name); + last; + } + } } elsif ($answer[0] eq 'concept') { - if (ref($Apache::hint::radiobutton{"$part_id.concept.".$answer[1]})) { - my @names=@{ $Apache::hint::radiobutton{"$part_id.concept.".$answer[1]} }; - if (grep(/^\Q$response\E$/,@names)) { - push(@Apache::hint::which,$name); + shift(@answer); + foreach my $answer (@answer) { + if (ref($Apache::hint::radiobutton{"$part_id.concept.".$answer})) { + my @names=@{ $Apache::hint::radiobutton{"$part_id.concept.".$answer} }; + if (grep(/^\Q$response\E$/,@names)) { + push(@Apache::hint::which,$name); + last; + } } } }