Diff for /loncom/interface/coursecatalog.pm between versions 1.88.2.9 and 1.108

version 1.88.2.9, 2021/12/12 21:47:58 version 1.108, 2025/02/24 23:20:17
Line 37  use Apache::lonnet; Line 37  use Apache::lonnet;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::courseclassifier;  use Apache::courseclassifier;
 use Apache::lonacc;  use Apache::lonacc;
   use HTML::Entities();
 use LONCAPA;  use LONCAPA;
 use LONCAPA::lonauthcgi;  use LONCAPA::lonauthcgi;
   
Line 57  sub handler { Line 58  sub handler {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['sortby','showdom']);                                              ['sortby','showdom']);
   
     my $codedom = &Apache::lonnet::default_login_domain();      my $serverdefdom = &Apache::lonnet::default_login_domain();
       my $codedom = $serverdefdom;
     my $hostname = $r->hostname();      my $hostname = $r->hostname();
   
     if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {       if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { 
Line 75  sub handler { Line 77  sub handler {
             $env{'form.showdom'} = '';              $env{'form.showdom'} = '';
         }          }
     }      }
     my $domdesc = &Apache::lonnet::domain($codedom,'description');      my $domdesc = &Apache::lonnet::domain($serverdefdom,'description');
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
       
       unless (($serverdefdom eq $codedom) ||
               (&Apache::lonnet::will_trust('catalog',$serverdefdom,$codedom))) {
           my $serverdomdesc = &Apache::lonnet::domain($serverdefdom,'description');
           $r->print(&Apache::loncommon::start_page('Course/Community Catalog'));
           &Apache::lonhtmlcommon::add_breadcrumb
               ({href=>"/adm/coursecatalog",
                 text=>"Course/Community Catalog"});
           $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));
           $r->print('<div role="main">'.&mt('Access to catalog LON-CAPA courses/communities unavailable for: "[_1]" on servers run by: "[_2]".',
                     $domdesc,$serverdomdesc).'</div>');
           $r->print(&Apache::loncommon::end_page());
           return OK;
       }
     my $crscats = &Apache::lonnet::get_dom_cats($codedom);      my $crscats = &Apache::lonnet::get_dom_cats($codedom);
     my %domdefaults = &Apache::lonnet::get_domain_defaults($codedom);      my %domdefaults = &Apache::lonnet::get_domain_defaults($codedom);
     my $knownuser = &user_is_known();      my $knownuser = &user_is_known();
