--- loncom/xml/lonplot.pm 2001/12/20 20:24:36 1.11 +++ loncom/xml/lonplot.pm 2001/12/21 15:27:29 1.13 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Dynamic plot # -# $Id: lonplot.pm,v 1.11 2001/12/20 20:24:36 matthew Exp $ +# $Id: lonplot.pm,v 1.13 2001/12/21 15:27:29 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -34,7 +34,7 @@ use Apache::File; use Apache::response; use Apache::lonxml; -use Digest::MD5 qw(md5 md5_hex md5_base64); +use Digest::MD5 qw(md5_base64); sub BEGIN { &Apache::lonxml::register('Apache::lonplot',('plot')); @@ -116,9 +116,9 @@ my %axis_defaults = my %curve_defaults = ( - color => {default => 'x000000', test => $color_test }, - name => {default => 'x000000', test => sub {1} },#sub {$_[0]=~/^[\w ]*$/} }, - linestyle => {default => 'lines', test => $linestyle_test } + color => {default => 'x000000', test => $color_test }, + name => {default => '', test => $words_test }, + linestyle => {default => 'lines', test => $linestyle_test } ); ## @@ -155,20 +155,32 @@ sub end_plot { ('title','xlabel','ylabel','key','axis','label','curve')); my $result = ''; if ($target eq 'web') { - ## Determine filename -- Need to use the 'id' thingy that Gerd - ## mentioned. + ## + ## Make sure we have all the input we need: + if (! defined(%plot )) { &set_defaults(\%plot,\%plot_defaults); } + if (! defined(%key )) {} # No key for this plot + if (! defined(%axis )) { &set_defaults(\%axis,\%axis_defaults); } + if (! defined($title )) {} # No title for this plot + if (! defined($xlabel)) {} # No xlabel for this plot + if (! defined($ylabel)) {} # No ylabel for this plot + if ($#labels < 0) { } # No labels for this plot + if ($#curves < 0) { } # This is an error + ## + ## Determine filename my $tmpdir = '/home/httpd/perl/tmp/'; - my $filename = $tmpdir.$ENV{'user.name'}.'_'.$ENV{'user.domain'}. - '_plot.data'; - my $usersees=md5_base64($filename.'_'.$ENV{'REMOTE_ADDR'}); - + my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}. + '_'.time.'_'.$$.'_plot.data'; ## Write the plot description to the file - my $fh=Apache::File->new('/home/httpd/perl/tmp/'.$filename); + my $fh=Apache::File->new(">$tmpdir$filename"); $result .= '
'; - $result .= &write_gnuplot_file($fh); + $result .= $filename.$/; + print $fh &write_gnuplot_file(); $result .= ''.$/; ## return image tag for the plot - $result .= '