--- loncom/homework/optionresponse.pm 2003/08/01 19:04:06 1.84 +++ loncom/homework/optionresponse.pm 2003/10/15 19:51:29 1.84.2.2 @@ -1,7 +1,7 @@ # LearningOnline Network with CAPA # option list style responses # -# $Id: optionresponse.pm,v 1.84 2003/08/01 19:04:06 sakharuk Exp $ +# $Id: optionresponse.pm,v 1.84.2.2 2003/10/15 19:51:29 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -303,11 +303,13 @@ sub displayfoils { my $break; my $solved=$Apache::lonhomework::history{"resource.$part.solved"}; my $status=$Apache::inputtags::status[-1]; - if ( - ($target ne 'tex') && - (($solved =~ /^correct/) || ($status eq 'SHOW_ANSWER')) ) { + if ( ($target ne 'tex') && + &Apache::response::show_answer() ) { + my $temp=1; foreach $name (@whichopt) { my $text=$Apache::response::foilgroup{$name.'.text'}; + my %lastresponse=&Apache::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"}); + my $lastopt=$lastresponse{$name}; if ($text!~/^\s*$/) { if ($target eq 'tex') { $break='\vskip 0 mm '; @@ -334,11 +336,12 @@ sub displayfoils { } if ($Apache::lonhomework::type eq 'exam') { if ($target ne 'tex') { - $result.=&webbubbles(\@opt,\@alphabet); + $result.=&webbubbles(\@opt,\@alphabet,$temp,$lastopt); } else { $result.=&bubbles(\@alphabet,\@opt); } } + $temp++; } } else { my $temp=1; @@ -375,7 +378,7 @@ sub displayfoils { } $result.=$break.$text."\n"; if ($Apache::lonhomework::type eq 'exam') { - $result.=&webbubbles(\@opt,\@alphabet,$temp); + $result.=&webbubbles(\@opt,\@alphabet,$temp,$lastopt); } $temp++; } else { @@ -456,18 +459,24 @@ sub optionlist_correction { sub webbubbles { - my ($ropt,$ralphabet,$temp)=@_; + my ($ropt,$ralphabet,$temp,$lastopt)=@_; my @opt=@$ropt; my @alphabet=@$ralphabet; my $result=''; - my $number_of_bubbles = $#opt + 1; - $result.= ''; - for (my $ind=0;$ind<$number_of_bubbles;$ind++) { - $result.=''; + my $number_of_bubbles = $#opt + 1; + $result.= '
'.$alphabet[$ind].': '.$opt[$ind].'
'; + for (my $ind=0;$ind<$number_of_bubbles;$ind++) { + my $checked=''; + if ($lastopt eq $opt[$ind]) { + $checked=' checked="on" '; } - $result.='
'; - return $result; + $result.=''.$alphabet[$ind].': '. + $opt[$ind].''; + } + $result.=''; + return $result; }