Diff for /loncom/interface/coursecatalog.pm between versions 1.53.4.4 and 1.71

version 1.53.4.4, 2010/02/12 00:21:30 version 1.71, 2012/10/04 13:41:10
Line 87  sub handler { Line 87  sub handler {
     }      }
     &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,      &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,
                                            \%idx,\@jsarray,$subcats);                                             \%idx,\@jsarray,$subcats);
       my ($numtitles,@codetitles);
     if ($env{'form.coursenum'} ne '' && &user_is_known()) {      if ($env{'form.coursenum'} ne '' && &user_is_known()) {
         &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems);          &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems,\@codetitles);
     } else {      } else {
         my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats);          my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats);
         my $catjs = <<"ENDSCRIPT";          my $catjs = <<"ENDSCRIPT";
Line 114  function setCourseId(caller) { Line 115  function setCourseId(caller) {
   
 ENDSCRIPT  ENDSCRIPT
         $catjs .= &courselink_javascript();           $catjs .= &courselink_javascript(); 
         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,
                                                    $catlinks,$catjs);                                                     $catlinks,$catjs,\@codetitles);
             if ($env{'form.state'} eq 'listing') {              if ($env{'form.state'} eq 'listing') {
                 $r->print(&print_course_listing($codedom,$numtitles));                  $r->print(&print_course_listing($codedom,$numtitles,undef,undef,undef,
                                                   \@codetitles));
             }              }
         } else {          } else {
             my (%add_entries);              my (%add_entries);
Line 164  ENDJS Line 165  ENDJS
                           $display_button.'" /></form><br /><br />');                            $display_button.'" /></form><br /><br />');
             }              }
             if ($env{'form.state'} eq 'listing') {              if ($env{'form.state'} eq 'listing') {
                 $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats));                  $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats,\@codetitles));
             }              }
         }          }
     }      }
Line 173  ENDJS Line 174  ENDJS
 }  }
   
 sub course_details {  sub course_details {
     my ($r,$codedom,$formname,$domdesc,$trails,$allitems) = @_;      my ($r,$codedom,$formname,$domdesc,$trails,$allitems,$codetitles) = @_;
     my $output;      my $output;
     my %add_entries = (topmargin    => "0",      my %add_entries = (topmargin    => "0",
                        marginheight => "0",);                         marginheight => "0",);
Line 181  sub course_details { Line 182  sub course_details {
              &courselink_javascript().'</script>'."\n";               &courselink_javascript().'</script>'."\n";
     my $start_page =      my $start_page =
         &Apache::loncommon::start_page('Course/Community Catalog',$js,          &Apache::loncommon::start_page('Course/Community Catalog',$js,
                                            {                                             {'add_entries' => \%add_entries, });
                                              'add_entries' => \%add_entries,  
                                              'no_inline_link'   => 1,});  
     $r->print($start_page);      $r->print($start_page);
     if ($env{'form.numtitles'} > 0) {      if ($env{'form.numtitles'} > 0) {
         &Apache::lonhtmlcommon::add_breadcrumb          &Apache::lonhtmlcommon::add_breadcrumb
                 ({href=>"/adm/coursecatalog",                  ({href=>"/adm/coursecatalog",
                   text=>"Course/Community Catalog"});                    text=>"Course/Community Catalog"});
     }      }
       my $brtextone = 'Course listing';
       my $brtexttwo = 'Course details';
       if ($env{'form.currcat_0'} eq 'communities::0') {
           $brtextone = 'Community listing';
           $brtexttwo = 'Community details';
       }
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
              ({href=>"javascript:document.$formname.submit()",               ({href=>"javascript:document.$formname.submit()",
               text=>"Course listing"},                text=>$brtextone},
              {text=>"Course details"});               {text=>$brtexttwo});
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));      $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));
     $r->print('<br />'.&mt('Detailed course information:').'<br /><br />'.      $r->print('<br />');
               &print_course_listing($codedom,undef,$trails,$allitems).      if ($env{'form.currcat_0'} eq 'communities::0') {
           $r->print(&mt('Detailed community information:'));
       } else {
           $r->print(&mt('Detailed course information:'));
       }
       $r->print('<br /><br />'.
                 &print_course_listing($codedom,undef,$trails,$allitems,undef,$codetitles).
               '<br /><br />');                '<br /><br />');
     $r->print('<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.      $r->print('<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.
               '<a href = "javascript:document.coursecatalog.submit()">'.                '<a href = "javascript:document.coursecatalog.submit()">');
               &mt('Back to course listing').'</a>'.      if ($env{'form.currcat_0'} eq 'communities::0') {
           $r->print(&mt('Back to community listing'));
       } else {
           $r->print(&mt('Back to course listing'));
       }
       $r->print('</a>'.
               &Apache::lonhtmlcommon::echo_form_input(['coursenum','catalogfilter',                &Apache::lonhtmlcommon::echo_form_input(['coursenum','catalogfilter',
                                                        'showdetails','courseid']).'</form>');                                                         'showdetails','courseid']).'</form>');
     return;      return;
