[LON-CAPA-cvs] cvs: loncom /interface coursecatalog.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Tue, 29 Aug 2006 21:20:06 -0000
This is a MIME encoded message
--raeburn1156886406
Content-Type: text/plain
raeburn Tue Aug 29 17:20:06 2006 EDT
Modified files:
/loncom/interface coursecatalog.pm
Log:
Some wording changes. Column added for crosslistings. Syllabus link now hidden by default. Auto-enrollment display modified to include check for valid sections and crosslistings. (Distillation of code shared with lonsupportreq.pm is next).
--raeburn1156886406
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060829172006.txt"
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.1 loncom/interface/coursecatalog.pm:1.2
--- loncom/interface/coursecatalog.pm:1.1 Tue Aug 29 17:03:11 2006
+++ loncom/interface/coursecatalog.pm Tue Aug 29 17:20:05 2006
@@ -109,7 +109,7 @@
my $numtitles = @codetitles;
my $domdesc = $Apache::lonnet::domaindescription{$codedom};
- $r->print('<h3>'.&mt('Display information about official [_1] courses in LON-CAPA:',$domdesc).'</h3>');
+ $r->print('<h3>'.&mt('Display information about official [_1] classes for which LON-CAPA courses have been created:',$domdesc).'</h3>');
$r->print(&mt('<b>Choose which course(s) to list.</b><br />'));
$r->print('<form name="coursecatalog" method="post">');
if ($numtitles > 0) {
@@ -193,19 +193,20 @@
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('<b>Note for students:</b> 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.<br /><br />');
+ $output = &mt('<b>Note for students:</b> 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.<br /><br />');
$output .= &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
'<th><a href="javascript:changeSort('."'code'".')">'.&mt('Code').'</a></th>'.
'<th>'.&mt('Sections').'</th>'.
+ '<th>'.&mt('Crosslisted').'</th>'.
'<th><a href="javascript:changeSort('."'title'".')">'.&mt('Title').'</a></th>'.
'<th><a href="javascript:changeSort('."'owner'".')">'.&mt('Owner').'</a></th>'.
- '<th>'.&mt('Students').'</th>'.
+ '<th>'.&mt('Student Status').'</th>'.
'<th>'.&mt('Default Access Dates').'</th>'.
- '<th>'.&mt('Auto-enrollment Dates').'</th>'.
+ '<th>'.&mt('Auto-enrollment').'</th>'.
&Apache::loncommon::end_data_table_header_row();
my %courseinfo;
foreach my $course (keys(%courses)) {
@@ -218,6 +219,7 @@
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 @@
$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 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 = '<td colspan="7">'.&mt('No information available').'</td>';
+ $output = '<td colspan="8">'.&mt('No information available for [_1].',
+ $code).'</td>';
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 @@
$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 @@
if ($endaccess) {
$accessdates .= &mt('To: ').$endaccess.'<br />';
}
- 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.'<br />';
- }
- if ($autoend) {
- $autoenrolldates .= &mt('Ends: ').$endaccess.'<br />';
}
- 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<br />Starts: ').
+ $autostart.'<br />'.$valid_classes;
+ }
+ }
+ } else {
+ if ($coursehash{'internal.autoend'} && $coursehash{'internal.autoend'} < $now) {
+ $autoenrolldates = &mt('Not enabled<br />Ended: ').$autoend;
+ } else {
+ my $valid_classes = &get_valid_classes($seclist,$xlist_items,
+ $code,$owner,$cdom,$cnum);
+ if ($valid_classes ne '') {
+ $autoenrolldates = &mt('Currently enabled<br />').
+ $valid_classes;
+ }
+ }
}
}
+ if (defined($coursehash{'showsyllabus'})) {
+ $showsyllabus = $coursehash{'showsyllabus'};
+ }
foreach my $status ('Active','Future','Expired') {
$countslist .= '<nobr>'.$status_title{$status}.': '.
$student_count{$status}.'</nobr><br />';
}
+ if ($xlist_items eq '') {
+ $xlist_items = &mt('No');
+ }
$output = '<td>'.$coursehash{'internal.coursecode'}.'</td>'.
'<td>'.$seclist.'</td>'.
- '<td>'.$title.' <font size="-2">'.
- &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$cnum,$cdom).
- '</font></td>'.
- '<td>'.$owner.'</td>'.
- '<td>'.$countslist.'</td>'.
- '<td>'.$accessdates.'</td>'.
- '<td>'.$autoenrolldates.'</td>';
+ '<td>'.$xlist_items.'</td>'.
+ '<td>'.$title.' <font size="-2">';
+ if ($showsyllabus) {
+ $output .= &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$cnum,$cdom);
+ }
+ $output .= '</font></td>'.
+ '<td>'.$ownerlast.'</td>'.
+ '<td>'.$countslist.'</td>'.
+ '<td>'.$accessdates.'</td>'.
+ '<td>'.$autoenrolldates.'</td>';
return $output;
}
@@ -376,7 +405,49 @@
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'}}).'<br />';
+ }
+ if (@{$validations{'xlists'}}) {
+ $response .= &mt('Courses: ').
+ join(',',@{$validations{'xlists'}});
+ }
+ }
+ return $response;
+}
+
1;
-
--raeburn1156886406--