--- loncom/homework/caparesponse/caparesponse.pm 2008/09/23 19:22:58 1.227.2.4 +++ loncom/homework/caparesponse/caparesponse.pm 2010/08/02 10:52:58 1.239 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.227.2.4 2008/09/23 19:22:58 raeburn Exp $ +# $Id: caparesponse.pm,v 1.239 2010/08/02 10:52:58 foxr 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) "; } @@ -514,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); @@ -533,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; @@ -585,9 +592,16 @@ sub end_numericalresponse { &get_table_sizes($number_of_bubbles,$bubble_display); my $j=0; my $cou=0; - $result.='\vskip -1 mm \noindent \begin{enumerate}\item[\textbf{'.$Apache::lonxml::counter.'}.]'; + $result.='\vskip 2mm \noindent '; + $result .= '\textbf{'.$Apache::lonxml::counter.'.} \vskip -3mm '; + for (my $i=0;$i<$number_of_tables;$i++) { - $result.='\vskip -1 mm \noindent \setlength{\tabcolsep}{2 mm}\begin{tabular}{'; + if ($i == 0) { + $result .= '\vskip -1mm '; + } else { + $result .= '\vskip 1mm '; + } + $result.='\noindent \setlength{\tabcolsep}{2 mm}\hskip 2pc\begin{tabular}{'; for (my $ind=0;$ind<$table_range[$j];$ind++) { $result.='p{3 mm}p{'.$celllength.' mm}'; } @@ -600,7 +614,6 @@ sub end_numericalresponse { $j++; $result.='\\\\\end{tabular}\vskip 0 mm '; } - $result.='\end{enumerate}'; } else { $increment = &Apache::response::repetition(); } @@ -611,7 +624,7 @@ sub end_numericalresponse { && (&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; @@ -752,16 +765,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') { @@ -1185,11 +1199,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;