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

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 18 Jun 2003 22:12:34 -0000


albertel		Wed Jun 18 18:12:34 2003 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
  Log:
  - making it so that <languageblock> can be used inside of stylefiles
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.185 loncom/homework/structuretags.pm:1.186
--- loncom/homework/structuretags.pm:1.185	Tue Jun 17 11:36:11 2003
+++ loncom/homework/structuretags.pm	Wed Jun 18 18:12:34 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.185 2003/06/17 15:36:11 albertel Exp $
+# $Id: structuretags.pm,v 1.186 2003/06/18 22:12:34 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -645,26 +645,7 @@
 
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
 	$target eq 'tex' || $target eq 'analyze') {
-	my $include = $token->[2]->{'include'};
-	my $exclude = $token->[2]->{'exclude'};
-        my %languages=&Apache::loncommon::display_languages();
-        $result='1';
-	if ($include) {
-            $result='';
-            foreach (split(/\,/,$include)) {
-                if ($languages{$_}) { $result='1'; }
-            }
-	}
-        if ($exclude) {
-            foreach (split(/\,/,$exclude)) {
-                if ($languages{$_}) { $result='0'; }
-            }
-	}
-	if ( ! $result ) {
-	    my $skip=&Apache::lonxml::get_all_text("/languageblock",$parser);
-	    &Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]");
-	}
-	$result='';
+	&Apache::lonxml::startredirection();
     } elsif ($target eq 'edit') {
 	$result .=&Apache::edit::tag_start($target,$token);
 	$result .=&Apache::edit::text_arg('Include Language:','include',
@@ -684,7 +665,31 @@
 sub end_languageblock {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result;
-    if ($target eq "edit") {
+
+    if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+	$target eq 'tex' || $target eq 'analyze') {
+	my $text=&Apache::lonxml::endredirection();
+	my $include= &Apache::lonxml::get_param('include',$parstack,$safeeval);
+	my $exclude= &Apache::lonxml::get_param('exclude',$parstack,$safeeval);
+	my %languages=&Apache::loncommon::display_languages();
+	$result='1';
+	if ($include) {
+	    $result='';
+	    foreach (split(/\,/,$include)) {
+		if ($languages{$_}) { $result='1'; }
+	    }
+	}
+	if ($exclude) {
+	    foreach (split(/\,/,$exclude)) {
+		if ($languages{$_}) { $result='0'; }
+	    }
+	}
+	if ( ! $result ) {
+	    $result='';
+	} else {
+	    $result=$text;
+	}
+    } elsif ($target eq "edit") {
 	$result.= &Apache::edit::tag_end($target,$token,'');
     }
     return $result;