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

www lon-capa-cvs-allow@mail.lon-capa.org
Wed, 12 Sep 2007 07:59:51 -0000


www		Wed Sep 12 03:59:51 2007 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
  Log:
  Yeah, I know ... but for something that does not work, it works better now.
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.397 loncom/homework/structuretags.pm:1.398
--- loncom/homework/structuretags.pm:1.397	Tue Sep 11 19:53:05 2007
+++ loncom/homework/structuretags.pm	Wed Sep 12 03:59:51 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.397 2007/09/11 23:53:05 albertel Exp $
+# $Id: structuretags.pm,v 1.398 2007/09/12 07:59:51 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1143,27 +1143,36 @@
 	$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') {
 	my $include = $token->[2]->{'include'};
 	my $exclude = $token->[2]->{'exclude'};
-        my $preferred_language=(&Apache::loncommon::preferred_languages)[0];
+        my @preferred_languages=&Apache::loncommon::preferred_languages();
 # This should not even happen, since we should at least have the server language
-        if (!$preferred_language) { $preferred_language='en'; }
+        if (!$preferred_languages[0]) { $preferred_languages[0]='en'; }
+# Now loop over all languages in order of preference
+        foreach my $preferred_language (@preferred_languages) {
 # If the languageblock has no arguments, show the contents
-        $result='1';
+           $result='1';
 # Do we have an include argument?
-	if ($include) {
+	   if ($include) {
 # If include is specified, by default, don't render the block
-            $result='';
-            foreach my $included_language (split(/\,/,$include)) {
+              $result='';
+              foreach my $included_language (split(/\,/,$include)) {
 # ... but if my preferred language is included, render it
-                if ($included_language eq $preferred_language) { $result='1'; }
-            }
-	}
+                 if ($included_language eq $preferred_language) {
+                    $result='1'; 
+                    last; 
+                 }
+              }
+	   }
 # Do we have an exclude argument?
-        if ($exclude) {
-            $result='1';
-            foreach my $excluded_language (split(/\,/,$exclude)) {
-                if ($excluded_language eq $preferred_language) { $result='0'; }
-            }
-	}
+           if ($exclude) {
+              $result='1';
+              foreach my $excluded_language (split(/\,/,$exclude)) {
+                 if ($excluded_language eq $preferred_language) {
+                    $result='0';
+                    last; 
+                 }
+              }
+	   }
+        }
 	if ( ! $result ) {
 	    my $skip=&Apache::lonxml::get_all_text("/languageblock",$parser,
 						   $style);