version 1.3, 2001/02/22 01:13:43
|
version 1.6, 2001/05/15 20:48:43
|
Line 14 sub start_imageresponse {
|
Line 14 sub start_imageresponse {
|
my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; |
#when in a radiobutton response use these |
#when in a radiobutton response use these |
&Apache::lonxml::register('Apache::imageresponse',('foilgroup','foil','text','image','rectangle')); |
&Apache::lonxml::register('Apache::imageresponse',('foilgroup','foil','text','image','rectangle')); |
|
push (@Apache::lonxml::namespace,'imageresponse'); |
my $id = &Apache::response::start_response($parstack,$safeeval); |
my $id = &Apache::response::start_response($parstack,$safeeval); |
return ''; |
return ''; |
} |
} |
|
|
sub end_imageresponse { |
sub end_imageresponse { |
&Apache::response::end_response; |
&Apache::response::end_response; |
|
pop @Apache::lonxml::namespace; |
return ''; |
return ''; |
} |
} |
|
|
%Apache::response::foilgroup={}; |
%Apache::response::foilgroup={}; |
sub start_foilgroup { |
sub start_foilgroup { |
%Apache::response::foilgroup={}; |
%Apache::response::foilgroup={}; |
return ''; |
$Apache::optionresponse::conceptgroup=0; |
} |
&Apache::response::setrandomnumber(); |
|
|
sub setrandomnumber { |
|
my $rndseed=&Apache::lonnet::rndseed(); |
|
$rndseed=unpack("%32i",$rndseed); |
|
$rndseed=$rndseed |
|
+&Apache::lonnet::numval($Apache::inputtags::part) |
|
+&Apache::lonnet::numval($Apache::inputtags::response['-1']); |
|
srand($rndseed); |
|
return ''; |
return ''; |
} |
} |
|
|
Line 52 sub whichfoils {
|
Line 46 sub whichfoils {
|
my ($max)=@_; |
my ($max)=@_; |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @whichopt =(); |
my @whichopt =(); |
while ((($#whichopt+1) < $max) && ($#names > -1)) { |
while ((($#whichopt) < $max) && ($#names > -1)) { |
my $aopt=int rand $#names; |
my $aopt=int rand $#names; |
&Apache::lonxml::debug("From $#names elms, picking $aopt"); |
&Apache::lonxml::debug("From $#names elms, picking $aopt"); |
$aopt=splice(@names,$aopt,1); |
$aopt=splice(@names,$aopt,1); |
Line 122 sub end_foilgroup {
|
Line 116 sub end_foilgroup {
|
my $result=''; |
my $result=''; |
my @whichopt; |
my @whichopt; |
if ($target eq 'web' || $target eq 'grade') { |
if ($target eq 'web' || $target eq 'grade') { |
&setrandomnumber(); |
|
my ($count,$max) = &getfoilcounts($parstack,$safeeval); |
my ($count,$max) = &getfoilcounts($parstack,$safeeval); |
if ($count>$max) { $count=$max } |
if ($count>$max) { $count=$max } |
&Apache::lonxml::debug("Count is $count from $max"); |
&Apache::lonxml::debug("Count is $count from $max"); |
Line 140 sub end_foilgroup {
|
Line 133 sub end_foilgroup {
|
} |
} |
|
|
sub start_conceptgroup { |
sub start_conceptgroup { |
|
$Apache::optionresponse::conceptgroup=1; |
|
%Apache::response::conceptgroup={}; |
|
return ''; |
} |
} |
|
|
sub end_conceptgroup { |
sub end_conceptgroup { |
|
my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; |
|
$Apache::optionresponse::conceptgroup=0; |
|
if ($target eq 'web' || $target eq 'grade') { |
|
my @names = @{ $Apache::response::conceptgroup{'names'} }; |
|
my $pick=int rand $#names+1; |
|
my $name=$names[$pick]; |
|
push @{ $Apache::response::foilgroup{'names'} }, $name; |
|
$Apache::response::foilgroup{"$name.text"} = $Apache::response::conceptgroup{"$name.text"}; |
|
$Apache::response::foilgroup{"$name.image"} = $Apache::response::conceptgroup{"$name.image"}; |
|
push(@{ $Apache::response::foilgroup{"$name.area"} }, @{ $Apache::response::conceptgroup{"$name.area"} }); |
|
my $args; |
|
if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } |
|
my $concept = &Apache::run::run("{$args;".'return $concept}',$safeeval); |
|
$Apache::response::foilgroup{"$name.concept"} = $concept; |
|
&Apache::lonxml::debug("Selecting $name in $concept"); |
|
} |
|
return ''; |
} |
} |
|
|
$Apache::imageresponse::curname=''; |
$Apache::imageresponse::curname=''; |