Diff for /loncom/interface/coursecatalog.pm between versions 1.32 and 1.33

version 1.32, 2008/06/27 04:59:45 version 1.33, 2008/06/30 04:07:06
Line 84  function setCatDepth(depth) { Line 84  function setCatDepth(depth) {
 }  }
   
 ENDSCRIPT  ENDSCRIPT
           if ($env{'form.state'} eq 'listing') {
               $catjs .= qq|
   function changeSort(caller) {
       document.$formname.sortby.value = caller;
       document.$formname.submit();
   }
   function setCourseId(caller) {
       document.$formname.coursenum.value = caller;
       document.$formname.submit();
   }\n|;
           }
         my $numtitles;          my $numtitles;
         if ($env{'form.currcat_0'} eq 'instcode::0') {          if ($env{'form.currcat_0'} eq 'instcode::0') {
             $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc,              $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc,
Line 96  ENDSCRIPT Line 107  ENDSCRIPT
             $catjs = '<script type="text/javascript">'."\n".$catjs."\n".'</script>';              $catjs = '<script type="text/javascript">'."\n".$catjs."\n".'</script>';
             &cat_header($r,$codedom,$catjs,\%add_entries,$catlinks);              &cat_header($r,$codedom,$catjs,\%add_entries,$catlinks);
             if ($env{'form.currcat_0'} ne '') {              if ($env{'form.currcat_0'} ne '') {
                   $r->print('<form name="'.$formname.
                             '" method="post" action="/adm/coursecatalog">'.
                             &additional_filters($codedom)."\n");
                   my ($currdepth,$deeper) = &get_depth_values();
                   $r->print('<input type="hidden" name="catalog_maxdepth" value="'.
                             $deeper.'" />'."\n");
                   for (my $i=0; $i<$deeper; $i++) {
                       $r->print('<input type="hidden" name="currcat_'.$i.'" value="'.$env{'form.currcat_'.$i}.'" />'."\n");
                   }
                   $r->print('<input type="hidden" name="coursenum" value="" />'."\n".
                             '<input type="hidden" name="sortby" value="" />'."\n".
                             '<input type="hidden" name="state" value="listing" />'."\n".
                             '<input type="hidden" name="showdom" value="'.
                             $env{'form.showdom'}.'" />'.
                             '<input type="submit" name="catalogfilter" value="'.
                             &mt('Display courses').'" /></form><br /><br />');
               }
               if ($env{'form.state'} eq 'listing') {
                 $r->print(&print_course_listing($codedom));                  $r->print(&print_course_listing($codedom));
             }              }
         }          }
