[LON-CAPA-cvs] cvs: loncom /homework edit.pm imageresponse.pm inputtags.pm randomlabel.pm structuretags.pm /xml lonplot.pm scripttag.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 30 Oct 2003 20:52:54 -0000
This is a MIME encoded message
--albertel1067547174
Content-Type: text/plain
albertel Thu Oct 30 15:52:54 2003 EDT
Modified files:
/loncom/xml scripttag.pm lonplot.pm
/loncom/homework edit.pm imageresponse.pm inputtags.pm
randomlabel.pm structuretags.pm
Log:
- BUG#1974, <textarea>s delete the initial linefeeds if they exist, now checks old value and preserves the \n from the old value if it had been there.
--albertel1067547174
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20031030155254.txt"
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.102 loncom/xml/scripttag.pm:1.103
--- loncom/xml/scripttag.pm:1.102 Thu Oct 30 15:20:00 2003
+++ loncom/xml/scripttag.pm Thu Oct 30 15:52:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# <script> definiton
#
-# $Id: scripttag.pm,v 1.102 2003/10/30 20:20:00 albertel Exp $
+# $Id: scripttag.pm,v 1.103 2003/10/30 20:52:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -104,12 +104,12 @@
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();
+ $result=$token->[4].&Apache::edit::modifiedfield('/script',$parser);
} elsif ( $target eq 'web' || $target eq 'tex' ||
$target eq 'grade' || $target eq 'answer' ||
$target eq 'analyze' ) {
+ my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);
if (!$Apache::lonxml::default_homework_loaded) {
&Apache::lonxml::default_homework_load($safeeval);
}
@@ -129,8 +129,9 @@
} elsif ($target eq "edit" ) {
#&Apache::run::run($bodytext,$safeeval);
#$result="<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />";
- $result=&Apache::edit::tag_start($target,$token,'Script');
- $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
+ my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);
+ $result=&Apache::edit::tag_start($target,$token,'Script');
+ $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
}
} else {
if ($target ne "meta") {
@@ -162,13 +163,13 @@
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();
+ $result=$token->[4].&Apache::edit::modifiedfield("/display",$parser);
} elsif ( $target eq 'web' || $target eq 'tex' ||
$target eq 'grade' || $target eq 'answer' ||
$target eq 'analyze') {
+ my $bodytext=&Apache::lonxml::get_all_text("/display",$parser);
if (!$Apache::lonxml::default_homework_loaded) {
&Apache::lonxml::default_homework_load($safeeval);
}
@@ -179,6 +180,7 @@
}
$Apache::lonxml::post_evaluate=0;
} elsif ($target eq "edit" ) {
+ my $bodytext=&Apache::lonxml::get_all_text("/display",$parser);
#$result =
# "<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />";
#$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);
@@ -228,9 +230,7 @@
&Apache::edit::end_table();
}
if ($target eq "modified" ) {
- $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
- $result=$token->[4].&Apache::edit::modifiedfield($token);
- &Apache::lonxml::debug($result);
+ $result=$token->[4].&Apache::edit::modifiedfield("/scriptlib",$parser);
}
return $result;
}
@@ -274,9 +274,7 @@
&Apache::edit::end_table();
}
if ($target eq "modified" ) {
- $bodytext=$$parser[$#$parser]->get_text("/parserlib");
- $result=$token->[4].&Apache::edit::modifiedfield($token);
- &Apache::lonxml::debug($result);
+ $result=$token->[4].&Apache::edit::modifiedfield("/parserlib",$parser);
}
return $result;
}
@@ -358,9 +356,7 @@
#my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
#$result.="Click<a href=\"$location\">here</a> to edit<br />"
} elsif ($target eq 'modified') {
- $bodytext=$$parser[$#$parser]->get_text("/import");
- $result=$token->[4].&Apache::edit::modifiedfield($token);
- &Apache::lonxml::debug($result);
+ $result=$token->[4].&Apache::edit::modifiedfield("/import",$parser);
} elsif ($target eq 'meta') {
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
$result.='<import part="'.$Apache::inputtags::part;
@@ -450,8 +446,7 @@
my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
$result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4)
} elsif ( $target eq 'modified') {
- my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
- $result=$token->[4].&Apache::edit::modifiedfield($token);
+ $result=$token->[4].&Apache::edit::modifiedfield("/comment",$parser);
} elsif ( $target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
$target eq 'answer' || $target eq 'meta' || $target eq 'analyze') {
#normally throw away comments
Index: loncom/xml/lonplot.pm
diff -u loncom/xml/lonplot.pm:1.92 loncom/xml/lonplot.pm:1.93
--- loncom/xml/lonplot.pm:1.92 Fri Oct 24 13:35:32 2003
+++ loncom/xml/lonplot.pm Thu Oct 30 15:52:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Dynamic plot
#
-# $Id: lonplot.pm,v 1.92 2003/10/24 17:35:32 matthew Exp $
+# $Id: lonplot.pm,v 1.93 2003/10/30 20:52:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -659,9 +659,8 @@
&Apache::edit::start_spanning_row().
&Apache::edit::editline('',$text,'',60);
} elsif ($target eq 'modified') {
- my $text=$$parser[-1]->get_text("/title");
$result.=&Apache::edit::rebuild_tag($token);
- $result.=&Apache::edit::modifiedfield($token);
+ $result.=&Apache::edit::modifiedfield("/title",$parser);
}
return $result;
}
@@ -693,9 +692,8 @@
&Apache::edit::start_spanning_row().
&Apache::edit::editline('',$text,'',60);
} elsif ($target eq 'modified') {
- my $text=$$parser[-1]->get_text("/xlabel");
$result.=&Apache::edit::rebuild_tag($token);
- $result.=&Apache::edit::modifiedfield($token);
+ $result.=&Apache::edit::modifiedfield("/xlabel",$parser);
}
return $result;
}
@@ -728,9 +726,8 @@
&Apache::edit::start_spanning_row().
&Apache::edit::editline('',$text,'',60);
} elsif ($target eq 'modified') {
- my $text=$$parser[-1]->get_text("/ylabel");
$result.=&Apache::edit::rebuild_tag($token);
- $result.=&Apache::edit::modifiedfield($token);
+ $result.=&Apache::edit::modifiedfield("/ylabel",$parser);
}
return $result;
}
@@ -770,8 +767,7 @@
&Apache::edit::get_new_args
($token,$parstack,$safeeval,keys(%label_defaults));
$result.=&Apache::edit::rebuild_tag($token);
- my $text=$$parser[-1]->get_text("/label");
- $result.=&Apache::edit::modifiedfield($token);
+ $result.=&Apache::edit::modifiedfield("/label",$parser);
}
return $result;
}
@@ -849,8 +845,7 @@
&Apache::edit::editline('',$text,'',60);
} elsif ($target eq 'modified') {
$result.=&Apache::edit::rebuild_tag($token);
- my $text=$$parser[-1]->get_text("/function");
- $result.=&Apache::edit::modifiedfield($token);
+ $result.=&Apache::edit::modifiedfield("/function",$parser);
}
return $result;
}
@@ -927,8 +922,7 @@
&Apache::edit::editline('',$text,'',60);
} elsif ($target eq 'modified') {
$result.=&Apache::edit::rebuild_tag($token);
- my $text=$$parser[-1]->get_text("/data");
- $result.=&Apache::edit::modifiedfield($token);
+ $result.=&Apache::edit::modifiedfield("/data",$parser);
}
return $result;
}
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.69 loncom/homework/edit.pm:1.70
--- loncom/homework/edit.pm:1.69 Fri Oct 24 17:45:32 2003
+++ loncom/homework/edit.pm Thu Oct 30 15:52:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# edit mode helpers
#
-# $Id: edit.pm,v 1.69 2003/10/24 21:45:32 albertel Exp $
+# $Id: edit.pm,v 1.70 2003/10/30 20:52:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -482,7 +482,7 @@
}
sub modifiedfield {
- my ($token) = @_;
+ my ($endtag,$parser) = @_;
my $result;
# foreach my $envkey (sort keys %ENV) {
# &Apache::lonxml::debug("$envkey ---- $ENV{$envkey}");
@@ -490,6 +490,9 @@
# &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth");
# &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"});
$result=$ENV{"form.homework_edit_$Apache::lonxml::curdepth"};
+ my $bodytext=&Apache::lonxml::get_all_text($endtag,$parser);
+ # textareas throw away intial \n
+ if ($bodytext=~/^\n/) { $result="\n".$result; }
return $result;
}
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.38 loncom/homework/imageresponse.pm:1.39
--- loncom/homework/imageresponse.pm:1.38 Mon Oct 27 15:04:34 2003
+++ loncom/homework/imageresponse.pm Thu Oct 30 15:52:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# image click response style
#
-# $Id: imageresponse.pm,v 1.38 2003/10/27 20:04:34 albertel Exp $
+# $Id: imageresponse.pm,v 1.39 2003/10/30 20:52:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -265,9 +265,7 @@
&Apache::edit::editfield($token->[1],$descr,'Text',60,2).
&Apache::edit::end_row();
} elsif ($target eq "modified") {
- my $descr=&Apache::lonxml::get_all_text('/text',$parser);
- $result=$token->[4].&Apache::edit::modifiedfield($token);
- &Apache::lonxml::debug($result);
+ $result=$token->[4].&Apache::edit::modifiedfield('/text',$parser);
}
return $result;
}
@@ -305,9 +303,7 @@
$result.=&Apache::edit::search(undef,'textnode').
&Apache::edit::end_row();
} elsif ($target eq "modified") {
- my $bgimg=&Apache::lonxml::get_all_text('/image',$parser);
- $result=$token->[4].&Apache::edit::modifiedfield($token);
- &Apache::lonxml::debug($result);
+ $result=$token->[4].&Apache::edit::modifiedfield('/image',$parser);
}
return $result;
}
@@ -454,9 +450,7 @@
&Apache::edit::entercoordpair(undef,'textnode').
&Apache::edit::end_row();
} elsif ($target eq "modified") {
- my $coords=&Apache::lonxml::get_all_text('/rectangle',$parser);
- $result=$token->[4].&Apache::edit::modifiedfield($token);
- &Apache::lonxml::debug($result);
+ $result=$token->[4].&Apache::edit::modifiedfield('/rectangle',$parser);
}
return $result;
}
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.121 loncom/homework/inputtags.pm:1.122
--- loncom/homework/inputtags.pm:1.121 Mon Oct 13 17:09:47 2003
+++ loncom/homework/inputtags.pm Thu Oct 30 15:52:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.121 2003/10/13 21:09:47 albertel Exp $
+# $Id: inputtags.pm,v 1.122 2003/10/30 20:52:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -145,8 +145,7 @@
} else {
$result=$token->[4];
}
- my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser);
- $result.=&Apache::edit::modifiedfield();
+ $result.=&Apache::edit::modifiedfield("/textfield",$parser);
} elsif ($target eq 'tex') {
my $number_of_lines = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
my $width_of_box = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
Index: loncom/homework/randomlabel.pm
diff -u loncom/homework/randomlabel.pm:1.51 loncom/homework/randomlabel.pm:1.52
--- loncom/homework/randomlabel.pm:1.51 Thu Oct 16 15:23:58 2003
+++ loncom/homework/randomlabel.pm Thu Oct 30 15:52:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# random labelling tool
#
-# $Id: randomlabel.pm,v 1.51 2003/10/16 19:23:58 sakharuk Exp $
+# $Id: randomlabel.pm,v 1.52 2003/10/30 20:52:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -404,7 +404,6 @@
$result.=&Apache::edit::editline('',$text,'',50).
&Apache::edit::end_table();
} elsif ($target eq 'modified') {
- my $text=$$parser[-1]->get_text("/label");
$result = '<label>';
if ($type eq 'image') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
@@ -416,7 +415,7 @@
$result = $token->[4];
}
}
- $result.=&Apache::edit::modifiedfield($token);
+ $result.=&Apache::edit::modifiedfield("/label",$parser);
}
return $result;
}
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.218 loncom/homework/structuretags.pm:1.219
--- loncom/homework/structuretags.pm:1.218 Fri Oct 24 17:04:21 2003
+++ loncom/homework/structuretags.pm Thu Oct 30 15:52:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.218 2003/10/24 21:04:21 albertel Exp $
+# $Id: structuretags.pm,v 1.219 2003/10/30 20:52:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1115,8 +1115,7 @@
&Apache::edit::editfield($token->[1],$text,"",80,4);
}
if ($target eq 'modified') {
- $text=&Apache::lonxml::get_all_text("endouttext",$parser);
- $result='<startouttext />'.&Apache::edit::modifiedfield();
+ $result='<startouttext />'.&Apache::edit::modifiedfield("endouttext",$parser);
}
if ($target eq 'tex') {
$result .= '\noindent ';
--albertel1067547174--