--- loncom/interface/coursecatalog.pm 2006/08/29 21:03:11 1.1
+++ loncom/interface/coursecatalog.pm 2006/09/25 00:16:56 1.5
@@ -60,6 +60,7 @@ sub handler {
my $totcodes = 0;
my $jscript = '';
my $formname = 'coursecatalog';
+ my $domdesc = $Apache::lonnet::domaindescription{$codedom};
$totcodes = &Apache::lonsupportreq::retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
if ($totcodes > 0) {
if ($ccode eq '') {
@@ -108,8 +109,7 @@ function changeSort(caller) {
$r->print($start_page);
my $numtitles = @codetitles;
- my $domdesc = $Apache::lonnet::domaindescription{$codedom};
- $r->print('
'.&mt('Display information about official [_1] courses in LON-CAPA:',$domdesc).'
');
+ $r->print(''.&mt('Display information about official [_1] classes for which LON-CAPA courses have been created:',$domdesc).'
');
$r->print(&mt('Choose which course(s) to list.
'));
$r->print('');
+ } else {
+ $r->print(&Apache::loncommon::start_page('Course Catalog','',
+ {
+ 'no_inline_link' => 1,}));
+ $r->print('
'.&mt('No official courses to display for [_1].',$domdesc));
}
if ($env{'form.state'} eq 'listing') {
- $r->print('
'.&print_course_listing($codedom));
+ $r->print('
'.&print_course_listing($codedom));
}
$r->print(&Apache::loncommon::end_page());
+ return OK;
}
sub print_course_listing {
@@ -193,19 +199,20 @@ sub print_course_listing {
my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.',
undef,undef,'Course');
if (keys(%courses) == 0) {
- $output = &mt('No courses match the criteria you selected');
+ $output = &mt('No courses match the criteria you selected.');
return $output;
}
- $output = &mt('Note for students: If STUINFO shows you as enrolled in a course, but there is no student role for the course in your LON-CAPA roles screen, please check the default access dates and/or auto-enrollment dates for the course listed below. Your roles screen will only display currently accessible roles.
');
+ $output = &mt('Note for students: If you are officially enrolled in a course but there is no student role for the course in your LON-CAPA roles screen, check the default access dates and/or auto-enrollment settings for the course below. Your roles screen displays only currently accessible roles.
');
$output .= &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
''.&mt('Code').' | '.
''.&mt('Sections').' | '.
+ ''.&mt('Crosslisted').' | '.
''.&mt('Title').' | '.
''.&mt('Owner').' | '.
- ''.&mt('Students').' | '.
+ ''.&mt('Student Status').' | '.
''.&mt('Default Access Dates').' | '.
- ''.&mt('Auto-enrollment Dates').' | '.
+ ''.&mt('Auto-enrollment').' | '.
&Apache::loncommon::end_data_table_header_row();
my %courseinfo;
foreach my $course (keys(%courses)) {
@@ -218,7 +225,8 @@ sub print_course_listing {
my $cleandesc=&HTML::Entities::encode($descr,'<>&"');
$cleandesc=~s/'/\\'/g;
my ($cdom,$cnum)=split(/\_/,$course);
- my ($desc,$instcode,$owner,$ttype) = split/:/,$courses{$course};
+
+ my ($desc,$instcode,$owner,$ttype) = split(/:/,$courses{$course});
$owner = &unescape($owner);
my ($ownername,$ownerdom);
if ($owner =~ /:/) {
@@ -238,6 +246,7 @@ sub print_course_listing {
$courseinfo{$course}{'code'} = $instcode;
$courseinfo{$course}{'ownerlastname'} = $ownernames{'lastname'};
$courseinfo{$course}{'title'} = $cleandesc;
+ $courseinfo{$course}{'owner'} = $owner;
}
my %Sortby;
foreach my $course (sort(keys(%courses))) {
@@ -268,21 +277,26 @@ sub print_course_listing {
sub courseinfo_row {
my ($info) = @_;
- my ($cdom,$cnum,$title,$owner,$output);
+ my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$output);
if (ref($info) eq 'HASH') {
$cdom = $info->{'cdom'};
$cnum = $info->{'cnum'};
$title = $info->{'title'};
- $owner = $info->{'ownerlastname'};
+ $ownerlast = $info->{'ownerlastname'};
+ $code = $info->{'code'};
+ $owner = $info->{'owner'};
} else {
- $output = ''.&mt('No information available').' | ';
+ $output = ''.&mt('No information available for [_1].',
+ $code).' | ';
return $output;
}
my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum);
my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
my %idx;
+ my @classids;
+ my @crosslistings;
$idx{'status'} = &Apache::loncoursedata::CL_STATUS();
- my %status_title = &Apache::lonlocal::texthash (
+ my %status_title = &Apache::lonlocal::texthash(
Expired => 'Previous access',
Active => 'Current access',
Future => 'Future access',
@@ -292,14 +306,16 @@ sub courseinfo_row {
Active => 0,
Future => 0,
);
- while (my ($student,$data) = each %$classlist) {
+ while (my ($student,$data) = each(%$classlist)) {
$student_count{$data->[$idx{'status'}]} ++;
}
my $seclist = &identify_sections($coursehash{'internal.sectionnums'});
+ my $xlist_items = &identify_sections($coursehash{'internal.crosslistings'});
my $countslist;
my $startaccess = '';
my $endaccess = '';
- my ($accessdates,$autoenrolldates);
+ my $now;
+ my ($accessdates,$autoenrolldates,$showsyllabus);
if ( defined($coursehash{'default_enrollment_start_date'}) ) {
$startaccess = &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_start_date'});
}
@@ -315,42 +331,61 @@ sub courseinfo_row {
if ($endaccess) {
$accessdates .= &mt('To: ').$endaccess.'
';
}
- if (!defined($coursehash{'internal.autoadds'}) || $coursehash{'internal.autoadds'} == 0) {
- $autoenrolldates = &mt('Not enabled');
- } else {
+ $autoenrolldates = &mt('Not enabled');
+ if (defined($coursehash{'internal.autoadds'}) && $coursehash{'internal.autoadds'} == 1) {
my ($autostart,$autoend);
if ( defined($coursehash{'internal.autostart'}) ) {
$autostart = &Apache::lonlocal::locallocaltime($coursehash{'internal.autostart'});
}
if ( defined($coursehash{'internal.autoend'}) ) {
$autoend = &Apache::lonlocal::locallocaltime($coursehash{'internal.autoend'});
- if ($coursehash{'internal.autoend'} == 0) {
- $autoend = "No ending date";
- }
- }
- if ($autostart) {
- $autoenrolldates .= &mt('Starts: ').$startaccess.'
';
}
- if ($autoend) {
- $autoenrolldates .= &mt('Ends: ').$endaccess.'
';
- }
- if ($autoenrolldates eq '') {
- $autoenrolldates = &mt('No start or end date set');
+ if ($coursehash{'internal.autostart'} > $now) {
+ if ($coursehash{'internal.autoend'} && $coursehash{'internal.autoend'} < $now) {
+ $autoenrolldates = &mt('Not enabled');
+ } else {
+ my $valid_classes = &get_valid_classes($seclist,$xlist_items,
+ $code,$owner,$cdom,$cnum);
+ if ($valid_classes ne '') {
+ $autoenrolldates = &mt('Not enabled
Starts: ').
+ $autostart.'
'.$valid_classes;
+ }
+ }
+ } else {
+ if ($coursehash{'internal.autoend'} && $coursehash{'internal.autoend'} < $now) {
+ $autoenrolldates = &mt('Not enabled
Ended: ').$autoend;
+ } else {
+ my $valid_classes = &get_valid_classes($seclist,$xlist_items,
+ $code,$owner,$cdom,$cnum);
+ if ($valid_classes ne '') {
+ $autoenrolldates = &mt('Currently enabled
').
+ $valid_classes;
+ }
+ }
}
}
+ if (defined($coursehash{'showsyllabus'})) {
+ $showsyllabus = $coursehash{'showsyllabus'};
+ }
foreach my $status ('Active','Future','Expired') {
$countslist .= ''.$status_title{$status}.': '.
$student_count{$status}.'
';
}
+ if ($xlist_items eq '') {
+ $xlist_items = &mt('No');
+ }
$output = ''.$coursehash{'internal.coursecode'}.' | '.
''.$seclist.' | '.
- ''.$title.' '.
- &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$cnum,$cdom).
- ' | '.
- ''.$owner.' | '.
- ''.$countslist.' | '.
- ''.$accessdates.' | '.
- ''.$autoenrolldates.' | ';
+ ''.$xlist_items.' | '.
+ ''.$title.' ';
+ if ($showsyllabus) {
+ $output .= &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$cnum,$cdom);
+ }
+ $output .= ' | '.
+ ''.$ownerlast.' | '.
+ ''.$countslist.' | '.
+ ''.$accessdates.' | '.
+ ''.$autoenrolldates.' | ';
return $output;
}
@@ -358,7 +393,7 @@ sub identify_sections {
my ($seclist) = @_;
my @secnums;
if ($seclist =~ /,/) {
- my @sections = split/,/,$seclist;
+ my @sections = split(/,/,$seclist);
foreach my $sec (@sections) {
$sec =~ s/:[^:]*$//;
push(@secnums,$sec);
@@ -366,8 +401,8 @@ sub identify_sections {
} else {
if ($seclist =~ m/^([^:]+):/) {
my $sec = $1;
- if (!grep/^$sec$/,@secnums) {
- push (@secnums,$sec);
+ if (!grep(/^\Q$sec\E$/,@secnums)) {
+ push(@secnums,$sec);
}
}
}
@@ -376,7 +411,49 @@ sub identify_sections {
return $seclist;
}
+sub get_valid_classes {
+ my ($seclist,$xlist_items,$crscode,$owner,$cdom,$cnum) = @_;
+ my $response;
+ my %validations;
+ @{$validations{'sections'}} = ();
+ @{$validations{'xlists'}} = ();
+ my $totalitems = 0;
+ if ($seclist) {
+ foreach my $sec (split(',',$seclist)) {
+ my $class = $crscode.$sec;
+ if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owner,
+ $class) eq 'ok') {
+ if (!grep(/^\Q$sec$\E/,@{$validations{'sections'}})) {
+ push(@{$validations{'sections'}},$sec);
+ $totalitems ++;
+ }
+ }
+ }
+ }
+ if ($xlist_items) {
+ foreach my $item (split(',',$xlist_items)) {
+ if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owner,
+ $item) eq 'ok') {
+ if (!grep(/^\Q$item$\E/,@{$validations{'xlists'}})) {
+ push(@{$validations{'xlists'}},$item);
+ $totalitems ++;
+ }
+ }
+ }
+ }
+ if ($totalitems > 0) {
+ if (@{$validations{'sections'}}) {
+ $response = &mt('Sections: ').
+ join(',',@{$validations{'sections'}}).'
';
+ }
+ if (@{$validations{'xlists'}}) {
+ $response .= &mt('Courses: ').
+ join(',',@{$validations{'xlists'}});
+ }
+ }
+ return $response;
+}
-1;
+1;