--- loncom/homework/caparesponse/caparesponse.pm 2003/04/21 20:59:02 1.95 +++ loncom/homework/caparesponse/caparesponse.pm 2003/05/09 22:24:05 1.97 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.95 2003/04/21 20:59:02 albertel Exp $ +# $Id: caparesponse.pm,v 1.97 2003/05/09 22:24:05 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -79,6 +79,16 @@ sub start_numericalresponse { $result=&Apache::response::meta_package_write('numericalresponse'); } elsif ($target eq 'answer' || $target eq 'grade') { &Apache::response::reset_params(); + } elsif ($target eq 'web') { + my $partid = $Apache::inputtags::part; + my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffunit'); + &Apache::lonxml::debug("Got unit $hideunit for $partid $id"); + #no way to enter units, with radio buttons + if (lc($hideunit) eq "yes") { + my $unit=&Apache::lonxml::get_param_var('unit',$parstack, + $safeeval); + if ($unit =~ /\S/) { $result.=" (in $unit) "; } + } } return $result; } @@ -124,8 +134,10 @@ sub end_numericalresponse { &Apache::lonxml::debug("current $response"); my $expression="&caparesponse_check_list('".$response."','". $$parstack[-1]; + my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffunit'); #no way to enter units, with radio buttons - if ($Apache::lonhomework::type eq 'exam') { + if ($Apache::lonhomework::type eq 'exam' || + lc($hideunit) eq "yes") { $expression.=';my $unit=undef;'; } foreach my $key (keys(%Apache::inputtags::params)) { @@ -153,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,