<$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 =""; - if ($target ne "edit" ) { - $bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]); - &Apache::run::run(&getfile($bodytext),$safeeval); - #print "ran $bodytext:
".&getfile($bodytext)."
"; - } else { - $result=&editfield($token->[1],$bodytext); + 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='
".&Apache::lonnet::getfile($bodytext)."
"); + } + if ($target eq "edit" ) { + $result= + &Apache::edit::tag_start($target,$token,'New Script Functions'). + &Apache::edit::editline($token->[1],$bodytext,'scriptlib',40). + &Apache::edit::browse(undef,'textnode'). + $error.'
" + + $bodytext=&Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]); + + if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade' + || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze' ) { + # FIXME this probably needs to be smart about construction vs. + # non construction space. + my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); + my $file=&Apache::lonnet::getfile($location); + if ($file == -1) { + &Apache::lonxml::error(" Unable to find $bodytext as $location for import"); + return ""; + } + my $importmode=&Apache::lonxml::get_param('importmode',$parstack,$safeeval); + if (($importmode eq 'problem') || ($importmode eq 'part')) { +# We are using import to import published problems + if (($importmode eq 'problem') || ($file=~/
" + } elsif ($target eq 'modified') { + &Apache::edit::get_new_args($token,$parstack,$safeeval,'importmode'); + $result='
';
+ }
+ }
+ return $result;
}
-sub editfield {
- my ($tag,$data)=@_;
-
- my $count=0;
- my $maxlength=-1;
- map { $count++;
- if (length($_) > $maxlength) { $maxlength = length ($_); }
- } split ("\n", $data);
-
- return " \n<$tag> \n \n</$tag> \n"; -} - -sub getfile { - my ($filename) = @_; - my $a=""; - &Apache::lonnet::repcopy("/raw".$filename); - { - my $fh=Apache::File->new("/home/httpd/html/res".$filename); - while (<$fh>) { - $a .=$_; +sub end_standalone { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; + my $result=''; + if ($target eq 'web' || $target eq 'webgrade' ) { + if ( $env{'request.course.id'} ) { + } else { + $result=' |