--- loncom/homework/caparesponse/caparesponse.pm 2004/02/26 18:24:24 1.126.2.2 +++ loncom/homework/caparesponse/caparesponse.pm 2004/02/26 16:36:48 1.135 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.126.2.2 2004/02/26 18:24:24 albertel Exp $ +# $Id: caparesponse.pm,v 1.135 2004/02/26 16:36:48 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,6 +29,7 @@ package Apache::caparesponse; use strict; use capa; +use Apache::lonlocal; BEGIN { &Apache::lonxml::register('Apache::caparesponse',('caparesponse','numericalresponse','stringresponse','formularesponse')); @@ -179,7 +180,7 @@ sub end_numericalresponse { my $unit=&Apache::lonxml::get_param_var('unit',$parstack, $safeeval); if ($target eq 'web') { - $result="
The correct answer is "; + $result="
".&mt('The correct answer is')." "; } for (my $i=0; $i <= $#answers; $i++) { my $answer=$answers[$i]; @@ -518,6 +519,16 @@ sub get_sigrange { } if (!$sig_ubound) { $sig_ubound=$sig_lbound; } } + if (($sig_ubound<$sig_lbound) || + ($sig_lbound > 15) || + ($sig =~/(\+|-)/ ) ) { + my $errormsg=&mt("Invalid Significant figures detected")." ($sig)"; + if ($ENV{'request.state'} eq 'construct') { + $errormsg.= + &Apache::loncommon::help_open_topic('Significant_Figures'); + } + &Apache::lonxml::error($errormsg); + } return ($sig_ubound,$sig_lbound); } @@ -536,16 +547,18 @@ sub start_stringresponse { [['cs','Case Sensitive'],['ci','Case Insensitive'], ['mc','Case Insensitive, Any Order'], ['re','Regular Expression']],$token); + $result.=&Apache::edit::checked_arg('Answer Display:','answerdisplay', + [['inline','Inline']],$token); $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); } elsif ($target eq 'modified') { - my $constructtag; - $constructtag=&Apache::edit::get_new_args($token,$parstack, - $safeeval,'answer', - 'type'); - if ($constructtag) { - $result = &Apache::edit::rebuild_tag($token); - $result.=&Apache::edit::handle_insert(); - } + my $constructtag; + $constructtag=&Apache::edit::get_new_args($token,$parstack, + $safeeval,'answer', + 'type','answerdisplay'); + if ($constructtag) { + $result = &Apache::edit::rebuild_tag($token); + $result.=&Apache::edit::handle_insert(); + } } elsif ($target eq 'answer' || $target eq 'grade') { &Apache::response::reset_params(); } @@ -560,6 +573,7 @@ sub end_stringresponse { my $id=$Apache::inputtags::response[-1]; my $answer=&Apache::lonxml::get_param('answer',$parstack,$safeeval); my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval); + my $answerdisplay=&Apache::lonxml::get_param('answerdisplay',$parstack,$safeeval); &Apache::lonxml::debug("current $answer ".$token->[2]); if (!$Apache::lonxml::default_homework_loaded) { &Apache::lonxml::default_homework_load($safeeval); @@ -622,7 +636,8 @@ sub end_stringresponse { my $status = $Apache::inputtags::status['-1']; if ( &Apache::response::show_answer() ) { if ($target eq 'web') { - $result="
The correct answer is ".$answer; + $result=($answerdisplay eq 'inline'?'':"
".&mt('The correct answer is')." ") + .$answer; # join(', ',@answers).".
"; } }