Line 104  sub handler { Line 119  sub handler {
           text=>"Course/Community Catalog"});            text=>"Course/Community Catalog"});
         $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));          $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));
         if ($knownuser || $canviewall) {          if ($knownuser || $canviewall) {
             $r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>');              $r->print('<div role="main">'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>');
         } else {          } else {
             if ($domdefaults{'catauth'} eq 'none') {              if ($domdefaults{'catauth'} eq 'none') {
                 $r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>');                  $r->print('<div role="main">'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>');
             } else {              } else {
                 $r->print('<div>'.&mt('The catalog of LON-CAPA courses/communities provided for: "[_1]" is only available to users who are logged in.',$domdesc).'</div>');                  $r->print('<div role="main">'.&mt('The catalog of LON-CAPA courses/communities provided for: "[_1]" is only available to users who are logged in.',$domdesc).'</div>');
             }              }
         }                }      
         $r->print(&Apache::loncommon::end_page());          $r->print(&Apache::loncommon::end_page());
         return OK;          return OK;
     }      }
   
       for (my $i=0; $i<=$env{'form.catalog_maxdepth'}; $i++) {
           if ($env{'form.currcat_'.$i} eq '-1') {
               $env{'form.currcat_'.$i} = '';
           }
           if (exists($env{'form.initialcurrcat_'.$i})) {
               if ($env{'form.currcat_'.$i} ne $env{'form.initialcurrcat_'.$i}) {
                   $env{'form.catalog_maxdepth'} = $i;
                   last;
               }
           }
       }
   
     my $cnum;      my $cnum;
     if ($cattype eq 'codesrch') {      if ($cattype eq 'codesrch') {
         my ($uniquecode,$codemsg,$brtext);          my ($uniquecode,$codemsg,$brtext);
Line 246  sub handler { Line 273  sub handler {
     } else {      } else {
         my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats);          my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats);
         my $wasacctext = &get_wasactive_text();          my $wasacctext = &get_wasactive_text();
           my %js_lt = &Apache::lonlocal::texthash(
                                                    'noch' => 'No changes made in drop-down lists',
                                                    'chsu' => 'Choose a subcategory to display',
                                                    'chca' => 'Choose a category to display',
           );
           &js_escape(\%js_lt);
         my $catjs = <<"ENDSCRIPT";          my $catjs = <<"ENDSCRIPT";
   
 function setCatDepth(depth) {  
     var depth = parseInt(depth);  
     if (depth !== NaN) {  
         if (depth > 0) {  
             var possmaxd = 0;  
             var toplevel = new Array($toplevelstr);  
             var maxdepths = new Array($maxdepthstr);  
             if (toplevel.length) {  
                 for (var i=0; i<toplevel.length; i++) {  
                     var item = unescape(toplevel[i]);  
                     if (item == document.coursecats.currcat_0.value) {  
                         possmaxd = maxdepths[i];  
                         break;  
                     }  
                 }  
             }  
             if (depth > possmaxd) {  
                 depth = possmaxd;  
             }  
         }  
         document.coursecats.catalog_maxdepth.value = depth;  
     } else {  
         document.coursecats.currcat_0.value = '';  
         document.coursecats.catalog_maxdepth.value = '';  
     }  
     document.coursecats.submit();  
     return;  
 }  
   
 function changeSort(caller) {  function changeSort(caller) {
     document.$formname.sortby.value = caller;      document.$formname.sortby.value = caller;
     document.$formname.submit();      document.$formname.submit();
Line 328  ENDTOGGJS Line 332  ENDTOGGJS
         } else {          } else {
             my (%add_entries);              my (%add_entries);
             my ($currdepth,$deeper) = &get_depth_values();              my ($currdepth,$deeper) = &get_depth_values();
             if ($selitem) {              my $alert = $js_lt{'chsu'};
                 my $alert = &mt('Choose a subcategory to display');              if (!$deeper) {
                 if (!$deeper) {                  $alert = $js_lt{'chca'};
                     $alert = &mt('Choose a category to display');              }
                 }              $catjs .= <<"ENDJS";
                 &js_escape(\$alert);  
                 $catjs .= <<ENDJS;  
 function check_selected() {  function check_selected() {
     if (document.coursecats.$selitem.options[document.coursecats.$selitem.selectedIndex].value == "") {      var currdepth = parseInt('$currdepth');
         alert('$alert');      var countchanged = 0;
       for (var i=0; i<=currdepth; i++) {
           var selidx = document.coursecats.elements['currcat_'+i].selectedIndex;
           var selvalue = document.coursecats.elements['currcat_'+i].options[selidx].value;
           if (i<currdepth) {
               var initialvalue = document.coursecats.elements['initialcurrcat_'+i].value;
               if (selvalue != initialvalue) {
                   countchanged ++;
               }
           } else {
               if (countchanged == 0) {
                   if (selvalue == "") {
                       alert('$alert');
                       return false;
                   } else {
                       countchanged ++;
                   }
               }
           }
       }
       if (countchanged == 0) {
           alert("$js_lt{'noch'}");
         return false;          return false;
     }      }
 }  }
 ENDJS  ENDJS
             }              my $js = '<script type="text/javascript">'."\n".
             $catjs = '<script type="text/javascript">'."\n".$catjs."\n".'</script>';                       '// <![CDATA['."\n".
             &cat_header($r,$codedom,$catjs,\%add_entries,$catlinks,undef,$cattype);                       "$catjs\n".
                        '// ]]>'."\n".
                        '</script>';
               &cat_header($r,$codedom,$js,\%add_entries,$catlinks,undef,$cattype);
             if ($env{'form.currcat_0'} ne '') {              if ($env{'form.currcat_0'} ne '') {
                 $r->print('<form name="'.$formname.                  $r->print('<form name="'.$formname.
                           '" method="post" action="/adm/coursecatalog">'.                            '" method="post" action="/adm/coursecatalog">'.
Line 357  ENDJS Line 383  ENDJS
                 my $display_button;                  my $display_button;
                 if ($env{'form.currcat_0'} eq 'communities::0') {                  if ($env{'form.currcat_0'} eq 'communities::0') {
                     $display_button = &mt('Display communities');                      $display_button = &mt('Display communities');
                   } elsif ($env{'form.currcat_0'} eq 'placement::0') {
                       $display_button = &mt('Display placement tests');
                 } else {                  } else {
                     $display_button = &mt('Display courses');                      $display_button = &mt('Display courses');
                 }                  }
Line 373  ENDJS Line 401  ENDJS
                                                 $canviewall,$hostname));                                                  $canviewall,$hostname));
             }              }
         }          }
           $r->print('</div>');
     }      }
     $r->print('<br />'.&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return OK;      return OK;
 }  }
   
