--- loncom/interface/coursecatalog.pm 2008/05/29 19:58:32 1.30 +++ loncom/interface/coursecatalog.pm 2008/06/30 04:07:06 1.33 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.30 2008/05/29 19:58:32 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.33 2008/06/30 04:07:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -84,6 +84,17 @@ function setCatDepth(depth) { } 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; if ($env{'form.currcat_0'} eq 'instcode::0') { $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc, @@ -96,11 +107,29 @@ ENDSCRIPT $catjs = ''; &cat_header($r,$codedom,$catjs,\%add_entries,$catlinks); if ($env{'form.currcat_0'} ne '') { + $r->print('
'. + &additional_filters($codedom)."\n"); + my ($currdepth,$deeper) = &get_depth_values(); + $r->print(''."\n"); + for (my $i=0; $i<$deeper; $i++) { + $r->print(''."\n"); + } + $r->print(''."\n". + ''."\n". + ''."\n". + ''. + '


'); + } + if ($env{'form.state'} eq 'listing') { $r->print(&print_course_listing($codedom)); } } } - $r->print(&Apache::loncommon::end_page()); + $r->print('
'.&Apache::loncommon::end_page()); return OK; } @@ -212,17 +241,6 @@ function setElements() { $jscript .= '}'; } } - if ($env{'form.state'} eq 'listing') { - $jscript .= qq| -function changeSort(caller) { - document.$formname.sortby.value = caller; - document.$formname.submit(); -} -function setCourseId(caller) { - document.$formname.coursenum.value = caller; - document.$formname.submit(); -}\n|; - } } $js = ''; @@ -232,11 +250,12 @@ function setCourseId(caller) { &cat_header($r,$codedom,$js,\%add_entries,$catlinks,$numtitles); my $cat_maxdepth = $env{'form.catalog_maxdepth'}; $r->print('
'. - ''. - ''. - ''); + ''."\n". + ''."\n". + ''. + &additional_filters($codedom)); if ($numtitles > 0) { - $r->print('
'.&mt('Choose which course(s) to list.').'
'); + $r->print(''.&mt('Choose which course(s) to list.').'
'); $r->print(''); for (my $k=0; $k<$lasttitle-1; $k++) { my (@items,@unsorted); @@ -267,34 +286,21 @@ function setCourseId(caller) { ''."\n". - '' - ); - 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(''); - } else { - $r->print(''); - } - $r->print('


'); + ''."\n"); if ($numtitles > 4) { $r->print('

'.$codetitles[$numtitles-1].'
'."\n". '
'."\n"); } $r->print('
'); } - $r->print(''); - if ($numtitles > 0) { - $r->print(''); - } - $r->print('
'); + $r->print(''."\n". + ''."\n". + ''."\n". + ''."\n". + ''. + ''); if (($numtitles > 0) && ($env{'form.state'} eq 'listing')) { $r->print('
'); } @@ -339,8 +345,8 @@ sub cat_header { '
'. ''.&mt('Domain:').''. &Apache::loncommon::select_dom_form($codedom,'showdom','',1). - ' 
'. - '
'. + ' 
'. + '
'. $catlinks.'
'); return; } @@ -349,21 +355,16 @@ sub category_breadcrumbs { 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 $currdepth = 0; - my $deeper = 0; - 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; - } + my (@cats,@trails,%allitems,%idx,@jsarray,$cathash); + if (ref($domconfig{'coursecategories'}) eq 'HASH') { + $cathash = $domconfig{'coursecategories'}{'cats'}; + } else { + $cathash = {}; } - $currcat_str = ''; + &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx, + \@jsarray); + my ($currdepth,$deeper) = &get_depth_values(); + my $currcat_str = ''; my $catlinks = ''.&mt('Catalog:').''; for (my $i=0; $i<$deeper; $i++) { $currcat_str .= ''; @@ -409,7 +410,7 @@ sub category_breadcrumbs { $catlinks .= ''."\n"; } $catlinks .= ''."\n". - ' '; + ' '; } } else { $catlinks .= &mt('Official courses (with institutional codes)'). @@ -439,13 +440,62 @@ sub category_breadcrumbs { $catlinks .= ''."\n"; } $catlinks .= ''."\n". - ' '; + ' '; } } $catlinks .= $currcat_str.'
'; 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 = ''; + 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 .= ''; + } + $output .= '
'."\n". + ''."\n".'
'. + ''."\n".'
'. + '

'; + return $output; +} + sub user_is_dc { my ($codedom) = @_; if (exists($env{'user.role.dc./'.$codedom.'/'})) { @@ -566,9 +616,14 @@ sub search_official_courselist { $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 +637,14 @@ sub search_courselist { } 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; } @@ -603,7 +663,7 @@ sub print_course_listing { if ($env{'form.coursenum'} ne '') { %courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.', $env{'form.coursenum'}, - undef,undef,'Course',1); + undef,undef,'.',1); if (keys(%courses) == 0) { $output .= &mt('The courseID provided does not match a course in this domain.'); return $output; @@ -618,8 +678,10 @@ sub print_course_listing { $output = &mt('No courses match the criteria you selected.'); return $output; } - if ($knownuser && !$env{'form.showdetails'}) { - $output = &mt('Note for students: 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.

'); + if (($knownuser) && (!$env{'form.showdetails'}) && (!&user_is_dc($domain))) { + $output = ''.&mt('Note for students:').' ' + .&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.') + .'

'; } } my $now = time;