[LON-CAPA-cvs] cvs: loncom /homework structuretags.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Tue, 17 Jul 2007 18:18:54 -0000


albertel		Tue Jul 17 14:18:54 2007 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
  Log:
  BUG#5322, <web> <text> editing outside of a <startouttext /> would cause their contents to disappear
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.382 loncom/homework/structuretags.pm:1.383
--- loncom/homework/structuretags.pm:1.382	Fri Jun 22 16:42:20 2007
+++ loncom/homework/structuretags.pm	Tue Jul 17 14:18:54 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.382 2007/06/22 20:42:20 albertel Exp $
+# $Id: structuretags.pm,v 1.383 2007/07/17 18:18:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,9 +47,19 @@
 
 sub start_web {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
-    my $bodytext=&Apache::lonxml::get_all_text("/web",$parser,$style);
-    if ($target eq 'web' || $target eq 'webgrade') {
-	return $bodytext;
+    if ($target ne 'edit' && $target ne 'modified') {
+	my $bodytext=&Apache::lonxml::get_all_text("/web",$parser,$style);
+	if ($target eq 'web' || $target eq 'webgrade') {
+	    return $bodytext;
+	}
+    } elsif ($target eq "edit" ) {
+	my $bodytext = 
+	    &Apache::lonxml::get_all_text_unbalanced("/web",$parser);
+	my $result = &Apache::edit::tag_start($target,$token);
+	$result .= &Apache::edit::editfield($token->[1],$bodytext,'',80,1);
+	return $result;
+    } elsif ( $target eq "modified" ) {
+	return $token->[4].&Apache::edit::modifiedfield("/web",$parser);
     }
     return '';
 }
@@ -61,9 +71,19 @@
 sub start_tex {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result='';
-    my $bodytext=&Apache::lonxml::get_all_text("/tex",$parser,$style);
-    if ($target eq 'tex') {
-	return $bodytext.' ';
+    if ($target ne 'edit' && $target ne 'modified') {
+	my $bodytext=&Apache::lonxml::get_all_text("/tex",$parser,$style);
+	if ($target eq 'tex') {
+	    return $bodytext.' ';
+	}
+    } elsif ($target eq "edit" ) {
+	my $bodytext = 
+	    &Apache::lonxml::get_all_text_unbalanced("/tex",$parser);
+	my $result = &Apache::edit::tag_start($target,$token);
+	$result .= &Apache::edit::editfield($token->[1],$bodytext,'',80,1);
+	return $result;
+    } elsif ( $target eq "modified" ) {
+	return $token->[4].&Apache::edit::modifiedfield("/tex",$parser);
     }
     return $result;;
 }