--- loncom/homework/caparesponse/caparesponse.pm 2003/04/21 20:59:02 1.95 +++ loncom/homework/caparesponse/caparesponse.pm 2003/05/09 22:00:16 1.96 @@ -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.96 2003/05/09 22:00:16 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)) {