--- loncom/homework/randomlabel.pm 2002/08/27 15:40:07 1.35 +++ loncom/homework/randomlabel.pm 2002/08/27 18:21:27 1.36 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # random labelling tool # -# $Id: randomlabel.pm,v 1.35 2002/08/27 15:40:07 sakharuk Exp $ +# $Id: randomlabel.pm,v 1.36 2002/08/27 18:21:27 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,6 +60,7 @@ package Apache::randomlabel; use Apache::lonnet; use strict; use Apache::edit; +use Apache::File(); BEGIN { &Apache::lonxml::register('Apache::randomlabel',('randomlabel','labelgroup','location','label')); @@ -106,13 +107,32 @@ sub start_randomlabel { $result.="\n"; $result.="\n"; } elsif ($target eq 'tex') { + my $newbgimg = $bgimg; $bgimg=~s/(.gif|.jpg)$/.eps/; $bgimg= &Apache::lonnet::filelocation($bgimg); if (not $ENV{'request.role'}=~/^au\./) { $bgimg=~s/http:\/[^\/]*/\/home\/httpd\/html/; $bgimg=~s/\/$//; + #if no eps file try to replicate it if (not-e $bgimg) { my $response = &Apache::lonnet::repcopy($bgimg); + #if replication failed try to find ps file + if (not-e $bgimg) { + $bgimg=~s/\.eps$/\.ps/; + #if no ps file try to replicate it + if (not-e $bgimg) { + $response = &Apache::lonnet::repcopy($bgimg); + #if replication failed try to produce eps file dynamically + $bgimg=~s/\.ps$/\.eps/; + my $temp_file; + my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat"; + $temp_file = Apache::File->new('>>'.$filename); + $newbgimg =~ s/(.*)\/res\//\/home\/httpd\/html\/res\//; + print $temp_file "$newbgimg\n"; + $bgimg =~ m/\/([^\/]+)$/; + $bgimg = '/home/httpd/prtspool/'.$1; + } + } } } else { $bgimg=~s/http:\/[^\/]*\/~([^\/]+)/\/home\/$1\/public_html/;