';
+ 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 .= '
'."\n".
+ ''."\n".'
'.
+ ''."\n".'
';
}
+ $output .= '
';
return $output;
}
+sub user_is_dc {
+ my ($codedom) = @_;
+ if (exists($env{'user.role.dc./'.$codedom.'/'})) {
+ my $livedc = 1;
+ my $now = time;
+ my ($start,$end)=split(/\./,$env{'user.role.dc./'.$codedom.'/'});
+ if ($start && $start>$now) { $livedc = 0; }
+ if ($end && $end <$now) { $livedc = 0; }
+ return $livedc;
+ }
+ return;
+}
+
+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'};
+ }
+ 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) = @_;
- my ($instcode,%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 {
+ $filterstr = $filter;
+ }
} else {
- $instcode .= $env{'form.'.$item};
- }
+ $filterstr = $filter;
+ }
+ } else {
+ $filterstr = $filter;
}
- $instcode .= '$';
- } else {
- $instcode = '.';
+ my $showhidden;
+ if (&user_is_dc($domain)) {
+ $showhidden = $env{'form.showhidden'};
+ }
+ %courses =
+ &Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',undef,undef,
+ '.',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) = @_;
+ my ($domain,$numtitles,$trails,$allitems,$subcats) = @_;
my $output;
my %courses;
my $knownuser = &user_is_known();
+ my $details = $env{'form.coursenum'};
+ if (&user_is_dc($domain)) {
+ if ($env{'form.showdetails'}) {
+ $details = 1;
+ }
+ }
if ($env{'form.coursenum'} ne '') {
%courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.',
$env{'form.coursenum'},
- undef,undef,'Course');
+ 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);
+ 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.');
return $output;
}
- if ($knownuser) {
- $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.')
+ .'