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

raeburn raeburn at source.lon-capa.org
Sun Mar 16 22:33:32 EDT 2014


raeburn		Mon Mar 17 02:33:32 2014 EDT

  Modified files:              
    /loncom/interface	courseclassifier.pm 
  Log:
  - Course/Community search in domains where institutional codes are defined:
    clicking radio buttons for official or unofficial courses will show/hide
    linked select boxes for filtering by institutional code.
  
  
Index: loncom/interface/courseclassifier.pm
diff -u loncom/interface/courseclassifier.pm:1.17 loncom/interface/courseclassifier.pm:1.18
--- loncom/interface/courseclassifier.pm:1.17	Sun Mar 16 22:27:06 2014
+++ loncom/interface/courseclassifier.pm	Mon Mar 17 02:33:32 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utilities for classifying courses based on institutional code
 #
-# $Id: courseclassifier.pm,v 1.17 2014/03/16 22:27:06 raeburn Exp $
+# $Id: courseclassifier.pm,v 1.18 2014/03/17 02:33:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -489,12 +489,27 @@
                 if ($officialjs) {
                     $jscript .= '
 
-function toggleOfficial() {';
+function toggleOfficial() {
+   var choice; 
+   for (var i=0; i<document.'.$formname.'.official.length; i++) {
+       if (document.'.$formname.'.official[i].checked) {
+           choice = document.'.$formname.'.official[i].value;
+       }
+   }
+   if (choice == "off") {
+       if (document.getElementById("instcodes")) {
+           document.getElementById("instcodes").style.display = "none";
+       }';
                     for (my $i=0; $i<@{$codetitles}-1; $i++) {
                         $jscript .= '
-            document.'.$formname.'.'.$codetitles->[$i].'.selectedIndex = 0;';
+       document.'.$formname.'.'.$codetitles->[$i].'.selectedIndex = 0;';
                     }
-    $jscript .=  '
+    $jscript .= '
+   } else {
+       if (document.getElementById("instcodes")) { 
+           document.getElementById("instcodes").style.display = "block";
+       }
+   }
 }
 
 function setOfficial(caller) {
@@ -564,7 +579,11 @@
     my $output;
     my @standardnames = &Apache::loncommon::get_standard_codeitems();
     if ($numtitles > 0) {
-        $output .= '<table><tr>';
+        my $style;
+        if ($env{'form.official'} eq 'off') {
+            $style = ' style="display: none"';
+        }
+        $output .= '<div id="instcodes"'.$style.'><table><tr>';
         for (my $k=0; $k<$lasttitle-1; $k++) {
             my (@items, at unsorted);
             if (ref($cat_items->{$codetitles->[$k]}) eq 'ARRAY') {
@@ -600,7 +619,7 @@
                        '<input type="text" name="'.$standardnames[$numtitles-1].
                        '" /><br />'."\n";
         }
-        $output .= '<br />';
+        $output .= '</div>';
     }
     return $output;
 }
@@ -614,13 +633,14 @@
     if ($numtitles > 0) {
         my $official = ' checked="checked" ';
         my $unofficial = '';
-        if ($env{'form.official'} eq 'off') {
+        if (($formname eq 'filterpicker') && ($env{'form.official'} eq 'off')) {
             $unofficial = $official;
             $official = '';
         }
         $output .= '<span class="LC_nobreak">'.&mt('Official course:').' <label>'.
-                   '<input type="radio" name="official" value="on"'.$official.' />'.
-                   &mt('Yes').'</label>'.(' 'x3).'<label>'.
+                   '<input type="radio" name="official" value="on"'.$official.
+                   ' onclick="toggleOfficial();" />'.&mt('Yes').'</label>'.
+                   (' 'x3).'<label>'.
                    '<input type="radio" name="official" value="off"'.$unofficial.
                    ' onclick="toggleOfficial();" />'.&mt('No').'</label></span><br />'.
                    &build_instcode_selectors($numtitles,$lasttitle,\%cat_items,$codetitles,




More information about the LON-CAPA-cvs mailing list