version 1.69, 2002/03/28 22:02:27
|
version 1.80, 2002/10/30 23:37:57
|
Line 43 BEGIN {
|
Line 43 BEGIN {
|
&Apache::lonxml::register('Apache::scripttag', |
&Apache::lonxml::register('Apache::scripttag', |
('script','scriptlib','parserlib','import', |
('script','scriptlib','parserlib','import', |
'window','display','storetc','physnet', |
'window','display','storetc','physnet', |
'standalone')); |
'standalone','comment')); |
} |
} |
|
|
sub start_script { |
sub start_script { |
Line 57 sub start_script {
|
Line 57 sub start_script {
|
if ( $target eq "modified" ) { |
if ( $target eq "modified" ) { |
$result=$token->[4].&Apache::edit::modifiedfield(); |
$result=$token->[4].&Apache::edit::modifiedfield(); |
} elsif ( $target eq 'web' || $target eq 'tex' || |
} elsif ( $target eq 'web' || $target eq 'tex' || |
$target eq 'grade' || $target eq 'answer') { |
$target eq 'grade' || $target eq 'answer' || |
&Apache::run::run($bodytext,$safeeval); |
$target eq 'analyze' ) { |
if (($target eq 'answer') && ($Apache::lonhomework::viewgrades == 'F')) { |
if (!$Apache::lonxml::default_homework_loaded) { |
$Apache::lonxml::evaluate--; |
&Apache::lonxml::default_homework_load($safeeval); |
$result.="<a href=\"javascript:newWindow=open(\'\',\'new_W\',\'width=500,height=200,scrollbars=1\');newWindow.document.open(\'text/html\',\'replace\');newWindow.document.writeln(\'<html><head><title>newwindow</title></head><body bgcolor="#FFFFFF"><pre>"; |
} |
my $listing= &Apache::run::dump($target,$safeeval); |
&Apache::run::run($bodytext,$safeeval); |
$listing =~ s/\n/\\n/g; |
if (($target eq 'answer') && ($Apache::lonhomework::viewgrades == 'F')) { |
$listing =~ s/\"/"/g; |
$Apache::lonxml::evaluate--; |
$listing =~ s/\'/’/g; |
$result.="<a href=\"javascript:newWindow=open(\'\',\'new_W\',\'width=500,height=200,scrollbars=1\');newWindow.document.open(\'text/html\',\'replace\');newWindow.document.writeln(\'<html><head><title>newwindow</title></head><body bgcolor="#FFFFFF"><pre>"; |
$listing =~ s/</</g; |
my $listing= &HTML::Entities::encode(&Apache::run::dump($target,$safeeval)); |
$listing =~ s/>/>/g; |
|
$listing =~ s/&/&/g; |
$result.=$listing; |
$result.=$listing; |
$result.= "</pre></body></html>\');newWindow.document.close();void(0);\">Script Vars</a><br />"; |
$result.= "</pre></body></html>\');newWindow.document.close();void(0);\">Script Vars</a><br />"; |
} |
} |
|
} elsif ($target eq "edit" ) { |
} elsif ($target eq "edit" ) { |
#&Apache::run::run($bodytext,$safeeval); |
#&Apache::run::run($bodytext,$safeeval); |
#$result="<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />"; |
#$result="<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />"; |
$result=&Apache::edit::tag_start($target,$token,'Script'); |
$result=&Apache::edit::tag_start($target,$token,'Script'); |
$result.=&Apache::edit::editfield($token->[1],$bodytext,'',50,4); |
$result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4); |
} |
} |
} else { |
} else { |
if ($target ne "meta") { |
if ($target ne "meta") { |
Line 98 sub end_script {
|
Line 97 sub end_script {
|
return $token->[2]; |
return $token->[2]; |
} elsif ($target eq 'edit' ) { |
} elsif ($target eq 'edit' ) { |
return &Apache::edit::end_table(); |
return &Apache::edit::end_table(); |
} elsif (($ENV{'request.state'} eq 'construct') && ($target eq 'answer')) { |
} elsif ($target eq 'answer') { |
$Apache::lonxml::evaluate++; |
$Apache::lonxml::evaluate++; |
} |
} |
return ''; |
return ''; |
Line 113 sub start_display {
|
Line 112 sub start_display {
|
if ( $target eq "modified" ) { |
if ( $target eq "modified" ) { |
$result=$token->[4].&Apache::edit::modifiedfield(); |
$result=$token->[4].&Apache::edit::modifiedfield(); |
} elsif ( $target eq 'web' || $target eq 'tex' || |
} elsif ( $target eq 'web' || $target eq 'tex' || |
$target eq 'grade' || $target eq 'answer') { |
$target eq 'grade' || $target eq 'answer' || |
$result=&Apache::run::run($bodytext,$safeeval); |
$target eq 'analyze') { |
if ($target eq 'grade' || $target eq 'answer' ) { |
if (!$Apache::lonxml::default_homework_loaded) { |
$result=''; # grade should produce no output |
&Apache::lonxml::default_homework_load($safeeval); |
} |
} |
|
$result=&Apache::run::run($bodytext,$safeeval); |
|
if ($target eq 'grade' || $target eq 'answer' || |
|
$target eq 'analyze') { |
|
$result=''; # grade should produce no output |
|
} |
} elsif ($target eq "edit" ) { |
} elsif ($target eq "edit" ) { |
#$result = |
#$result = |
# "<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />"; |
# "<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />"; |
#$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1); |
#$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1); |
$result=&Apache::edit::tag_start($target,$token,'Script With Display'); |
$result=&Apache::edit::tag_start($target,$token,'Script With Display'); |
$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1) |
$result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,1) |
} |
} |
return $result; |
return $result; |
} |
} |
Line 140 sub start_scriptlib {
|
Line 144 sub start_scriptlib {
|
my $result =''; |
my $result =''; |
my $error=''; |
my $error=''; |
|
|
if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || $target eq 'edit' || $target eq 'answer') { |
if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || |
|
$target eq 'edit' || $target eq 'answer' || $target eq 'analyze') { |
$bodytext=$$parser[$#$parser]->get_text("/scriptlib"); |
$bodytext=$$parser[$#$parser]->get_text("/scriptlib"); |
$bodytext=&Apache::run::evaluate($bodytext,$safeeval, |
$bodytext=&Apache::run::evaluate($bodytext,$safeeval, |
$$parstack[$#$parstack]); |
$$parstack[$#$parstack]); |
Line 185 sub start_parserlib {
|
Line 190 sub start_parserlib {
|
my $bodytext; |
my $bodytext; |
my $result =""; |
my $result =""; |
my $error=''; |
my $error=''; |
if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || $target eq 'edit' || $target eq 'answer') { |
if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || |
|
$target eq 'edit' || $target eq 'answer' || $target eq 'analyze') { |
$bodytext=$$parser[$#$parser]->get_text("/parserlib"); |
$bodytext=$$parser[$#$parser]->get_text("/parserlib"); |
$bodytext=&Apache::run::evaluate($bodytext,$safeeval, |
$bodytext=&Apache::run::evaluate($bodytext,$safeeval, |
$$parstack[$#$parstack]); |
$$parstack[$#$parstack]); |
Line 258 sub start_import {
|
Line 264 sub start_import {
|
|
|
$bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]); |
$bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]); |
|
|
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer') { |
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
|
$target eq 'tex' || $target eq 'analyze' ) { |
# FIXME this probably needs to be smart about construction vs. |
# FIXME this probably needs to be smart about construction vs. |
# non construction space. |
# non construction space. |
my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); |
my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); |
Line 343 sub end_physnet {
|
Line 350 sub end_physnet {
|
|
|
sub start_standalone { |
sub start_standalone { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
if ($target eq 'web' && $ENV{'request.course.id'} ) { |
my $result=''; |
my $inside = &Apache::lonxml::get_all_text("/standalone",$$parser[-1]); |
if ($target eq 'web' ) { |
|
if ( $ENV{'request.course.id'} ) { |
|
my $inside = &Apache::lonxml::get_all_text("/standalone",$$parser[-1]); |
|
} else { |
|
$result='<table bgcolor="#E1E1E1" border="2"><tr><td>'; |
|
} |
} |
} |
return ''; |
return $result; |
} |
} |
|
|
sub end_standalone { |
sub end_standalone { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
my $result=''; |
|
if ($target eq 'web' ) { |
|
if ( $ENV{'request.course.id'} ) { |
|
} else { |
|
$result='</td></tr></table>'; |
|
} |
|
} |
|
return $result; |
|
} |
|
|
|
sub start_comment { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
my $result=''; |
|
if ($target eq 'edit') { |
|
$result=&Apache::edit::tag_start($target,$token); |
|
my $bodytext=&Apache::lonxml::get_all_text("/comment",$$parser[$#$parser]); |
|
$result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4) |
|
} elsif ( $target eq 'modified') { |
|
$result=$token->[4].&Apache::edit::modifiedfield($token); |
|
} elsif ( $target eq 'web' || $target eq 'tex' || $target eq 'grade' || |
|
$target eq 'answer' || $target eq 'meta' || $target eq 'analyze') { |
|
#normally throw away comments |
|
my $bodytext=&Apache::lonxml::get_all_text("/comment",$$parser[$#$parser]); |
|
} |
|
return $result; |
|
} |
|
|
|
sub end_comment { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
|
if ($target eq 'edit' ) { return &Apache::edit::end_table(); } |
return ''; |
return ''; |
} |
} |
|
|