--- loncom/homework/caparesponse/caparesponse.pm 2003/04/21 20:59:02 1.95
+++ loncom/homework/caparesponse/caparesponse.pm 2003/05/13 15:27:45 1.98
@@ -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.98 2003/05/13 15:27:45 sakharuk 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,
@@ -303,7 +318,13 @@ sub end_numericalresponse {
}
if ($target eq 'answer') {
if ($high) { $ans.=' ['.$low.','.$high.']'; }
- if ($sighigh) { $ans.= " Sig $siglow - $sighigh"; }
+ if ($sighigh) {
+ if ($ENV{'form.print_answer'} eq 'yes') {
+ $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);
@@ -315,8 +336,13 @@ sub end_numericalresponse {
}
if ($unit) {
if ($target eq 'answer') {
- $result.=&Apache::response::answer_part($$tagstack[-1],
- "Unit: $unit");
+ if ($ENV{'form.print_answer'} eq 'yes') {
+ $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);