--- loncom/homework/randomlabel.pm 2003/05/06 11:54:08 1.44 +++ loncom/homework/randomlabel.pm 2003/06/19 22:23:10 1.46 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # random labelling tool # -# $Id: randomlabel.pm,v 1.44 2003/05/06 11:54:08 www Exp $ +# $Id: randomlabel.pm,v 1.46 2003/06/19 22:23:10 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -99,19 +99,18 @@ sub start_randomlabel { &Apache::lonxml::startredirection(); $result.="BGIMG=".&Apache::lonnet::escape($bgimg); } elsif ($target eq 'tex') { - my $newbgimg = $bgimg; - $bgimg=~s/\.(gif|jpg|png|jpeg)$/\.eps/i; - $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) { - if (&Apache::lonnet::repcopy($bgimg) ne OK ) { - #if replication failed try to find ps file - $bgimg=~s/\.eps$/\.ps/; - #if no ps file try to replicate it - if (not-e $bgimg && + my $newbgimg = $bgimg; + $bgimg=~s/\.(gif|jpg|png|jpeg)$/\.eps/i; + $bgimg= &Apache::lonnet::filelocation($bgimg); + $bgimg=~s/http:\/[^\/]*/\/home\/httpd\/html/; + $bgimg=~s/\/$//; + #if no eps file try to replicate it + if (not-e $bgimg) { + if (&Apache::lonnet::repcopy($bgimg) ne OK ) { + #if replication failed try to find ps file + $bgimg=~s/\.eps$/\.ps/; + #if no ps file try to replicate it + if (not -e $bgimg && &Apache::lonnet::repcopy($bgimg) ne OK) { #if replication failed try to produce eps file dynamically $bgimg=~s/\.ps$/\.eps/; @@ -123,11 +122,8 @@ sub start_randomlabel { $bgimg =~ m/\/([^\/]+)$/; $bgimg = '/home/httpd/prtspool/'.$1; } - } - } - } else { - $bgimg=~s/http:\/[^\/]*\/~([^\/]+)/\/home\/$1\/public_html/; - } + } + } $bgimg=~s/\/$//; my $dirtywidth=$texwidth+5; if ($texwidth==90) { @@ -180,14 +176,11 @@ sub end_randomlabel { &Apache::lonnet::appenv(("imagerequest.$token"=>&Apache::lonnet::escape($args))); } elsif ($target eq 'tex') { $result='\end{picture}\\\\'; - @$parstack[-1]=~/\$height\s*=\s*?"(.+)?"/; - my $one=$1; - @$parstack[-1]=~/\$width\s*=\s*?"(.+)?"/; - my $two=$1; - @$parstack[-1]=~/\$texwidth\s*=\s*?"(.+)?"/; - my $three=$1; - my $howtoskipback = $three*$one/$two; - $result.=' \vskip -'.$howtoskipback.' mm }'; + my $height=&Apache::lonxml::get_param('height',$parstack,$safeeval); + my $width=&Apache::lonxml::get_param('width',$parstack,$safeeval); + my $texwidth=&Apache::lonxml::get_param('texwidth',$parstack,$safeeval); + my $howtoskipback = $texwidth*$height/$width; + $result.= ' \vskip -'.$howtoskipback.' mm } \\\\ '; } elsif ($target eq 'edit') { $result.=&Apache::edit::end_table; }