--- loncom/homework/randomlabel.pm 2002/07/22 17:15:55 1.31
+++ 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.31 2002/07/22 17:15:55 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,21 +107,44 @@ sub start_randomlabel {
$result.="\n
";
} elsif ($target eq 'tex') {
- $result='\end{picture}\\\\';
- if (@$parstack[-1]=~/\$texwidth\s*=\s*?"90/) { #"
+ $result='\end{picture}\\\\}';
@$parstack[-1]=~/\$height\s*=\s*?"(.+)?"/;
- my $howtoskipback = $1/45;
- $result.=' \vskip -'.$howtoskipback.' cm ';
- }
+ 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 ';
} elsif ($target eq 'edit') {
$result.=&Apache::edit::end_table;
}
@@ -283,10 +310,10 @@ sub end_labelgroup {
my $y = $Apache::randomlabel::ycoord[$i];
my $value = $Apache::randomlabel::value[$i];
#x latex coordinate
- my $tcX=($x-5)*($texwidth/$wwidth);
+ my $tcX=($x)*($texwidth/$wwidth);
#y latex coordinate
- my $ratio=($wwidth > 0 ? $wheight/$wwidth : 1 );
- my $tcY=$TY1-$y*($TY1/$wheight)+$texwidth*$ratio;
+# my $ratio=($wwidth > 0 ? $wheight/$wwidth : 1 );
+ my $tcY=$TY1-$y*($TY1/$wheight);
$tcX=sprintf('%.2f',$tcX);
$tcY=sprintf('%.2f',$tcY);
$result.='\put('.$tcX.','.$tcY.'){\normalsize \bf '.$label.'}'."\n";