--- loncom/homework/drawimage.pm 2024/04/05 02:31:23 1.11 +++ loncom/homework/drawimage.pm 2024/04/05 04:05:08 1.12 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # programatic image drawing # -# $Id: drawimage.pm,v 1.11 2024/04/05 02:31:23 raeburn Exp $ +# $Id: drawimage.pm,v 1.12 2024/04/05 04:05:08 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,7 +29,10 @@ package Apache::drawimage; use strict; use Apache::loncommon; +use Apache::lonnet; +use Apache::lonxml; use lib '/home/httpd/lib/perl/'; +use Time::HiRes qw(gettimeofday); use LONCAPA; @@ -54,16 +57,42 @@ sub start_drawimage { sub end_drawimage { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result; + # need to call rand everytime start_script would evaluate, as the + # safe space rand number generator and the global rand generator + # are not separate + my $randnumber; + if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' || + $target eq 'answer') { + $randnumber=int(rand(1000)); + } if ($target eq 'web' || $target eq 'tex') { my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval); my $height =&Apache::lonxml::get_param('height',$parstack,$safeeval); my $bgcolor =&Apache::lonxml::get_param('bgcolor',$parstack,$safeeval); if (!$width) { $width=300; } if (!$height) { $height=300; } - $result.="