--- loncom/xml/scripttag.pm 2001/01/04 19:15:02 1.29
+++ loncom/xml/scripttag.pm 2007/01/23 21:28:41 1.140
@@ -1,203 +1,615 @@
# The LearningOnline Network with CAPA
# ';
+ }
+ return ('','no');
+}
-sub BEGIN {
- &Apache::lonxml::register('Apache::scripttag',('script','scriptlib',
- 'parserlib','import',
- 'footnote','display'));
+sub end_LONCAPA_INTERNAL_LONHTTPD_PORT {
+ return ('','no');
}
sub start_script {
- my ($target,$token,$parstack,$parser,$safeeval)=@_;
- my $args ='';
- if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
- my $type = &Apache::run::run("{$args;".'return $type}',$safeeval);
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ @Apache::scripttag::parser_env = @_;
my $result='';
- #&Apache::lonxml::debug("found type of $type");
+ my $type= &Apache::lonxml::get_param('type',$parstack,$safeeval);
+ &Apache::lonxml::debug("found type of $type");
if ($type eq "loncapa/perl") {
- my $bodytext=&Apache::lonxml::get_all_text("/script",$$parser[$#$parser]);
-
if ( $target eq "modified" ) {
-
- } elsif ( $target eq "web" || $target eq "grade" ) {
- &Apache::run::run($bodytext,$safeeval);
+ $result=$token->[4].&Apache::edit::modifiedfield('/script',$parser);
+ } elsif ( $target eq 'web' || $target eq 'tex' ||
+ $target eq 'grade' || $target eq 'webgrade' ||
+ $target eq 'answer' || $target eq 'analyze' ) {
+ my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
+ if (!$Apache::lonxml::default_homework_loaded) {
+ &Apache::lonxml::default_homework_load($safeeval);
+ }
+ &Apache::run::run($bodytext,$safeeval);
+ if (($target eq 'answer') &&
+ ($env{'form.answer_output_mode'} ne 'tex') &&
+ ($Apache::lonhomework::viewgrades == 'F')) {
+ $Apache::lonxml::evaluate--;
+ my (undef,undef,$udom,$uname)=&Apache::lonnet::whichuser();
+ my $windowopen=&Apache::lonhtmlcommon::javascript_docopen();
+ my $start_page =
+ &Apache::loncommon::start_page('Script Vars', undef,
+ {'only_body' => 1,
+ 'bgcolor' => '#FFFFFF',
+ 'js_ready' => 1,});
+ my $end_page =
+ &Apache::loncommon::end_page({'js_ready' => 1,});
+
+ $uname =~s/\W//g;
+ $udom =~s/\W//g;
+ $result.="Script Vars
";
+ }
} elsif ($target eq "edit" ) {
- &Apache::run::run($bodytext,$safeeval);
- $result="
<$token->[1]> output:
$bodytext
Source:
";
- $result.=&editfield($token->[1],$bodytext);
+ #&Apache::run::run($bodytext,$safeeval);
+ #$result="
<$token->[1]> output:
$bodytext
Source:
";
+ my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
+ $result=&Apache::edit::tag_start($target,$token,'Script');
+ $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
+ } elsif ($target eq 'meta') {
+ my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
}
} else {
- if ($target ne "meta") { $result = $token->[4]; }
+ my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
+ if ($target ne "meta" && $target ne 'tex') {
+ $result = $token->[4];
+ $result.=$bodytext;
+ }
}
return $result;
}
sub end_script {
- my ($target,$token,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
if ( $target eq "meta" ) { return ''; }
- my $args ='';
- if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
- my $type = &Apache::run::run("{$args;".'return $type}',$safeeval);
+ 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 ($type ne "loncapa/perl" && $target ne 'tex') {
+ return $token->[2];
+ } elsif ($target eq 'edit' ) {
+ return &Apache::edit::end_table();
+ } elsif ($target eq 'answer') {
+ $Apache::lonxml::evaluate++;
+ }
return '';
}
sub start_display {
- my ($target,$token,$parstack,$parser,$safeeval)=@_;
- my $args ='';
- if ( $#$parstack > -1 ) {
- $args=$$parstack[$#$parstack];
- }
- my $bodytext=&Apache::lonxml::get_all_text("/display",$$parser[$#$parser]);
-
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ @Apache::scripttag::parser_env = @_;
+ my $result;
+
if ( $target eq "modified" ) {
- }
- my $result=&Apache::run::run($bodytext,$safeeval);
- if ($target eq 'grade' ) {
- # grade should produce no output
- $result='';
- }
- if ($target eq "edit" ) {
- $result =
- "
<$token->[1]> output:
$bodytext
Source:
";
- $result.=&editfield($token->[1],$bodytext);
+ $result=$token->[4].&Apache::edit::modifiedfield("/display",$parser);
+ } elsif ( $target eq 'web' || $target eq 'tex' ||
+ $target eq 'grade' || $target eq 'webgrade' ||
+ $target eq 'answer' || $target eq 'analyze') {
+ my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
+ if (!$Apache::lonxml::default_homework_loaded) {
+ &Apache::lonxml::default_homework_load($safeeval);
+ }
+ $result=&Apache::run::run($bodytext,$safeeval);
+ if ($target eq 'grade' || $target eq 'answer' ||
+ $target eq 'analyze') {
+ # grade/answer/analyxe should produce no output but if we
+ # are redirecting, the redirecter should know what to do
+ # with the output
+ if (!$Apache::lonxml::redirection) { $result=''; }
+ }
+ $Apache::lonxml::post_evaluate=0;
+ } elsif ($target eq "edit" ) {
+ my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
+ #$result =
+ # "
<$token->[1]> output:
$bodytext
Source:
";
+ #$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);
+ $result=&Apache::edit::tag_start($target,$token,'Script With Display');
+ $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,1)
+ } elsif ($target eq 'meta') {
+ my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
}
return $result;
}
sub end_display {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
+ return '';
}
sub start_scriptlib {
- my ($target,$token,$parstack,$parser,$safeeval)=@_;
- my $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
- my $result ="";
-
- $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
- $$parstack[$#$parstack]);
- my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
- $bodytext);
- my $script=&Apache::lonnet::getfile($location);
- if ($script == -1) {
- &Apache::lonxml::error(" Unable to find $location for scriptlib");
- return "";
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $bodytext;
+ my $result ='';
+ my $error='';
+
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
+ $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
+ $target eq 'analyze' || $target eq 'webgrade') {
+ $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
+ $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
+ $$parstack[$#$parstack]);
+ my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
+ $bodytext);
+ my $script=&Apache::lonnet::getfile($location);
+ if ($script == -1) {
+ if ($target eq 'edit') {
+ $error='