--- loncom/homework/default_homework.lcpm 2002/09/26 20:46:48 1.52 +++ loncom/homework/default_homework.lcpm 2003/02/12 22:45:01 1.57 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run() # -# $Id: default_homework.lcpm,v 1.52 2002/09/26 20:46:48 albertel Exp $ +# $Id: default_homework.lcpm,v 1.57 2003/02/12 22:45:01 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -101,11 +101,11 @@ sub caparesponse_check { $sig_ubound =15; #SIG_UB_DEFAULT } else { ($sig_lbound,$sig_ubound) = split /,/,$sig; - if (!$sig_lbound) { + if (!defined($sig_lbound)) { $sig_lbound = 0; #SIG_LB_DEFAULT $sig_ubound =15; #SIG_UB_DEFAULT } - if (!$sig_ubound) { $sig_ubound=$sig_lbound; } + if (!defined($sig_ubound)) { $sig_ubound=$sig_lbound; } } my $result = &caparesponse_capa_check_answer($response,$answer,$type, $tol_type,$tol, @@ -152,6 +152,8 @@ sub get_array_args { sub caparesponse_check_list { my ($response,$expr)=@_; my $result; + $expr =~ s/\\/\\\\/g; + $expr =~ s/\'/\\\'/g; my ($result,@list) = &get_array_args($expr,'answer'); my $aresult=''; my $current_answer; @@ -180,12 +182,15 @@ sub caparesponse_check_list { my $awards=''; for ($i=0; $i<@list;$i++) { $result.="trying answer :$list[$i]:\n"; + my $thisanswer=$list[$i]; + $thisanswer=~ s/\\/\\\\/g; + $thisanswer =~ s/\'/\\\'/g; if ($unit eq '') { $aresult=&caparesponse_check($responselist[$i], - $expr.';my $answer=\''.$list[$i].'\';'); + $expr.';my $answer=\''.$thisanswer.'\';'); } else { $aresult=&caparesponse_check($responselist[$i]." $unit", - $expr.';my $answer=\''.$list[$i].'\';'); + $expr.';my $answer=\''.$thisanswer.'\';'); } my ($temp)=split /:/, $aresult; $awards.="$temp,"; @@ -240,7 +245,9 @@ sub hinton { sub random { my ($start,$end,$step)=@_; if ( ! $hidden::RANDOMINIT ) { - &random_set_seed_from_phrase($external::randomseed); + if ($external::randomseed == 0) { $external::randomseed=1; } + &random_set_seed(1,int(abs($external::randomseed))); + &math_random_uniform(); $hidden::RANDOMINIT=1; } if (!defined($step)) { $step=1; } @@ -565,7 +572,7 @@ sub map { } } } - &random_set_seed(@seed); + &random_set_seed(@oldseed); return ''; }