--- loncom/homework/caparesponse/caparesponse.pm 2003/05/09 22:00:16 1.96 +++ loncom/homework/caparesponse/caparesponse.pm 2003/05/19 21:40:04 1.103 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.96 2003/05/09 22:00:16 albertel Exp $ +# $Id: caparesponse.pm,v 1.103 2003/05/19 21:40:04 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -165,7 +165,10 @@ sub end_numericalresponse { $safeeval); my $award = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"}; my $status = $Apache::inputtags::status['-1']; - if ($award =~ /^correct/ || $status eq "SHOW_ANSWER" || $ENV{'form.texaward'} eq '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, @@ -306,7 +309,7 @@ sub end_numericalresponse { if ($Apache::inputtags::params{'sig'}) { ($sighigh,$siglow)=&get_sigrange($Apache::inputtags::params{'sig'}); } - if ($fmt) { + if ($fmt && $$tagstack[-1] eq 'numericalresponse') { $ans = sprintf('%.'.$fmt,$ans); if ($high) { $high=sprintf('%.'.$fmt,$high); @@ -314,8 +317,14 @@ sub end_numericalresponse { } } if ($target eq 'answer') { - if ($high) { $ans.=' ['.$low.','.$high.']'; } - if ($sighigh) { $ans.= " Sig $siglow - $sighigh"; } + 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}"; + } else { + $ans.= " Sig $siglow - $sighigh"; + } + } $result.=&Apache::response::answer_part($$tagstack[-1],$ans); } elsif ($target eq 'analyze') { push (@{ $Apache::lonhomework::analyze{"$part_id.answer"} }, $ans); @@ -325,16 +334,21 @@ sub end_numericalresponse { } } } - if ($unit) { + if (defined($unit) and ($unit ne '') and + $$tagstack[-1] eq 'numericalresponse') { if ($target eq 'answer') { - $result.=&Apache::response::answer_part($$tagstack[-1], - "Unit: $unit"); + if ($ENV{'form.answer_output_mode'} eq 'tex') { + $result.=&Apache::response::answer_part($$tagstack[-1], + "Unit: \\verb|$unit|"); + } else { + $result.=&Apache::response::answer_part($$tagstack[-1], + "Unit: $unit"); + } } elsif ($target eq 'analyze') { - push (@{ $Apache::lonhomework::analyze{"$part_id.unit"} }, - $unit); + push (@{ $Apache::lonhomework::analyze{"$part_id.unit"} }, $unit); } } - if ($type || $token->[1] eq 'stringresponse') { + if ($type || $$tagstack[-1] eq 'stringresponse') { my $string='Case Insensitive'; if ($type eq 'mc') { $string='Multiple Choice'; @@ -346,10 +360,15 @@ sub end_numericalresponse { $string='Formula'; } if ($target eq 'answer') { - $result.=&Apache::response::answer_part($$tagstack[-1], - ''.$string.''); + if ($ENV{'form.answer_output_mode'} eq 'tex') { + $result.=&Apache::response::answer_part($$tagstack[-1], + "\\textbf{$string}"); + } else { + $result.=&Apache::response::answer_part($$tagstack[-1], + "$string"); + } } elsif ($target eq 'analyze') { - push (@{ $Apache::lonhomework::analyze{"$part_id.type"} }, + push (@{ $Apache::lonhomework::analyze{"$part_id.str_type"} }, $type); } }