'.&mt('Domain:').' | '.
&Apache::loncommon::select_dom_form($codedom,'showdom','',1,$onchange));
@@ -423,73 +345,71 @@ sub category_breadcrumbs {
my ($dom,@cats) = @_;
my $crumbsymbol = ' ▶ ';
my ($currdepth,$deeper) = &get_depth_values();
- my $currcat_str = '';
- my $catlinks = ' | '.&mt('Catalog:').' | ';
+ my $currcat_str =
+ ''.
+ '';
+ my $catlinks = ''.&mt('Catalog:').' | ';
my $has_subcats;
my $selitem;
- for (my $i=0; $i<$deeper; $i++) {
- $currcat_str .= '';
- my ($cattitle,$shallower);
- if ($i == 0) {
- if (ref($cats[0]) eq 'ARRAY') {
- if (@{$cats[0]} > 1) {
- $cattitle = &mt('Main Categories');
- }
+ if (ref($cats[0]) eq 'ARRAY') {
+ if (@{$cats[0]} == 0) {
+ $catlinks .= &mt('No categories defined in this domain');
+ } elsif (@{$cats[0]} == 1) {
+ if ($cats[0][0] eq 'instcode') {
+ $catlinks .= &mt('Official courses (with institutional codes)');
+ $env{'form.currcat_0'} = 'instcode::0';
+ } elsif ($cats[0][0] eq 'communities') {
+ $catlinks .= &mt('Communities');
+ $env{'form.currcat_0'} = 'communities::0';
+ } else {
+ my $name = $cats[0][0];
+ my $item = &escape($name).'::0';
+ $catlinks .= $name;
+ $env{'form.currcat_0'} = $item;
}
+ $currcat_str .= '';
} else {
- $shallower = $i-1;
- my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});
- $cattitle = $cat;
- }
- if ($cattitle ne '') {
- $catlinks .= ' | '.$cattitle.''.$crumbsymbol.' | ';
- }
- }
- if ($deeper == 0) {
- $catlinks .= '';
- if (ref($cats[0]) eq 'ARRAY') {
- if ((@{$cats[0]} == 1) && (@cats == 1)) {
- if ($cats[0][0] eq 'instcode') {
- $catlinks .= &mt('Official courses (with institutional codes)').
- '';
- $env{'form.currcat_0'} = 'instcode::0';
- } else {
- my $name = $cats[0][0];
- my $item = &escape($name).'::0';
- $catlinks .= $name.
- '';
- $env{'form.currcat_0'} = $item;
- }
+ $catlinks .= &main_category_selector(@cats);
+ if (($env{'form.currcat_0'} ne '') &&
+ ($env{'form.currcat_0'} ne 'instcode::0')) {
+ $catlinks .= $crumbsymbol;
} else {
- $has_subcats = 1;
- my $buttontext = &mt('Show subcategories');
- $selitem = 'currcat_0';
- $catlinks .= ' | ';
+ }
+ }
+ } else {
+ $catlinks .= &mt('Official courses (with institutional codes)');
+ $env{'form.currcat_0'} = 'instcode::0';
+ $currcat_str .= '';
+ }
+ if ($deeper) {
+ for (my $i=1; $i<=$deeper; $i++) {
+ my $shallower = $i-1;
+ next if ($shallower == 0);
+ my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});
+ if ($cat ne '') {
+ $catlinks .= ''.
+ ''."\n".
- ' ';
+ $catlinks .= '';
}
- } else {
- $catlinks .= &mt('Official courses (with institutional codes)').
- '';
- $env{'form.currcat_0'} = 'instcode::0';
+ unless ($i == $deeper) {
+ $catlinks .= $crumbsymbol;
+ }
}
- } else {
my ($cat,$container,$depth);
if ($env{'form.currcat_'.$currdepth} eq '') {
my $shallower = $currdepth - 1;
@@ -497,38 +417,66 @@ sub category_breadcrumbs {
} else {
($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$currdepth});
}
- my $deeper = $depth +1;
- my $currcat = $cat;
- if ($cat eq 'instcode') {
- $currcat = &mt('Official courses (with institutional codes)');
- }
- $catlinks .= ' | '.$currcat.'';
- if (ref($cats[$deeper]{$cat}) eq 'ARRAY') {
+ my $deeperlevel = $depth +1;
+ if (ref($cats[$deeperlevel]{$cat}) eq 'ARRAY') {
$has_subcats = 1;
my $buttontext = &mt('Show subcategories');
- $selitem = 'currcat_'.$deeper;
- $catlinks .= ': '."\n";
} elsif ($cat ne 'instcode') {
$catlinks .= ' '.&mt('(No subcategories)');
}
+ } else {
+ $selitem = 'currcat_0';
}
$catlinks .= $currcat_str.' |
| ';
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 {
my $currdepth = 0;
my $deeper = 0;
@@ -573,10 +521,15 @@ sub additional_filters {
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 {
+ $selfenroll_text = &mt('Only show courses which allow self-enrollment');
+ }
$output .= ' '.
' | ';
if (&user_is_dc($codedom)) {
my $showdetails_status;
@@ -588,14 +541,20 @@ sub additional_filters {
$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 .= '
';
@@ -615,113 +574,9 @@ 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";
- }
- return $output;
-}
-
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'};
@@ -760,20 +615,25 @@ 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';
+ } 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) = @_;
my $output;
my %courses;
my $knownuser = &user_is_known();
@@ -788,17 +648,25 @@ 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.');
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $output .= &mt('The courseID provided does not match a community in this domain.');
+ } else {
+ $output .= &mt('The courseID provided does not match a course in this domain.');
+ }
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.');
+ 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'}) && (!&user_is_dc($domain))) {
@@ -853,10 +721,14 @@ sub construct_data_table {
}
if ($knownuser) {
if ($details) {
- $output .=
- ' | '.&mt('Default Access Dates for Students').' | '.
- ''.&mt('Student Counts').' | '.
- ''.&mt('Auto-enrollment of[_1]registered students',' ').' | ';
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $output .= ''.&mt('Default Access Dates for Members').' | ';
+ } else {
+ $output .=
+ ''.&mt('Default Access Dates for Students').' | '.
+ ''.&mt('Student Counts').' | '.
+ ''.&mt('Auto-enrollment of[_1]registered students',' ').' | ';
+ }
} else {
$output .= ''.&mt('Details').' | ';
}
@@ -927,14 +799,14 @@ sub build_courseinfo_hash {
$selfenroll_end = $courses->{$course}{'selfenroll_end_date'};
$categories = $courses->{$course}{'categories'};
push(@owners,$singleowner);
- if (ref($courses->{$course}{'co-owners'}) eq 'ARRAY') {
- foreach my $item (@{$courses->{$course}{'co-owners'}}) {
+ if ($courses->{$course}{'co-owners'} ne '') {
+ foreach my $item (split(/,/,$courses->{$course}{'co-owners'})) {
push(@owners,$item);
}
}
}
foreach my $owner (@owners) {
- my ($ownername,$ownerdom) = @_;
+ my ($ownername,$ownerdom);
if ($owner =~ /:/) {
($ownername,$ownerdom) = split(/:/,$owner);
} else {
@@ -1125,10 +997,14 @@ sub courseinfo_row {
''.$ownerlast.' | ';
if ($knownuser) {
if ($details) {
- $output .=
- ''.$accessdates.' | '.
- ''.$counts.' | '.
- ''.$autoenrollment.' | ';
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $output .= ''.$accessdates.' | ';
+ } else {
+ $output .=
+ ''.$accessdates.' | '.
+ ''.$counts.' | '.
+ ''.$autoenrollment.' | ';
+ }
} else {
$output .= "".&mt('Show more details').' | ';
}
@@ -1141,7 +1017,13 @@ sub courseinfo_row {
if (($info->{'selfenroll_start'} > 0) && ($info->{'selfenroll_start'} > $now)) {
$output .= ''.&mt('Starts: [_1]',''.$showstart.'').' '.&mt('Ends: [_1]',''.$showend.'').' | ';
} else {
- $output .= ''.&mt('Enroll in course').' | ';
+ $output .= ''.&mt('Enroll in course').' ';
+ if ($info->{'selfenroll_end'} == 0) {
+ $output .= &mt('Available permanently');
+ } elsif ($info->{'selfenroll_end'} > $now) {
+ $output .= &mt('Self-enrollment ends: [_1]',''.$showend.'');
+ }
+ $output .= ' | ';
}
$selfenroll = 1;
}
@@ -1219,145 +1101,6 @@ sub get_valid_classes {
return $response;
}
-sub javascript_select_filler {
- my ($formname,$scripttext,$codetitles,$longtitles_str,$allidlist) = @_;
- my $output = < -1) {
- document.$formname.Number.options[0] = new Option('All','0',false,false);
- for (var k=0; k -1) {
- for (var i=0; i -1) {
- for (var i=0; i -1) {
- for (var k=0; k
---|