version 1.96, 2004/03/25 16:55:16
|
version 1.101, 2004/08/29 07:49:35
|
Line 46 sub start_response {
|
Line 46 sub start_response {
|
push (@Apache::inputtags::response,$id); |
push (@Apache::inputtags::response,$id); |
push (@Apache::inputtags::responselist,$id); |
push (@Apache::inputtags::responselist,$id); |
@Apache::inputtags::inputlist=(); |
@Apache::inputtags::inputlist=(); |
if ($Apache::inputtags::part eq '') { |
if ($Apache::inputtags::part eq '' && |
&Apache::lonxml::error(&HTML::Entities::encode(&mt("Found a <*response> outside of a <part> in a <part>ed problem"))); |
!$Apache::lonhomework::ignore_response_errors) { |
|
&Apache::lonxml::error(&HTML::Entities::encode(&mt("Found a <*response> outside of a <part> in a <part>ed problem"),'<>&"')); |
} |
} |
if ($Apache::inputtags::response_with_no_part && |
if ($Apache::inputtags::response_with_no_part && |
$Apache::inputtags::part ne '0') { |
$Apache::inputtags::part ne '0') { |
&Apache::lonxml::error(&HTML::Entities::encode(&mt("<*response>s are both inside of <part> and outside of <part>, this is not a valid problem, errors in grading may occur.")).'<br />'); |
&Apache::lonxml::error(&HTML::Entities::encode(&mt("<*response>s are both inside of <part> and outside of <part>, this is not a valid problem, errors in grading may occur."),'<>&"').'<br />'); |
} |
} |
if ($Apache::inputtags::part eq '0') { |
if ($Apache::inputtags::part eq '0') { |
$Apache::inputtags::response_with_no_part=1; |
$Apache::inputtags::response_with_no_part=1; |
Line 84 sub end_hintresponse {
|
Line 85 sub end_hintresponse {
|
return ''; |
return ''; |
} |
} |
|
|
# used by response to set the non-safe space random number generator to something |
my @randomseeds; |
# that is stable and unique based on the part number and response number |
sub pushrandomnumber { |
|
my $rand_alg=&Apache::lonnet::get_rand_alg(); |
|
if (!$rand_alg || $rand_alg eq '32bit' || $rand_alg eq '64bit' || |
|
$rand_alg eq '64bit2') { |
|
# do nothing |
|
} else { |
|
my @seed=&Math::Random::random_get_seed(); |
|
push (@randomseeds,\@seed); |
|
} |
|
&Apache::response::setrandomnumber(); |
|
} |
|
sub poprandomnumber { |
|
my $rand_alg=&Apache::lonnet::get_rand_alg(); |
|
if (!$rand_alg || $rand_alg eq '32bit' || $rand_alg eq '64bit' || |
|
$rand_alg eq '64bit2') { |
|
return; |
|
} |
|
my $seed=pop(@randomseeds); |
|
if ($seed) { |
|
&Math::Random::random_set_seed(@$seed); |
|
} else { |
|
&Apache::lonxml::error("Unable to restore random algorithm."); |
|
} |
|
} |
sub setrandomnumber { |
sub setrandomnumber { |
my $rndseed; |
my $rndseed; |
$rndseed=&Apache::structuretags::setup_rndseed(); |
$rndseed=&Apache::structuretags::setup_rndseed(); |
if (!defined($rndseed)) { $rndseed=&Apache::lonnet::rndseed(); } |
if (!defined($rndseed)) { $rndseed=&Apache::lonnet::rndseed(); } |
&Apache::lonxml::debug("randseed $rndseed"); |
&Apache::lonxml::debug("randseed $rndseed"); |
# $rndseed=unpack("%32i",$rndseed); |
# $rndseed=unpack("%32i",$rndseed); |
my $rndmod=(&Apache::lonnet::numval($Apache::inputtags::part) << 10); |
my $rand_alg=&Apache::lonnet::get_rand_alg(); |
if (defined($Apache::inputtags::response['-1'])) { |
my $rndmod; |
$rndmod+=&Apache::lonnet::numval($Apache::inputtags::response[-1]); |
if (!$rand_alg || $rand_alg eq '32bit' || $rand_alg eq '64bit' || |
} |
$rand_alg eq '64bit2') { |
if ($rndseed =~/,/) { |
$rndmod=(&Apache::lonnet::numval($Apache::inputtags::part) << 10); |
{ |
if (defined($Apache::inputtags::response[-1])) { |
use integer; |
$rndmod+=&Apache::lonnet::numval($Apache::inputtags::response[-1]); |
my ($num1,$num2)=split(/,/,$rndseed); |
|
$num1+=$rndmod; |
|
$num2+=$rndmod; |
|
$rndseed="$num1,$num2"; |
|
} |
} |
} else { |
} else { |
|
$rndmod=(&Apache::lonnet::numval2($Apache::inputtags::part) << 10); |
|
if (defined($Apache::inputtags::response[-1])) { |
|
$rndmod+=&Apache::lonnet::numval2($Apache::inputtags::response[-1]); |
|
} |
|
} |
|
if ($rndseed =~/([,:])/) { |
|
my $char=$1; |
|
use integer; |
|
my ($num1,$num2)=split(/\Q$char\E/,$rndseed); |
|
$num1+=$rndmod; |
|
$num2+=$rndmod; |
|
$rndseed=$num1.$char.$num2; |
|
} else { |
$rndseed+=$rndmod; |
$rndseed+=$rndmod; |
} |
} |
&Apache::lonnet::setup_random_from_rndseed($rndseed); |
&Apache::lonnet::setup_random_from_rndseed($rndseed); |
Line 188 sub meta_part_order {
|
Line 221 sub meta_part_order {
|
if (@Apache::inputtags::partlist) { |
if (@Apache::inputtags::partlist) { |
my @parts=@Apache::inputtags::partlist; |
my @parts=@Apache::inputtags::partlist; |
shift(@parts); |
shift(@parts); |
return '<partorder>'.join(',',@parts).'</partorder>'; |
return '<partorder>'.join(',',@parts).'</partorder>'."\n"; |
} else { |
} else { |
return '<partorder>0</partorder>'; |
return '<partorder>0</partorder>'."\n"; |
|
} |
|
} |
|
|
|
sub meta_response_order { |
|
if (@Apache::inputtags::responselist) { |
|
return '<responseorder>'.join(',',@Apache::inputtags::responselist). |
|
'</responseorder>'."\n"; |
} |
} |
} |
} |
|
|
Line 199 sub check_for_previous {
|
Line 239 sub check_for_previous {
|
my %previous; |
my %previous; |
$previous{'used'} = 0; |
$previous{'used'} = 0; |
foreach my $key (sort(keys(%Apache::lonhomework::history))) { |
foreach my $key (sort(keys(%Apache::lonhomework::history))) { |
if ($key =~ /resource\.$partid\.$id\.submission/) { |
if ($key =~ /resource\.$partid\.$id\.submission$/) { |
&Apache::lonxml::debug("Trying $key"); |
&Apache::lonxml::debug("Trying $key"); |
my $pastresponse=$Apache::lonhomework::history{$key}; |
my $pastresponse=$Apache::lonhomework::history{$key}; |
if ($pastresponse eq $curresponse) { |
if ($pastresponse eq $curresponse) { |