Line 472  sub validate_input { Line 501  sub validate_input {
     }      }
   
     foreach my $key (sort(keys(%env))) {      foreach my $key (sort(keys(%env))) {
         if ($key =~ /^form\.(.+)$/) {          if ($key =~ /^form\.currcat_(.+)$/) {
             unless ($possibles{$1}) {              unless ($possibles{'currcat_'.$1}) {
                 delete($env{$key});                  delete($env{$key});
             }              }
         }          }
Line 663  sub course_details { Line 692  sub course_details {
     }      }
     my $brtextone = 'Course listing';      my $brtextone = 'Course listing';
     my $brtexttwo = 'Course details';      my $brtexttwo = 'Course details';
       my $textthree = &mt('Detailed course information:');
       my $textfour = &mt('Back to course listing');
     if ($env{'form.currcat_0'} eq 'communities::0') {      if ($env{'form.currcat_0'} eq 'communities::0') {
         $brtextone = 'Community listing';          $brtextone = 'Community listing';
         $brtexttwo = 'Community details';          $brtexttwo = 'Community details';
           $textthree = &mt('Detailed community information:');
           $textfour = &mt('Back to community listing');
       } elsif ($env{'form.currcat_0'} eq 'placement::0') {
           $brtextone = 'Placement test listing';
           $brtexttwo = 'Placement test details';
           $textthree = &mt('Detailed placement test information:');
           $textfour = &mt('Back to placement test listing');
     }      }
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
              ({href=>"javascript:document.$formname.submit()",               ({href=>"javascript:document.$formname.submit()",
Line 673  sub course_details { Line 711  sub course_details {
              {text=>$brtexttwo});               {text=>$brtexttwo});
     $r->print(      $r->print(
         &Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog').          &Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog').
         '<h2>'.          '<div role="main">'.
         (($env{'form.currcat_0'} eq 'communities::0') ?          '<h2>'.$textthree.'</h2>'.
             &mt('Detailed community information:') :  
             &mt('Detailed course information:')).  
         '</h2>'.  
         &print_course_listing($codedom,undef,$trails,$allitems,undef,$codetitles,undef,$hostname).          &print_course_listing($codedom,undef,$trails,$allitems,undef,$codetitles,undef,$hostname).
         '<br />'.          '<br />'.
         '<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.          '<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.
         &Apache::lonhtmlcommon::actionbox([          &Apache::lonhtmlcommon::actionbox([
             '<a href = "javascript:document.coursecatalog.submit()">'.              '<a href = "javascript:document.coursecatalog.submit()">'.$textfour.'</a>']).
             (($env{'form.currcat_0'} eq 'communities::0') ?  
                 &mt('Back to community listing') : &mt('Back to course listing')).  
             '</a>'  
         ]).  
         &Apache::lonhtmlcommon::echo_form_input(['coursenum','catalogfilter',          &Apache::lonhtmlcommon::echo_form_input(['coursenum','catalogfilter',
                                                  'showdetails','courseid']).                                                   'showdetails','courseid']).
         '</form>');          '</form></div>');
     return;      return;
 }  }
   
Line 814  sub cat_header { Line 845  sub cat_header {
     my $brtext = 'Course listing';      my $brtext = 'Course listing';
     if ($env{'form.currcat_0'} eq 'communities::0') {      if ($env{'form.currcat_0'} eq 'communities::0') {
         $brtext = 'Community listing';          $brtext = 'Community listing';
       } elsif ($env{'form.currcat_0'} eq 'placement::0') {
           $brtext = 'Placement test listing';
     }      }
     if ($env{'form.state'} eq 'listing') {      if ($env{'form.state'} eq 'listing') {
         if ($numtitles > 0) {          if ($numtitles > 0) {
Line 830  sub cat_header { Line 863  sub cat_header {
         ({href=>"/adm/coursecatalog",          ({href=>"/adm/coursecatalog",
           text=>"Course/Community Catalog"});            text=>"Course/Community Catalog"});
     }      }
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));      $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog').
                 '<div role="main">');
     if ($cattype eq 'std') {      if ($cattype eq 'std') {
         my $onchange = 'this.form.submit()';  
         $r->print('<form name="coursecatdom" method="post" action="/adm/coursecatalog">'.          $r->print('<form name="coursecatdom" method="post" action="/adm/coursecatalog">'.
                   '<table border="0"><tr><td><b>'.&mt('Domain:').'</b></td><td>'.                    '<table border="0"><tr><th align="left"><label for="showdom">'.&mt('Domain:').'</label></th><td>'.
                   &Apache::loncommon::select_dom_form($codedom,'showdom','',1,$onchange));                    &Apache::loncommon::select_dom_form($codedom,'showdom','',1,'','','','','showdom').
         if (!$onchange) {                    '&nbsp;<input type="submit" name="godom" value="'.&mt('Change').'" />'."\n".
    $r->print('&nbsp;<input type="submit" name="godom" value="'.&mt('Change').'" />');                    '<input type="hidden" name="initialshowdom" value="'.$codedom.'" />'."\n".
         }                    '</td></tr></table></form>');
         $r->print('</td></tr></table></form>');      }
       my $onsubmit;
       unless ($env{'form.currcat_0'} eq 'instcode::0') {
           $onsubmit = ' onsubmit="return check_selected();"';
     }      }
     $r->print('<form name="coursecats" method="post" action="/adm/coursecatalog"'.      $r->print('<form name="coursecats" method="post" action="/adm/coursecatalog"'.$onsubmit.'>'.
               ' onsubmit="return check_selected();">'.  
               '<table border="0"><tr>'.$catlinks.'</tr></table></form>');                '<table border="0"><tr>'.$catlinks.'</tr></table></form>');
     return;      return;
 }  }
Line 854  sub category_breadcrumbs { Line 889  sub category_breadcrumbs {
     my $currcat_str =       my $currcat_str = 
         '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" />'.          '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" />'.
         '<input type="hidden" name="showdom" value="'.$dom.'" />';          '<input type="hidden" name="showdom" value="'.$dom.'" />';
     my $catlinks = '<td valign="top"><b>'.&mt('Catalog:').'</b></td><td><table><tr><td>';      my $catlinks = '<th class="LC_middle LC_left">'.&mt('Catalog:').'</th><td><div class="LC_leftfloat">';
     my $has_subcats;      my $has_subcats;
     my $selitem;      my $selitem;
       my $update_button;
     if (ref($cats[0]) eq 'ARRAY') {      if (ref($cats[0]) eq 'ARRAY') {
         if (@{$cats[0]} == 0) {          if (@{$cats[0]} == 0) {
             $catlinks .= &mt('No categories defined in this domain');               $catlinks .= &mt('No categories defined in this domain'); 
Line 867  sub category_breadcrumbs { Line 903  sub category_breadcrumbs {
             } elsif ($cats[0][0] eq 'communities') {              } elsif ($cats[0][0] eq 'communities') {
                 $catlinks .= &mt('Communities');                  $catlinks .= &mt('Communities');
                 $env{'form.currcat_0'} = 'communities::0';                  $env{'form.currcat_0'} = 'communities::0';
               } elsif ($cats[0][0] eq 'placement') {
                   $catlinks .= &mt('Placement Tests');
                   $env{'form.currcat_0'} = 'placement::0';
             } else {              } else {
                 my $name = $cats[0][0];                  my $name = $cats[0][0];
                 my $item = &escape($name).'::0';                  my $item = &escape($name).'::0';
Line 875  sub category_breadcrumbs { Line 914  sub category_breadcrumbs {
             }              }
             $currcat_str .= '<input type="hidden" name="currcat_0" value="'.$env{'form.currcat_0'}.'" />';              $currcat_str .= '<input type="hidden" name="currcat_0" value="'.$env{'form.currcat_0'}.'" />';
         } else {          } else {
               $update_button = 1;
             $catlinks .= &main_category_selector(@cats);              $catlinks .= &main_category_selector(@cats);
             if (($env{'form.currcat_0'} ne '') &&               if (($env{'form.currcat_0'} ne '') && 
                 ($env{'form.currcat_0'} ne 'instcode::0')) {                  ($env{'form.currcat_0'} ne 'instcode::0')) {
Line 884  sub category_breadcrumbs { Line 924  sub category_breadcrumbs {
     } else {      } else {
         $catlinks .= &mt('Official courses (with institutional codes)');          $catlinks .= &mt('Official courses (with institutional codes)');
                      $env{'form.currcat_0'} = 'instcode::0';                       $env{'form.currcat_0'} = 'instcode::0';
          $currcat_str .= '<input type="hidden" name="currcat_0" value="'.$env{'form.currcat_0'}.'" />';          $currcat_str .= '<input type="hidden" name="currcat_0" value="'.$env{'form.currcat_0'}.'" />';
     }      }
     if ($deeper) {      if ($deeper) {
         for (my $i=1; $i<=$deeper; $i++) {          for (my $i=1; $i<=$deeper; $i++) {
Line 892  sub category_breadcrumbs { Line 932  sub category_breadcrumbs {
             next if ($shallower == 0);              next if ($shallower == 0);
             my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});              my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});
             if ($cat ne '') {              if ($cat ne '') {
                 $catlinks .= '<td valign="top">'.                  my $labeltext = &HTML::Entities::encode(&mt('Level [_1] category',$shallower),'<>&"');
                              '<select name="currcat_'.$shallower.'" onchange="'.                  $catlinks .= '<select name="currcat_'.$shallower.'" aria-label="'.$labeltext.'">';
                              'setCatDepth('."'$shallower'".');this.form.submit();">';  
                 if (ref($cats[$shallower]{$container}) eq 'ARRAY') {                  if (ref($cats[$shallower]{$container}) eq 'ARRAY') {
                     $catlinks .= '<option value="">'.&mt('De-select').'</option>';                      $catlinks .= '<option value="-1">'.&mt('De-select').'</option>';
                     for (my $j=0; $j<@{$cats[$shallower]{$container}}; $j++) {                      for (my $j=0; $j<@{$cats[$shallower]{$container}}; $j++) {
                         my $name = $cats[$shallower]{$container}[$j];                          my $name = $cats[$shallower]{$container}[$j];
                         my $item = &escape($name).':'.&escape($container).':'.$shallower;                          my $item = &escape($name).':'.&escape($container).':'.$shallower;
Line 908  sub category_breadcrumbs { Line 947  sub category_breadcrumbs {
                            '<option value="'.$item.'"'.$selected.'>'.$name.'</option>';                             '<option value="'.$item.'"'.$selected.'>'.$name.'</option>';
                     }                      }
                 }                  }
                 $catlinks .= '</select>';                  $catlinks .= '</select>'.
                                '<input type="hidden" name="initialcurrcat_'.$shallower.'" value="'.$env{'form.currcat_'.$shallower}.'" />';
             }              }
             unless ($i == $deeper) {              unless ($i == $deeper) {
                 $catlinks .= $crumbsymbol;                  $catlinks .= $crumbsymbol;
Line 926  sub category_breadcrumbs { Line 966  sub category_breadcrumbs {
             $has_subcats = 1;              $has_subcats = 1;
             my $buttontext = &mt('Show subcategories');              my $buttontext = &mt('Show subcategories');
             my $selitem = 'currcat_'.$deeperlevel;              my $selitem = 'currcat_'.$deeperlevel;
             $catlinks .= '&nbsp;<select name="'.$selitem.'" onchange="this.form.submit()">';              my $labeltext = &HTML::Entities::encode(&mt('Level [_1] category',$deeperlevel),'<>&"');
               $catlinks .= '&nbsp;<select name="'.$selitem.'" aria-label="'.$labeltext.'">';
             if (@{$cats[$deeperlevel]{$cat}}) {              if (@{$cats[$deeperlevel]{$cat}}) {
                 $catlinks .= '<option value="" selected="selected">'.                  $catlinks .= '<option value="" selected="selected">'.
                              &mt('Subcategory ...').'</option>';                               &mt('Subcategory ...').'</option>';
Line 943  sub category_breadcrumbs { Line 984  sub category_breadcrumbs {
     } else {      } else {
         $selitem = 'currcat_0';          $selitem = 'currcat_0';
     }      }
     $catlinks .= $currcat_str.'</td></tr></table></td>';      $catlinks .= $currcat_str;
       if ($update_button) {
           $catlinks .= '&nbsp;<input type="submit" name="gocat" value="'.&mt('Update').'" />'."\n";
       }
       $catlinks .= '</div></td>';
     return ($catlinks,$has_subcats,$selitem);      return ($catlinks,$has_subcats,$selitem);
 }  }
   
 sub main_category_selector {  sub main_category_selector {
     my (@cats) = @_;      my (@cats) = @_;
     my $maincatlinks = '<select name="currcat_0" onchange="setCatDepth('."'0'".');this.form.submit();">'."\n";      my $labeltext = &HTML::Entities::encode(&mt('Top level category'),'<>&"');
       my $maincatlinks = '<select name="currcat_0" aria-label="'.$labeltext.'">'."\n";
     if (ref($cats[0]) eq 'ARRAY') {      if (ref($cats[0]) eq 'ARRAY') {
         if (@{$cats[0]} > 1) {          if (@{$cats[0]} > 1) {
             my $selected = '';              my $selected = '';
Line 971  sub main_category_selector { Line 1017  sub main_category_selector {
                 $maincatlinks .= &mt('Official courses (with institutional codes)');                  $maincatlinks .= &mt('Official courses (with institutional codes)');
             } elsif ($name eq 'communities') {              } elsif ($name eq 'communities') {
                 $maincatlinks .= &mt('Communities');                  $maincatlinks .= &mt('Communities');
               } elsif ($name eq 'placement') {
                   $maincatlinks .= &mt('Placement Tests');
             } else {              } else {
                 $maincatlinks .= $name;                  $maincatlinks .= $name;
             }              }
             $maincatlinks .= '</option>'."\n";              $maincatlinks .= '</option>'."\n";
         }          }
         $maincatlinks .= '</select>'."\n";          $maincatlinks .= '</select>'."\n".
                            '<input type="hidden" name="initialcurrcat_0" value="'.$env{'form.currcat_0'}.'" />'."\n";
     }      }
     return $maincatlinks;      return $maincatlinks;
 }  }
Line 1002  sub additional_filters { Line 1051  sub additional_filters {
     if ($is_dc || $canviewall) {      if ($is_dc || $canviewall) {
         $output .= '<fieldset><legend>'.&mt('Options').'</legend>';          $output .= '<fieldset><legend>'.&mt('Options').'</legend>';
     }      }
     $output .= '<table><tr><td valign="top">';      $output .= '<div class="LC_floatleft" style="text-align: top">';
     if (($env{'form.currcat_0'} ne 'instcode::0') &&      if (($env{'form.currcat_0'} ne 'instcode::0') &&
         ($env{'form.currcat_0'} ne '') && ($has_subcats)) {          ($env{'form.currcat_0'} ne '') && ($has_subcats)) {
         my $include_subcat_status;          my $include_subcat_status;
Line 1033  sub additional_filters { Line 1082  sub additional_filters {
     my $selfenroll_text;      my $selfenroll_text;
     if ($env{'form.currcat_0'} eq 'communities::0') {      if ($env{'form.currcat_0'} eq 'communities::0') {
         $selfenroll_text = &mt('Only show communities which currently allow self-enrollment (or will allow it in the future)');          $selfenroll_text = &mt('Only show communities which currently allow self-enrollment (or will allow it in the future)');
       } elsif ($env{'form.currcat_0'} eq 'placement::0') {
           $selfenroll_text = &mt('Only show placement tests which currently allow self-enrollment (or will allow it in the future)');
     } else {      } else {
         $selfenroll_text = &mt('Only show courses which currently allow self-enrollment (or will allow it in the future)');          $selfenroll_text = &mt('Only show courses which currently allow self-enrollment (or will allow it in the future)');
     }      }
Line 1061  sub additional_filters { Line 1112  sub additional_filters {
             }              }
         } else {          } else {
             $statusdisplay = 'none';              $statusdisplay = 'none';
             $cellborder = 'border-left: 0px';              $cellborder = 'border-left: 0px;';
         }          }
           $cellborder .= ' vertical-align: top;';
         if ($env{'form.currcat_0'} eq 'communities::0') {          if ($env{'form.currcat_0'} eq 'communities::0') {
             $details_text = &mt('Show full details for each community (domain staff only)');              $details_text = &mt('Show full details for each community (domain staff only)');
             $hidden_text = &mt('Include communities set to be hidden from catalog (domain staff only)');              $hidden_text = &mt('Include communities set to be hidden from catalog (domain staff only)');
           } elsif ($env{'form.currcat_0'} eq 'placement::0') {
               $details_text = &mt('Show full details for each placement test (domain staff only)');
               $hidden_text = &mt('Include placement tests set to be hidden from catalog (domain staff only)');
         } else {          } else {
             $details_text = &mt('Show full details for each course (domain staff only)');              $details_text = &mt('Show full details for each course (domain staff only)');
             $hidden_text = &mt('Include courses set to be hidden from catalog (domain staff only)');              $hidden_text = &mt('Include courses set to be hidden from catalog (domain staff only)');
Line 1079  sub additional_filters { Line 1134  sub additional_filters {
         $output .= '<span class="LC_nobreak">'.          $output .= '<span class="LC_nobreak">'.
                    '<label><input type="checkbox" name="showdetails" value="1" '.                     '<label><input type="checkbox" name="showdetails" value="1" '.
                    $showdetails_status.'onclick="toggleStatuses();" />'.                     $showdetails_status.'onclick="toggleStatuses();" />'.
                    $details_text.'</label></span></td>'."\n".                     $details_text.'</label></span></div>'."\n".
                    '<td id="statuscell" valign="top" style="'.$cellborder.'">'.                     '<div class="LC_floatleft" id="statuscell" style="'.$cellborder.'">'.
                    '<div id="statuschoice" style="display:'.$statusdisplay.'">';                     '<div class="LC_floatleft" id="statuschoice" style="display:'.$statusdisplay.'; margin-left: 10px">';
         if (ref($orderref) eq 'ARRAY') {          if (ref($orderref) eq 'ARRAY') {
             if (@{$orderref} > 0) {              if (@{$orderref} > 0) {
                 foreach my $type (@{$orderref}) {                  foreach my $type (@{$orderref}) {
Line 1111  sub additional_filters { Line 1166  sub additional_filters {
                             date      => 'immediately prior to specific date:',                              date      => 'immediately prior to specific date:',
                         );                          );
                         my @statuses = &Apache::loncommon::get_env_multiple('form.showcounts');                          my @statuses = &Apache::loncommon::get_env_multiple('form.showcounts');
                         $output .= '<span id="choosewasacctext" class="LC_nobreak">';                          my $wasactivetext;
                         if ($checked) {                          if ($checked) {
                             $output .= &get_wasactive_text();                              $wasactivetext = &get_wasactive_text();
                         }                          }
                         $output .= '</span>'.                          $output .= '<div id="choosewasactive" style="display:'.$wasactivedisplay.'">'."\n".
                                    '<div id="choosewasactive" style="display:'.$wasactivedisplay.'">'.                                     '<fieldset style="margin-left: 4px">'."\n".
                                    '<table>';                                     '<legend id="choosewasacctext" style="font-weight: normal">'."\n".
                                      $wasactivetext.'</legend>'."\n";
                         my @milestones = ('accessend');                          my @milestones = ('accessend');
                         if (&Apache::lonnet::auto_run(undef,$codedom)) {                          if (&Apache::lonnet::auto_run(undef,$codedom)) {
                             push(@milestones,'enrollend');                              push(@milestones,'enrollend');
Line 1133  sub additional_filters { Line 1189  sub additional_filters {
                                 $checked = ' checked="checked"';                                  $checked = ' checked="checked"';
                             }                              }
                             $output .=                              $output .=
                                 '<tr><td width="10">&nbsp;</td><td>'.                                  '<span class="LC_nobreak" style="padding-left:10px;"><label>'.
                                 '<span class="LC_nobreak"><label>'.  
                                 '<input type="radio" value="'.$item.'" name="wasactive"'.$checked.' />'.                                  '<input type="radio" value="'.$item.'" name="wasactive"'.$checked.' />'.
                                 $milestonetext{$item}.'</label></span>';                                  $milestonetext{$item}.'</label></span>';
                             if ($item eq 'date') {                              if ($item eq 'date') {
Line 1152  sub additional_filters { Line 1207  sub additional_filters {
                                                                         '','','',1,'',                                                                          '','','',1,'',
                                                                         '','',1);                                                                          '','',1);
                             }                              }
                             $output .= '</td></tr>';                              $output .= '<br />';
                         }                          }
                         $output .= '</table></div>';                          $output .= '</fieldset></div>';
                     }                      }
                     $output .= '<br />';                      $output .= '<br />';
                 }                  }
             }              }
         }          }
         $output .= '</div></td>';          $output .= '</div></div>';
     } else {      } else {
         $output .= '</td>';            $output .= '</div>';  
     }      }
     $output .= '</tr></table></fieldset></div>'.      $output .= '</fieldset></div>'.
                '<div style="clear:both;margin:0;"></div>';                   '<div style="clear:both;margin:0;"></div>';  
     return $output;      return $output;
 }  }
Line 1223  sub get_statustitles { Line 1278  sub get_statustitles {
 }  }
   
 sub get_wasactive_text {  sub get_wasactive_text {
     my $wasacctext = ' -- ';      my $wasacctext;
     if ($env{'form.currcat_0'} eq 'communities::0') {      if ($env{'form.currcat_0'} eq 'communities::0') {
         $wasacctext .= &mt('where member access status was current ...');          $wasacctext .= &mt('count where member access status was current ...');
     } else {      } else {
         $wasacctext .= &mt('where student access status was current ...');          $wasacctext .= &mt('count where student access status was current ...');
     }      }
     return $wasacctext;      return $wasacctext;
 }  }
Line 1279  sub search_courselist { Line 1334  sub search_courselist {
         }          }
         if ($env{'form.currcat_0'} eq 'communities::0') {          if ($env{'form.currcat_0'} eq 'communities::0') {
             $typefilter = 'Community';              $typefilter = 'Community';
           } elsif ($env{'form.currcat_0'} eq 'placement::0') {
               $typefilter = 'Placement';
         } else {          } else {
             $typefilter = '.';              $typefilter = '.';
         }          }
Line 1310  sub print_course_listing { Line 1367  sub print_course_listing {
             $output = '<p class="LC_error">';              $output = '<p class="LC_error">';
             if ($env{'form.currcat_0'} eq 'communities::0') {              if ($env{'form.currcat_0'} eq 'communities::0') {
                 $output .= &mt('The courseID provided does not match a community in this domain.');                  $output .= &mt('The courseID provided does not match a community in this domain.');
             } else {               } elsif ($env{'form.currcat_0'} eq 'placement::0') {
                   $output .= &mt('The courseID provided does not match a placement test in this domain.');
               } else {
                 $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.');
             }              }
             $output .= '</p>';              $output .= '</p>';
Line 1326  sub print_course_listing { Line 1385  sub print_course_listing {
             $output = '<p class="LC_info">';              $output = '<p class="LC_info">';
             if ($env{'form.currcat_0'} eq 'communities::0') {              if ($env{'form.currcat_0'} eq 'communities::0') {
                 $output .= &mt('No communities match the criteria you selected.');                  $output .= &mt('No communities match the criteria you selected.');
               } elsif ($env{'form.currcat_0'} eq 'placement::0') {
                   $output .= &mt('No placement tests match the criteria you selected.');
             } else {              } else {
                 $output .= &mt('No courses match the criteria you selected.');                  $output .= &mt('No courses match the criteria you selected.');
             }              }
Line 1375  sub construct_data_table { Line 1436  sub construct_data_table {
         if (defined($sortname{$item})) {          if (defined($sortname{$item})) {
             $output .= '<a href="javascript:changeSort('."'$sortname{$item}'".')">'.&mt($item).'</a>';              $output .= '<a href="javascript:changeSort('."'$sortname{$item}'".')">'.&mt($item).'</a>';
         } elsif ($item eq 'Count') {          } elsif ($item eq 'Count') {
             $output .= '&nbsp;&nbsp;';              $output .= '#';
         } else {          } else {
             $output .= &mt($item);              $output .= &mt($item);
         }          }
Line 1387  sub construct_data_table { Line 1448  sub construct_data_table {
             if ($env{'form.currcat_0'} eq 'communities::0') {              if ($env{'form.currcat_0'} eq 'communities::0') {
                 $output .= '<th>'.&mt('Default Access Dates for Members').'</th>'.                  $output .= '<th>'.&mt('Default Access Dates for Members').'</th>'.
                            '<th>'.&mt('Member Counts').'</th>';                             '<th>'.&mt('Member Counts').'</th>';
               } elsif ($env{'form.currcat_0'} eq 'placement::0') {
                   $output .=
                       '<th>'.&mt('Default Access Dates for Students').'</th>'.
                       '<th>'.&mt('Student Counts').'</th>';               
             } else {              } else {
                 $output .=                  $output .=
                     '<th>'.&mt('Default Access Dates for Students').'</th>'.                      '<th>'.&mt('Default Access Dates for Students').'</th>'.
Line 1434  sub construct_data_table { Line 1499  sub construct_data_table {
     my (%numbers,%creditsum);      my (%numbers,%creditsum);
     my ($showcredits,$defofficial,$defunofficial,$deftextbook);      my ($showcredits,$defofficial,$defunofficial,$deftextbook);
     my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);      my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
     unless ($env{'form.currcat_0'} eq 'communities::0') {      unless (($env{'form.currcat_0'} eq 'communities::0') || ($env{'form.currcat_0'} eq 'placement::0')) {
         if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {          if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
             $showcredits = 1;              $showcredits = 1;
             $defofficial = $domdefaults{'officialcredits'};              $defofficial = $domdefaults{'officialcredits'};
Line 1520  sub construct_data_table { Line 1585  sub construct_data_table {
                 $lt{'Active'} = &mt('Total current members');                   $lt{'Active'} = &mt('Total current members'); 
                 $lt{'Future'} = &mt('Total future members');                  $lt{'Future'} = &mt('Total future members');
                 $lt{'Previous'} = &mt('Total previous members');                  $lt{'Previous'} = &mt('Total previous members');
               } elsif ($env{'form.currcat_0'} eq 'placement::0') {
                   $lt{'courses'} = &mt('Total placement tests');
             }              }
             my $colspan = 8;              my $colspan = 8;
             if ($showcredits) {              if ($showcredits) {
Line 1850  sub courseinfo_row { Line 1917  sub courseinfo_row {
             @cats = split('&',$categories);              @cats = split('&',$categories);
         }          }
         if ((ref($trails) eq 'ARRAY') && (ref($allitems) eq 'HASH')) {          if ((ref($trails) eq 'ARRAY') && (ref($allitems) eq 'HASH')) {
             my @categories = map { $trails->[$allitems->{$_}]; } @cats;              my @categories;
               foreach my $cat (@cats) {
                   next if ($cat eq '');
                   if (($allitems->{$cat} ne '') && ($trails->[$allitems->{$cat}] ne '')) {
                       push(@categories,$trails->[$allitems->{$cat}]);
                   }
               }
             $categorylist = join('<br />',@categories);              $categorylist = join('<br />',@categories);
         }          }
         if ($categorylist eq '') {          if ($categorylist eq '') {
Line 1880  sub courseinfo_row { Line 1953  sub courseinfo_row {
             $output .=              $output .=
                 '<td>'.$accessdates.'</td>'.                  '<td>'.$accessdates.'</td>'.
                 '<td>'.$counts.'</td>';                  '<td>'.$counts.'</td>';
             unless ($env{'form.currcat_0'} eq 'communities::0') {              unless (($env{'form.currcat_0'} eq 'communities::0') || ($env{'form.currcat_0'} eq 'placement::0')) {
                 $output .= '<td>'.$autoenrollment.'</td>';                  $output .= '<td>'.$autoenrollment.'</td>';
             }              }
         } else {          } else {

Removed from v.1.88.2.9  
changed lines
  Added in v.1.108


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