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

schualex schualex@source.lon-capa.org
Wed, 03 Jun 2009 17:17:03 -0000


schualex		Wed Jun  3 17:17:03 2009 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  function displaymenu:
  close and open the pickbox in step 2 to add an extra parameter-chooser between them.
  
  function parmmenu:
  cutting the function parmmenu in different functions to handle them in overview and tablemode. new functions: shortCuts(the shortcuts for normally used setti
  ngs like "select all"); parmboxes(displayes the checkboxes with the parms)
  i've added an overview-box in parmmenu that displays all selected parms without showing the parm-checkboxes. Especially the shortcuts are working in it. all 
  possible parms are with hidden style. A javascript function controlls the checkboxes and enables the hidden style of the selected parm.
  
  There are some new javascript functions, that allows to set the display-style. hideParms() and showParms() are for hidding and showing the parm-checkbox-fiel
  dset. checkCheckbox() is for setting the display-style a of parameter value. The Checkthis() and Checkall() functions are modified that they are able to disp
  lay or hide also the overview-listitems as well as they are checking the parm-checkboxes.
  
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.452 loncom/interface/lonparmset.pm:1.453
--- loncom/interface/lonparmset.pm:1.452	Sat May 30 21:52:30 2009
+++ loncom/interface/lonparmset.pm	Wed Jun  3 17:17:03 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.452 2009/05/30 21:52:30 bisitz Exp $
+# $Id: lonparmset.pm,v 1.453 2009/06/03 17:17:03 schualex Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1249,15 +1249,25 @@
     $r->print(<<ENDSCRIPT);
 <script type="text/javascript">
     function checkall(value, checkName) {
+
+        var li = "_li";
+        var displayOverview = "";
+        
+        if (value == false) {
+            displayOverview = "none"
+        }
+
 	for (i=0; i<document.forms.parmform.elements.length; i++) {
             ele = document.forms.parmform.elements[i];
             if (ele.name == checkName) {
                 document.forms.parmform.elements[i].checked=value;
+                document.getElementById(document.forms.parmform.elements[i].value.concat(li)).style.display = displayOverview;
             }
         }
     }
 
     function checkthis(thisvalue, checkName) {
+        checkboxChecked(thisvalue);
 	for (i=0; i<document.forms.parmform.elements.length; i++) {
             ele = document.forms.parmform.elements[i];
             if (ele.name == checkName) {
@@ -1284,7 +1294,6 @@
  	checkthis('contentclose','pscat');
     }
 
-
     function checkvisi() {
 	checkthis('hiddenresource','pscat');
  	checkthis('encrypturl','pscat');
@@ -1306,15 +1315,72 @@
 	checkthis('maxtries','pscat');
     }
 
+    function hideParms() {
+        document.getElementById('LC_parm_overview_parm_menu').style.display = "none";
+    }
+
+    function showParms() {
+        document.getElementById('LC_parm_overview_parm_menu').style.display = "";
+    }
+
+    function checkboxChecked(id) {
+        var li = "_li";
+        var id_li = id.concat(li);
+
+        if (document.getElementById(id_li).style.display == "none") {
+            document.getElementById(id_li).style.display = "";
+        }
+        else {
+            document.getElementById(id_li).style.display = "none";
+        }
+    }
+
 </script>
 ENDSCRIPT
     $r->print();
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View')));
-    $r->print("\n".'<table id="LC_parm_overview_parm_menu"><tr>');
+
+    #part to print selected parms overview
+    $r->print('<table id="LC_parm_overview_parm_overview">'
+             .'<tr>'
+             .'<td style="vertical-align:top; width:250px"><p>'.&mt('Selected Parameters').': ');
+
+    #print out all possible parms and hide it
+    $r->print('<td>');
+    $r->print('<ol style="list-style-type:disc">');
+    foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
+        $r->print('<li id="'.$tempkey.'_li" value="'.$tempkey.'_li" name="pscat_li"');
+        if (!($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat})) {
+            $r->print('style="display:none"');
+        }
+        
+        $r->print('>'.($$allparms{$tempkey}=~/\s/ ? $$allparms{$tempkey} : $tempkey).'</li>');
+    }
+    $r->print('<a href="javascript:showParms()">('.&mt('add more parameter').')'
+             .'</a></p></td>');
+    $r->print('</td>');
+    $r->print('</tr>'
+             .'</table>');
+
+    &shortCuts($r,$allparms,$pscat,$keyorder);
+
+    $r->print('</table>');
+}
+
+sub parmboxes {
+    my ($r,$allparms,$pscat,$keyorder)=@_;
+    my $tempkey;
+
+    #part to print the parm-list
+    $r->print('<table><tr><td><fieldset id="LC_parm_overview_parm_menu" style="display:none"><legend><b>'.&mt('Parameter').'</legend>');
+    $r->print("\n".'<table>');
     my $cnt=0;
+
+    $r->print('<tr>');
     foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
 	$r->print("\n".'<td><label><input type="checkbox" name="pscat" ');
-	$r->print('value="'.$tempkey.'"');
+	$r->print('value="'.$tempkey.'" ');
+        $r->print('onclick="checkboxChecked(\''.$tempkey.'\')"');
 	if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
 	    $r->print(' checked="checked"');
 	}
