--- loncom/homework/caparesponse/caparesponse.pm 2003/06/24 20:41:56 1.105 +++ loncom/homework/caparesponse/caparesponse.pm 2003/10/23 19:36:02 1.107.2.4 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.105 2003/06/24 20:41:56 albertel Exp $ +# $Id: caparesponse.pm,v 1.107.2.4 2003/10/23 19:36:02 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -114,7 +114,6 @@ sub end_numericalresponse { if ( $response =~ /[^\s]/) { my $ad; my %previous = &Apache::response::check_for_previous($response,$partid,$id); - $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response; &Apache::lonxml::debug("submitted a $response
\n"); &Apache::lonxml::debug($$parstack[-1] . "\n
"); @@ -131,6 +130,7 @@ sub end_numericalresponse { $response =~ s/\\/\\\\/g; $response =~ s/\'/\\\'/g; } + $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response; &Apache::lonxml::debug("current $response"); my $expression="&caparesponse_check_list('".$response."','". $$parstack[-1]; @@ -169,10 +169,7 @@ sub end_numericalresponse { $safeeval); my $award = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"}; my $status = $Apache::inputtags::status['-1']; - if ( ($award =~ /^correct/ - && lc($Apache::lonhomework::problemstatus) ne 'no') - || $status eq "SHOW_ANSWER" - || $ENV{'form.texaward'} eq 'SHOW_ANSWER') { + if ( &Apache::response::show_answer() ) { my (@formats)=&Apache::lonxml::get_param_var('format',$parstack, $safeeval); my $unit=&Apache::lonxml::get_param_var('unit',$parstack, @@ -234,11 +231,16 @@ sub end_numericalresponse { if ($$tagstack[-1] eq 'numericalresponse') { if ($unit=~/\S/) {$result.=' (in '.$unit.')

';} $result.= ''; + my $previous=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.$id.submission"}; for (my $ind=0;$ind<$number_of_bubbles;$ind++) { + my $checked=''; + if ($previous eq $bubble_values[$ind]) { + $checked=" checked='on' "; + } $result.=''; + '" value="'.$bubble_values[$ind].'" '.$checked + .' />'.$alphabet[$ind].': '. + $bubble_values[$ind].''; } $result.='
'. - $alphabet[$ind].': '. - $bubble_values[$ind].'
'; } elsif ($$tagstack[-1] eq 'formularesponse') { @@ -247,7 +249,7 @@ sub end_numericalresponse {

'; } } elsif ($target eq 'tex') { - if (defined $unit and $Apache::lonhomework::type eq 'exam') { + if ((defined $unit) and ($unit=~/\S/) and ($Apache::lonhomework::type eq 'exam')) { $result.=' \textit{(in} \verb|'.$unit.'|\textit{)} '; } if ($$tagstack[-1] eq 'numericalresponse') { @@ -324,7 +326,7 @@ sub end_numericalresponse { if ($high && $$tagstack[-1] eq 'numericalresponse') { $ans.=' ['.$low.','.$high.']'; } if ($sighigh && $$tagstack[-1] eq 'numericalresponse') { if ($ENV{'form.answer_output_mode'} eq 'tex') { - $ans.= " Sig \\textit{$siglow - $sighigh}"; + $ans.= " Sig $siglow - $sighigh"; } else { $ans.= " Sig $siglow - $sighigh"; } @@ -343,7 +345,7 @@ sub end_numericalresponse { if ($target eq 'answer') { if ($ENV{'form.answer_output_mode'} eq 'tex') { $result.=&Apache::response::answer_part($$tagstack[-1], - "Unit: \\verb|$unit|"); + " Unit: $unit "); } else { $result.=&Apache::response::answer_part($$tagstack[-1], "Unit: $unit"); @@ -443,6 +445,7 @@ sub format_number { sub make_numerical_bubbles { my ($number_of_bubbles,$target,$answer,$format) =@_; + my @oldseed=&Math::Random::random_get_seed(); my @bubble_values = (); my @factors = (1.13,1.17,1.25,1.33,1.45); #default values of factors my @powers = (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0); #default values for powers @@ -457,6 +460,7 @@ sub make_numerical_bubbles { $format,$target); } + &Math::Random::random_set_seed(@oldseed); return @bubble_values; }