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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 27 Jun 2008 04:59:46 -0000


This is a MIME encoded message

--raeburn1214542786
Content-Type: text/plain

raeburn		Fri Jun 27 00:59:46 2008 EDT

  Modified files:              
    /loncom/interface	coursecatalog.pm 
  Log:
  - Checkboxes:
    - Show full details for each course (DC only)
    - Include courses set to be hidden from catalog (DC only)
    - Only show courses which allow self-enrollment
   moved to be available for both display of courses auto-catalogued by institutional code and display of courses catalogued manually.
  - Some &mt().
  
  
--raeburn1214542786
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080627005946.txt"

Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.31 loncom/interface/coursecatalog.pm:1.32
--- loncom/interface/coursecatalog.pm:1.31	Fri Jun 20 09:45:12 2008
+++ loncom/interface/coursecatalog.pm	Fri Jun 27 00:59:45 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for displaying the course catalog interface
 #
-# $Id: coursecatalog.pm,v 1.31 2008/06/20 13:45:12 bisitz Exp $
+# $Id: coursecatalog.pm,v 1.32 2008/06/27 04:59:45 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -100,7 +100,7 @@
             }
         }
     }
-    $r->print(&Apache::loncommon::end_page());
+    $r->print('<br />'.&Apache::loncommon::end_page());
     return OK;
 }
 
@@ -216,14 +216,47 @@
                 $jscript .= qq|
 function changeSort(caller) {
     document.$formname.sortby.value = caller;
+    copy_filters();
     document.$formname.submit();
 }
 function setCourseId(caller) {
-   document.$formname.coursenum.value = caller;
-   document.$formname.submit(); 
+    document.$formname.coursenum.value = caller;
+    copy_filters();
+    document.$formname.submit(); 
 }\n|;
             }
         }
