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

www lon-capa-cvs-allow@mail.lon-capa.org
Mon, 10 Sep 2007 16:25:39 -0000


www		Mon Sep 10 12:25:39 2007 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
  Log:
  Bug #4816: At least make languageblock WORK. 
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.393 loncom/homework/structuretags.pm:1.394
--- loncom/homework/structuretags.pm:1.393	Mon Sep 10 09:39:16 2007
+++ loncom/homework/structuretags.pm	Mon Sep 10 12:25:38 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.393 2007/09/10 13:39:16 www Exp $
+# $Id: structuretags.pm,v 1.394 2007/09/10 16:25:38 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1140,17 +1140,25 @@
 	$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') {
 	my $include = $token->[2]->{'include'};
 	my $exclude = $token->[2]->{'exclude'};
-        my %languages=&Apache::loncommon::display_languages();
+        my $preferred_language=(&Apache::loncommon::preferred_languages)[0];
+# This should not even happen, since we should at least have the server language
+        unless ($preferred_language) { $preferred_language='en'; }
+# If the languageblock has no arguments, show the contents
         $result='1';
+# Do we have an include argument?
 	if ($include) {
+# If include is specified, by default, don't render the block
             $result='';
-            foreach (split(/\,/,$include)) {
-                if ($languages{$_}) { $result='1'; }
+            foreach my $included_language (split(/\,/,$include)) {
+# ... but if my preferred language is included, render it
+                if ($included_language eq $preferred_language) { $result='1'; }
             }
 	}
+# Do we have an exclude argument?
         if ($exclude) {
-            foreach (split(/\,/,$exclude)) {
-                if ($languages{$_}) { $result='0'; }
+            $result='1';
+            foreach my $excluded_language (split(/\,/,$exclude)) {
+                if ($excluded_language eq $preferred_language) { $result='0'; }
             }
 	}
 	if ( ! $result ) {