[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm

amueller amueller@source.lon-capa.org
Tue, 14 Jul 2009 13:53:04 -0000


amueller		Tue Jul 14 13:53:04 2009 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  -Parameters have now a fixed order.
  -In Hash %category_order the order is defined.
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.466 loncom/interface/lonparmset.pm:1.467
--- loncom/interface/lonparmset.pm:1.466	Wed Jul  1 17:11:38 2009
+++ loncom/interface/lonparmset.pm	Tue Jul 14 13:53:03 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.466 2009/07/01 17:11:38 bisitz Exp $
+# $Id: lonparmset.pm,v 1.467 2009/07/14 13:53:03 amueller Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1457,12 +1457,28 @@
     } ( @{$name});
 }
 
+sub category_order {
+    return (
+        'time_settings' => 1,
+        'grading' => 2,
+        'tries' => 3,
+        'problem_appearance' => 4,
+        'hiding' => 5,
+        'behaviour_of_input_fields' => 6,
+        'high_level_randomization'  => 7,
+        'slots' => 8,
+        'file_submission' => 9,
+        'misc' => 10
+    );
+
+}
 
 sub parmboxes {
     my ($r,$allparms,$pscat,$keyorder)=@_;
     my $tempkey;
     my $tempparameter;
     my %categories = &categories;
+    my %category_order = &category_order();
     my %categoryList = (
         'time_settings' => [],
         'grading' => [],
@@ -1475,7 +1491,6 @@
         'file_submission' => [],
         'misc' => [],
    );
-
     foreach $tempparameter (keys %$allparms) {
         &whatIsMyCategory($tempparameter, \%categoryList);
     }
@@ -1485,16 +1500,15 @@
     );
 
     #Print parameters
-    my ($category, $list) = undef;
-    while (($category, $list) = each %categoryList) {
-        if(@$list == 0) {
+    for my $key (sort { $category_order{$a} <=> $category_order{$b} } keys %categoryList) {
+        if(@{$categoryList{$key}} == 0) {
             next;
         } else { 
             $r->print('<fieldset>'
                      .'<legend>'
-                     .&mt($categories{$category})
+                     .&mt($categories{$key})
                      .'</legend>'."\n");
-            foreach $tempkey (&keysindisplayorderCategory($list,$keyorder)) {
+            foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) {
                     $r->print('<span class="LC_nobreak">'
                              .'<label><input type="checkbox" name="pscat" ');
 	            $r->print('value="'.$tempkey.'" ');