--- loncom/xml/lonplot.pm 2002/02/27 22:10:23 1.51 +++ loncom/xml/lonplot.pm 2002/03/14 19:02:30 1.56 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Dynamic plot # -# $Id: lonplot.pm,v 1.51 2002/02/27 22:10:23 matthew Exp $ +# $Id: lonplot.pm,v 1.56 2002/03/14 19:02:30 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,7 +29,7 @@ # 12/17 12/18 12/19 12/20 12/21 12/27 12/28 12/30 12/31 Matthew # 01/01/02 Matthew # 01/02 01/03 01/04 01/07 01/08 01/09 Matthew -# 01/21 02/05 02/06 Matthew +# 01/21 02/05 02/06 2/28Matthew package Apache::lonplot; @@ -144,6 +144,8 @@ A gnuplot tag can contain the fol
Allows specification of the x and y coordinate 'tics' on the axes. This is mostly used to adjust the grid lines when a grid is displayed. +If you are having trouble with your plot, please read the help +available on Plot Curve. ENDPLOTHELP my %gnuplot_defaults = @@ -441,25 +443,36 @@ sub end_gnuplot { &Apache::lonxml::deregister('Apache::lonplot', ('title','xlabel','ylabel','key','axis','label','curve')); my $result = ''; + my $randnumber; + # need to call rand everytime start_script would evaluate, as the + # safe space rand number generator and the global rand generator + # are not seperate + if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' || + $target eq 'answer') { + $randnumber=int(rand(1000)); + } if ($target eq 'web' || $target eq 'tex') { &check_inputs(); # Make sure we have all the data we need ## ## Determine filename my $tmpdir = '/home/httpd/perl/tmp/'; my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}. - '_'.time.'_'.$$.int(rand(1000)).'_plot.data'; + '_'.time.'_'.$$.$randnumber.'_plot.data'; ## Write the plot description to the file &write_gnuplot_file($tmpdir,$filename,$target); + $filename = &Apache::lonnet::escape($filename); ## return image tag for the plot if ($target eq 'web') { $result .= <<"ENDIMAGE"; -image should be /cgi-bin/plot.gif?$filename ENDIMAGE } elsif ($target eq 'tex') { + &Apache::lonnet::ssi('cgi-bin/plot.gif?file=$filename'. + '&output=eps'); $result = "$filename.eps"; } } elsif ($target eq 'edit') {