--- loncom/interface/coursecatalog.pm 2008/06/27 04:59:45 1.32 +++ loncom/interface/coursecatalog.pm 2008/07/04 15:40:04 1.34 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.32 2008/06/27 04:59:45 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.34 2008/07/04 15:40:04 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,6 +107,24 @@ 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)); } } @@ -212,51 +241,7 @@ function setElements() { $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 = ''; if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) { @@ -268,11 +253,7 @@ function display_courses() { ''."\n". ''."\n". ''. - ''."\n"); - if (&user_is_dc($codedom)) { - $r->print(''."\n". - ''."\n"); - } + &additional_filters($codedom)); if ($numtitles > 0) { $r->print(''.&mt('Choose which course(s) to list.').'
'); $r->print(''); @@ -312,12 +293,14 @@ function display_courses() { } $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('
'); } @@ -358,33 +341,12 @@ sub cat_header { text=>"Select courses"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Select courses')); } - $r->print('
'. - ''. - '
'.&mt('Domain:').''. + $r->print(''. + ''. - ''. - $catlinks.''); - 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(''); - } - $r->print('
'.&mt('Domain:').''. &Apache::loncommon::select_dom_form($codedom,'showdom','',1). - ' 
'. - '

'); + ' 
'. + '
'. + ''.$catlinks.'
'); return; } @@ -400,18 +362,8 @@ sub category_breadcrumbs { } &Apache::loncommon::extract_categories($cathash,\@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; - } - } - $currcat_str = ''; + my ($currdepth,$deeper) = &get_depth_values(); + my $currcat_str = ''; my $catlinks = ''.&mt('Catalog:').''; for (my $i=0; $i<$deeper; $i++) { $currcat_str .= ''; @@ -430,7 +382,7 @@ sub category_breadcrumbs { if (ref($cats[0]) eq 'ARRAY') { if ((@{$cats[0]} == 1) && ($cats[0][0] eq 'instcode')) { $catlinks .= &mt('Official courses (with institutional codes)'). - ''; + ''; $env{'form.currcat_0'} = 'instcode::0'; } else { $catlinks .= ''."\n". - ' '; + ' '; } } else { $catlinks .= &mt('Official courses (with institutional codes)'). - ''; + ''; $env{'form.currcat_0'} = 'instcode::0'; } } else { @@ -487,13 +439,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.'/'})) { @@ -661,7 +662,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; @@ -858,7 +859,7 @@ sub build_courseinfo_hash { if ( defined($coursehash{'default_enrollment_end_date'}) ) { $endaccess = &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_end_date'}); if ($coursehash{'default_enrollment_end_date'} == 0) { - $endaccess = "No ending date"; + $endaccess = &mt('No ending date'); } } if ($startaccess) { @@ -867,6 +868,33 @@ sub build_courseinfo_hash { if ($endaccess) { $accessdates .= &mt('To: ').$endaccess.'
'; } + if (($selfenroll_types ne '') && + ($selfenroll_end > 0 && $selfenroll_end > $now)) { + my ($selfenroll_start_access,$selfenroll_end_access); + if (($coursehash{'default_enrollment_start_date'} ne + $coursehash{'internal.selfenroll_start_access'}) || + ($coursehash{'default_enrollment_end_date'} ne + $coursehash{'internal.selfenroll_end_access'})) { + if ( defined($coursehash{'internal.selfenroll_start_access'}) ) { + $selfenroll_start_access = &Apache::lonlocal::locallocaltime($coursehash{'internal.selfenroll_start_access'}); + } + if ( defined($coursehash{'default_enrollment_end_date'}) ) { + $selfenroll_end_access = &Apache::lonlocal::locallocaltime($coursehash{'internal.selfenroll_end_access'}); + if ($coursehash{'internal.selfenroll_end_access'} == 0) { + $selfenroll_end_access = &mt('No ending date'); + } + } + if ($selfenroll_start_access || $selfenroll_end_access) { + $accessdates .= '

'.&mt('Self-enrollers:').'
'; + if ($selfenroll_start_access) { + $accessdates .= &mt('From: ').$selfenroll_start_access.'
'; + } + if ($selfenroll_end_access) { + $accessdates .= &mt('To: ').$selfenroll_end_access.'
'; + } + } + } + } $courseinfo{$course}{'access'} = $accessdates; } if ($xlist_items eq '') {