Line 212  function setElements() { Line 241  function setElements() {
                     $jscript .= '}';                      $jscript .= '}';
                 }                  }
             }              }
             if ($env{'form.state'} eq 'listing') {  
                 $jscript .= qq|  
 function changeSort(caller) {  
     document.$formname.sortby.value = caller;  
     copy_filters();  
     document.$formname.submit();  
 }  
 function setCourseId(caller) {  
     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".          $js = '<script type"text/javascript">'."\n$jscript\n$catjs\n".
               '</script>';                '</script>';
         if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) {          if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) {
Line 268  function display_courses() { Line 253  function display_courses() {
                   '<input type="hidden" name="catalog_maxdepth" value="'.$cat_maxdepth.'" />'."\n".                    '<input type="hidden" name="catalog_maxdepth" value="'.$cat_maxdepth.'" />'."\n".
                   '<input type="hidden" name="showdom" value="'.$env{'form.showdom'}.'" />'."\n".                    '<input type="hidden" name="showdom" value="'.$env{'form.showdom'}.'" />'."\n".
                   '<input type="hidden" name="currcat_0" value="instcode::0" />'.                    '<input type="hidden" name="currcat_0" value="instcode::0" />'.
                   '<input type="hidden" name="showselfenroll" value="" />'."\n");                    &additional_filters($codedom));
         if (&user_is_dc($codedom)) {  
             $r->print('<input type="hidden" name="showhidden" value="" />'."\n".  
                       '<input type="hidden" name="showdetails" value="" />'."\n");  
         }  
         if ($numtitles > 0) {          if ($numtitles > 0) {
             $r->print('<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>');              $r->print('<table><tr>');
Line 312  function display_courses() { Line 293  function display_courses() {
             }              }
             $r->print('<br />');              $r->print('<br />');
         }          }
         $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" />');          $r->print('<input type="hidden" name="coursenum" value="" />'."\n".
         if ($numtitles > 0) {                    '<input type="hidden" name="sortby" value="" />'."\n".
             $r->print('<input type="button" name="catalogfilter" value="'.&mt('Display courses').'" onclick="javascript:display_courses()" />');                    '<input type="hidden" name="state" value="listing" />'."\n".
         }                    '<input type="hidden" name="form.currcat_0" value="instcode::0" />'."\n".
         $r->print('<input type="hidden" name="numtitles" value="'.                    '<input type="submit" name="catalogfilter" value="'.
                   $numtitles.'" /></form>');                    &mt('Display courses').'" />'.
                     '<input type="hidden" name="numtitles" value="'.$numtitles.
                     '" /></form>');
         if (($numtitles > 0) && ($env{'form.state'} eq 'listing')) {          if (($numtitles > 0) && ($env{'form.state'} eq 'listing')) {
             $r->print('<br />');              $r->print('<br />');
         }          }
Line 362  sub cat_header { Line 345  sub cat_header {
               '<form name="coursecatdom" method="post" action="/adm/coursecatalog">'.                '<form name="coursecatdom" method="post" action="/adm/coursecatalog">'.
               '<td><b>'.&mt('Domain:').'</b></td><td>'.                '<td><b>'.&mt('Domain:').'</b></td><td>'.
               &Apache::loncommon::select_dom_form($codedom,'showdom','',1).                &Apache::loncommon::select_dom_form($codedom,'showdom','',1).
       '&nbsp;<input type="submit" name="godom" value="'.&mt('Go').'"></td></form></tr>'.        '&nbsp;<input type="submit" name="godom" value="'.&mt('Change').'"></td></form></tr>'.
       '<form name="coursecats" method="post" action="/adm/coursecatalog"><tr>'.        '<tr><form name="coursecats" method="post" action="/adm/coursecatalog">'.
               $catlinks.'</tr>');                $catlinks.'</form></tr></table>');
     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;      return;
 }  }
   