+        $jscript .= qq| 
+function copy_filters() { 
+   if (document.coursecats.showselfenroll.checked) {
+       document.$formname.showselfenroll.value = '1';
+   } else {
+       document.$formname.showselfenroll.value = '';
+   }
+|;
+        if (&user_is_dc($codedom)) {
+            $jscript .= qq|
+   if (document.coursecats.showhidden.checked) {
+       document.$formname.showhidden.value = '1';
+   } else {
+       document.$formname.showhidden.value = '';
+   }
+   if (document.coursecats.showdetails.checked) {
+       document.$formname.showdetails.value = '1';
+   } else {
+       document.$formname.showdetails.value = '';
+   }
+|;
+        }
+        $jscript .= qq| 
+}
+
+function display_courses() {
+    copy_filters();
+    document.$formname.submit();
+}
+
+|;
         $js = '<script type"text/javascript">'."\n$jscript\n$catjs\n".
               '</script>';
         if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) {
@@ -232,11 +265,16 @@
         &cat_header($r,$codedom,$js,\%add_entries,$catlinks,$numtitles);
         my $cat_maxdepth = $env{'form.catalog_maxdepth'};
         $r->print('<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.
-                  '<input type="hidden" name="catalog_maxdepth" value="'.$cat_maxdepth.'" />'.
-                  '<input type="hidden" name="showdom" value="'.$env{'form.showdom'}.'" />'.
-                  '<input type="hidden" name="currcat_0" value="instcode::0" />');
+                  '<input type="hidden" name="catalog_maxdepth" value="'.$cat_maxdepth.'" />'."\n".
+                  '<input type="hidden" name="showdom" value="'.$env{'form.showdom'}.'" />'."\n".
+                  '<input type="hidden" name="currcat_0" value="instcode::0" />'.
+                  '<input type="hidden" name="showselfenroll" value="" />'."\n");
+        if (&user_is_dc($codedom)) {
+            $r->print('<input type="hidden" name="showhidden" value="" />'."\n".
+                      '<input type="hidden" name="showdetails" value="" />'."\n");
+        }
         if ($numtitles > 0) {
-            $r->print('<br /><b>'.&mt('Choose which course(s) to list.').'</b><br />');
+            $r->print('<b>'.&mt('Choose which course(s) to list.').'</b><br />');
             $r->print('<table><tr>');
             for (my $k=0; $k<$lasttitle-1; $k++) {
                 my (@items,@unsorted);
@@ -267,22 +305,7 @@
                       '<select name="'.$codetitles[$lasttitle-1].'">'."\n".
                       '<option value="0">All'."\n".
                       '</option>'."\n".'</select>'."\n".
-                 '</td>'
-                );
-            my $show_selfenroll_status;
-            if ($env{'form.showselfenroll'}) {
-                $show_selfenroll_status = 'checked="checked" ';
-            }
-            if (&user_is_dc($codedom)) {
-                my $showdetails_status;
-                if ($env{'form.showdetails'}) {
-                    $showdetails_status = 'checked="checked" ';
-                }
-                $r->print('<td></td><td><label><input type="checkbox" name="showdetails" value="1" '.$showdetails_status.'/>'.&mt('Show full details for each course (DC only)').'</label><br /><label><input type="checkbox" name="showselfenroll" value="1" '.$show_selfenroll_status.'/>'.&mt('Only show courses which allow self-enrollment').'</label></td>');
-            } else {
-                $r->print('<td></td><td><br /><label><input type="checkbox" name="showselfenroll" value="1" '.$show_selfenroll_status.'/>'.&mt('Only show courses which allow self-enrollment').'</label></td>');
-            }
-            $r->print('</tr></table>');
+                 '</td></tr></table>'."\n");
             if ($numtitles > 4) {
                 $r->print('<br /><br />'.$codetitles[$numtitles-1].'<br />'."\n".
                 '<input type="text" name="'.$codetitles[$numtitles-1].'" /><br />'."\n");
@@ -291,7 +314,7 @@
         }
         $r->print('<input type="hidden" name="coursenum" value="" /><input type="hidden" name="sortby" value="" /><input type="hidden" name="state" value="listing" /><input type="hidden" name="form.currcat_0" value="instcode::0" />');
         if ($numtitles > 0) {
-            $r->print('<input type="submit" name="catalogfilter" value="'.&mt('Display courses').'" />');
+            $r->print('<input type="button" name="catalogfilter" value="'.&mt('Display courses').'" onclick="javascript:display_courses()" />');
         }
         $r->print('<input type="hidden" name="numtitles" value="'.
                   $numtitles.'" /></form>');
@@ -339,9 +362,29 @@
               '<form name="coursecatdom" method="post" action="/adm/coursecatalog">'.
               '<td><b>'.&mt('Domain:').'</b></td><td>'.
               &Apache::loncommon::select_dom_form($codedom,'showdom','',1).
-	      '&nbsp;<input type="submit" name="godom" value="Go"></td></form></tr><tr>'.
-	      '<form name="coursecats" method="post" action="/adm/coursecatalog">'.
-              $catlinks.'</form></tr></table>');
+	      '&nbsp;<input type="submit" name="godom" value="'.&mt('Go').'"></td></form></tr>'.
+	      '<form name="coursecats" method="post" action="/adm/coursecatalog"><tr>'.
+              $catlinks.'</tr>');
+    my $show_selfenroll_status;
+    if ($env{'form.showselfenroll'}) {
+        $show_selfenroll_status = 'checked="checked" ';
+    }
+    if (&user_is_dc($codedom)) {
+        my $showdetails_status;
+        if ($env{'form.showdetails'}) {
+            $showdetails_status = 'checked="checked" ';
+        }
+        my $showhidden_status;
+        if ($env{'form.showhidden'}) {
+             $showhidden_status = 'checked="checked" ';
+        }
+        $r->print('<tr><td colspan="2"><label><input type="checkbox" name="showdetails" value="1" '.$showdetails_status.'/>'.&mt('Show full details for each course (DC only)').'</label></td></tr><tr><td colspan="2"><label><input type="checkbox" name="showhidden" value="1" '.$showhidden_status.'/>'.&mt('Include courses set to be hidden from catalog (DC only)').'</label></td></tr>');
+    }
+    $r->print('<tr><td colspan="2">'.
+              '<label><input type="checkbox" name="showselfenroll" value="1" '.
+              $show_selfenroll_status.'/>'.
+              &mt('Only show courses which allow self-enrollment').
+              '</label></td></tr></form></table><br />');
     return;
 }
 
