1: # The LearningOnline Network with CAPA
2: # <script> definiton
3: #
4: # $Id: scripttag.pm,v 1.123 2005/02/24 01:21:50 albertel Exp $
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: #
28:
29: package Apache::scripttag;
30:
31: use strict;
32: use Apache::lonnet;
33: use Apache::style;
34: use AlgParser;
35:
36: #Globals
37: # this used to pass around the standard callsub arguments to a tag func
38: # so xmlparse can reenter the inner_xmlparse loop.
39:
40: @Apache::scripttag::parser_env = ();
41: BEGIN {
42: &Apache::lonxml::register('Apache::scripttag',
43: ('script','scriptlib','parserlib','import',
44: 'window','display','storetc','physnet',
45: 'standalone','comment','num','parse','algebra',
46: 'LONCAPA_INTERNAL_TURN_STYLE_ON',
47: 'LONCAPA_INTERNAL_TURN_STYLE_OFF',
48: 'LONCAPA_INTERNAL_LONHTTPD_PORT'));
49: }
50:
51: sub start_LONCAPA_INTERNAL_TURN_STYLE_ON {
52: $Apache::lonxml::usestyle=1;
53: $Apache::lonxml::style_values='';
54: return ('','no');
55: }
56:
57: sub end_LONCAPA_INTERNAL_TURN_STYLE_ON {
58: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
59: my $end=&Apache::lonxml::get_param('end',$parstack,$safeeval);
60: if (defined($end)) {
61: &Apache::lonxml::end_tag($tagstack,$parstack,$token);
62: }
63: return ('','no');
64: }
65:
66: sub start_LONCAPA_INTERNAL_TURN_STYLE_OFF {
67: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
68: $Apache::lonxml::usestyle=0;
69: my $end=&Apache::lonxml::get_param('end',$parstack,$safeeval);
70: if (!$end) {
71: $Apache::lonxml::style_values=$$parstack[-1];
72: $Apache::lonxml::style_end_values=$$parstack[-1];
73: } else {
74: $Apache::lonxml::style_values=$Apache::lonxml::style_end_values;
75: $Apache::lonxml::style_end_values='';
76: }
77: return ('','no');
78: }
79:
80: sub end_LONCAPA_INTERNAL_TURN_STYLE_OFF {
81: return ('','no');
82: }
83:
84: sub start_LONCAPA_INTERNAL_LONHTTPD_PORT {
85: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
86: if ($target eq 'web') {
87: my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
88: if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
89: return '<script type="text/javascript">var lonhttpdport=\''.
90: $lonhttpdPort.'\';</script>';
91: }
92: return ('','no');
93: }
94:
95: sub end_LONCAPA_INTERNAL_LONHTTPD_PORT {
96: return ('','no');
97: }
98:
99: sub start_script {
100: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
101: @Apache::scripttag::parser_env = @_;
102: my $result='';
103: my $type= &Apache::lonxml::get_param('type',$parstack,$safeeval);
104: &Apache::lonxml::debug("found type of $type");
105: if ($type eq "loncapa/perl") {
106: if ( $target eq "modified" ) {
107: $result=$token->[4].&Apache::edit::modifiedfield('/script',$parser);
108: } elsif ( $target eq 'web' || $target eq 'tex' ||
109: $target eq 'grade' || $target eq 'answer' ||
110: $target eq 'analyze' ) {
111: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
112: if (!$Apache::lonxml::default_homework_loaded) {
113: &Apache::lonxml::default_homework_load($safeeval);
114: }
115: &Apache::run::run($bodytext,$safeeval);
116: if (($target eq 'answer') &&
117: ($ENV{'form.answer_output_mode'} ne 'tex') &&
118: ($Apache::lonhomework::viewgrades == 'F')) {
119: $Apache::lonxml::evaluate--;
120: my (undef,undef,$udom,$uname)=&Apache::lonxml::whichuser();
121: my $windowopen=&Apache::lonhtmlcommon::javascript_docopen();
122: $result.="<script type=\"text/javascript\">
123: // <!--
124: function LONCAPA_scriptvars_".$uname."_".$udom."_"."$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.$windowopen;newWindow.document.writeln('<html><head><title>Script Vars</title></head><body bgcolor=\"#FFFFFF\"><pre>";
125: my $listing=&Apache::run::dump($target,$safeeval);
126: $listing=~s/\'/\\\'/g;
127: $listing=~s/\n/\\n/g;
128: $listing=~s/\r/\\r/g;
129: $result.=$listing;
130: $result.= "</pre></body></html>');newWindow.document.close();}
131: // -->
132: </script><a href=\"javascript:LONCAPA_scriptvars_".$uname."_".$udom."_$Apache::lonxml::curdepth();void(0);\">Script Vars</a><br />";
133: }
134: } elsif ($target eq "edit" ) {
135: #&Apache::run::run($bodytext,$safeeval);
136: #$result="<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />";
137: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
138: $result=&Apache::edit::tag_start($target,$token,'Script');
139: $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
140: } elsif ($target eq 'meta') {
141: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
142: }
143: } else {
144: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
145: if ($target ne "meta" && $target ne 'tex') {
146: $result = $token->[4];
147: $result.=$bodytext;
148: }
149: }
150: return $result;
151: }
152:
153: sub end_script {
154: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
155: if ( $target eq "meta" ) { return ''; }
156: my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval);
157: my $result='';
158: #other script blocks need to survive
159: if ($type ne "loncapa/perl" && $target ne 'tex') {
160: return $token->[2];
161: } elsif ($target eq 'edit' ) {
162: return &Apache::edit::end_table();
163: } elsif ($target eq 'answer') {
164: $Apache::lonxml::evaluate++;
165: }
166: return '';
167: }
168:
169: sub start_display {
170: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
171: @Apache::scripttag::parser_env = @_;
172: my $result;
173:
174: if ( $target eq "modified" ) {
175: $result=$token->[4].&Apache::edit::modifiedfield("/display",$parser);
176: } elsif ( $target eq 'web' || $target eq 'tex' ||
177: $target eq 'grade' || $target eq 'answer' ||
178: $target eq 'analyze') {
179: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
180: if (!$Apache::lonxml::default_homework_loaded) {
181: &Apache::lonxml::default_homework_load($safeeval);
182: }
183: $result=&Apache::run::run($bodytext,$safeeval);
184: if ($target eq 'grade' || $target eq 'answer' ||
185: $target eq 'analyze') {
186: # grade/answer/analyxe should produce no output but if we
187: # are redirecting, the redirecter should know what to do
188: # with the output
189: if (!$Apache::lonxml::redirection) { $result=''; }
190: }
191: $Apache::lonxml::post_evaluate=0;
192: } elsif ($target eq "edit" ) {
193: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
194: #$result =
195: # "<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />";
196: #$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);
197: $result=&Apache::edit::tag_start($target,$token,'Script With Display');
198: $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,1)
199: } elsif ($target eq 'meta') {
200: my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
201: }
202: return $result;
203: }
204:
205: sub end_display {
206: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
207: if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
208: return '';
209: }
210:
211: sub start_scriptlib {
212: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
213: my $bodytext;
214: my $result ='';
215: my $error='';
216:
217: if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
218: $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
219: $target eq 'analyze') {
220: $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
221: $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
222: $$parstack[$#$parstack]);
223: my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
224: $bodytext);
225: my $script=&Apache::lonnet::getfile($location);
226: if ($script == -1) {
227: if ($target eq 'edit') {
228: $error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
229: } else {
230: &Apache::lonxml::error("<b> Unable to find <i>$location</i> for scriptlib</b>");
231: return "";
232: }
233: }
234: &Apache::run::run($script,$safeeval);
235: #&Apache::lonxml::debug("ran $bodytext:<br />".&Apache::lonnet::getfile($bodytext)."<br />");
236: }
237: if ($target eq "edit" ) {
238: $result=
239: &Apache::edit::tag_start($target,$token,'New Script Functions').
240: &Apache::edit::editline($token->[1],$bodytext,'scriptlib',40).
241: &Apache::edit::browse(undef,'textnode').
242: $error.'</td></tr>'.
243: &Apache::edit::end_table();
244: }
245: if ($target eq "modified" ) {
246: $result=$token->[4].&Apache::edit::modifiedfield("/scriptlib",$parser);
247: }
248: return $result;
249: }
250:
251: sub end_scriptlib {
252: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
253: my @result;
254: if ($target eq "edit" ) { $result[1]='no'; }
255: return @result;
256: }
257:
258: sub start_parserlib {
259: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
260: my $bodytext;
261: my $result ="";
262: my $error='';
263: if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
264: $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
265: $target eq 'analyze') {
266: $bodytext=$$parser[$#$parser]->get_text("/parserlib");
267: $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
268: $$parstack[$#$parstack]);
269: my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
270: $bodytext);
271: my $styletext=&Apache::lonnet::getfile($location);
272: #&Apache::lonxml::debug("found :$bodytext: in :$location: with :$styletext:");
273: if ($styletext == -1) {
274: if ($target eq 'edit') {
275: $error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
276: } else {
277: &Apache::lonxml::error("<b> Unable to find <i>$location</i> for parserlib</b>");
278: return "";
279: }
280: }
281: %$style = ( %$style , &Apache::style::styleparser($target,$styletext));
282: }
283: if ($target eq "edit" ) {
284: $result=
285: &Apache::edit::tag_start($target,$token,'New Tag Definitions').
286: &Apache::edit::editline($token->[1],$bodytext,'',40).
287: $error.'</td></tr>'.
288: &Apache::edit::end_table();
289: }
290: if ($target eq "modified" ) {
291: $result=$token->[4].&Apache::edit::modifiedfield("/parserlib",$parser);
292: }
293: return $result;
294: }
295:
296: sub end_parserlib {
297: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
298: my @result;
299: if ($target eq "edit" ) { $result[1]='no'; }
300: return @result;
301: }
302:
303: sub start_window {
304: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
305: my $result = '';
306: if ($target eq 'web') {
307: &Apache::lonxml::startredirection;
308: } elsif ($target eq 'tex') {
309: $result = '\unskip\footnote{';
310: } elsif ($target eq 'edit') {
311: $result.=&Apache::edit::tag_start($target,$token);
312: $result.=&Apache::edit::text_arg('Text of Link:','linktext',$token,70);
313: $result.=&Apache::edit::text_arg('Height:','width',$token,5);
314: $result.=&Apache::edit::text_arg('Width:','height',$token,5);
315: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
316: } elsif ($target eq 'modified') {
317: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
318: $safeeval,'linttext',
319: 'width','height');
320: if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
321: }
322: return $result;
323: }
324:
325: sub end_window {
326: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
327: my $result;
328: if ($target eq 'web') {
329: my $output=&Apache::lonxml::endredirection;
330: $output =~ s/[\n\r]/ /g;
331: # $output = &HTML::Entities::encode($output,'<>&"\'');
332: $output =~ s/\'/\\\'/g;
333: my $linktext= &Apache::lonxml::get_param('linktext',$parstack,$safeeval);
334: if (!$linktext) { $linktext='<sup>*</sup>'; }
335: my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval);
336: if (!$width) { $width='500'; }
337: my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
338: if (!$height) { $height='200'; }
339: $result = "<script type=\"text/javascript\"> function LONCAPA_newwindow_$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=$width,height=$height,scrollbars=1');newWindow.document.open('text/html','replace');newWindow.document.writeln('<html><head><title>newwindow</title></head><body bgcolor=\"#FFFFFF\"> $output </body></html>');newWindow.document.close();}</script><a href=\"javascript:LONCAPA_newwindow_$Apache::lonxml::curdepth();void(0);\">$linktext</a>";
340: } elsif ($target eq 'tex') {
341: $result = '}';
342: } else {
343: $result = '';
344: }
345: return $result;
346: }
347:
348: sub start_import {
349: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
350: my $bodytext=$$parser[$#$parser]->get_text("/import");
351: my $result ="";
352:
353: $bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]);
354:
355: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
356: $target eq 'tex' || $target eq 'analyze' ) {
357: # FIXME this probably needs to be smart about construction vs.
358: # non construction space.
359: my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
360: my $file=&Apache::lonnet::getfile($location);
361: if ($file == -1) {
362: &Apache::lonxml::error("<b> Unable to find <i>$bodytext as $location</i> for import</b>");
363: return "";
364: }
365:
366: my $dir=$location;
367: $dir=~s:/[^/]*$::;
368: # &Apache::lonxml::debug("directory $dir $location file $file \n<b>END</b>\n");
369: my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
370: if (!$id) { $id=$Apache::lonxml::curdepth; }
371: push(@Apache::inputtags::import,$id);
372: push(@Apache::inputtags::importlist,$id);
373:
374: &Apache::lonxml::newparser($parser,\$file,$dir);
375:
376: } elsif ($target eq "edit" ) {
377: $result.=&Apache::edit::tag_start($target,$token);
378: $result.=&Apache::edit::editline($token->[1],$bodytext,'',40);
379: $result.=&Apache::edit::browse(undef,'textnode');
380: #FIXME this need to convert $bodytext to be a contruction space reference
381: #my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
382: #$result.="Click<a href=\"$location\">here</a> to edit<br />"
383: } elsif ($target eq 'modified') {
384: $result=$token->[4].&Apache::edit::modifiedfield("/import",$parser);
385: } elsif ($target eq 'meta') {
386: my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
387: $result.='<import part="'.$Apache::inputtags::part;
388: if ($id) {
389: $result.='" id="'.$id;
390: }
391: $result.='">';
392: $result.=$bodytext;
393: $result.='</import>';
394: }
395: return $result;
396: }
397:
398: sub end_import {
399: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
400: pop(@Apache::inputtags::import);
401: my $result;
402: if ($target eq 'edit' ) { $result=&Apache::edit::end_row.
403: &Apache::edit::end_table(); }
404: return $result;
405: }
406:
407: sub start_storetc {
408: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
409: my $result = '';
410: &Apache::lonxml::startredirection;
411: return $result;
412: }
413:
414: sub end_storetc {
415: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
416: my $result;
417: my $output=&Apache::lonxml::endredirection;
418: $output =~ s/\"/\"\;/g;
419: $result = '{\bf '.$output.'.}}\write\tcfile{\protect\tcpc{ '.$output.'.}{\the\value{relpage}}}';
420: return $result;
421: }
422:
423:
424: sub start_physnet {
425: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
426: my $bodytext = '/adm/includes/physnet.sty';
427: my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
428: my $cbistyletext=&Apache::lonnet::getfile($location);
429:
430: %$style = (%$style,&Apache::style::styleparser($target,$cbistyletext));
431: $$parser['-1']->unget_token($token);
432: # if ( defined($$style{'physnet'}) ) {
433: # &Apache::lonxml::newparser($parser,\$$style{'physnet'});
434: # }
435: return "";
436: }
437:
438: sub end_physnet {
439: return '';
440: }
441:
442: sub start_standalone {
443: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
444: my $result='';
445: if ($target eq 'web' ) {
446: if ( $ENV{'request.course.id'} ) {
447: my $inside = &Apache::lonxml::get_all_text("/standalone",$parser);
448: } else {
449: $result='<table bgcolor="#E1E1E1" border="2"><tr><td>';
450: }
451: }
452: return $result;
453: }
454:
455: sub end_standalone {
456: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
457: my $result='';
458: if ($target eq 'web' ) {
459: if ( $ENV{'request.course.id'} ) {
460: } else {
461: $result='</td></tr></table>';
462: }
463: }
464: return $result;
465: }
466:
467: sub start_comment {
468: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
469: my $result='';
470: if ($target eq 'edit') {
471: $result=&Apache::edit::tag_start($target,$token);
472: my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
473: $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4)
474: } elsif ( $target eq 'modified') {
475: $result=$token->[4].&Apache::edit::modifiedfield("/comment",$parser);
476: } elsif ( $target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
477: $target eq 'answer' || $target eq 'meta' || $target eq 'analyze') {
478: #normally throw away comments
479: my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
480: }
481: return $result;
482: }
483:
484: sub end_comment {
485: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
486: if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
487: return '';
488: }
489:
490:
491: sub xmlparse {
492: my ($string) = @_;
493: &Apache::lonxml::debug("xmlparse recursion starting with $string");
494: # Apache::run::evaluate does an 'eval' on the name of the subroutine
495: # if it detects something that looks like a subroutine, this ends up calling
496: # things without any arguments and since perl is nice enough to pass
497: # along the default arguments when you don't explicitly say no arguments
498: # if you call &xmlparse, it gets &xmlparse passed as it argument.
499: # Same thing soccurs with &chemparse.
500: if ($string eq '&xmlparse') { return '&xmlparse'; }
501: if ($string eq '&chemparse') { return '&chemparse'; }
502: my ($target,$token,$tagstack,$parstack,$oldparser,$safeeval,$style)=
503: @Apache::scripttag::parser_env;
504: my @parser;
505: &Apache::lonxml::newparser(\@parser,\$string);
506: my $result=&Apache::lonxml::inner_xmlparse($target,$tagstack,
507: $parstack,\@parser,
508: $safeeval,$style);
509: &Apache::lonxml::debug("target is $target xmlparse recursion ending with $result");
510: return $result;
511: }
512:
513: sub start_num {
514: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
515: my $result = '';
516: my $inside = &Apache::lonxml::get_all_text_unbalanced("/num",$parser);
517: if ($target eq 'tex' || $target eq 'web') {
518: $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
519: if (!$Apache::lonxml::default_homework_loaded) {
520: &Apache::lonxml::default_homework_load($safeeval);
521: }
522: @Apache::scripttag::parser_env = @_;
523: my $format=&Apache::lonxml::get_param('format',$parstack,$safeeval);
524: $result=&Apache::run::run("return &prettyprint(q\0$inside\0,q\0$format\0);",$safeeval);
525: }
526: return $result;
527: }
528:
529: sub end_num {
530: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
531: my $result = '';
532: return $result;
533: }
534:
535: sub start_parse {
536: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
537: my $result = '';
538: if ( $target eq 'web' || $target eq 'tex' ||
539: $target eq 'grade' || $target eq 'answer' ||
540: $target eq 'analyze') {
541: my $inside = &Apache::lonxml::get_all_text_unbalanced("/parse",$parser);
542: $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
543: if (!$Apache::lonxml::default_homework_loaded) {
544: &Apache::lonxml::default_homework_load($safeeval);
545: }
546: @Apache::scripttag::parser_env = @_;
547: $result=&Apache::run::run("return &xmlparse(q\0$inside\0);",$safeeval);
548: }
549: return $result;
550: }
551:
552: sub end_parse {
553: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
554: my $result = '';
555: return $result;
556: }
557:
558: sub start_algebra {
559: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
560: my $result = '';
561: if ( $target eq 'web' || $target eq 'tex' ||
562: $target eq 'grade' || $target eq 'answer' ||
563: $target eq 'analyze') {
564: my $inside = &Apache::lonxml::get_all_text_unbalanced("/algebra",$parser);
565: $inside = &Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
566: if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
567: $result=&Apache::lontexconvert::algebra($inside,$target);
568: }
569: $Apache::lonxml::post_evaluate=0;
570: }
571: return $result;
572: }
573:
574: sub end_algebra {
575: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
576: my $result = '';
577: return $result;
578: }
579:
580: 1;
581: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>