version 1.124, 2005/08/17 16:52:37
|
version 1.126, 2005/11/01 21:33:49
|
Line 119 sub setrandomnumber {
|
Line 119 sub setrandomnumber {
|
&Apache::lonxml::debug("randseed $rndseed"); |
&Apache::lonxml::debug("randseed $rndseed"); |
# $rndseed=unpack("%32i",$rndseed); |
# $rndseed=unpack("%32i",$rndseed); |
my $rand_alg=&Apache::lonnet::get_rand_alg(); |
my $rand_alg=&Apache::lonnet::get_rand_alg(); |
my $rndmod; |
my ($rndmod,$rndmod2); |
|
|
my ($id1,$id2,$shift_amt); |
my ($id1,$id2,$shift_amt); |
if ($Apache::lonhomework::parsing_a_problem) { |
if ($Apache::lonhomework::parsing_a_problem) { |
Line 133 sub setrandomnumber {
|
Line 133 sub setrandomnumber {
|
if (defined($Apache::bridgetask::instance[-1])) { |
if (defined($Apache::bridgetask::instance[-1])) { |
$id2=$Apache::bridgetask::instance[-1]; |
$id2=$Apache::bridgetask::instance[-1]; |
} |
} |
|
Apache->request->print("<p> $id1 $id2</p>"); |
$shift_amt=scalar(@Apache::bridgetask::instance); |
$shift_amt=scalar(@Apache::bridgetask::instance); |
} |
} |
&Apache::lonxml::debug("id1: $id1, id2: $id2, shift_amt: $shift_amt"); |
&Apache::lonxml::debug("id1: $id1, id2: $id2, shift_amt: $shift_amt"); |
Line 143 sub setrandomnumber {
|
Line 144 sub setrandomnumber {
|
} elsif ($rand_alg eq '64bit3') { |
} elsif ($rand_alg eq '64bit3') { |
$rndmod=(&Apache::lonnet::numval2($id1) << 10); |
$rndmod=(&Apache::lonnet::numval2($id1) << 10); |
if (defined($id2)) { $rndmod+=&Apache::lonnet::numval2($id2); } |
if (defined($id2)) { $rndmod+=&Apache::lonnet::numval2($id2); } |
} else { |
} elsif ($rand_alg eq '64bit4') { |
my $shift=(4*$shift_amt)%30; |
my $shift=(4*$shift_amt)%30; |
$rndmod=(&Apache::lonnet::numval3($id1) << (($shift+15)%30)); |
$rndmod=(&Apache::lonnet::numval3($id1) << (($shift+15)%30)); |
if (defined($id2)) { |
if (defined($id2)) { |
$rndmod+=(&Apache::lonnet::numval3($id2) << $shift ); |
$rndmod+=(&Apache::lonnet::numval3($id2) << $shift ); |
} |
} |
|
} else { |
|
($rndmod,$rndmod2)=&Apache::lonnet::digest("$id1,$id2"); |
|
|
} |
} |
if ($rndseed =~/([,:])/) { |
if ($rndseed =~/([,:])/) { |
my $char=$1; |
my $char=$1; |
use integer; |
use integer; |
my ($num1,$num2)=split(/\Q$char\E/,$rndseed); |
my ($num1,$num2)=split(/\Q$char\E/,$rndseed); |
$num1+=$rndmod; |
$num1+=$rndmod; |
$num2+=$rndmod; |
$num2+= ((defined($rndmod2)) ? $rndmod2 : $rndmod); |
if($Apache::lonnet::_64bit) { $num1=(($num1<<32)>>32); $num2=(($num2<<32)>>32); } |
if($Apache::lonnet::_64bit) { $num1=(($num1<<32)>>32); $num2=(($num2<<32)>>32); } |
$rndseed=$num1.$char.$num2; |
$rndseed=$num1.$char.$num2; |
} else { |
} else { |
Line 582 sub repetition {
|
Line 586 sub repetition {
|
my $id = $Apache::inputtags::part; |
my $id = $Apache::inputtags::part; |
my $weight = &Apache::lonnet::EXT("resource.$id.weight"); |
my $weight = &Apache::lonnet::EXT("resource.$id.weight"); |
if (!defined($weight) || ($weight eq '')) { $weight=1; } |
if (!defined($weight) || ($weight eq '')) { $weight=1; } |
my $repetition = int $weight/9; |
my $repetition = int($weight/10); |
if ($weight % 9 != 0) {$repetition++;} |
if ($weight % 10 != 0) { $repetition++; } |
return $repetition; |
return $repetition; |
} |
} |
|
|
Line 592 sub scored_response {
|
Line 596 sub scored_response {
|
my $repetition=&repetition(); |
my $repetition=&repetition(); |
my $score=0; |
my $score=0; |
for (my $i=0;$i<$repetition;$i++) { |
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); |
my $increase=&Apache::response::getresponse($i+1); |
if ($increase ne '') { $score+=$increase+1; } |
if ($increase ne '') { $score+=$increase+1; } |
} |
} |