version 1.5, 2001/01/12 01:07:13
|
version 1.6, 2001/01/12 15:32:29
|
Line 26 sub end_radiobuttonresponse {
|
Line 26 sub end_radiobuttonresponse {
|
%Apache::response::foilgroup={}; |
%Apache::response::foilgroup={}; |
sub start_foilgroup { |
sub start_foilgroup { |
%Apache::response::foilgroup={}; |
%Apache::response::foilgroup={}; |
|
return ''; |
} |
} |
|
|
sub setrandomnumber { |
sub setrandomnumber { |
Line 44 sub end_foilgroup {
|
Line 45 sub end_foilgroup {
|
my $name; |
my $name; |
my $result; |
my $result; |
&setrandomnumber(); |
&setrandomnumber(); |
my $rrargs =''; |
my ($truecnt,$falsecnt,$max) = &getfoilcounts($parstack,$safeeval); |
if ( $#$parstack > 0 ) { $rrargs=$$parstack['-2']; } |
my $count=0; |
my $max = &Apache::run::run("{$rrargs;".'return $max}',$safeeval); |
# we will add in 1 of the true statements |
my $answer = int(rand $max); |
if (($falsecnt+1)>$max) { $count=$max } else { $count=$falsecnt+1; } |
|
my $answer = int(rand ($count)); |
|
&Apache::lonxml::debug("Answer is $answer, $count from $max, $falsecnt"); |
if ($target eq 'web') { |
if ($target eq 'web') { |
$result=&displayfoils($max,$answer); |
$result=&displayfoils($max,$answer); |
} elsif ( $target eq 'grade') { |
} elsif ( $target eq 'grade') { |
Line 68 sub end_foilgroup {
|
Line 71 sub end_foilgroup {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub getfoilcounts { |
|
my ($parstack,$safeeval)=@_; |
|
my $rrargs =''; |
|
if ( $#$parstack > 0 ) { $rrargs=$$parstack['-2']; } |
|
my $max = &Apache::run::run("{$rrargs;".'return $max}',$safeeval); |
|
my @names = @{ $Apache::response::foilgroup{'names'} }; |
|
my $truecnt=0; |
|
my $falsecnt=0; |
|
my $name; |
|
|
|
foreach $name (@names) { |
|
if ($Apache::response::foilgroup{$name.'.value'} eq 'true') { |
|
$truecnt++; |
|
} elsif ($Apache::response::foilgroup{$name.'.value'} eq 'false') { |
|
$falsecnt++; |
|
} |
|
} |
|
return ($truecnt,$falsecnt,$max); |
|
} |
|
|
sub displayfoils { |
sub displayfoils { |
my ($max,$answer)=@_; |
my ($max,$answer)=@_; |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @names = @{ $Apache::response::foilgroup{'names'} }; |