Line 233  END Line 249  END
 }  }
   
 sub instcode_course_selector {  sub instcode_course_selector {
     my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs) = @_;      my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles) = @_;
     my %coursecodes = ();      my %coursecodes = ();
     my %codes = ();      my %codes = ();
     my @codetitles = ();  
     my %cat_titles = ();      my %cat_titles = ();
     my %cat_order = ();      my %cat_order = ();
     my %cat_items;      my %cat_items;
Line 246  sub instcode_course_selector { Line 261  sub instcode_course_selector {
                        marginheight => "0",);                         marginheight => "0",);
     my ($jscript,$totcodes,$numtitles,$lasttitle) =       my ($jscript,$totcodes,$numtitles,$lasttitle) = 
         &Apache::courseclassifier::instcode_selectors_data($codedom,$formname,          &Apache::courseclassifier::instcode_selectors_data($codedom,$formname,
                            \%cat_items,\@codetitles,\%cat_titles,\%cat_order);                             \%cat_items,$codetitles,\%cat_titles,\%cat_order);
     my $js = '<script type"text/javascript">'."\n$jscript\n$catjs\n".      my $js = '<script type"text/javascript">'."\n$jscript\n$catjs\n".
               '</script>';                '</script>';
     if ($totcodes) {      if ($totcodes) {
Line 263  sub instcode_course_selector { Line 278  sub instcode_course_selector {
         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 />'.
                       &Apache::courseclassifier::build_instcode_selectors($numtitles,                        &Apache::courseclassifier::build_instcode_selectors($numtitles,
                        $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order));                         $lasttitle,\%cat_items,$codetitles,\%cat_titles,\%cat_order));
         }          }
         $r->print('<input type="hidden" name="coursenum" value="" />'."\n".          $r->print('<input type="hidden" name="coursenum" value="" />'."\n".
                   '<input type="hidden" name="sortby" value="" />'."\n".                    '<input type="hidden" name="sortby" value="" />'."\n".
                   '<input type="hidden" name="state" value="listing" />'."\n".                    '<input type="hidden" name="state" value="listing" />'."\n".
                   '<input type="hidden" name="form.currcat_0" value="instcode::0" />'."\n".  
                   '<input type="submit" name="catalogfilter" value="'.                    '<input type="submit" name="catalogfilter" value="'.
                   &mt('Display courses').'" />'.                    &mt('Display courses').'" />'.
                   '<input type="hidden" name="numtitles" value="'.$numtitles.                    '<input type="hidden" name="numtitles" value="'.$numtitles.
Line 289  sub instcode_course_selector { Line 303  sub instcode_course_selector {
 sub cat_header {  sub cat_header {
     my ($r,$codedom,$js,$add_entries,$catlinks,$numtitles) = @_;      my ($r,$codedom,$js,$add_entries,$catlinks,$numtitles) = @_;
     my $start_page =      my $start_page =
         &Apache::loncommon::start_page('Course/Community Catalog',$js,          &Apache::loncommon::start_page('Other',$js,
                                        {                                         { 'add_entries' => $add_entries, });
                                          'add_entries' => $add_entries,  
                                          'no_inline_link'   => 1,});  
     $r->print($start_page);      $r->print($start_page);
       my $brtext = 'Course listing';
       if ($env{'form.currcat_0'} eq 'communities::0') {
           $brtext = 'Community listing';
       }
     if ($env{'form.state'} eq 'listing') {      if ($env{'form.state'} eq 'listing') {
         if ($numtitles > 0) {          if ($numtitles > 0) {
             &Apache::lonhtmlcommon::add_breadcrumb              &Apache::lonhtmlcommon::add_breadcrumb
                 ({href=>"/adm/coursecatalog",                  ({href=>"/adm/coursecatalog",
                   text=>"Course/Community Catalog"},                    text=>"Course/Community Catalog"},
                  {text=>"Course listing"});                   {text=>$brtext});
         } else {          } else {
             &Apache::lonhtmlcommon::add_breadcrumb              &Apache::lonhtmlcommon::add_breadcrumb
             ({text=>"Course listing"});              ({text=>$brtext});
         }          }
     } else {      } else {
         &Apache::lonhtmlcommon::add_breadcrumb          &Apache::lonhtmlcommon::add_breadcrumb
Line 310  sub cat_header { Line 326  sub cat_header {
           text=>"Course/Community Catalog"});            text=>"Course/Community Catalog"});
     }      }
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));      $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));
     my $onchange;      my $onchange = 'this.form.submit()';
     unless (($env{'browser.interface'} eq 'textual') || ($env{'form.interface'} eq 'textual')) {  
         $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><td><b>'.&mt('Domain:').'</b></td><td>'.
               &Apache::loncommon::select_dom_form($codedom,'showdom','',1,$onchange));                &Apache::loncommon::select_dom_form($codedom,'showdom','',1,$onchange));
