--- loncom/homework/randomlabel.pm	2003/02/07 22:03:21	1.43
+++ 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.43 2003/02/07 22:03:21 albertel 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) {
@@ -139,6 +135,9 @@ sub start_randomlabel {
     }
   } elsif ($target eq 'edit') {
     $result.=&Apache::edit::tag_start($target,$token);
+    $Apache::edit::bgimgsrc=
+	&Apache::lonxml::get_param('bgimg',$parstack,$safeeval);
+    $Apache::edit::bgimgsrccurdepth=$Apache::lonxml::curdepth;
     $result.=&Apache::edit::text_arg('Image:','bgimg',$token,75).' ';
     $result.=&Apache::edit::browse('bgimg').' ';
     $result.=&Apache::edit::search('bgimg').'<br />'.
@@ -177,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;
   }
@@ -345,6 +341,7 @@ sub start_location {
     $result.=&Apache::edit::tag_start($target,$token);
     $result.=&Apache::edit::text_arg('X:','x',$token,4).
       &Apache::edit::text_arg('Y:','y',$token,4).
+      &Apache::edit::entercoords('x','y','attribute','width','height').'&nbsp;&nbsp;&nbsp;'.
 	&Apache::edit::text_arg('Value:','value',$token).
 	  &Apache::edit::end_row();
     $result.=&Apache::edit::end_table;