--- loncom/homework/caparesponse/caparesponse.pm 2008/09/12 09:56:10 1.232
+++ loncom/homework/caparesponse/caparesponse.pm 2010/02/28 23:45:43 1.237
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# caparesponse definition
#
-# $Id: caparesponse.pm,v 1.232 2008/09/12 09:56:10 raeburn Exp $
+# $Id: caparesponse.pm,v 1.237 2010/02/28 23:45:43 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -310,9 +310,6 @@ sub start_numericalresponse {
$safeeval);
if ($unit =~ /\S/) { $result.=" (in $unit) "; }
}
- if (($token->[1] eq 'formularesponse') &&
- ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER')) {
- }
if ( &Apache::response::show_answer() ) {
&set_answertext($tag_internal_answer_name,$target,$token,$tagstack,
$parstack,$parser,$safeeval,-1);
@@ -430,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) {
@@ -447,7 +448,7 @@ sub check_submission {
use Time::HiRes;
my $t0 = [Time::HiRes::gettimeofday()];
my ($result,@msgs) =
- &Apache::run::run("&caparesponse_check_list($tag)",$safeeval);
+ &Apache::run::run("&caparesponse_check_list()",$safeeval);
&Apache::lonxml::debug("checking $name $result with $response took ".&Time::HiRes::tv_interval($t0));
&Apache::lonxml::debug('msgs are '.join(':',@msgs));
my ($awards)=split(/:/,$result);
@@ -532,11 +533,18 @@ sub end_numericalresponse {
$Apache::inputtags::params{'sig'});
}
&Apache::lonxml::debug("\n
result:$result:$Apache::lonxml::curdepth
\n");
- if ($Apache::lonhomework::type eq 'survey' &&
- ($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
- $ad eq 'EXACT_ANS')) {
- $ad='SUBMITTED';
- }
+ if (($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
+ $ad eq 'EXACT_ANS')) {
+ if ($Apache::lonhomework::type eq 'survey') {
+ $ad='SUBMITTED';
+ } elsif ($Apache::lonhomework::type eq 'surveycred') {
+ $ad='SUBMITTED_CREDIT';
+ } elsif ($Apache::lonhomework::type eq 'anonsurvey') {
+ $ad='ANONYMOUS';
+ } elsif ($Apache::lonhomework::type eq 'anonsurveycred') {
+ $ad='ANONYMOUS_CREDIT';
+ }
+ }
&Apache::response::handle_previous(\%previous,$ad);
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
$Apache::lonhomework::results{"resource.$partid.$id.awardmsg"}=$msg;
@@ -607,9 +615,8 @@ 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.'.turnoneditor') ne 'no')){
- $result.=&Apache::response::edit_mathresponse_button($id,"HWVAL_$id");
-#hier
+ && (&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);
@@ -752,16 +759,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') {
@@ -1161,13 +1169,15 @@ 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)) {
&Apache::lonxml::debug(" doing $name with ".join(':',@{ $answer{$name}{'answers'} }));
${$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=dclone($answer{$name});
- my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list($$tagstack[-1])",$safeeval);
+ my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list()",$safeeval);
&Apache::lonxml::debug('msgs are'.join(':',@msgs));
my ($awards)=split(/:/,$result);
my (@awards) = split(/,/,$awards);
@@ -1183,11 +1193,18 @@ sub end_stringresponse {
\@final_msgs,
\@names,1);
}
- if ($Apache::lonhomework::type eq 'survey' &&
- ($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
- $ad eq 'EXACT_ANS')) {
- $ad='SUBMITTED';
- }
+ if (($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
+ $ad eq 'EXACT_ANS')) {
+ if ($Apache::lonhomework::type eq 'survey') {
+ $ad='SUBMITTED';
+ } elsif ($Apache::lonhomework::type eq 'surveycred') {
+ $ad='SUBMITTED_CREDIT';
+ } elsif ($Apache::lonhomework::type eq 'anonsurvey') {
+ $ad='ANONYMOUS';
+ } elsif ($Apache::lonhomework::type eq 'anonsurveycred') {
+ $ad='ANONYMOUS_CREDIT';
+ }
+ }
&Apache::response::handle_previous(\%previous,$ad);
$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
$Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=$msg;