version 1.94, 2004/03/12 18:41:43
|
version 1.105, 2004/09/27 22:47:49
|
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; |
} else { |
$num2+=$rndmod; |
$rndmod=(&Apache::lonnet::numval2($Apache::inputtags::part) << 10); |
$rndseed="$num1,$num2"; |
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 { |
} else { |
$rndseed+=$rndmod; |
$rndseed+=$rndmod; |
} |
} |
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}+1; |
|
} else { |
|
$response = $let_to_num{$response}; |
|
} |
} |
} |
} else { |
} else { |
$response = $ENV{$formparm}; |
$response = $ENV{$formparm}; |
Line 597 sub analyze_store_foilgroup {
|
Line 643 sub analyze_store_foilgroup {
|
push (@{ $Apache::lonhomework::analyze{"$part_id.shown"} }, @{ $shown }); |
push (@{ $Apache::lonhomework::analyze{"$part_id.shown"} }, @{ $shown }); |
} |
} |
|
|
|
sub check_if_computed { |
|
my ($token,$parstack,$safeeval,$name)=@_; |
|
my $value = &Apache::lonxml::get_param($name,$parstack,$safeeval); |
|
if ($value ne $token->[2]{$name}) { |
|
my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]"; |
|
$Apache::lonhomework::analyze{"$part_id.answercomputed"} = 1; |
|
} |
|
} |
|
|
sub pick_foil_for_concept { |
sub pick_foil_for_concept { |
my ($target,$attrs,$hinthash,$parstack,$safeeval)=@_; |
my ($target,$attrs,$hinthash,$parstack,$safeeval)=@_; |
if (not defined(@{ $Apache::response::conceptgroup{'names'} })) { return; } |
if (not defined(@{ $Apache::response::conceptgroup{'names'} })) { return; } |
Line 632 sub pick_foil_for_concept {
|
Line 687 sub pick_foil_for_concept {
|
|
|
} |
} |
|
|
|
sub get_response_param { |
|
my ($id,$name,$default)=@_; |
|
my $parameter; |
|
if ($ENV{'request.state'} eq 'construct' && |
|
defined($Apache::inputtags::params{$name})) { |
|
$parameter=$Apache::inputtags::params{$name}; |
|
} else { |
|
$parameter=&Apache::lonnet::EXT("resource.$id.$name"); |
|
} |
|
if (!defined($parameter) || $parameter eq '') { |
|
$parameter = $default; |
|
} |
|
return $parameter; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |