--- loncom/homework/caparesponse/caparesponse.pm 2005/12/06 10:01:57 1.184
+++ loncom/homework/caparesponse/caparesponse.pm 2006/03/09 00:41:13 1.188
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# caparesponse definition
#
-# $Id: caparesponse.pm,v 1.184 2005/12/06 10:01:57 albertel Exp $
+# $Id: caparesponse.pm,v 1.188 2006/03/09 00:41:13 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -191,17 +191,22 @@ sub start_numericalresponse {
$safeeval);
for (my $i=0; $i <= $#answers; $i++) {
my $answer=$answers[$i];
- my $format;
- if ($#formats > 0) {
- $format=$formats[$i];
+ if ( scalar(@$tagstack)
+ && $tagstack->[-1] ne 'numericalresponse') {
+ $answertxt.=$answer.',';
} else {
- $format=$formats[0];
+ my $format;
+ if ($#formats > 0) {
+ $format=$formats[$i];
+ } else {
+ $format=$formats[0];
+ }
+ if ($unit=~/\$/) { $format="\$".$format; $unit=~s/\$//g; }
+ if ($unit=~/\,/) { $format="\,".$format; $unit=~s/\,//g; }
+ my $formatted=&format_number($answer,$format,$target,
+ $safeeval);
+ $answertxt.=$formatted.',';
}
- if ($unit=~/\$/) { $format="\$".$format; $unit=~s/\$//g; }
- if ($unit=~/\,/) { $format="\,".$format; $unit=~s/\,//g; }
- my $formatted=&format_number($answer,$format,$target,
- $safeeval);
- $answertxt.=$formatted.',';
}
chop $answertxt;
if ($target eq 'web') {
@@ -357,10 +362,6 @@ sub end_numericalresponse {
$bubble_display->[$ind].'';
}
$result.='';
- } elsif ($tag eq 'formularesponse') {
- $result.= '
-
';
}
} elsif ($target eq 'tex') {
if ((defined $unit) and ($unit=~/\S/) and ($Apache::lonhomework::type eq 'exam')) {
@@ -388,14 +389,7 @@ sub end_numericalresponse {
}
$result.='\end{enumerate}';
} else {
- $result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';
- my $repetition = &Apache::response::repetition();
- $result.='\begin{enumerate}';
- for (my $i=0;$i<$repetition;$i++) {
- $result.='\item[\textbf{'.($Apache::lonxml::counter+$i).'}.]\textit{Leave blank on scoring form}\vskip 0 mm';
- }
- $increment=$repetition;
- $result.= '\end{enumerate}';
+ $increment = &Apache::response::repetition();
}
}
}
@@ -422,7 +416,8 @@ sub end_numericalresponse {
if ($target eq 'answer') {
$result.=&Apache::response::answer_header($tag);
- if ($Apache::lonhomework::type eq 'exam') {
+ if ($tag eq 'numericalresponse'
+ && $Apache::lonhomework::type eq 'exam') {
my ($bubble_values,undef,$correct) = &make_numerical_bubbles($partid,
$id,$target,$parstack,$safeeval);
$result.=&Apache::response::answer_part($tag,$correct);
@@ -603,7 +598,7 @@ sub format_number {
my $ans;
if ($format eq '') {
#What is the number? (integer,decimal,floating point)
- if ($number=~/^(\d*\.?\d*)(E|e)(\d*)$/) {
+ if ($number=~/^(\d*\.?\d*)(E|e)[+\-]?(\d*)$/) {
$format = '3e';
} elsif ($number=~/^(\d*)\.(\d*)$/) {
$format = '4f';
@@ -850,19 +845,6 @@ sub end_stringresponse {
$Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=$msg;
}
}
- } elsif ($target eq 'web' || $target eq 'tex') {
- my $award = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
- my $status = $Apache::inputtags::status['-1'];
- if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') {
- $result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';
- $increment = &Apache::response::repetition();
- $result.='\begin{enumerate}';
- for (my $i=0;$i<$increment;$i++) {
- $result.='\item[\textbf{'.($Apache::lonxml::counter+$i).
- '}.]\textit{Leave blank on scoring form}\vskip 0 mm';
- }
- $result.= '\end{enumerate}';
- }
} elsif ($target eq 'answer' || $target eq 'analyze') {
if ($target eq 'analyze') {
push (@{ $Apache::lonhomework::analyze{"parts"} },"$part.$id");