[LON-CAPA-cvs] cvs: loncom /homework imageresponse.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 03 May 2002 20:44:46 -0000
albertel Fri May 3 16:44:46 2002 EDT
Modified files:
/loncom/homework imageresponse.pm
Log:
- implements BUG#238 for image response (showallfoils)
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.17 loncom/homework/imageresponse.pm:1.18
--- loncom/homework/imageresponse.pm:1.17 Mon Feb 4 12:30:53 2002
+++ loncom/homework/imageresponse.pm Fri May 3 16:44:46 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# image click response style
#
-# $Id: imageresponse.pm,v 1.17 2002/02/04 17:30:53 albertel Exp $
+# $Id: imageresponse.pm,v 1.18 2002/05/03 20:44:46 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -69,6 +69,7 @@
my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
# +1 since instructors will count from 1
my $count = $#{ $Apache::response::foilgroup{'names'} }+1;
+ if (&Apache::response::showallfoils()) { $max=$count; }
return ($count,$max);
}
@@ -79,7 +80,12 @@
my @whichopt =();
while ((($#whichopt+1) < $max) && ($#names > -1)) {
&Apache::lonxml::debug("Have $#whichopt max is $max");
- my $aopt=int(rand($#names+1));
+ my $aopt;
+ if (&Apache::response::showallfoils()) {
+ $aopt=0;
+ } else {
+ $aopt=int(rand($#names+1));
+ }
&Apache::lonxml::debug("From $#names elms, picking $aopt");
$aopt=splice(@names,$aopt,1);
&Apache::lonxml::debug("Picked $aopt");
@@ -200,7 +206,8 @@
if ($target eq 'web' || $target eq 'grade') {
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
if ($name eq '') { $name=$Apache::lonxml::curdepth; }
- if ( $Apache::imageresponse::conceptgroup ) {
+ if ( $Apache::imageresponse::conceptgroup
+ && !&Apache::response::showallfoils()) {
push(@{ $Apache::response::conceptgroup{'names'} }, $name);
} else {
push(@{ $Apache::response::foilgroup{'names'} }, $name);
@@ -225,7 +232,8 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
if ($target eq 'web') {
my $name = $Apache::imageresponse::curname;
- if ( $Apache::imageresponse::conceptgroup ) {
+ if ( $Apache::imageresponse::conceptgroup
+ && !&Apache::response::showallfoils() ) {
$Apache::response::conceptgroup{"$name.text"} = &Apache::lonxml::endredirection;
} else {
$Apache::response::foilgroup{"$name.text"} = &Apache::lonxml::endredirection;
@@ -246,7 +254,8 @@
my $name = $Apache::imageresponse::curname;
my $image = &Apache::lonxml::endredirection;
&Apache::lonxml::debug("out is $image");
- if ( $Apache::imageresponse::conceptgroup ) {
+ if ( $Apache::imageresponse::conceptgroup
+ && !&Apache::response::showallfoils()) {
$Apache::response::conceptgroup{"$name.image"} = $image;
} else {
$Apache::response::foilgroup{"$name.image"} = $image;
@@ -284,7 +293,8 @@
my $name = $Apache::imageresponse::curname;
my $area = &Apache::lonxml::endredirection;
&Apache::lonxml::debug("out is $area for $name");
- if ( $Apache::imageresponse::conceptgroup ) {
+ if ( $Apache::imageresponse::conceptgroup
+ && !&Apache::response::showallfoils()) {
push @{ $Apache::response::conceptgroup{"$name.area"} },"rectangle:$area";
} else {
push @{ $Apache::response::foilgroup{"$name.area"} },"rectangle:$area";