';
+ if (($env{'form.currcat_0'} ne 'instcode::0') &&
+ ($env{'form.currcat_0'} ne '') && ($has_subcats)) {
+ my $include_subcat_status;
+ if ($env{'form.withsubcats'}) {
+ $include_subcat_status = 'checked="checked" ';
}
+ my $counter = $env{'form.catalog_maxdepth'};
+ if ($counter > 0) {
+ if ($env{'form.state'} eq 'listing') {
+ $counter --;
+ } elsif ($env{'form.currcat_'.$counter} eq '') {
+ $counter --;
+ }
+ }
+ my ($catname) = split(/:/,$env{'form.currcat_'.$counter});
+ if ($catname ne '') {
+ $output .= '
';
+ }
+ }
+ my $show_selfenroll_status;
+ if ($env{'form.showselfenroll'}) {
+ $show_selfenroll_status = 'checked="checked" ';
+ }
+ my $selfenroll_text;
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $selfenroll_text = &mt('Only show communities which allow self-enrollment');
} else {
- $r->print(&Apache::loncommon::start_page('Course Catalog','',
- {
- 'no_inline_link' => 1,}));
- $r->print(' '.&mt('No official courses to display for [_1].',$domdesc));
+ $selfenroll_text = &mt('Only show courses which allow self-enrollment');
}
- return $numtitles;
+ $output .= '
'.
+ '
';
+ 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');
+ my ($details_text,$hidden_text);
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $details_text = &mt('Show full details for each community ([_1] only)',$dc_title);
+ $hidden_text = &mt('Include communities set to be hidden from catalog ([_1] only)',$dc_title);
+ } else {
+ $details_text = &mt('Show full details for each course ([_1] only)',$dc_title);
+ $hidden_text = &mt('Include courses set to be hidden from catalog ([_1] only)',$dc_title);
+ }
+ $output .= '
'."\n".
+ ''."\n".'
'.
+ ''."\n".'
';
+ }
+ $output .= '
';
+ return $output;
}
sub user_is_dc {
@@ -304,121 +560,66 @@ sub user_is_dc {
return;
}
-sub recurse_options {
- my ($currkey,$currlist,$level,$cat,$cat_options,$data,$by_year,$by_sem,$by_dept) = @_;
- if (ref($currlist) eq 'HASH') {
- $level ++;
- foreach my $key (sort(keys(%{$currlist}))) {
- $$data[$level-1]= $key;
- &recurse_options($key,$currlist->{$key},$level,$cat,$cat_options,$data,$by_year,$by_sem,$by_dept);
- }
- } else {
- $level --;
- my @contents = split(/","/,$currlist);
- foreach my $item (@contents) {
- if (!grep(/^\Q$item\E$/,@{$cat_options->{$cat}})) {
- push(@{$cat_options->{$cat}},$item);
- }
- if ($level == 3) {
- if (!grep/^\Q$item\E$/,@{$by_year->{$data->[1]}->{$currkey}}) {
- push(@{$by_year->{$data->[1]}->{$currkey}},$item);
- }
- if (!grep/^\Q$item\E$/,@{$by_sem->{$data->[2]}->{$currkey}}) {
- push(@{$by_sem->{$data->[2]}->{$currkey}},$item);
- }
- if (!grep/^\Q$item\E$/,@{$by_dept->{$currkey}}) {
- push(@{$by_dept->{$currkey}},$item);
- }
-
- }
- }
- }
- return $level;
-}
-
-sub build_javascript {
- my ($by_year,$by_sem,$by_dept,$cat_order,$codetitles) = @_;
- my @unsorted = keys(%{$by_year});
- my @sorted_yrs;
- &Apache::courseclassifier::sort_cats('0',$cat_order,$codetitles,\@unsorted,\@sorted_yrs);
- my $output = 'var idcse_by_yr_year = new Array("'.join('","',@sorted_yrs).'");'."\n".
- 'var idcse_by_yr_dept = new Array('.scalar(@sorted_yrs).');'."\n".
- 'var idcse_by_yr_num = new Array('.scalar(@sorted_yrs).');'."\n";
- for (my $i=0; $i<@sorted_yrs; $i++) {
- my $numkeys = keys(%{$by_year->{$sorted_yrs[$i]}});
- $output .= " idcse_by_yr_num[$i] = new Array($numkeys);\n";
- if (ref($by_year->{$sorted_yrs[$i]}) eq 'HASH') {
- @unsorted = keys(%{$by_year->{$sorted_yrs[$i]}});
- my @sorted_depts;
- &Apache::courseclassifier::sort_cats('2',$cat_order,$codetitles,\@unsorted,\@sorted_depts);
- $output .= qq| idcse_by_yr_dept[$i] = new Array ("|.join('","',@sorted_depts).'");'."\n";
- for (my $j=0; $j<@sorted_depts; $j++) {
- $output .= qq| idcse_by_yr_num[$i][$j] = new Array ("|;
- $output .= join('","',sort(@{$by_year->{$sorted_yrs[$i]}->{$sorted_depts[$j]}})).'");'."\n";
- }
- }
- }
- @unsorted = keys(%{$by_sem});
- my @sorted_sems;
- &Apache::courseclassifier::sort_cats('1',$cat_order,$codetitles,\@unsorted,\@sorted_sems);
- $output .= 'idcse_by_sem_sems = new Array("'.join('","',@sorted_sems).'");'."\n".
- 'idcse_by_sem_dept = new Array('.scalar(@sorted_sems).');'."\n".
- 'idcse_by_sem_num = new Array('.scalar(@sorted_sems).');'."\n";
- for (my $i=0; $i<@sorted_sems; $i++) {
- my $numkeys = keys(%{$by_sem->{$sorted_sems[$i]}});
- $output .= " idcse_by_sem_num[$i] = new Array($numkeys);\n";
- if (ref($by_sem->{$sorted_sems[$i]}) eq 'HASH') {
- @unsorted = keys(%{$by_sem->{$sorted_sems[$i]}});
- my @sorted_depts;
- &Apache::courseclassifier::sort_cats('2',$cat_order,$codetitles,\@unsorted,\@sorted_depts);
- $output .= qq| idcse_by_sem_dept[$i] = new Array("|.join('","',@sorted_depts).'");'."\n";
- for (my $j=0; $j<@sorted_depts; $j++) {
- $output .= qq| idcse_by_sem_num[$i][$j] = new Array ("|.join('","',sort(@{$by_sem->{$sorted_sems[$i]}->{$sorted_depts[$j]}})).'");'."\n";
- }
- }
- }
- @unsorted = keys(%{$by_dept});
- my @sorted_deps;
- &Apache::courseclassifier::sort_cats('2',$cat_order,$codetitles,\@unsorted,\@sorted_deps);
- $output .= 'idcse_by_dep = new Array('.scalar(@sorted_deps).');'."\n";
- for (my $k=0; $k<@sorted_deps; $k++) {
- $output .= qq| idcse_by_dep[$k] = new Array ("|.join('","',sort(@{$by_dept->{$sorted_deps[$k]}})).'");'."\n";
+sub search_official_courselist {
+ my ($domain,$numtitles) = @_;
+ my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles);
+ my $showhidden;
+ if (&user_is_dc($domain)) {
+ $showhidden = $env{'form.showhidden'};
}
- return $output;
+ my %courses =
+ &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.',undef,undef,
+ 'Course',1,$env{'form.showselfenroll'},undef,
+ $showhidden,'coursecatalog');
+ return %courses;
}
sub search_courselist {
- my ($domain,$numtitles) = @_;
- my $instcode;
- if (defined($numtitles) && $numtitles == 0) {
- $instcode = '.+';
- } else {
- my (%codedefaults,@code_order);
- my $defaults_result =
- &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults,
- \@code_order);
- if ($defaults_result eq 'ok') {
- $instcode ='^';
- foreach my $item (@code_order) {
- if ($env{'form.'.$item} eq '0' ) {
- $instcode .= $codedefaults{$item};
+ my ($domain,$subcats) = @_;
+ my $cat_maxdepth = $env{'form.catalog_maxdepth'};
+ my $filter = $env{'form.currcat_'.$cat_maxdepth};
+ if (($filter eq '') && ($cat_maxdepth > 0)) {
+ my $shallower = $cat_maxdepth - 1;
+ $filter = $env{'form.currcat_'.$shallower};
+ }
+ my %courses;
+ my $filterstr;
+ if ($filter ne '') {
+ if ($env{'form.withsubcats'}) {
+ if (ref($subcats) eq 'HASH') {
+ if (ref($subcats->{$filter}) eq 'ARRAY') {
+ $filterstr = join('&',@{$subcats->{$filter}});
+ if ($filterstr ne '') {
+ $filterstr = $filter.'&'.$filterstr;
+ }
} else {
- $instcode .= $env{'form.'.$item};
+ $filterstr = $filter;
}
- }
- $instcode .= '$';
+ } else {
+ $filterstr = $filter;
+ }
} else {
- $instcode = '.';
+ $filterstr = $filter;
+ }
+ my ($showhidden,$typefilter);
+ if (&user_is_dc($domain)) {
+ $showhidden = $env{'form.showhidden'};
}
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $typefilter = 'Community';
+ } else {
+ $typefilter = '.';
+ }
+ %courses =
+ &Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',undef,undef,
+ $typefilter,1,$env{'form.showselfenroll'},
+ $filterstr,$showhidden,'coursecatalog');
}
- my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.',
- undef,undef,'Course',1);
return %courses;
}
-
sub print_course_listing {
- my ($domain,$numtitles) = @_;
+ my ($domain,$numtitles,$trails,$allitems,$subcats) = @_;
my $output;
my %courses;
my $knownuser = &user_is_known();
@@ -431,37 +632,61 @@ 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;
}
} else {
- %courses = &search_courselist($domain,$numtitles);
+ if ($env{'form.currcat_0'} eq 'instcode::0') {
+ %courses = &search_official_courselist($domain,$numtitles);
+ } else {
+ %courses = &search_courselist($domain,$subcats);
+ }
if (keys(%courses) == 0) {
- $output = &mt('No courses match the criteria you selected.');
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $output = &mt('No communities match the criteria you selected.');
+ } else {
+ $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.')
+ .'