$id1 $id2
"); + $shift_amt=scalar(@Apache::bridgetask::instance); + } + &Apache::lonxml::debug("id1: $id1, id2: $id2, shift_amt: $shift_amt"); + if (!$rand_alg || $rand_alg eq '32bit' || $rand_alg eq '64bit' || + $rand_alg eq '64bit2') { + $rndmod=(&Apache::lonnet::numval($id1) << 10); + if (defined($id2)) { $rndmod+=&Apache::lonnet::numval($id2); } + } elsif ($rand_alg eq '64bit3') { + $rndmod=(&Apache::lonnet::numval2($id1) << 10); + if (defined($id2)) { $rndmod+=&Apache::lonnet::numval2($id2); } + } 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+= ((defined($rndmod2)) ? $rndmod2 : $rndmod); + if($Apache::lonnet::_64bit) { $num1=(($num1<<32)>>32); $num2=(($num2<<32)>>32); } + $rndseed=$num1.$char.$num2; + } else { + $rndseed+=$rndmod; + if($Apache::lonnet::_64bit) { + use integer; + $rndseed=(($rndseed<<32)>>32); + } + } + &Apache::lonxml::debug("randseed $rndmod $rndseed"); + &Apache::lonnet::setup_random_from_rndseed($rndseed); + return ''; +} + +sub meta_parameter_write { + my ($name,$type,$default,$display)=@_; + my $partref=$Apache::inputtags::part; + my $result='Answer for Part:'. + $Apache::inputtags::part. ' | '."\n"; + } + return $result; +} + +sub answer_part { + my ($type,$answer) = @_; + my $result; + if ($env{'form.answer_output_mode'} eq 'tex') { + 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.' | '; + } + return $result; +} + +sub answer_footer { + my ($type) = @_; + my $result; + if ($env{'form.answer_output_mode'} eq 'tex') { + $result = ' \end{tabular} \vskip 0 mm '; + } else { + $result = '