Line 400  sub category_breadcrumbs { Line 363  sub category_breadcrumbs {
     }      }
     &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx,      &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx,
                                            \@jsarray);                                             \@jsarray);
     my $currdepth = 0;      my ($currdepth,$deeper) = &get_depth_values();
     my $deeper = 0;      my $currcat_str = '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" /><input type="hidden" name="showdom" value="'.$dom.'" />';
     my $currcat_str;  
     if ($env{'form.catalog_maxdepth'} ne '') {  
         $currdepth = $env{'form.catalog_maxdepth'};  
         if ($env{'form.currcat_'.$currdepth} eq '') {  
             $deeper = $currdepth;  
         } else {  
             $deeper = $currdepth + 1;  
         }  
     }  
     $currcat_str = '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" /><input type="hidden" name="showdom" value="'.$dom.'" />';  
     my $catlinks = '<td valign="top"><b>'.&mt('Catalog:').'</b></td><td><table><tr>';      my $catlinks = '<td valign="top"><b>'.&mt('Catalog:').'</b></td><td><table><tr>';
     for (my $i=0; $i<$deeper; $i++) {      for (my $i=0; $i<$deeper; $i++) {
         $currcat_str .= '<input type="hidden" name="currcat_'.$i.'" value="'.$env{'form.currcat_'.$i}.'" />';          $currcat_str .= '<input type="hidden" name="currcat_'.$i.'" value="'.$env{'form.currcat_'.$i}.'" />';
Line 457  sub category_breadcrumbs { Line 410  sub category_breadcrumbs {
                     $catlinks .= '</option>'."\n";                      $catlinks .= '</option>'."\n";
                 }                  }
                 $catlinks .= '</select>'."\n".                  $catlinks .= '</select>'."\n".
                              '&nbsp;<input type="submit" name="gocats" value="'.&mt('Display courses').'" />';                               '&nbsp;<input type="submit" name="gocats" value="'.&mt('Change').'" />';
             }              }
         } else {          } else {
             $catlinks .= &mt('Official courses (with institutional codes)').              $catlinks .= &mt('Official courses (with institutional codes)').
Line 487  sub category_breadcrumbs { Line 440  sub category_breadcrumbs {
                 $catlinks .= '<option value="'.$item.'">'.$name.'</option>'."\n";                  $catlinks .= '<option value="'.$item.'">'.$name.'</option>'."\n";
             }              }
             $catlinks .= '</select>'."\n".              $catlinks .= '</select>'."\n".
                          '&nbsp;<input type="submit" name="gocats" value="'.&mt('Display courses').'" />';                           '&nbsp;<input type="submit" name="gocats" value="'.&mt('Change').'" />';
         }          }
     }      }
     $catlinks .= $currcat_str.'</td></tr></table></td>';      $catlinks .= $currcat_str.'</td></tr></table></td>';
     return $catlinks;      return $catlinks;
 }  }
   
   sub get_depth_values {
       my $currdepth = 0;
       my $deeper = 0;
       if ($env{'form.catalog_maxdepth'} ne '') {
           $currdepth = $env{'form.catalog_maxdepth'};
           if ($env{'form.currcat_'.$currdepth} eq '') {
               $deeper = $currdepth;
           } else {
               $deeper = $currdepth + 1;
           }
       }
       return ($currdepth,$deeper);
   }
   
   sub additional_filters {
       my ($codedom) = @_;
       my $output = '<table>';
       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" ';
           }
           my $dc_title = &Apache::lonnet::plaintext('dc');
           $output .= '<tr><td>'."\n".
                      '<label><input type="checkbox" name="showdetails" value="1" '.
                      $showdetails_status.'/>'."\n".
                      &mt('Show full details for each course ([_1] only)',$dc_title).
                      '</label>'."\n".'</td></tr><tr><td>'.
                      '<label><input type="checkbox" name="showhidden" value="1" '.
                      $showhidden_status.'/>'.
                      &mt('Include courses set to be hidden from catalog ([_1] only)',$dc_title).
                      '</label>'."\n".'</td></tr>';
       }
       $output .= '<tr><td>'.
                  '<label><input type="checkbox" name="showselfenroll" value="1" '.
                  $show_selfenroll_status.'/>'.
                  &mt('Only show courses which allow self-enrollment').
                  '</label></td></tr></table><br />';
       return $output;
   }
   
 sub user_is_dc {  sub user_is_dc {
     my ($codedom) = @_;      my ($codedom) = @_;
     if (exists($env{'user.role.dc./'.$codedom.'/'})) {      if (exists($env{'user.role.dc./'.$codedom.'/'})) {
Line 661  sub print_course_listing { Line 663  sub print_course_listing {
     if ($env{'form.coursenum'} ne '') {      if ($env{'form.coursenum'} ne '') {
         %courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.',          %courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.',
                                                  $env{'form.coursenum'},                                                   $env{'form.coursenum'},
                                                  undef,undef,'Course',1);                                                   undef,undef,'.',1);
         if (keys(%courses) == 0) {          if (keys(%courses) == 0) {
             $output .= &mt('The courseID provided does not match a course in this domain.');              $output .= &mt('The courseID provided does not match a course in this domain.');
             return $output;              return $output;

Removed from v.1.32  
changed lines
  Added in v.1.33


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>