--- loncom/homework/caparesponse/caparesponse.pm 2003/10/15 19:54:45 1.107.2.2 +++ loncom/homework/caparesponse/caparesponse.pm 2003/09/22 13:04:55 1.110 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.107.2.2 2003/10/15 19:54:45 albertel Exp $ +# $Id: caparesponse.pm,v 1.110 2003/09/22 13:04:55 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -169,7 +169,10 @@ sub end_numericalresponse { $safeeval); my $award = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"}; my $status = $Apache::inputtags::status['-1']; - if ( &Apache::response::show_answer() ) { + if ( ($award =~ /^correct/ + && lc($Apache::lonhomework::problemstatus) ne 'no') + || $status eq "SHOW_ANSWER" + || $ENV{'form.texaward'} eq 'SHOW_ANSWER') { my (@formats)=&Apache::lonxml::get_param_var('format',$parstack, $safeeval); my $unit=&Apache::lonxml::get_param_var('unit',$parstack, @@ -191,6 +194,7 @@ sub end_numericalresponse { } my $formatted; if ((defined($format)) && ($format ne '')) { + $format=~s/e/E/g; &Apache::lonxml::debug("formatting with :$format: answer :$answer:"); $formatted=sprintf('%.'.$format,$answer).','; } else { @@ -231,16 +235,11 @@ 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].'">'. + $alphabet[$ind].': '. + $bubble_values[$ind].''; } $result.='
'.$alphabet[$ind].': '. - $bubble_values[$ind].'
'; } elsif ($$tagstack[-1] eq 'formularesponse') { @@ -368,7 +367,7 @@ sub end_numericalresponse { if ($target eq 'answer') { if ($ENV{'form.answer_output_mode'} eq 'tex') { $result.=&Apache::response::answer_part($$tagstack[-1], - "\\textbf{$string}"); + "$string"); } else { $result.=&Apache::response::answer_part($$tagstack[-1], "$string"); @@ -418,12 +417,13 @@ sub format_number { my ($number,$format,$target)=@_; my $ans; if ($format ne '') { + $format=~s/e/E/g; $ans = sprintf('%.'.$format,$number); } else { my $format = ''; #What is the number? (integer,decimal,floating point) if ($number=~/^(\d*\.?\d*)(E|e)(\d*)$/) { - $format = 'e'.$2; + $format = 'e'.$3; } elsif ($number=~/^(\d*)\.(\d*)$/) { $format = '4f'; } elsif ($number=~/^(\d*)$/) {