--- loncom/homework/imageresponse.pm 2002/07/23 14:41:06 1.19 +++ loncom/homework/imageresponse.pm 2003/01/16 02:55:05 1.23 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # image click response style # -# $Id: imageresponse.pm,v 1.19 2002/07/23 14:41:06 sakharuk Exp $ +# $Id: imageresponse.pm,v 1.23 2003/01/16 02:55:05 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,6 +30,7 @@ package Apache::imageresponse; use strict; +use Image::Magick; BEGIN { &Apache::lonxml::register('Apache::imageresponse',('imageresponse')); @@ -55,9 +56,9 @@ sub end_imageresponse { return ''; } -%Apache::response::foilgroup={}; +%Apache::response::foilgroup=(); sub start_foilgroup { - %Apache::response::foilgroup={}; + %Apache::response::foilgroup=(); $Apache::imageresponse::conceptgroup=0; &Apache::response::setrandomnumber(); return ''; @@ -84,7 +85,7 @@ sub whichfoils { if (&Apache::response::showallfoils()) { $aopt=0; } else { - $aopt=int(rand($#names+1)); + $aopt=int(&Math::Random::random_uniform() * ($#names+1)); } &Apache::lonxml::debug("From $#names elms, picking $aopt"); $aopt=splice(@names,$aopt,1); @@ -114,7 +115,6 @@ sub displayfoils { sub gradefoils { my (@whichopt) = @_; - my $result=''; my $x; my $y; my $result; @@ -174,7 +174,7 @@ sub end_foilgroup { sub start_conceptgroup { $Apache::imageresponse::conceptgroup=1; - %Apache::response::conceptgroup={}; + %Apache::response::conceptgroup=(); return ''; } @@ -184,7 +184,7 @@ sub end_conceptgroup { if ($target eq 'web' || $target eq 'grade') { if (defined(@{ $Apache::response::conceptgroup{'names'} })) { my @names = @{ $Apache::response::conceptgroup{'names'} }; - my $pick=int(rand($#names+1)); + my $pick=int(&Math::Random::random_uniform() * ($#names+1)); my $name=$names[$pick]; if (defined(@{ $Apache::response::conceptgroup{"$name.area"} })) { push @{ $Apache::response::foilgroup{'names'} }, $name; @@ -324,14 +324,14 @@ sub end_image { #where can we find the picture? if (-e $newsrc) { if ($path) { - $currentstring .= '\vskip 0 mm \noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; + $currentstring .= '\vskip 0 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} '; } } else { my $temp_file; my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat"; $temp_file = Apache::File->new('>>'.$filename); print $temp_file "$src\n"; - $currentstring .= '\vskip 0 mm \graphicspath{{/home/httpd/prtspool/}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; + $currentstring .= '\vskip 0 mm \graphicspath{{/home/httpd/prtspool/}}\includegraphics[width='.$width_param.' mm]{'.$file.'} '; } } return $currentstring;