Annotation of loncom/homework/randomlabel.pm, revision 1.73
1.1 tsai 1: # The LearningOnline Network with CAPA
2: # random labelling tool
1.8 albertel 3: #
1.73 ! foxr 4: # $Id: randomlabel.pm,v 1.72 2005/04/18 21:41:51 foxr Exp $
1.8 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.1 tsai 28: # SYNTAX:
1.4 albertel 29: # <randomlabel bgimg="URL" width="12" height="45" texwidth="50">
30: # <labelgroup name="GroupOne" type="image">
31: # <location x="123" y="456" />
32: # <location x="321" y="654" />
33: # <location x="213" y="546" />
34: # <label description="TEXT-1">IMG-URL</label>
35: # <label description="TEXT-2">IMG-URL</label>
36: # <label description="TEXT-3">IMG-URL</label>
1.1 tsai 37: # </labelgroup>
1.4 albertel 38: # <labelgroup name="GroupTwo" type="text">
39: # <location x="12" y="45" />
40: # <location x="32" y="65" />
41: # <location x="21" y="54" />
1.3 tsai 42: # <label>TEXT-1</label>
43: # <label>TEXT-2</label>
44: # <label>TEXT-3</label>
1.1 tsai 45: # </labelgroup>
46: # </randomlabel>
47: # ===========================================
1.3 tsai 48: # side effect:
49: # location (123,456): $GroupOne[0] = 2 # images give out indexes
50: # (321,654): $GroupOne[1] = 1
51: # (213,546): $GroupOne[2] = 0
52: # location (12,45) : $GroupTwo[0] = "TEXT-3"
53: # (32,65) : $GroupTwo[1] = "TEXT-1"
54: # (21,54) : $GroupTwo[2] = "TEXT-2"
1.1 tsai 55: # ===========================================
56: package Apache::randomlabel;
1.24 sakharuk 57: use Apache::lonnet;
1.1 tsai 58: use strict;
1.13 sakharuk 59: use Apache::edit;
1.36 sakharuk 60: use Apache::File();
1.38 sakharuk 61: use Apache::Constants qw(:common :http);
1.72 foxr 62: use Image::Magick;
1.73 ! foxr 63: use Apache::lonplot;
1.1 tsai 64:
1.53 albertel 65: my %args;
66: my $cgi_id;
1.73 ! foxr 67: my $scale_factor; # image scale factor.
1.53 albertel 68:
1.13 sakharuk 69: BEGIN {
1.57 albertel 70: &Apache::lonxml::register('Apache::randomlabel',('randomlabel','labelgroup','location','label','bgimg'));
1.1 tsai 71: }
72:
1.23 matthew 73: sub check_int {
74: # utility function to do error checking on a integer.
75: my ($num,$default) = @_;
76: $default = 100 if (! defined($default));
77: $num =~ s/\s+//g; # We dont need no stinkin white space!
78: # If it is a real, just grab the integer part.
79: ($num,undef) = split (/\./,$num) if ($num =~ /\./);
80: # set to default if what we have left doesn't match anything...
81: $num = $default unless ($num =~/^\d+$/);
82: return $num;
83: }
84:
1.64 albertel 85: my ($height_param,$width_param);
1.1 tsai 86: sub start_randomlabel {
1.47 albertel 87: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
88: my $result='';
89: push (@Apache::lonxml::namespace,'randomlabel');
1.64 albertel 90: ($height_param,$width_param)=(0,0);
1.47 albertel 91: my $bgimg= &Apache::lonxml::get_param('bgimg',$parstack,$safeeval);
1.60 albertel 92: if ( defined($bgimg) && $bgimg !~ /^http:/ ) {
1.47 albertel 93: $bgimg=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$bgimg);
1.66 raeburn 94: if (&Apache::lonnet::repcopy($bgimg) ne 'ok') {
1.47 albertel 95: $bgimg='/home/httpd/html/adm/lonKaputt/lonlogo_broken.gif';
96: }
1.42 www 97: }
1.59 albertel 98: $Apache::randomlabel::obj_cnt=0;
1.47 albertel 99: if ($target eq 'web') {
1.53 albertel 100: $cgi_id=&Apache::loncommon::get_cgi_id();
101: %args=();
102: $args{"cgi.$cgi_id.BGIMG"}=&Apache::lonnet::escape($bgimg);
1.64 albertel 103: } elsif ($target eq 'tex' && defined($bgimg)) {
104: $result.=&make_eps_image($bgimg,$parstack,$safeeval);
1.47 albertel 105: } elsif ($target eq 'edit') {
106: $result.=&Apache::edit::tag_start($target,$token);
107: $Apache::edit::bgimgsrc=
108: &Apache::lonxml::get_param('bgimg',$parstack,$safeeval);
109: $Apache::edit::bgimgsrccurdepth=$Apache::lonxml::curdepth;
110: $result.=&Apache::edit::text_arg('Image:','bgimg',$token,75).' ';
111: $result.=&Apache::edit::browse('bgimg').' ';
112: $result.=&Apache::edit::search('bgimg').'<br />'.
113: &Apache::edit::text_arg('Width(pixel):' ,'width' ,$token,6).
114: &Apache::edit::text_arg('Height(pixel):','height' ,$token,6).
115: &Apache::edit::text_arg('TeXWidth(mm):' ,'texwidth',$token,6).
116: &Apache::edit::end_row().&Apache::edit::start_spanning_row();
117: } elsif ($target eq 'modified') {
118: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
119: $safeeval,'bgimg','width',
120: 'height','texwidth');
121: if ($constructtag) {
122: $result = &Apache::edit::rebuild_tag($token);
123: $result.=&Apache::edit::handle_insert();
124: }
1.31 sakharuk 125: }
1.47 albertel 126: return $result;
1.1 tsai 127: }
128:
129: sub end_randomlabel {
1.47 albertel 130: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
131: my $result='';
132: my $count;
133: pop @Apache::lonxml::namespace;
134: if ($target eq 'web') {
1.59 albertel 135: $count = $Apache::randomlabel::obj_cnt;
136: if( $count != 0) { $args{"cgi.$cgi_id.OBJCOUNT"}=$count; }
1.53 albertel 137: $result.='<img src="/adm/randomlabel.png?token='.$cgi_id.'" /><br />'."\n";
138: &Apache::lonnet::appenv(%args);
1.47 albertel 139: } elsif ($target eq 'tex') {
140: $result='\end{picture}\\\\';
1.64 albertel 141: $result.= ' \vskip -'.$height_param.' mm } \\\\ ';
1.47 albertel 142: } elsif ($target eq 'edit') {
143: $result.=&Apache::edit::end_table;
144: }
145: return $result;
1.1 tsai 146: }
147:
1.57 albertel 148: sub start_bgimg {
149: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
150: my $result='';
151: if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
1.64 albertel 152: &Apache::lonxml::startredirection();
1.57 albertel 153: }
154: return $result;
155: }
156:
157: sub end_bgimg {
158: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
159: my $result='';
160: if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
1.64 albertel 161: my $bgimg=&Apache::lonxml::endredirection();
1.57 albertel 162: if ($target eq 'web') {
163: $bgimg=&Apache::imageresponse::clean_up_image($bgimg);
164: $args{"cgi.$cgi_id.BGIMG"}=&Apache::lonnet::escape($bgimg);
165: } elsif ($target eq 'tex') {
1.73 ! foxr 166: # Some bg images can create latex for us... e.g. gnuplot.
! 167: # If it looks like we have some latex use that,
! 168: # otherwise, assume this is a resource name that must
! 169: # be converted into the latex to create an eps insertion.
! 170: #
! 171: my $src = $bgimg;
! 172: $src =~ s/\s+$//s;
! 173: $src =~ s/^\s+//s;
! 174:
! 175:
! 176: if ($src =~ /^\\graphicspath/) {
! 177: $height_param = $Apache::lonplot::plot{'height'}*0.3;
! 178: $width_param = $Apache::lonplot::plot{'width'}*0.3;
! 179: &Apache::lonxml::debug("height $height_param");
! 180: &Apache::lonxml::debug("Width $width_param");
! 181: $scale_factor=1.0;
! 182: my $dirty_width = $width_param + 5;
! 183: $result .= '\parbox{'.$dirty_width.'mm}{';
! 184: $result .= $src;
! 185: $result .= '\begin{picture}('."$height_param,$width_param)";
! 186: $result .= "(0,-$height_param)";
! 187: } else {
! 188:
! 189:
! 190: $result.=&make_eps_image($bgimg,$parstack,$safeeval,-2);
! 191: }
1.57 albertel 192: }
193: }
194: return $result;
195: }
196: sub make_eps_image {
1.64 albertel 197: my ($bgimg,$parstack,$safeeval,$depth)=@_;
1.73 ! foxr 198: &Apache::lonxml::debug("image prior to get_eps_image: $bgimg");
1.64 albertel 199: my ($path,$file) = &Apache::londefdef::get_eps_image($bgimg);
1.73 ! foxr 200: &Apache::lonxml::debug("image after: $bgimg");
1.64 albertel 201: ($height_param,$width_param)=
202: &Apache::londefdef::image_size($bgimg,0.3,$parstack,$safeeval,
203: $depth,1);
1.73 ! foxr 204:
! 205: &Apache::lonxml::debug("Image size: $height_param x $width_param");
! 206:
1.64 albertel 207: my $dirtywidth=$width_param+5;
1.68 foxr 208: my $result ="\n".'\vspace*{2mm}\noindent'."\n".
209: '\parbox{'.$dirtywidth.
1.64 albertel 210: ' mm}{ \noindent \epsfxsize='.$width_param.
211: ' mm \epsffile{'.$path.$file.
1.68 foxr 212: '}\setlength{\unitlength}{1mm}'."\n".' \begin{picture}('.
213: $width_param.','.$height_param.')(0,-'.$height_param.')'."\n";
1.72 foxr 214: my $magick = Image::Magick->new;
215: $magick->Read($bgimg);
216: my $initial_width = $magick->Get('width');
1.73 ! foxr 217: &Apache::lonxml::debug("ImageMagick thinks width is; $initial_width");
1.72 foxr 218: $scale_factor = $width_param / $initial_width;
1.57 albertel 219: return $result;
220: }
221:
1.1 tsai 222: sub start_labelgroup {
1.47 albertel 223: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
224: my $result='';
225: my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
226: my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval);
227: $type =~tr/A-Z/a-z/;
1.48 albertel 228: if ($target ne 'modified' && ($name =~ /\W/ || $name =~ /^[0-9]/)) {
229: &Apache::lonxml::error("Only _ a-z A-Z and 0-9 are allowed in the name to a labelgroup, and the first character can not be a number.<br />");
230: }
1.47 albertel 231: if ($target eq 'web' || $target eq 'tex' ||
232: $target eq 'grade' || $target eq 'answer' || $target eq 'analyze') {
233: $Apache::randomlabel::groupname=$name;
234: $Apache::randomlabel::type=$type;
235: @Apache::randomlabel::xcoord = ();
236: @Apache::randomlabel::ycoord = ();
237: @Apache::randomlabel::value = ();
238: @Apache::randomlabel::label_arr = ();
1.68 foxr 239: @Apache::randomlabel::description = ();
1.47 albertel 240: } elsif ($target eq 'edit') {
241: $result.=&Apache::edit::tag_start($target,$token);
242: $result.=&Apache::edit::text_arg('Name:','name',$token).
1.63 albertel 243: &Apache::edit::select_arg('Type:','type',['text','image'],$token);
244: if (!defined($token->[2]{'TeXsize'})) {
245: $token->[2]{'TeXsize'}='\normalsize';
246: }
247: $result.=&Apache::edit::select_arg('TeX font size:','TeXsize',
248: ['\tiny','\scriptsize',
249: '\footnotesize','\small',
250: '\normalsize','\large','\Large',
251: '\LARGE','\huge','\Huge'],
252: $token);
253: $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
1.47 albertel 254: } elsif ($target eq 'modified') {
255: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
1.63 albertel 256: $safeeval,'name','type',
257: 'TeXsize');
1.47 albertel 258: if ($constructtag) {
259: $result = &Apache::edit::rebuild_tag($token);
260: $result.=&Apache::edit::handle_insert();
261: }
1.4 albertel 262: }
1.47 albertel 263: return $result;
1.1 tsai 264: }
265:
1.72 foxr 266: #
267: # Utility sub to compute the width of a label.
268: #
269: sub get_label_width {
270: my $label = shift;
271: &Apache::lonxml::debug("image label = $label");
272: if (-e $label) {
273: &Apache::lonxml::debug("$label exists");
274: } else {
275: &Apache::lonxml::debug("$label does not exist");
276: }
277: my $magick = Image::Magick->new;
278: $magick->Read($label);
279: my $pixel_width = $magick->Get('width');
280: return $pixel_width * $scale_factor;
281:
282:
283: }
1.5 albertel 284: sub add_vars {
1.47 albertel 285: my ($name,$order,$label,$labelorder,$value,$image,$safeeval) = @_;
1.61 albertel 286: if (!defined($name) || $name eq '') { return; }
1.47 albertel 287: my $code = '${'.$name."}{'".($order+1)."'}='".$label."';";
288: my $out=Apache::run::run($code,$safeeval);
289: if ($value) {
290: $code = '${'.$name."}{'value_".($order+1)."'}='".$value."';";
291: $out=Apache::run::run($code,$safeeval);
292: $code = '${'.$name."}{'labelvalue_".($labelorder+1)."'}='".$value."';";
293: $out=Apache::run::run($code,$safeeval);
294: }
295: if ($image) {
296: my $code = '${'.$name."}{'image_".($order+1)."'}='".$image."';";
297: my $out=Apache::run::run($code,$safeeval);
298: }
299: $code = '${'.$name."}{'numlocations'}='".($order+1)."';";
1.5 albertel 300: $out=Apache::run::run($code,$safeeval);
1.4 albertel 301: }
1.5 albertel 302:
1.1 tsai 303: # begin to assign labels to locations
304: sub end_labelgroup {
1.47 albertel 305: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
306: my $gname = $Apache::randomlabel::groupname;
307: my $type = $Apache::randomlabel::type;
308: my $result='';
309: if ($target eq 'web' || $target eq 'answer' || $target eq 'grade' ||
310: $target eq 'analyze') {
311: my @idx_arr = (0 .. $#Apache::randomlabel::label_arr);
312: &Apache::structuretags::shuffle(\@idx_arr);
313: for(0 .. $#Apache::randomlabel::label_arr) {
314: my $str;
315: my $label = "$Apache::randomlabel::label_arr[ $idx_arr[$_] ]";
316: my $x = $Apache::randomlabel::xcoord[$_];
317: my $y = $Apache::randomlabel::ycoord[$_];
318: my $value = $Apache::randomlabel::value[$_];
1.59 albertel 319: my $i=$Apache::randomlabel::obj_cnt++;
1.47 albertel 320: if( $type eq 'text') {
321: &add_vars($gname,$_,$label,$idx_arr[$_],$value,'',$safeeval);
1.59 albertel 322: $str = join(':',$x,$y,&Apache::lonnet::escape($label));
323: $args{"cgi.$cgi_id.OBJTYPE"}.='LABEL:';
1.47 albertel 324: } elsif ( $type eq 'image') {
325: &add_vars($gname,$_,
326: $Apache::randomlabel::description[$idx_arr[$_]],
327: $idx_arr[$_],$value,$label,$safeeval);
1.59 albertel 328: $str = join(':',$x,$y,&Apache::lonnet::escape($label));
329: $args{"cgi.$cgi_id.OBJTYPE"}.='IMAGE:';
1.47 albertel 330: } else {
331: &Apache::lonxml::error('Unknown type of label :'.$type.':');
332: }
1.59 albertel 333: if ($target eq 'web') { $args{"cgi.$cgi_id.OBJ$i"} =$str; }
1.47 albertel 334: }
335: } elsif ($target eq 'tex') {
336: my $WX1=0; # Web x-coord. of upper left corner (ULC)
337: my $WY1=0; # Web y-coord. of (ULC)
338: my $wwidth=&Apache::lonxml::get_param('width',$parstack,$safeeval,-2);
339: my $wheight=&Apache::lonxml::get_param('height',$parstack,$safeeval,-2);
1.63 albertel 340: my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
341: if (!defined($TeXsize)) { $TeXsize='\\normalsize'; }
1.62 albertel 342:
1.47 albertel 343: my @idx_arr = (0 .. $#Apache::randomlabel::label_arr);
344: &Apache::structuretags::shuffle(\@idx_arr);
345:
346: &Apache::lonxml::debug("Array is:".$#Apache::randomlabel::label_arr.":");
347: for(my $i=0;$i <= $#Apache::randomlabel::label_arr; $i++) {
348: my $label = "$Apache::randomlabel::label_arr[ $idx_arr[$i] ]";
349: my $x = $Apache::randomlabel::xcoord[$i];
1.62 albertel 350: # FIXME the 3.5 here is the 'height' of the letter in TeX
351: my $y = $Apache::randomlabel::ycoord[$i]-3.5;
1.47 albertel 352: my $value = $Apache::randomlabel::value[$i];
353: #x latex coordinate
1.64 albertel 354: my $tcX=($x)*($width_param/$wwidth);
1.47 albertel 355: #y latex coordinate
356: # my $ratio=($wwidth > 0 ? $wheight/$wwidth : 1 );
1.64 albertel 357: my $tcY=$height_param-$y*($height_param/$wheight);
1.47 albertel 358: $tcX=sprintf('%.2f',$tcX);
359: $tcY=sprintf('%.2f',$tcY);
1.70 foxr 360: $result .= '\put('.$tcX.','.$tcY.'){';
1.47 albertel 361: if( $type eq 'text') {
1.70 foxr 362: $result.= $TeXsize.' \bf '.$label."}\n";
1.47 albertel 363: &add_vars($gname,$i,$label,$idx_arr[$i],$value,'',$safeeval);
364: } elsif ( $type eq 'image') {
1.71 foxr 365: my ($path,$file) = &Apache::londefdef::get_eps_image($label);
366: my $image_name = $path.$file;
1.72 foxr 367: my $label_width = get_label_width($label);
368:
369: $result .= '\includegraphics[width='.$label_width.'mm]{'
1.71 foxr 370: .$image_name."}}\n";
1.47 albertel 371: &add_vars($gname,$i,
372: $Apache::randomlabel::description[$idx_arr[$i]],
373: $idx_arr[$i],$value,$label,$safeeval);
374: } else {
375: &Apache::lonxml::error('Unknown type of label :'.$type.':');
376: }
377: }
378: } elsif ($target eq 'edit') {
379: $result.=&Apache::edit::end_table;
1.3 tsai 380: }
1.47 albertel 381: return $result;
1.1 tsai 382: }
383:
1.5 albertel 384: # <location x="123" y="456" value="some value"/>
1.1 tsai 385: sub start_location {
1.47 albertel 386: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
387: my $x= &check_int(&Apache::lonxml::get_param('x',$parstack,$safeeval),50);
388: my $y= &check_int(&Apache::lonxml::get_param('y',$parstack,$safeeval),50);
389: my $value= &Apache::lonxml::get_param('value',$parstack,$safeeval);
390: my $result='';
391: push(@Apache::randomlabel::xcoord,$x);
392: push(@Apache::randomlabel::ycoord,$y);
393: push(@Apache::randomlabel::value,$value);
394: if ($target eq 'edit') {
395: $result.=&Apache::edit::tag_start($target,$token);
396: $result.=&Apache::edit::text_arg('X:','x',$token,4).
397: &Apache::edit::text_arg('Y:','y',$token,4).
398: &Apache::edit::entercoords('x','y','attribute','width','height').' '.
399: &Apache::edit::text_arg('Value:','value',$token).
400: &Apache::edit::end_row();
401: $result.=&Apache::edit::end_table;
402: } elsif ($target eq 'modified') {
403: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
404: $safeeval,'x','y','value');
405: if ($constructtag) {
406: $result = &Apache::edit::rebuild_tag($token);
407: $result.=&Apache::edit::handle_insert();
408: }
1.4 albertel 409: }
1.47 albertel 410: return $result;
1.1 tsai 411: }
412:
413: sub end_location {
1.47 albertel 414: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
415: my @result;
416: if ($target eq 'edit') { @result=('','no') }
417: return @result;
1.1 tsai 418: }
419:
1.2 tsai 420: # <label>$var_abc</label>
1.1 tsai 421: sub start_label {
1.47 albertel 422: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
423: my $result='';
424: my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval,-2);
425: if ($target eq 'web' || $target eq 'tex' ||
426: $target eq 'grade' || $target eq 'answer' || $target eq 'analyze') {
1.57 albertel 427: &Apache::lonxml::startredirection;
1.47 albertel 428: } elsif ($target eq 'edit') {
429: $result.=&Apache::edit::tag_start($target,$token,"$type Label");
430: my $text=&Apache::lonxml::get_all_text("/label",$parser);
431: if ($type eq 'image') {
432: $result.=&Apache::edit::end_row().
433: &Apache::edit::start_spanning_row();
434: $result.=&Apache::edit::text_arg('Description:','description',
435: $token);
436: }
437: if ($type eq 'text') { $result.="Label Text:"; }
438: if ($type eq 'image') { $result.="Path to image: "; }
439: $result.=&Apache::edit::editline('',$text,'',50).
440: &Apache::edit::end_table();
441: } elsif ($target eq 'modified') {
442: $result = '<label>';
443: if ($type eq 'image') {
444: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
445: $safeeval,
446: 'description');
447: if ($constructtag) {
448: $result = &Apache::edit::rebuild_tag($token);
449: } else {
450: $result = $token->[4];
451: }
452: }
1.52 albertel 453: $result.=&Apache::edit::modifiedfield("/label",$parser);
1.26 albertel 454: }
1.47 albertel 455: return $result;
1.1 tsai 456: }
457:
458: sub end_label {
1.47 albertel 459: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
460: my @result;
1.57 albertel 461: if ($target eq 'edit') {
462: @result=('','no') ;
463: } elsif ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
464: $target eq 'answer' || $target eq 'analyze') {
465: my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval,-2);
466: my $ltext=&Apache::lonxml::endredirection;
467: if ($type eq 'image') {
1.70 foxr 468: if ($target eq 'tex') {
469: # For tex targets, our image url has been potentially corrupted
470: # by prepending \'s in front of special latex symbols.
471: # For now we only worry about the _ case (most common?)
472: # There's a whole host of theim in lonxml::latex_special_symbols
473: # that could potentially have to be re-done.
474:
475: $ltext =~ s/\\_/_/g;
476: }
1.57 albertel 477: &Apache::lonxml::debug("Turning $ltext, $Apache::lonxml::pwd[-1]");
478: $ltext=&Apache::imageresponse::clean_up_image($ltext);
479: # $ltext=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],
480: # $ltext);
481: &Apache::lonxml::debug("into $ltext");
482: my $description = &Apache::lonxml::get_param('description',
483: $parstack,$safeeval);
484: push(@Apache::randomlabel::description,$description);
1.61 albertel 485: } else {
486: $ltext=~s/[\r\n]*//gs
1.57 albertel 487: }
488: push(@Apache::randomlabel::label_arr,$ltext);
489: }
1.47 albertel 490: return @result;
1.1 tsai 491: }
492:
493: 1;
494: __END__
495:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>