--- loncom/interface/coursecatalog.pm 2007/01/12 21:07:37 1.17
+++ loncom/interface/coursecatalog.pm 2007/01/12 23:37:22 1.18
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.17 2007/01/12 21:07:37 albertel Exp $
+# $Id: coursecatalog.pm,v 1.18 2007/01/12 23:37:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -67,10 +67,10 @@ sub handler {
if ($env{'form.coursenum'} ne '' && &user_is_known()) {
&course_details($r,$codedom,$formname,$domdesc);
} else {
- &course_selector($r,$codedom,$formname,$domdesc);
+ my $numtitles = &course_selector($r,$codedom,$formname,$domdesc);
if ($env{'form.state'} eq 'listing') {
- $r->print('
'.&print_course_listing($codedom).'
');
- }
+ $r->print(&print_course_listing($codedom,$numtitles).'
');
+ }
}
$r->print(&Apache::loncommon::end_page());
return OK;
@@ -137,41 +137,49 @@ sub course_selector {
if ($numtitles > 4) {
$lasttitle = 4;
}
- my @data = ('top');
- for (my $k=0; $k<$lasttitle; $k++) {
- my $cat = $codetitles[$k];
- my $level = 1;
- $level = &recurse_options($codetitles[$k],$idlist{$codetitles[$k]},$level,$cat,\%cat_items,\@data,\%by_year,\%by_sem,\%by_dept); }
- $scripttext .= &build_javascript(\%by_year,\%by_sem,\%by_dept,\%cat_order,\@codetitles);
- $jscript .= &javascript_select_filler($formname,$scripttext,\@codetitles,$longtitles_str,$allidlist);
- }
- if ($env{'form.state'} eq 'listing') {
- $jscript .= '
+ if ($numtitles == 0) {
+ if (!defined($env{'form.state'})) {
+ $env{'form.state'} = 'listing';
+ }
+ } else {
+ my @data = ('top');
+ for (my $k=0; $k<$lasttitle; $k++) {
+ my $cat = $codetitles[$k];
+ my $level = 1;
+ $level = &recurse_options($codetitles[$k],$idlist{$codetitles[$k]},$level,$cat,\%cat_items,\@data,\%by_year,\%by_sem,\%by_dept);
+ }
+ $scripttext .= &build_javascript(\%by_year,\%by_sem,\%by_dept,\%cat_order,\@codetitles);
+ $jscript .= &javascript_select_filler($formname,$scripttext,\@codetitles,$longtitles_str,$allidlist);
+ if ($env{'form.state'} eq 'listing') {
+ $jscript .= '
function setElements() {
';
- for (my $i=0; $i<@codetitles-1; $i++) {
- if ($env{'form.'.$codetitles[$i]} != -1) {
- $jscript .= '
+ for (my $i=0; $i<@codetitles-1; $i++) {
+ if ($env{'form.'.$codetitles[$i]} != -1) {
+ $jscript .= '
for (var j=0; j'."\n$jscript\n".
'';
my %add_entries = (topmargin => "0",
marginheight => "0",);
- if ($env{'form.state'} eq 'listing') {
+ if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) {
$add_entries{'onLoad'} = 'setElements()';
}
my $start_page =
@@ -207,9 +216,9 @@ function setCourseId(caller) {
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Select courses'));
}
$r->print(''.&mt('Display information about official [_1] classes for which LON-CAPA courses have been created:',$domdesc).'
');
- $r->print(&mt('Choose which course(s) to list.
'));
$r->print('