# The LearningOnline Network with CAPA
# ';
}
return ('','no');
}
sub end_LONCAPA_INTERNAL_LONHTTPD_PORT {
return ('','no');
}
sub start_script {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
@Apache::scripttag::parser_env = @_;
my $result='';
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);
if ( $target eq "modified" ) {
$result=$token->[4].&Apache::edit::modifiedfield();
} elsif ( $target eq 'web' || $target eq 'tex' ||
$target eq 'grade' || $target eq 'answer' ||
$target eq 'analyze' ) {
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--;
$result.="Script Vars
";
}
} elsif ($target eq "edit" ) {
#&Apache::run::run($bodytext,$safeeval);
#$result="
<$token->[1]> output:
$bodytext
Source:
";
$result=&Apache::edit::tag_start($target,$token,'Script');
$result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
}
} else {
if ($target ne "meta") {
$result = $token->[4];
my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);
$result.=$bodytext;
}
}
return $result;
}
sub end_script {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
if ( $target eq "meta" ) { return ''; }
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];
} elsif ($target eq 'edit' ) {
return &Apache::edit::end_table();
} elsif ($target eq 'answer') {
$Apache::lonxml::evaluate++;
}
return '';
}
sub start_display {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result;
my $bodytext=&Apache::lonxml::get_all_text("/display",$parser);
if ( $target eq "modified" ) {
$result=$token->[4].&Apache::edit::modifiedfield();
} elsif ( $target eq 'web' || $target eq 'tex' ||
$target eq 'grade' || $target eq 'answer' ||
$target eq 'analyze') {
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') {
$result=''; # grade should produce no output
}
} elsif ($target eq "edit" ) {
#$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)
}
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,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $bodytext;
my $result ='';
my $error='';
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=&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='