@@ -349,9 +392,14 @@
     my ($dom) = @_;
     my %domconfig =
         &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
-    my (@cats,@trails,%allitems,%idx,@jsarray);
-    &Apache::loncommon::extract_categories($domconfig{'coursecategories'},\@cats,\@trails,
-                                           \%allitems,\%idx,\@jsarray);
+    my (@cats,@trails,%allitems,%idx,@jsarray,$cathash);
+    if (ref($domconfig{'coursecategories'}) eq 'HASH') {
+        $cathash = $domconfig{'coursecategories'}{'cats'};
+    } else {
+        $cathash = {};
+    }
+    &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx,
+                                           \@jsarray);
     my $currdepth = 0;
     my $deeper = 0;
     my $currcat_str;
@@ -409,7 +457,7 @@
                     $catlinks .= '</option>'."\n";
                 }
                 $catlinks .= '</select>'."\n".
-                             '&nbsp;<input type="submit" name="gocats" value="Go" />';
+                             '&nbsp;<input type="submit" name="gocats" value="'.&mt('Display courses').'" />';
             }
         } else {
             $catlinks .= &mt('Official courses (with institutional codes)').
@@ -439,7 +487,7 @@
                 $catlinks .= '<option value="'.$item.'">'.$name.'</option>'."\n";
             }
             $catlinks .= '</select>'."\n".
-                         '&nbsp;<input type="submit" name="gocats" value="Go" />';
+                         '&nbsp;<input type="submit" name="gocats" value="'.&mt('Display courses').'" />';
         }
     }
     $catlinks .= $currcat_str.'</td></tr></table></td>';
@@ -566,9 +614,14 @@
             $instcode = '.';
         }
     }
-    my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.',
-                                                undef,undef,'Course',1,
-                                                $env{'form.showselfenroll'});
+    my $showhidden;
+    if (&user_is_dc($domain)) {
+        $showhidden = $env{'form.showhidden'};
+    }
+    my %courses = 
+        &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.',undef,undef,
+                                      'Course',1,$env{'form.showselfenroll'},undef,
+                                      $showhidden,'coursecatalog');
     return %courses;
 }
 
@@ -582,9 +635,14 @@
     }
     my %courses;
     if ($filter ne '') {
-        %courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',
-                                                 undef,undef,'Course',1,
-                                                 $env{'form.showselfenroll'},$filter);
+        my $showhidden;
+        if (&user_is_dc($domain)) {
+            $showhidden = $env{'form.showhidden'};
+        }
+        %courses = 
+            &Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',undef,undef,
+                                          '.',1,$env{'form.showselfenroll'},
+                                          $filter,$showhidden,'coursecatalog');
     }
     return %courses;
 }
@@ -618,7 +676,7 @@
             $output = &mt('No courses match the criteria you selected.');
             return $output;
         }
-        if ($knownuser && !$env{'form.showdetails'}) {
+        if (($knownuser) && (!$env{'form.showdetails'}) && (!&user_is_dc($domain))) {
             $output = '<b>'.&mt('Note for students:').'</b> '
                      .&mt('If you are officially enrolled in a course but the course is not listed in your LON-CAPA courses, click the "Show more details" link for the specific course and check the default access dates and/or automated enrollment settings.')
                      .'<br /><br />';

--raeburn1214542786--