--- loncom/interface/coursecatalog.pm 2006/08/29 21:03:11 1.1 +++ loncom/interface/coursecatalog.pm 2006/08/29 21:20:05 1.2 @@ -109,7 +109,7 @@ function changeSort(caller) { 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('
'); if ($numtitles > 0) { @@ -193,19 +193,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,6 +219,7 @@ 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}; $owner = &unescape($owner); my ($ownername,$ownerdom); @@ -238,6 +240,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,19 +271,24 @@ 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 ( Expired => 'Previous access', @@ -296,10 +304,12 @@ sub courseinfo_row { $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 +325,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; } @@ -376,7 +405,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::autovalidate_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::autovalidate_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; -