@@ -1322,13 +1388,23 @@
                                                   : $tempkey)
                   .'</label></td>');
  	$cnt++;
-        if ($cnt==3) {
+        if ($cnt==4) {
 	    $r->print("</tr>\n<tr>");
 	    $cnt=0;
 	}
     }
     $r->print('</tr>'
-             .'<tr id="LC_parm_overview_parm_menu_selectors">'
+             .'</table>'
+             .'<a href="javascript:hideParms()" style="font-weight:normal">('.&mt('hide more parameter').')');
+
+    #&shortCuts($r,$allparms,$pscat,$keyorder);
+    $r->print('</fieldset></td></tr></table>');
+}
+sub shortCuts {
+    my ($r,$allparms,$pscat,$keyorder)=@_;
+
+    #part to print out the shortcuts for parmselection
+    $r->print('<table><tr id="LC_parm_overview_parm_menu_selectors">'
              .'<td valign="top">'
              .'<fieldset><legend><b>'.&mt('Parameter Selection').'</b></legend>'
              .'<span class="LC_nobreak">'
@@ -1365,8 +1441,7 @@
              .'</span>'
              .'</fieldset>'
              .'</td>'
-             .'</tr></table>'
-    );
+             .'</tr></table>');
 }
 
 sub partmenu {
@@ -1490,8 +1565,10 @@
     $r->print(&Apache::lonhtmlcommon::topic_bar (2,&mt('Select Parameters')));
     $r->print(&Apache::lonhtmlcommon::start_pick_box());
     &parmmenu($r,$allparms,$pscat,$keyorder);
-    $r->print(&Apache::lonhtmlcommon::row_closure());
-
+    #$r->print(&Apache::lonhtmlcommon::row_closure());
+    $r->print(&Apache::lonhtmlcommon::end_pick_box());
+    &parmboxes($r,$allparms,$pscat,$keyorder);
+    $r->print(&Apache::lonhtmlcommon::start_pick_box());
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
     &partmenu($r,$allparts,$psprt);
     $r->print(&Apache::lonhtmlcommon::row_closure(1));
@@ -2810,8 +2887,10 @@
     $r->print('<div>');
     $r->print(&Apache::lonhtmlcommon::start_pick_box());
     &parmmenu($r,\%allparms,\@pscat,\%keyorder);
-    $r->print(&Apache::lonhtmlcommon::row_closure());
-
+    #$r->print(&Apache::lonhtmlcommon::row_closure());
+    $r->print(&Apache::lonhtmlcommon::end_pick_box());
+    &parmboxes($r,\%allparms,\@pscat,\%keyorder);
+    $r->print(&Apache::lonhtmlcommon::start_pick_box());
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
     #$r->print('</td><td class="LC_parm_overview_restrictions">'.
      $r->print('<table>'.