version 1.97, 2004/03/31 05:23:59
|
version 1.104, 2004/09/24 19:44:00
|
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::lonhomework::ignore_response_errors) { |
&Apache::lonxml::error(&HTML::Entities::encode(&mt("Found a <*response> outside of a <part> in a <part>ed problem"),'<>&"')); |
&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 && |
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) { |
Line 460 sub answer_footer {
|
Line 500 sub answer_footer {
|
} |
} |
|
|
sub showallfoils { |
sub showallfoils { |
my $return=0; |
if (defined($ENV{'form.showallfoils'})) { |
if (defined($ENV{'form.showallfoils'}) && |
my ($symb)=&Apache::lonxml::whichuser(); |
$ENV{'request.state'} eq 'construct') { |
if ($ENV{'request.state'} eq 'construct' || |
$return=1; |
($ENV{'user.adv'} && $symb eq '')) { |
|
return 1; |
|
} |
} |
} |
return $return; |
return 0; |
} |
} |
|
|
sub getresponse { |
sub getresponse { |
Line 490 sub getresponse {
|
Line 532 sub getresponse {
|
$Apache::lonhomework::results{"resource.$part.$id.scantron"}.= |
$Apache::lonhomework::results{"resource.$part.$id.scantron"}.= |
$response; |
$response; |
if ($resulttype ne 'letter') { |
if ($resulttype ne 'letter') { |
$response = $let_to_num{$response}; |
if ($resulttype eq 'A is 1') { |
|
$response = $let_to_num{$response}; |
|
} else { |
|
$response = $let_to_num{$response}+1; |
|
} |
} |
} |
} else { |
} else { |
$response = $ENV{$formparm}; |
$response = $ENV{$formparm}; |