--- loncom/homework/response.pm 2005/06/29 19:20:10 1.122 +++ loncom/homework/response.pm 2005/11/01 21:33:49 1.126 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # various response type definitons response definition # -# $Id: response.pm,v 1.122 2005/06/29 19:20:10 albertel Exp $ +# $Id: response.pm,v 1.126 2005/11/01 21:33:49 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -71,14 +71,14 @@ sub start_hintresponse { my ($parstack,$safeeval)=@_; my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); if ($id eq '') { $id = $Apache::lonxml::curdepth; } - push (@Apache::inputtags::response,$id); - push (@Apache::inputtags::responselist,$id); + push (@Apache::inputtags::hint,$id); + push (@Apache::inputtags::hintlist,$id); push (@Apache::inputtags::paramstack,[%Apache::inputtags::params]); return $id; } sub end_hintresponse { - pop @Apache::inputtags::response; + pop @Apache::inputtags::hint; if (defined($Apache::inputtags::paramstack[-1])) { %Apache::inputtags::params= @{ pop(@Apache::inputtags::paramstack) }; @@ -119,7 +119,7 @@ sub setrandomnumber { &Apache::lonxml::debug("randseed $rndseed"); # $rndseed=unpack("%32i",$rndseed); my $rand_alg=&Apache::lonnet::get_rand_alg(); - my $rndmod; + my ($rndmod,$rndmod2); my ($id1,$id2,$shift_amt); if ($Apache::lonhomework::parsing_a_problem) { @@ -133,6 +133,7 @@ sub setrandomnumber { if (defined($Apache::bridgetask::instance[-1])) { $id2=$Apache::bridgetask::instance[-1]; } + Apache->request->print("

$id1 $id2

"); $shift_amt=scalar(@Apache::bridgetask::instance); } &Apache::lonxml::debug("id1: $id1, id2: $id2, shift_amt: $shift_amt"); @@ -143,19 +144,22 @@ sub setrandomnumber { } elsif ($rand_alg eq '64bit3') { $rndmod=(&Apache::lonnet::numval2($id1) << 10); if (defined($id2)) { $rndmod+=&Apache::lonnet::numval2($id2); } - } else { + } elsif ($rand_alg eq '64bit4') { my $shift=(4*$shift_amt)%30; $rndmod=(&Apache::lonnet::numval3($id1) << (($shift+15)%30)); if (defined($id2)) { $rndmod+=(&Apache::lonnet::numval3($id2) << $shift ); } + } else { + ($rndmod,$rndmod2)=&Apache::lonnet::digest("$id1,$id2"); + } if ($rndseed =~/([,:])/) { my $char=$1; use integer; my ($num1,$num2)=split(/\Q$char\E/,$rndseed); $num1+=$rndmod; - $num2+=$rndmod; + $num2+= ((defined($rndmod2)) ? $rndmod2 : $rndmod); if($Apache::lonnet::_64bit) { $num1=(($num1<<32)>>32); $num2=(($num2<<32)>>32); } $rndseed=$num1.$char.$num2; } else { @@ -505,7 +509,15 @@ sub answer_part { my ($type,$answer) = @_; my $result; if ($env{'form.answer_output_mode'} eq 'tex') { - $result = ' \verb|'.$answer.'|\\\\ \hline '; + my $to_use='|'; + foreach my $value (32..126) { + my $char=pack('c',$value); + if ($answer !~ /\Q$char\E/) { + $to_use=$char; + last; + } + } + $result = '\verb'.$to_use.$answer.$to_use.'\\\\ \hline '; } else { $result = ''.$answer.''; } @@ -574,8 +586,8 @@ sub repetition { my $id = $Apache::inputtags::part; my $weight = &Apache::lonnet::EXT("resource.$id.weight"); if (!defined($weight) || ($weight eq '')) { $weight=1; } - my $repetition = int $weight/9; - if ($weight % 9 != 0) {$repetition++;} + my $repetition = int($weight/10); + if ($weight % 10 != 0) { $repetition++; } return $repetition; } @@ -584,6 +596,7 @@ sub scored_response { my $repetition=&repetition(); my $score=0; for (my $i=0;$i<$repetition;$i++) { + # A is 1, B is 2, etc. (get response return 0-9 and then we add 1) my $increase=&Apache::response::getresponse($i+1); if ($increase ne '') { $score+=$increase+1; } }