';
- return ($catlinks,$has_subcats);
+ return ($catlinks,$has_subcats,$selitem);
+}
+
+sub main_category_selector {
+ my (@cats) = @_;
+ my $maincatlinks = ''."\n";
+ if (ref($cats[0]) eq 'ARRAY') {
+ if (@{$cats[0]} > 1) {
+ my $selected = '';
+ if ($env{'form.currcat_0'} eq '') {
+ $selected = ' selected="selected"';
+ }
+ $maincatlinks .=
+ ''."\n";
+ }
+ for (my $i=0; $i<@{$cats[0]}; $i++) {
+ my $name = $cats[0][$i];
+ my $item = &escape($name).'::0';
+ my $selected;
+ if ($env{'form.currcat_0'} eq $item) {
+ $selected = ' selected="selected"';
+ }
+ $maincatlinks .= ''."\n";
+ }
+ $maincatlinks .= ''."\n";
+ }
+ return $maincatlinks;
}
sub get_depth_values {
@@ -498,9 +1020,14 @@ sub get_depth_values {
}
sub additional_filters {
- my ($codedom,$has_subcats) = @_;
- my $output = '
';
- if (($env{'form.currcat_0'} ne 'instcode::0') &&
+ my ($codedom,$has_subcats,$canviewall) = @_;
+ my $is_dc = &user_is_dc($codedom);
+ my $output = '
';
+ if ($is_dc || $canviewall) {
+ $output .= '
'.
+ '';
return $output;
}
@@ -569,113 +1211,59 @@ 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'};
@@ -714,25 +1302,33 @@ sub search_courselist {
} else {
$filterstr = $filter;
}
- my $showhidden;
+ 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,
- '.',1,$env{'form.showselfenroll'},
+ $typefilter,1,$env{'form.showselfenroll'},
$filterstr,$showhidden,'coursecatalog');
}
return %courses;
}
sub print_course_listing {
- my ($domain,$numtitles,$trails,$allitems,$subcats) = @_;
+ 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;
}
@@ -742,29 +1338,44 @@ sub print_course_listing {
$env{'form.coursenum'},
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 .= '
';
return $output;
}
} else {
if ($env{'form.currcat_0'} eq 'instcode::0') {
- %courses = &search_official_courselist($domain,$numtitles);
+ %courses = &search_official_courselist($domain,$numtitles,$codetitles);
} else {
%courses = &search_courselist($domain,$subcats);
}
if (keys(%courses) == 0) {
- $output = &mt('No courses match the criteria you selected.');
+ $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'}) && (!&user_is_dc($domain))) {
+ 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.')
.'