--- loncom/homework/caparesponse/caparesponse.pm 2008/03/06 16:28:22 1.223
+++ loncom/homework/caparesponse/caparesponse.pm 2010/08/20 03:44:18 1.236.12.1
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# caparesponse definition
#
-# $Id: caparesponse.pm,v 1.223 2008/03/06 16:28:22 www Exp $
+# $Id: caparesponse.pm,v 1.236.12.1 2010/08/20 03:44:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -305,7 +305,7 @@ sub start_numericalresponse {
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") {
+ if ((lc($hideunit) eq "yes") && ($Apache::lonhomework::type ne 'exam')) {
my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
$safeeval);
if ($unit =~ /\S/) { $result.=" (in $unit) "; }
@@ -427,8 +427,12 @@ sub check_submission {
}
} elsif ($tag eq 'numericalresponse') {
$$args_ref{'type'}='float';
+ } elsif ($tag eq 'stringresponse') {
+ if ($$args_ref{'type'} eq '') {
+ $$args_ref{'type'} = 'ci';
+ }
}
-
+
&add_in_tag_answer($parstack,$safeeval);
if (!%answer) {
@@ -510,12 +514,12 @@ sub end_numericalresponse {
&Apache::lonxml::debug($$parstack[-1] . "\n
");
if ( &Apache::response::submitted('scantron')) {
- &add_in_tag_answer($parstack,$safeeval);
- my ($values,$display)=&make_numerical_bubbles($partid,$id,
- $target,$parstack,$safeeval);
- $response=$values->[$response];
- }
- $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
+ &add_in_tag_answer($parstack,$safeeval);
+ my ($values,$display)=&make_numerical_bubbles($partid,$id,
+ $target,$parstack,$safeeval);
+ $response=$values->[$response];
+ }
+ $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
my ($ad,$msg,$name)=&check_submission($response,$partid,$id,
$tag,$parstack,
$safeeval);
@@ -602,6 +606,12 @@ sub end_numericalresponse {
}
}
}
+ if (($target eq 'web') && ($tag eq 'formularesponse')
+ && ($Apache::lonhomework::type ne 'exam') && ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER')
+ && (&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffeditor') ne 'yes')) {
+ $result.=&Apache::response::edit_mathresponse_button($id,"HWVAL_$id");
+ }
+
&Apache::response::setup_prior_tries_hash(\&format_prior_response_numerical);
} elsif ($target eq 'edit') {
$result.=''.&Apache::edit::end_table;
@@ -678,12 +688,12 @@ sub end_numericalresponse {
#}
}
if ($high && $tag eq 'numericalresponse') {
- $element.=': ['.$low.','.$high.']';
+ $element.='; ['.$low.'; '.$high.']';
$tolline .= "[$low, $high]";
}
if (defined($sighigh) && $tag eq 'numericalresponse') {
if ($env{'form.answer_output_mode'} eq 'tex') {
- $element.= ": Sig $siglow - $sighigh";
+ $element.= "; Sig $siglow - $sighigh";
} else {
$element.= " Sig $siglow - $sighigh";
$sigline .= "[$siglow, $sighigh]";
@@ -742,16 +752,17 @@ sub end_numericalresponse {
if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
my $error;
if ($tag eq 'formularesponse') {
- $error=&mt('Computer\'s answer is incorrect ("[_1]").',join(', ',@$response));
+ $error=&mt("Computer's answer is incorrect ([_1]).",'"'.join(', ',@$response).'"');
} else {
# answer failed check if it is sig figs that is failing
my ($ad,$msg)=&check_submission($response,$partid,$id,
$tag,$parstack,
$safeeval,1);
+ $error=&mt("Computer's answer is incorrect ([_1]).",'"'.join(', ',@$response).'"').' ';
if ($sigline ne '') {
- $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] or significant figures [_3] need to be adjusted.',join(', ',@$response),$tolline,$sigline);
+ $error.=&mt('It is likely that the tolerance range [_1] or significant figures [_2] need to be adjusted.',$tolline,$sigline);
} else {
- $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] needs to be adjusted.',join(', ',@$response),$tolline);
+ $error.=&mt('It is likely that the tolerance range [_1] needs to be adjusted.',$tolline);
}
}
if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
@@ -1151,7 +1162,9 @@ sub end_stringresponse {
my @args = ('type');
my $args_ref = &setup_capa_args($safeeval,$parstack,
\@args,$response);
-
+ if ($$args_ref{'type'} eq '') {
+ $$args_ref{'type'} = 'ci';
+ }
&add_in_tag_answer($parstack,$safeeval);
my (@final_awards,@final_msgs,@names);
foreach my $name (keys(%answer)) {