Annotation of loncom/homework/imageresponse.pm, revision 1.33
1.12 albertel 1: # The LearningOnline Network with CAPA
1.14 albertel 2: # image click response style
3: #
1.33 ! ng 4: # $Id: imageresponse.pm,v 1.32 2003/07/31 20:38:12 ng Exp $
1.14 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.33 ! ng 28: # July,August 2003 H. K. Ng
! 29: #
1.25 www 30: #FIXME LATER assumes multiple possible submissions but only one is possible
31: #currently
1.3 albertel 32:
1.1 albertel 33: package Apache::imageresponse;
34: use strict;
1.21 harris41 35: use Image::Magick;
1.33 ! ng 36: use GD;
1.1 albertel 37:
1.16 harris41 38: BEGIN {
1.12 albertel 39: &Apache::lonxml::register('Apache::imageresponse',('imageresponse'));
1.1 albertel 40: }
41:
42: sub start_imageresponse {
1.12 albertel 43: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.13 albertel 44: my $result;
1.12 albertel 45: #when in a radiobutton response use these
46: &Apache::lonxml::register('Apache::imageresponse',('foilgroup','foil','text','image','rectangle','conceptgroup'));
47: push (@Apache::lonxml::namespace,'imageresponse');
48: my $id = &Apache::response::start_response($parstack,$safeeval);
1.13 albertel 49: if ($target eq 'meta') {
50: $result=&Apache::response::meta_package_write('imageresponse');
51: }
52: return $result;
1.1 albertel 53: }
54:
55: sub end_imageresponse {
1.30 albertel 56: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
57: &Apache::response::end_response;
58: pop @Apache::lonxml::namespace;
59: &Apache::lonxml::deregister('Apache::imageresponse',('foilgroup','foil','text','image','rectangle','conceptgroup'));
60: my $result;
61: if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
62: return $result;
1.1 albertel 63: }
64:
1.20 albertel 65: %Apache::response::foilgroup=();
1.1 albertel 66: sub start_foilgroup {
1.20 albertel 67: %Apache::response::foilgroup=();
1.12 albertel 68: $Apache::imageresponse::conceptgroup=0;
69: &Apache::response::setrandomnumber();
70: return '';
1.1 albertel 71: }
72:
1.2 albertel 73: sub getfoilcounts {
1.12 albertel 74: my ($parstack,$safeeval)=@_;
75:
76: my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
77: # +1 since instructors will count from 1
78: my $count = $#{ $Apache::response::foilgroup{'names'} }+1;
1.18 albertel 79: if (&Apache::response::showallfoils()) { $max=$count; }
1.12 albertel 80: return ($count,$max);
1.2 albertel 81: }
82:
83: sub whichfoils {
1.12 albertel 84: my ($max)=@_;
85: if (!defined(@{ $Apache::response::foilgroup{'names'} })) { return; }
86: my @names = @{ $Apache::response::foilgroup{'names'} };
87: my @whichopt =();
88: while ((($#whichopt+1) < $max) && ($#names > -1)) {
89: &Apache::lonxml::debug("Have $#whichopt max is $max");
1.18 albertel 90: my $aopt;
91: if (&Apache::response::showallfoils()) {
92: $aopt=0;
93: } else {
1.22 albertel 94: $aopt=int(&Math::Random::random_uniform() * ($#names+1));
1.18 albertel 95: }
1.12 albertel 96: &Apache::lonxml::debug("From $#names elms, picking $aopt");
97: $aopt=splice(@names,$aopt,1);
98: &Apache::lonxml::debug("Picked $aopt");
99: push (@whichopt,$aopt);
100: }
101: return @whichopt;
1.2 albertel 102: }
103:
104: sub displayfoils {
1.24 sakharuk 105: my ($target,@whichopt) = @_;
1.12 albertel 106: my $result ='';
107: my $name;
108: my $temp=1;
109: foreach $name (@whichopt) {
1.24 sakharuk 110: $result.=$Apache::response::foilgroup{"$name.text"};
1.28 albertel 111: &Apache::lonxml::debug("Text is $result");
1.24 sakharuk 112: if ($target eq 'tex') {$result.="\\vskip 0 mm \n";} else {$result.="<br />\n";}
1.12 albertel 113: my $image=$Apache::response::foilgroup{"$name.image"};
1.28 albertel 114: &Apache::lonxml::debug("image is $image");
1.12 albertel 115: if ($Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"} =~ /^correct/ ) {
1.24 sakharuk 116: if ($target eq 'tex') {
117: $result.=$Apache::response::foilgroup{"$name.image"}."\\vskip 0 mm \n";
118: } else {
119: $result.="<img src=\"$image\"/> <br />\n";
120: }
1.12 albertel 121: } else {
1.24 sakharuk 122: if ($target eq 'tex') {
123: $result.=$Apache::response::foilgroup{"$name.image"}."\\vskip 0 mm \n";
124: } else {
125: $result.="<input type=\"image\" name=\"HWVAL_$Apache::inputtags::response['-1']:$temp\" src=\"$image\"/> <br />\n";
126: }
1.12 albertel 127: }
128: $temp++;
129: }
130: return $result;
1.2 albertel 131: }
132:
1.3 albertel 133: sub gradefoils {
1.12 albertel 134: my (@whichopt) = @_;
135: my $x;
136: my $y;
137: my $result;
138: my $id=$Apache::inputtags::response['-1'];
139: my $temp=1;
140: foreach my $name (@whichopt) {
141: $x=$ENV{"form.HWVAL_$id:$temp.x"};
142: $y=$ENV{"form.HWVAL_$id:$temp.y"};
143: &Apache::lonxml::debug("Got a x of $x and a y of $y for $name");
1.29 albertel 144: if (defined($x) && defined($y) &&
145: defined(@{ $Apache::response::foilgroup{"$name.area"} })) {
1.12 albertel 146: my @areas = @{ $Apache::response::foilgroup{"$name.area"} };
147: my $grade="INCORRECT";
148: foreach my $area (@areas) {
149: &Apache::lonxml::debug("Area is $area for $name");
150: $area =~ m/([a-z]*):/;
151: &Apache::lonxml::debug("Area of type $1");
152: if ($1 eq 'rectangle') {
153: $grade=&grade_rectangle($area,$x,$y);
154: } else {
155: &Apache::lonxml::error("Unknown area style $area");
1.9 albertel 156: }
1.12 albertel 157: &Apache::lonxml::debug("Area said $grade");
158: if ($grade eq 'APPROX_ANS') { last; }
159: }
160: &Apache::lonxml::debug("Foil was $grade");
161: if ($grade eq 'INCORRECT') { $result= 'INCORRECT'; }
162: if (($grade eq 'APPROX_ANS') && ($result ne 'APPROX_ANS')) { $result=$grade; }
163: &Apache::lonxml::debug("Question is $result");
164: $temp++;
165: }
166: }
167: $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.submission"}="$x:$y";
168: $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}=$result;
169: return '';
1.3 albertel 170: }
171:
1.1 albertel 172: sub end_foilgroup {
1.12 albertel 173: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
174: my $result='';
175: my @whichopt;
1.24 sakharuk 176: if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') {
1.12 albertel 177: my ($count,$max) = &getfoilcounts($parstack,$safeeval);
178: if ($count>$max) { $count=$max }
179: &Apache::lonxml::debug("Count is $count from $max");
180: @whichopt = &whichfoils($max);
1.28 albertel 181: if ($target eq 'web' || $target eq 'tex') {
182: $result=&displayfoils($target,@whichopt);
183: } elsif ($target eq 'grade') {
184: if ( defined $ENV{'form.submitted'}) { &gradefoils(@whichopt); }
185: }
1.26 albertel 186: } elsif ($target eq 'edit') {
187: $result=&Apache::edit::end_table();
1.12 albertel 188: }
189: return $result;
1.1 albertel 190: }
191:
192: sub start_conceptgroup {
1.12 albertel 193: $Apache::imageresponse::conceptgroup=1;
1.20 albertel 194: %Apache::response::conceptgroup=();
1.12 albertel 195: return '';
1.1 albertel 196: }
197:
198: sub end_conceptgroup {
1.12 albertel 199: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.26 albertel 200: $Apache::imageresponse::conceptgroup=0;
201: my $result;
1.24 sakharuk 202: if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') {
1.12 albertel 203: if (defined(@{ $Apache::response::conceptgroup{'names'} })) {
204: my @names = @{ $Apache::response::conceptgroup{'names'} };
1.22 albertel 205: my $pick=int(&Math::Random::random_uniform() * ($#names+1));
1.12 albertel 206: my $name=$names[$pick];
207: if (defined(@{ $Apache::response::conceptgroup{"$name.area"} })) {
208: push @{ $Apache::response::foilgroup{'names'} }, $name;
209: $Apache::response::foilgroup{"$name.text"} = $Apache::response::conceptgroup{"$name.text"};
210: $Apache::response::foilgroup{"$name.image"} = $Apache::response::conceptgroup{"$name.image"};
211: push(@{ $Apache::response::foilgroup{"$name.area"} }, @{ $Apache::response::conceptgroup{"$name.area"} });
212: my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval);
213: $Apache::response::foilgroup{"$name.concept"} = $concept;
214: &Apache::lonxml::debug("Selecting $name in $concept");
215: }
1.9 albertel 216: }
1.26 albertel 217: } elsif ($target eq 'edit') {
218: $result=&Apache::edit::end_table();
1.12 albertel 219: }
1.26 albertel 220: return $result;
1.31 albertel 221: }
222:
223: sub insert_foil {
224: return '
225: <foil>
226: <image></image>
227: <text></text>
228: <rectangle></rectangle>
229: </foil>
230: ';
1.1 albertel 231: }
232:
1.12 albertel 233: $Apache::imageresponse::curname='';
1.1 albertel 234: sub start_foil {
1.12 albertel 235: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.24 sakharuk 236: if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') {
1.12 albertel 237: my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
238: if ($name eq '') { $name=$Apache::lonxml::curdepth; }
1.18 albertel 239: if ( $Apache::imageresponse::conceptgroup
240: && !&Apache::response::showallfoils()) {
1.12 albertel 241: push(@{ $Apache::response::conceptgroup{'names'} }, $name);
242: } else {
243: push(@{ $Apache::response::foilgroup{'names'} }, $name);
244: }
245: $Apache::imageresponse::curname=$name;
246: }
247: return '';
1.1 albertel 248: }
249:
250: sub end_foil {
1.26 albertel 251: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
252: my $result;
253: if ($target eq 'edit') {
254: $result=&Apache::edit::end_table();
255: }
256: return $result;
1.1 albertel 257: }
258:
259: sub start_text {
1.12 albertel 260: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.25 www 261: my $result='';
262: if ($target eq 'web' || $target eq 'tex') {
263: &Apache::lonxml::startredirection;
264: } elsif ($target eq 'edit') {
1.26 albertel 265: my $descr=&Apache::lonxml::get_all_text('/text',$parser);
1.25 www 266: $result=&Apache::edit::tag_start($target,$token,'Task Description').
267: &Apache::edit::editfield($token->[1],$descr,'Text',60,2).
1.26 albertel 268: &Apache::edit::end_row();
1.25 www 269: } elsif ($target eq "modified") {
1.26 albertel 270: my $descr=&Apache::lonxml::get_all_text('/text',$parser);
1.25 www 271: $result=$token->[4].&Apache::edit::modifiedfield($token);
272: &Apache::lonxml::debug($result);
273: }
274: return $result;
1.1 albertel 275: }
276:
277: sub end_text {
1.12 albertel 278: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.26 albertel 279: my $result;
1.24 sakharuk 280: if ($target eq 'web' || $target eq 'tex') {
1.12 albertel 281: my $name = $Apache::imageresponse::curname;
1.18 albertel 282: if ( $Apache::imageresponse::conceptgroup
283: && !&Apache::response::showallfoils() ) {
1.12 albertel 284: $Apache::response::conceptgroup{"$name.text"} = &Apache::lonxml::endredirection;
285: } else {
286: $Apache::response::foilgroup{"$name.text"} = &Apache::lonxml::endredirection;
1.7 albertel 287: }
1.26 albertel 288: } elsif ($target eq 'edit') {
289: $result=&Apache::edit::end_table();
1.12 albertel 290: }
1.26 albertel 291: return $result;
1.1 albertel 292: }
293:
294: sub start_image {
1.12 albertel 295: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.25 www 296: my $result='';
297: if ($target eq 'web' || $target eq 'tex') {
298: &Apache::lonxml::startredirection;
299: } elsif ($target eq 'edit') {
1.26 albertel 300: my $bgimg=&Apache::lonxml::get_all_text('/image',$parser);
1.27 www 301: $Apache::edit::bgimgsrc=$bgimg;
302: $Apache::edit::bgimgsrcdepth=$Apache::lonxml::curdepth;
303:
1.25 www 304: $result=&Apache::edit::tag_start($target,$token,'Clickable Image').
305: &Apache::edit::editline($token->[1],$bgimg,'Image Source File',40);
306: $result.=&Apache::edit::browse(undef,'textnode').' ';
307: $result.=&Apache::edit::search(undef,'textnode').
1.26 albertel 308: &Apache::edit::end_row();
1.25 www 309: } elsif ($target eq "modified") {
1.26 albertel 310: my $bgimg=&Apache::lonxml::get_all_text('/image',$parser);
1.25 www 311: $result=$token->[4].&Apache::edit::modifiedfield($token);
312: &Apache::lonxml::debug($result);
313: }
314: return $result;
1.1 albertel 315: }
316:
1.33 ! ng 317: sub get_image {
! 318: my ($imgsrc,$set_trans)=@_;
! 319: my $image;
! 320: if ($imgsrc !~ /\.(png|jpg|jpeg)$/i) {
! 321: my $conv_image = Image::Magick->new;
! 322: my $current_figure = $conv_image->Read('filename'=>$imgsrc);
! 323: $conv_image->Set('magick'=>'png');
! 324: my @blobs=$conv_image->ImageToBlob();
! 325: undef $conv_image;
! 326: $image = GD::Image->new($blobs[0]);
! 327: } else {
! 328: GD::Image->trueColor(1);
! 329: $image = GD::Image->new($imgsrc);
! 330: }
! 331: if ($set_trans && defined($image)) {
! 332: my $white=$image->colorExact(255,255,255);
! 333: if ($white != -1) { $image->transparent($white); }
! 334: }
! 335: return $image;
! 336: }
! 337:
1.1 albertel 338: sub end_image {
1.26 albertel 339: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
340: my $result;
1.24 sakharuk 341: my $name = $Apache::imageresponse::curname;
1.12 albertel 342: if ($target eq 'web') {
343: my $image = &Apache::lonxml::endredirection;
1.32 ng 344: &Apache::lonxml::debug("original image is $image");
345: my $id=$Apache::inputtags::response['-1'];
346: my $temp=1;
347: my $x=$ENV{"form.HWVAL_$id:$temp.x"};
348: my $y=$ENV{"form.HWVAL_$id:$temp.y"};
349: if (defined ($x) && defined ($y)) {
350: &Apache::lonxml::debug("x and y defined as $x,$y");
1.33 ! ng 351: my $currentImage = &get_image('/home/httpd/html'.$image,1);
! 352: if (! defined($currentImage)) {
! 353: &Apache::lonnet::logthis('Unable to create image object for '.$image);
! 354: return '';
! 355: }
! 356: my $red;
! 357: if (!($red = $currentImage->colorResolve(255,0,0))) {
! 358: $red = $currentImage->colorClosestHWB(255,0,0);
! 359: }
1.32 ng 360: my $length = 6;
1.33 ! ng 361: $currentImage->line($x-$length,$y-$length,$x+$length,$y+$length,$red);
! 362: $currentImage->line($x-$length,$y+$length,$x+$length,$y-$length,$red);
! 363:
! 364: my ($nameWOext) = ($image =~ /^.*\/(.*)\..*$/);
! 365: &Apache::lonxml::debug("graph name $nameWOext");
! 366: my $webImageName = "/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_".
! 367: $nameWOext.'.png'; #needs to be more random or specific
1.32 ng 368: my $newImageName = '/home/httpd'.$webImageName;
369:
1.33 ! ng 370: my $imgfh = Apache::File->new('>'.$newImageName);
! 371: print $imgfh $currentImage->png;
1.32 ng 372: $image = $webImageName;
373: }
374: &Apache::lonxml::debug("out image is $image");
1.18 albertel 375: if ( $Apache::imageresponse::conceptgroup
376: && !&Apache::response::showallfoils()) {
1.12 albertel 377: $Apache::response::conceptgroup{"$name.image"} = $image;
378: } else {
379: $Apache::response::foilgroup{"$name.image"} = $image;
1.7 albertel 380: }
1.26 albertel 381: } elsif ($target eq 'edit') {
382: $result=&Apache::edit::end_table();
1.19 sakharuk 383: } elsif ($target eq 'tex') {
384: my $src = &Apache::lonxml::endredirection;
385: $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
386: my $width_param = '';
387: my $height_param = '';
388: my $scaling = .3;
389: my $image = Image::Magick->new;
390: my $current_figure = $image->Read($src);
391: $width_param = $image->Get('width') * $scaling;;
392: $height_param = $image->Get('height') * $scaling;;
393: undef $image;
394: my $epssrc = $src;
395: $epssrc =~ s/(\.gif|\.jpg)$/\.eps/i;
396: if (not -e $epssrc) {
397: my $localfile = $epssrc;
398: $localfile =~ s/.*(\/res)/$1/;
399: my $file;
400: my $path;
401: if ($localfile =~ m!(.*)/([^/]*)$!) {
402: $file = $2;
403: $path = $1.'/';
404: }
405: my $signal_eps = 0;
406: my @content_directory = &Apache::lonnet::dirlist($path);
407: for (my $iy=0;$iy<=$#content_directory;$iy++) {
408: my @tempo_array = split(/&/,$content_directory[$iy]);
409: $content_directory[$iy] = $tempo_array[0];
410: if ($file eq $tempo_array[0]) {
411: $signal_eps = 1;
412: last;
413: }
414: }
415: if ($signal_eps) {
416: my $eps_file = &Apache::lonnet::getfile($localfile);
417: } else {
418: $localfile = $src;
419: $localfile =~ s/.*(\/res)/$1/;
420: my $as = &Apache::lonnet::getfile($src);
421: }
422: }
423: my $file;
424: my $path;
425: if ($src =~ m!(.*)/([^/]*)$!) {
426: $file = $2;
427: $path = $1.'/';
428: }
429: my $newsrc = $src;
1.27 www 430: $newsrc =~ s/(\.gif|\.jpg|\.jpeg)$/\.eps/i;
431: $file=~s/(\.gif|\.jpg|\.jpeg)$/\.eps/i;
1.19 sakharuk 432: #do we have any specified size of the picture?
433: my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
434: my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
435: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval);
436: if ($TeXwidth ne '') {
437: $width_param = $TeXwidth;
438: } elsif ($TeXheight ne '') {
439: $width_param = $TeXheight/$height_param*$width_param;
440: } elsif ($width ne '') {
441: $width_param = $width*$scaling;
442: }
443: #where can we find the picture?
444: if (-e $newsrc) {
445: if ($path) {
1.24 sakharuk 446: $Apache::response::foilgroup{"$name.image"} ='\vskip 0 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
1.19 sakharuk 447: }
448: } else {
449: my $temp_file;
450: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
451: $temp_file = Apache::File->new('>>'.$filename);
452: print $temp_file "$src\n";
1.24 sakharuk 453: $Apache::response::foilgroup{"$name.image"} ='\vskip 0 mm \graphicspath{{/home/httpd/prtspool/}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
1.19 sakharuk 454: }
1.24 sakharuk 455: }
1.26 albertel 456: return $result;
1.1 albertel 457: }
458:
459: sub start_rectangle {
1.12 albertel 460: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.25 www 461: my $result='';
462: if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') {
463: &Apache::lonxml::startredirection;
464: } elsif ($target eq 'edit') {
1.26 albertel 465: my $coords=&Apache::lonxml::get_all_text('/rectangle',$parser);
1.25 www 466: $result=&Apache::edit::tag_start($target,$token,'Rectangle').
467: &Apache::edit::editline($token->[1],$coords,'Coordinate Pairs',40).
1.27 www 468: &Apache::edit::entercoordpair(undef,'textnode').
1.26 albertel 469: &Apache::edit::end_row();
1.25 www 470: } elsif ($target eq "modified") {
1.26 albertel 471: my $coords=&Apache::lonxml::get_all_text('/rectangle',$parser);
1.25 www 472: $result=$token->[4].&Apache::edit::modifiedfield($token);
473: &Apache::lonxml::debug($result);
474: }
475: return $result;
1.1 albertel 476: }
477:
1.3 albertel 478: sub grade_rectangle {
1.12 albertel 479: my ($spec,$x,$y) = @_;
480: &Apache::lonxml::debug("Spec is $spec");
481: $spec=~m/rectangle:\(([0-9]+),([0-9]+)\)\-\(([0-9]+),([0-9]+)\)/;
482: my $x1=$1;
483: my $y1=$2;
484: my $x2=$3;
485: my $y2=$4;
486: &Apache::lonxml::debug("Point $x1,$y1,$x2,$y2");
487: if ($x1 > $x2) { my $temp=$x1;$x1=$x2;$x2=$temp; }
488: if ($y1 > $y2) { my $temp=$y1;$y1=$y2;$y2=$temp; }
1.17 albertel 489: if (($x >= $x1) && ($x <= $x2) && ($y >= $y1) && ($y <= $y2)) {
490: return 'APPROX_ANS';
491: }
1.12 albertel 492: return 'INCORRECT';
1.3 albertel 493: }
494:
1.1 albertel 495: sub end_rectangle {
1.12 albertel 496: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.26 albertel 497: my $result;
1.24 sakharuk 498: if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') {
1.12 albertel 499: my $name = $Apache::imageresponse::curname;
500: my $area = &Apache::lonxml::endredirection;
501: &Apache::lonxml::debug("out is $area for $name");
1.18 albertel 502: if ( $Apache::imageresponse::conceptgroup
503: && !&Apache::response::showallfoils()) {
1.12 albertel 504: push @{ $Apache::response::conceptgroup{"$name.area"} },"rectangle:$area";
505: } else {
506: push @{ $Apache::response::foilgroup{"$name.area"} },"rectangle:$area";
1.7 albertel 507: }
1.26 albertel 508: } elsif ($target eq 'edit') {
509: $result=&Apache::edit::end_table();
1.12 albertel 510: }
1.26 albertel 511: return $result;
1.1 albertel 512: }
513: 1;
514: __END__
515:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>