--- loncom/xml/scripttag.pm 2001/08/20 17:14:55 1.50 +++ loncom/xml/scripttag.pm 2001/11/05 22:59:33 1.56 @@ -31,8 +31,17 @@ sub start_script { my $bodytext=&Apache::lonxml::get_all_text("/script",$$parser[$#$parser]); if ( $target eq "modified" ) { $result=$token->[4].&Apache::edit::modifiedfield(); - } elsif ( $target eq "web" || $target eq "grade" ) { + } elsif ( $target eq 'web' || $target eq 'tex' || + $target eq 'grade' || $target eq 'answer') { &Apache::run::run($bodytext,$safeeval); + if (($ENV{'request.state'} eq 'construct') && ($target eq 'answer')) { + $Apache::lonxml::evaluate--; + $result.="newwindow
";
+	my $listing= &Apache::run::dump($target,$safeeval);
+	$listing =~ s/\n/\\n/g;
+	$result.=$listing;
+	$result.= "
\');newWindow.document.close();void(0);\">Script Vars

"; + } } elsif ($target eq "edit" ) { #&Apache::run::run($bodytext,$safeeval); #$result="
<$token->[1]> output:
$bodytext
Source:
"; @@ -51,8 +60,13 @@ sub end_script { my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval); my $result=''; #other script blocks need to survive - if ($type ne "loncapa/perl") { return $token->[2]; } - if ($target eq 'edit' ) { return &Apache::edit::end_table(); } + if ($type ne "loncapa/perl") { + return $token->[2]; + } elsif ($target eq 'edit' ) { + return &Apache::edit::end_table(); + } elsif (($ENV{'request.state'} eq 'construct') && ($target eq 'answer')) { + $Apache::lonxml::evaluate++; + } return ''; } @@ -64,9 +78,10 @@ sub start_display { if ( $target eq "modified" ) { $result=$token->[4].&Apache::edit::modifiedfield(); - } elsif ( $target eq "web" || $target eq "grade" ) { + } elsif ( $target eq 'web' || $target eq 'tex' || + $target eq 'grade' || $target eq 'answer') { $result=&Apache::run::run($bodytext,$safeeval); - if ($target eq 'grade' ) { + if ($target eq 'grade' || $target eq 'answer' ) { $result=''; # grade should produce no output } } elsif ($target eq "edit" ) { @@ -91,7 +106,7 @@ sub start_scriptlib { my $result =''; my $error=''; - if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || $target eq 'edit') { + if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || $target eq 'edit' || $target eq 'answer') { $bodytext=$$parser[$#$parser]->get_text("/scriptlib"); $bodytext=&Apache::run::evaluate($bodytext,$safeeval, $$parstack[$#$parstack]); @@ -136,7 +151,7 @@ sub start_parserlib { my $bodytext; my $result =""; my $error=''; - if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || $target eq 'edit') { + if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || $target eq 'edit' || $target eq 'answer') { $bodytext=$$parser[$#$parser]->get_text("/parserlib"); $bodytext=&Apache::run::evaluate($bodytext,$safeeval, $$parstack[$#$parstack]); @@ -209,7 +224,7 @@ sub start_import { $bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]); - if ($target eq 'web' || $target eq 'grade') { + if ($target eq 'web' || $target eq 'grade' || $target eq 'answer') { # FIXME this probably needs to be smart about construction vs. # non construction space. my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); @@ -223,18 +238,20 @@ sub start_import { $dir=~s:/[^/]*$::; # &Apache::lonxml::debug("directory $dir $location file $file \nEND\n"); &Apache::lonxml::newparser($parser,\$file,$dir); - } - if ($target eq "edit" ) { + } elsif ($target eq "edit" ) { $result.=&Apache::edit::tag_start($target,$token); $result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1); #FIXME this need to convert $bodytext to be a contruction space reference #my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); #$result.="Clickhere to edit
" - } - if ($target eq 'modified') { + } elsif ($target eq 'modified') { $bodytext=$$parser[$#$parser]->get_text("/import"); $result=&Apache::edit::modifiedfield($token); &Apache::lonxml::debug($result); + } elsif ($target eq 'meta') { + $result.=''; + $result.=$bodytext; + $result.=''; } return $result; } @@ -255,8 +272,8 @@ sub end_storetc { my $result; my $output=&Apache::lonxml::endredirection; $output =~ s/\"/\"\;/g; - $result = "{\bf $output.}}\write\tcfile{\protect\tcpc{ $output.}{\the\value{relpage}}}"; - return $result; + $result = '{\bf '.$output.'.}}\write\tcfile{\protect\tcpc{ '.$output.'.}{\the\value{relpage}}}'; + return $result; }