[LON-CAPA-cvs] cvs: loncom /xml scripttag.pm
www
www@source.lon-capa.org
Sun, 23 May 2010 12:29:25 -0000
www Sun May 23 12:29:25 2010 EDT
Modified files:
/loncom/xml scripttag.pm
Log:
Not completely tested: directly import a problem
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.152 loncom/xml/scripttag.pm:1.153
--- loncom/xml/scripttag.pm:1.152 Tue Apr 27 20:29:20 2010
+++ loncom/xml/scripttag.pm Sun May 23 12:29:25 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# <script> definiton
#
-# $Id: scripttag.pm,v 1.152 2010/04/27 20:29:20 faziophi Exp $
+# $Id: scripttag.pm,v 1.153 2010/05/23 12:29:25 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -372,7 +372,7 @@
my $bodytext=$$parser[$#$parser]->get_text("/import");
my $result ="";
- $bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]);
+ $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' ) {
@@ -384,7 +384,11 @@
&Apache::lonxml::error("<b> Unable to find <i>$bodytext as $location</i> for import</b>");
return "";
}
-
+ my $importmode=&Apache::lonxml::get_param('importmode',$parstack,$safeeval);
+ if ($importmode eq 'problem') {
+ $file=~s/^\s*<problem>/<library>/s;
+ $file=~s/<\/problem>\s*$/<\/library>/s;
+ }
my $dir=$location;
$dir=~s:/[^/]*$::;
# &Apache::lonxml::debug("directory $dir $location file $file \n<b>END</b>\n");
@@ -397,13 +401,28 @@
} elsif ($target eq "edit" ) {
$result.=&Apache::edit::tag_start($target,$token);
- $result.=&Apache::edit::editline($token->[1],$bodytext,'',40);
+ my $location=$token->[1];
+ $location=~s/^\s*//s;
+ $location=~s/\s*$//s;
+ $result.=&Apache::edit::editline($location,$bodytext,'',40);
$result.=&Apache::edit::browse(undef,'textnode');
+ $result.= '<label>'.&mt('Import as:').
+ '<select name="importmode_'.$Apache::lonxml::curdepth.'">';
+ foreach my $option ('','problem') {
+ $result.='<option value="'.$option.'"';
+ if ($option eq &Apache::lonxml::get_param('importmode',$parstack,$safeeval)) {
+ $result.=' selected="selected"';
+ }
+ $result.='>'.($option?&mt('as problem'):&mt('as standard library')).'</option>';
+ }
+ $result.='</select></label>';
#FIXME this need to convert $bodytext to be a contruction space reference
#my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
#$result.="Click<a href=\"$location\">here</a> to edit<br />"
} elsif ($target eq 'modified') {
- $result=$token->[4].&Apache::edit::modifiedfield("/import",$parser);
+ &Apache::edit::get_new_args($token,$parstack,$safeeval,'importmode');
+ $result='<import id="'.$token->[2]{'id'}.'" importmode="'.$token->[2]{'importmode'}.'">';
+ $result.=&Apache::edit::modifiedfield("/import",$parser);
} elsif ($target eq 'meta') {
my $id= &Apache::lonxml::get_id($parstack,$safeeval);
$result.='<import part="'.$Apache::inputtags::part;