Line 366  sub category_breadcrumbs { Line 379  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 381  sub category_breadcrumbs { Line 394  sub category_breadcrumbs {
                     $catlinks .= '<option value="">'.&mt('De-select').'</option>';                      $catlinks .= '<option value="">'.&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).':'.$container.':'.$shallower;                          my $item = &escape($name).':'.&escape($container).':'.$shallower;
                         my $selected = '';                          my $selected = '';
                         if ($item eq $env{'form.currcat_'.$shallower}) {                          if ($item eq $env{'form.currcat_'.$shallower}) {
                             $selected = ' selected="selected"';                              $selected = ' selected="selected"';
Line 509  sub additional_filters { Line 522  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 allow self-enrollment');          $selfenroll_text = &mt('Only show communities which currently allow self-enrollment (or will allow it in the future)');
     } else {      } else {
         $selfenroll_text = &mt('Only show courses which allow self-enrollment');          $selfenroll_text = &mt('Only show courses which currently allow self-enrollment (or will allow it in the future)');
     }      }
     $output .= '<tr><td>'.      $output .= '<tr><td>'.
                '<label><input type="checkbox" name="showselfenroll" value="1" '.                 '<label><input type="checkbox" name="showselfenroll" value="1" '.
Line 561  sub user_is_dc { Line 574  sub user_is_dc {
 }  }
   
 sub search_official_courselist {  sub search_official_courselist {
     my ($domain,$numtitles) = @_;      my ($domain,$numtitles,$codetitles) = @_;
     my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles);      my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles,$codetitles);
     my $showhidden;      my $showhidden;
     if (&user_is_dc($domain)) {      if (&user_is_dc($domain)) {
         $showhidden = $env{'form.showhidden'};          $showhidden = $env{'form.showhidden'};
Line 619  sub search_courselist { Line 632  sub search_courselist {
 }  }
   
 sub print_course_listing {  sub print_course_listing {
     my ($domain,$numtitles,$trails,$allitems,$subcats) = @_;      my ($domain,$numtitles,$trails,$allitems,$subcats,$codetitles) = @_;
     my $output;      my $output;
     my %courses;      my %courses;
     my $knownuser = &user_is_known();      my $knownuser = &user_is_known();
Line 634  sub print_course_listing { Line 647  sub print_course_listing {
                                                  $env{'form.coursenum'},                                                   $env{'form.coursenum'},
                                                  undef,undef,'.',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.');              if ($env{'form.currcat_0'} eq 'communities::0') {
                   $output .= &mt('The courseID provided does not match a community in this domain.');
               } else { 
                   $output .= &mt('The courseID provided does not match a course in this domain.');
               }
             return $output;              return $output;
         }          }
     } else {      } else {
         if ($env{'form.currcat_0'} eq 'instcode::0') {          if ($env{'form.currcat_0'} eq 'instcode::0') {
             %courses = &search_official_courselist($domain,$numtitles);              %courses = &search_official_courselist($domain,$numtitles,$codetitles);
         } else {          } else {
             %courses = &search_courselist($domain,$subcats);              %courses = &search_courselist($domain,$subcats);
         }          }
         if (keys(%courses) == 0) {          if (keys(%courses) == 0) {
             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 =
                       '<p class="LC_info">'
                      .&mt('No communities match the criteria you selected.')
                      .'</p>';
             } else {              } else {
                 $output = &mt('No courses match the criteria you selected.');                  $output =
                       '<p class="LC_info">'
                      .&mt('No courses match the criteria you selected.')
                      .'</p>';
             }              }
             return $output;              return $output;
         }          }
Line 676  sub construct_data_table { Line 699  sub construct_data_table {
         $sortname{'Code'} = 'code';          $sortname{'Code'} = 'code';
         $sortname{'Categories'} = 'cats';          $sortname{'Categories'} = 'cats';
         $sortname{'Title'} = 'title';          $sortname{'Title'} = 'title';
         $sortname{'Owner(s)'} = 'owner';          $sortname{'Owner & Co-owner(s)'} = 'owner';
     }      }
     my $output = &Apache::loncommon::start_data_table().      my $output = &Apache::loncommon::start_data_table().
                  &Apache::loncommon::start_data_table_header_row();                   &Apache::loncommon::start_data_table_header_row();
Line 686  sub construct_data_table { Line 709  sub construct_data_table {
     } else {      } else {
         push(@coltitles,'Categories');          push(@coltitles,'Categories');
     }      }
     push(@coltitles,('Sections','Crosslisted','Title','Owner(s)'));      push(@coltitles,('Sections','Crosslisted','Title','Owner & Co-owner(s)'));
     if (ref($usersections) eq 'HASH') {      if (ref($usersections) eq 'HASH') {
        $coltitles[1] = 'Your Section';         $coltitles[1] = 'Your Section';
     }      }
Line 703  sub construct_data_table { Line 726  sub construct_data_table {
     }      }
     if ($knownuser) {      if ($knownuser) {
         if ($details) {          if ($details) {
             $output .=              if ($env{'form.currcat_0'} eq 'communities::0') {
               '<th>'.&mt('Default Access Dates for Students').'</th>'.                  $output .= '<th>'.&mt('Default Access Dates for Members').'</th>';
               '<th>'.&mt('Student Counts').'</th>'.              } else {
               '<th>'.&mt('Auto-enrollment of[_1]registered students','<br />').'</th>';                  $output .=
                       '<th>'.&mt('Default Access Dates for Students').'</th>'.
                       '<th>'.&mt('Student Counts').'</th>'.
                       '<th>'.&mt('Auto-enrollment of[_1]registered students','<br />').'</th>';
               }
         } else {          } else {
             $output .= '<th>'.&mt('Details').'</th>';              $output .= '<th>'.&mt('Details').'</th>';
         }          }
Line 777  sub build_courseinfo_hash { Line 804  sub build_courseinfo_hash {
             $selfenroll_end = $courses->{$course}{'selfenroll_end_date'};              $selfenroll_end = $courses->{$course}{'selfenroll_end_date'};
             $categories = $courses->{$course}{'categories'};              $categories = $courses->{$course}{'categories'};
             push(@owners,$singleowner);              push(@owners,$singleowner);
             if (ref($courses->{$course}{'co-owners'}) eq 'ARRAY') {              if ($courses->{$course}{'co-owners'} ne '') {
                 foreach my $item (@{$courses->{$course}{'co-owners'}}) {                  foreach my $item (split(/,/,$courses->{$course}{'co-owners'})) {
                     push(@owners,$item);                      push(@owners,$item);
                 }                  }
             }              }
Line 975  sub courseinfo_row { Line 1002  sub courseinfo_row {
                '<td>'.$ownerlast.'</td>';                 '<td>'.$ownerlast.'</td>';
     if ($knownuser) {      if ($knownuser) {
         if ($details) {          if ($details) {
             $output .=              if ($env{'form.currcat_0'} eq 'communities::0') {
                '<td>'.$accessdates.'</td>'.                   $output .= '<td>'.$accessdates.'</td>';
                '<td>'.$counts.'</td>'.              } else { 
                '<td>'.$autoenrollment.'</td>';                  $output .=
                       '<td>'.$accessdates.'</td>'. 
                       '<td>'.$counts.'</td>'.
                       '<td>'.$autoenrollment.'</td>';
               }
         } else {          } else {
             $output .= "<td><a href=\"javascript:setCourseId('$cnum')\">".&mt('Show more details').'</a></td>';              $output .= "<td><a href=\"javascript:setCourseId('$cnum')\">".&mt('Show more details').'</a></td>';
         }          }
Line 991  sub courseinfo_row { Line 1022  sub courseinfo_row {
             if (($info->{'selfenroll_start'} > 0) && ($info->{'selfenroll_start'} > $now)) {              if (($info->{'selfenroll_start'} > 0) && ($info->{'selfenroll_start'} > $now)) {
                 $output .= '<td>'.&mt('Starts: [_1]','<span class="LC_cusr_emph">'.$showstart.'</span>').'<br />'.&mt('Ends: [_1]','<span class="LC_cusr_emph">'.$showend.'</span>').'</td>';                  $output .= '<td>'.&mt('Starts: [_1]','<span class="LC_cusr_emph">'.$showstart.'</span>').'<br />'.&mt('Ends: [_1]','<span class="LC_cusr_emph">'.$showend.'</span>').'</td>';
             } else {               } else { 
                 $output .= '<td><a href="javascript:ToSelfenroll('."'$course'".')">'.&mt('Enroll in course').'</a></td>';                  $output .= '<td><a href="javascript:ToSelfenroll('."'$course'".')">'.&mt('Enroll in course').'</a><br />';
                   if ($info->{'selfenroll_end'} == 0) {
                       $output .= &mt('Available permanently');
                   } elsif ($info->{'selfenroll_end'} > $now) {
                       $output .= &mt('Self-enrollment ends: [_1]','<span class="LC_cusr_emph">'.$showend.'</span>');
                   }
                   $output .= '</td>';
             }              }
             $selfenroll = 1;              $selfenroll = 1;
         }          }

Removed from v.1.53.4.4  
changed lines
  Added in v.1.71


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