';
+ return ($catlinks,$has_subcats,$selitem);
+}
+
+sub main_category_selector {
+ my (@cats) = @_;
+ my $maincatlinks = ''."\n";
+ }
+ return $maincatlinks;
+}
+
+sub get_depth_values {
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 '') {
@@ -356,87 +1016,186 @@ sub category_breadcrumbs {
$deeper = $currdepth + 1;
}
}
- $currcat_str = '';
- my $catlinks = '
'.&mt('Catalog:').'
';
- for (my $i=0; $i<$deeper; $i++) {
- $currcat_str .= '';
- my ($cattitle,$shallower);
- if ($i == 0) {
- $cattitle = &mt('Main Categories');
- } else {
- $shallower = $i-1;
- my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});
- $cattitle = $cat;
+ return ($currdepth,$deeper);
+}
+
+sub additional_filters {
+ my ($codedom,$has_subcats,$canviewall) = @_;
+ my $is_dc = &user_is_dc($codedom);
+ my $output = '
';
+ if ($is_dc || $canviewall) {
+ $output .= '
'.
+ '';
+ return $output;
}
sub user_is_dc {
@@ -452,121 +1211,72 @@ 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);
- }
-
- }
- }
+sub canview_all {
+ my ($knownuser,$codedom) = @_;
+ my $canviewall = 0;
+ my $page = 'coursecatalog';
+ if (&LONCAPA::lonauthcgi::can_view($page)) {
+ $canviewall = 1;
+ } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) {
+ $canviewall= 1;
+ } elsif (($knownuser) && ($codedom ne '')) {
+ if (&Apache::lonnet::allowed('dcd',$codedom)) {
+ $canviewall = 1;
+ }
+ }
+ return $canviewall;
+}
+
+sub get_statustitles {
+ my ($caller) = @_;
+ my @status_order = ('Active','Future','Previous');
+ my %status_title;
+ if ($caller eq 'filters') {
+ %status_title = &Apache::lonlocal::texthash(
+ Previous => 'Show count for past access',
+ Active => 'Show count for current student access',
+ Future => 'Show count for future student access',
+ );
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $status_title{'Active'} = 'Show count for current member access';
+ $status_title{'Future'} = 'Show count for future member access';
+ }
+ } else {
+ %status_title = &Apache::lonlocal::texthash(
+ Previous => 'Previous access',
+ Active => 'Current access',
+ Future => 'Future access',
+ );
}
- 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";
+ return (\%status_title,\@status_order);
+}
+
+sub get_wasactive_text {
+ my $wasacctext = ' -- ';
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $wasacctext .= &mt('where member access status was current ...');
+ } else {
+ $wasacctext .= &mt('where student access status was current ...');
}
- return $output;
+ return $wasacctext;
}
sub search_official_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};
- } else {
- $instcode .= $env{'form.'.$item};
- }
- }
- $instcode .= '$';
- } else {
- $instcode = '.';
- }
+ my ($domain,$numtitles,$codetitles) = @_;
+ my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles,$codetitles);
+ 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'});
+ 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 ($domain,$subcats) = @_;
my $cat_maxdepth = $env{'form.catalog_maxdepth'};
my $filter = $env{'form.currcat_'.$cat_maxdepth};
if (($filter eq '') && ($cat_maxdepth > 0)) {
@@ -574,21 +1284,51 @@ sub search_courselist {
$filter = $env{'form.currcat_'.$shallower};
}
my %courses;
+ my $filterstr;
if ($filter ne '') {
- %courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',
- undef,undef,'Course',1,
- $env{'form.showselfenroll'},$filter);
+ 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 {
+ $filterstr = $filter;
+ }
+ } else {
+ $filterstr = $filter;
+ }
+ my ($showhidden,$typefilter);
+ if (&user_is_dc($domain)) {
+ $showhidden = $env{'form.showhidden'};
+ }
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $typefilter = 'Community';
+ } elsif ($env{'form.currcat_0'} eq 'placement::0') {
+ $typefilter = 'Placement';
+ } else {
+ $typefilter = '.';
+ }
+ %courses =
+ &Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',undef,undef,
+ $typefilter,1,$env{'form.showselfenroll'},
+ $filterstr,$showhidden,'coursecatalog');
}
return %courses;
}
sub print_course_listing {
- my ($domain,$numtitles) = @_;
+ my ($domain,$numtitles,$trails,$allitems,$subcats,$codetitles,$canviewall,$hostname) = @_;
my $output;
my %courses;
my $knownuser = &user_is_known();
+ my $canviewall = &canview_all();
my $details = $env{'form.coursenum'};
- if (&user_is_dc($domain)) {
+ if (&user_is_dc($domain) || $canviewall) {
if ($env{'form.showdetails'}) {
$details = 1;
}
@@ -596,44 +1336,72 @@ 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.');
+ $output = '
';
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $output .= &mt('The courseID provided does not match a community in this domain.');
+ } elsif ($env{'form.currcat_0'} eq 'placement::0') {
+ $output .= &mt('The courseID provided does not match a placement test in this domain.');
+ } else {
+ $output .= &mt('The courseID provided does not match a course in this domain.');
+ }
+ $output .= '
';
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $output .= &mt('No communities match the criteria you selected.');
+ } elsif ($env{'form.currcat_0'} eq 'placement::0') {
+ $output .= &mt('No placement tests match the criteria you selected.');
+ } else {
+ $output .= &mt('No courses match the criteria you selected.');
+ }
+ $output .= '
';
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)) && (!$canviewall)) {
+ $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;
- my %domconfig =
- &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
- $output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig);
- $output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']);
+ $output .= &construct_data_table($knownuser,$domain,\%courses,$details,undef,
+ $now,$trails,$allitems,$canviewall,$hostname);
+ $output .= "\n".'';
return $output;
}
sub construct_data_table {
- my ($knownuser,$courses,$details,$usersections,$now,$domconfig) = @_;
+ my ($knownuser,$domain,$courses,$details,$usersections,$now,
+ $trails,$allitems,$canviewall,$hostname) = @_;
my %sortname;
if (($details eq '') || ($env{'form.showdetails'})) {
$sortname{'Code'} = 'code';
+ $sortname{'Categories'} = 'cats';
$sortname{'Title'} = 'title';
- $sortname{'Owner(s)'} = 'owner';
+ $sortname{'Owner & Co-owner(s)'} = 'owner';
}
my $output = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row();
- my @coltitles = ('Count','Code','Sections','Crosslisted','Title','Owner(s)');
+ my @coltitles = ('Count');
+ if ($env{'form.currcat_0'} eq 'instcode::0') {
+ push(@coltitles,'Code');
+ } else {
+ push(@coltitles,'Categories');
+ }
+ push(@coltitles,('Sections','Crosslisted','Title','Owner & Co-owner(s)'));
if (ref($usersections) eq 'HASH') {
$coltitles[1] = 'Your Section';
}
@@ -648,24 +1416,81 @@ sub construct_data_table {
}
$output .= '';
}
- if ($knownuser) {
+ my (@fields,%fieldtitles,$wasactiveon);
+ if ($knownuser || ($canviewall && $details)) {
if ($details) {
- $output .=
- '