[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm
www
lon-capa-cvs-allow@mail.lon-capa.org
Thu, 06 Mar 2008 14:27:43 -0000
www Thu Mar 6 09:27:43 2008 EDT
Modified files:
/loncom/homework default_homework.lcpm
Log:
Bug #4680: zero does not need units
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.132 loncom/homework/default_homework.lcpm:1.133
--- loncom/homework/default_homework.lcpm:1.132 Thu Mar 6 09:04:09 2008
+++ loncom/homework/default_homework.lcpm Thu Mar 6 09:27:43 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
#
-# $Id: default_homework.lcpm,v 1.132 2008/03/06 14:04:09 www Exp $
+# $Id: default_homework.lcpm,v 1.133 2008/03/06 14:27:43 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -260,13 +260,10 @@
sub caparesponse_check_list {
my $responses=$LONCAPA::CAPAresponse_args{'response'};
-# &LONCAPA_INTERNAL_DEBUG(" answer is ".
-# &LONCAPA_INTERNAL_Dumper($LONCAPA::CAPAresponse_answer).":\n");
-# &LONCAPA_INTERNAL_DEBUG(" respons is ".
-# &LONCAPA_INTERNAL_Dumper($responses).":\n");
&LONCAPA_INTERNAL_DEBUG("args ".join(':',%LONCAPA::CAPAresponse_args));
my $type = $LONCAPA::CAPAresponse_args{'type'};
- &LONCAPA_INTERNAL_DEBUG("Got type :$type:\n");
+ my $answerunit=$LONCAPA::CAPAresponse_args{'unit'};
+ &LONCAPA_INTERNAL_DEBUG("Got type :$type: answer unit :$answerunit:\n");
my $num_input_lines =
scalar(@{$LONCAPA::CAPAresponse_answer->{'answers'}});
@@ -291,8 +288,6 @@
$responses->[$which]=[$responses->[$which]];
}
}
-# &LONCAPA_INTERNAL_DEBUG(" parsed response is ".
-# &LONCAPA_INTERNAL_Dumper($responses).":\n");
foreach my $which (0..($num_input_lines-1)) {
my $answer_size =
scalar(@{$LONCAPA::CAPAresponse_answer->{'answers'}[$which]});
@@ -319,19 +314,20 @@
}
&LONCAPA_INTERNAL_DEBUG("Final final response :$responses->[0][-1]:$unit:");
$unit=~s/\s//;
- if ($unit ne '') {
- foreach my $response (@$responses) {
- foreach my $element (@$response) {
- $element =~ s/\s//g;
- my $appendunit=$unit;
- if ($unit=~/\%/) {
- $element=$element/100;
- $appendunit=~s/\%//;
- }
- $element .= " $appendunit";
- &LONCAPA_INTERNAL_DEBUG("Made response element :$element:");
- }
- }
+ foreach my $response (@$responses) {
+ foreach my $element (@$response) {
+ $element =~ s/\s//g;
+ my $appendunit=$unit;
+ if ($unit=~/\%/) {
+ $element=$element/100;
+ $appendunit=~s/\%//;
+ }
+ if (($element==0) && ($unit!~/\w/) && ($answerunit=~/\w/)) {
+ $appendunit=$answerunit;
+ }
+ $element .= " $appendunit";
+ &LONCAPA_INTERNAL_DEBUG("Made response element :$element:");
+ }
}
foreach my $thisanswer (@{ $LONCAPA::CAPAresponse_answer->{'answers'} }) {