version 1.1, 2006/08/29 21:03:11
|
version 1.4, 2006/09/13 21:35:46
|
Line 109 function changeSort(caller) {
|
Line 109 function changeSort(caller) {
|
|
|
my $numtitles = @codetitles; |
my $numtitles = @codetitles; |
my $domdesc = $Apache::lonnet::domaindescription{$codedom}; |
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(&mt('<b>Choose which course(s) to list.</b><br />')); |
$r->print('<form name="coursecatalog" method="post">'); |
$r->print('<form name="coursecatalog" method="post">'); |
if ($numtitles > 0) { |
if ($numtitles > 0) { |
Line 123 function changeSort(caller) {
|
Line 123 function changeSort(caller) {
|
my @items = (); |
my @items = (); |
my @longitems = (); |
my @longitems = (); |
if ($idlist{$codetitles[0]} =~ /","/) { |
if ($idlist{$codetitles[0]} =~ /","/) { |
@items = split/","/,$idlist{$codetitles[0]}; |
@items = split(/","/,$idlist{$codetitles[0]}); |
} else { |
} else { |
$items[0] = $idlist{$codetitles[0]}; |
$items[0] = $idlist{$codetitles[0]}; |
} |
} |
if (defined($idlist_titles{$codetitles[0]})) { |
if (defined($idlist_titles{$codetitles[0]})) { |
if ($idlist_titles{$codetitles[0]} =~ /","/) { |
if ($idlist_titles{$codetitles[0]} =~ /","/) { |
@longitems = split/","/,$idlist_titles{$codetitles[0]}; |
@longitems = split(/","/,$idlist_titles{$codetitles[0]}); |
} else { |
} else { |
$longitems[0] = $idlist_titles{$codetitles[0]}; |
$longitems[0] = $idlist_titles{$codetitles[0]}; |
} |
} |
Line 165 function changeSort(caller) {
|
Line 165 function changeSort(caller) {
|
$r->print('<br /><input type="hidden" name="state" value="listing" /><input type="hidden" name="sortby" value="" /><input type="submit" name="catalogfilter" value="'.&mt('Display courses').'" /></form>'); |
$r->print('<br /><input type="hidden" name="state" value="listing" /><input type="hidden" name="sortby" value="" /><input type="submit" name="catalogfilter" value="'.&mt('Display courses').'" /></form>'); |
} |
} |
if ($env{'form.state'} eq 'listing') { |
if ($env{'form.state'} eq 'listing') { |
$r->print('<br /><br >'.&print_course_listing($codedom)); |
$r->print('<br /><br />'.&print_course_listing($codedom)); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
Line 193 sub print_course_listing {
|
Line 193 sub print_course_listing {
|
my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.', |
my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.', |
undef,undef,'Course'); |
undef,undef,'Course'); |
if (keys(%courses) == 0) { |
if (keys(%courses) == 0) { |
$output = &mt('No courses match the criteria you selected'); |
$output = &mt('No courses match the criteria you selected.'); |
return $output; |
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(). |
$output .= &Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
'<th><a href="javascript:changeSort('."'code'".')">'.&mt('Code').'</a></th>'. |
'<th><a href="javascript:changeSort('."'code'".')">'.&mt('Code').'</a></th>'. |
'<th>'.&mt('Sections').'</th>'. |
'<th>'.&mt('Sections').'</th>'. |
|
'<th>'.&mt('Crosslisted').'</th>'. |
'<th><a href="javascript:changeSort('."'title'".')">'.&mt('Title').'</a></th>'. |
'<th><a href="javascript:changeSort('."'title'".')">'.&mt('Title').'</a></th>'. |
'<th><a href="javascript:changeSort('."'owner'".')">'.&mt('Owner').'</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('Default Access Dates').'</th>'. |
'<th>'.&mt('Auto-enrollment Dates').'</th>'. |
'<th>'.&mt('Auto-enrollment').'</th>'. |
&Apache::loncommon::end_data_table_header_row(); |
&Apache::loncommon::end_data_table_header_row(); |
my %courseinfo; |
my %courseinfo; |
foreach my $course (keys(%courses)) { |
foreach my $course (keys(%courses)) { |
Line 218 sub print_course_listing {
|
Line 219 sub print_course_listing {
|
my $cleandesc=&HTML::Entities::encode($descr,'<>&"'); |
my $cleandesc=&HTML::Entities::encode($descr,'<>&"'); |
$cleandesc=~s/'/\\'/g; |
$cleandesc=~s/'/\\'/g; |
my ($cdom,$cnum)=split(/\_/,$course); |
my ($cdom,$cnum)=split(/\_/,$course); |
my ($desc,$instcode,$owner,$ttype) = split/:/,$courses{$course}; |
|
|
my ($desc,$instcode,$owner,$ttype) = split(/:/,$courses{$course}); |
$owner = &unescape($owner); |
$owner = &unescape($owner); |
my ($ownername,$ownerdom); |
my ($ownername,$ownerdom); |
if ($owner =~ /:/) { |
if ($owner =~ /:/) { |
Line 238 sub print_course_listing {
|
Line 240 sub print_course_listing {
|
$courseinfo{$course}{'code'} = $instcode; |
$courseinfo{$course}{'code'} = $instcode; |
$courseinfo{$course}{'ownerlastname'} = $ownernames{'lastname'}; |
$courseinfo{$course}{'ownerlastname'} = $ownernames{'lastname'}; |
$courseinfo{$course}{'title'} = $cleandesc; |
$courseinfo{$course}{'title'} = $cleandesc; |
|
$courseinfo{$course}{'owner'} = $owner; |
} |
} |
my %Sortby; |
my %Sortby; |
foreach my $course (sort(keys(%courses))) { |
foreach my $course (sort(keys(%courses))) { |
Line 268 sub print_course_listing {
|
Line 271 sub print_course_listing {
|
|
|
sub courseinfo_row { |
sub courseinfo_row { |
my ($info) = @_; |
my ($info) = @_; |
my ($cdom,$cnum,$title,$owner,$output); |
my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$output); |
if (ref($info) eq 'HASH') { |
if (ref($info) eq 'HASH') { |
$cdom = $info->{'cdom'}; |
$cdom = $info->{'cdom'}; |
$cnum = $info->{'cnum'}; |
$cnum = $info->{'cnum'}; |
$title = $info->{'title'}; |
$title = $info->{'title'}; |
$owner = $info->{'ownerlastname'}; |
$ownerlast = $info->{'ownerlastname'}; |
|
$code = $info->{'code'}; |
|
$owner = $info->{'owner'}; |
} else { |
} else { |
$output = '<td colspan="7">'.&mt('No information available').'</td>'; |
$output = '<td colspan="8">'.&mt('No information available for [_1].', |
|
$code).'</td>'; |
return $output; |
return $output; |
} |
} |
my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum); |
my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum); |
my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum); |
my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum); |
my %idx; |
my %idx; |
|
my @classids; |
|
my @crosslistings; |
$idx{'status'} = &Apache::loncoursedata::CL_STATUS(); |
$idx{'status'} = &Apache::loncoursedata::CL_STATUS(); |
my %status_title = &Apache::lonlocal::texthash ( |
my %status_title = &Apache::lonlocal::texthash( |
Expired => 'Previous access', |
Expired => 'Previous access', |
Active => 'Current access', |
Active => 'Current access', |
Future => 'Future access', |
Future => 'Future access', |
Line 292 sub courseinfo_row {
|
Line 300 sub courseinfo_row {
|
Active => 0, |
Active => 0, |
Future => 0, |
Future => 0, |
); |
); |
while (my ($student,$data) = each %$classlist) { |
while (my ($student,$data) = each(%$classlist)) { |
$student_count{$data->[$idx{'status'}]} ++; |
$student_count{$data->[$idx{'status'}]} ++; |
} |
} |
my $seclist = &identify_sections($coursehash{'internal.sectionnums'}); |
my $seclist = &identify_sections($coursehash{'internal.sectionnums'}); |
|
my $xlist_items = &identify_sections($coursehash{'internal.crosslistings'}); |
my $countslist; |
my $countslist; |
my $startaccess = ''; |
my $startaccess = ''; |
my $endaccess = ''; |
my $endaccess = ''; |
my ($accessdates,$autoenrolldates); |
my $now; |
|
my ($accessdates,$autoenrolldates,$showsyllabus); |
if ( defined($coursehash{'default_enrollment_start_date'}) ) { |
if ( defined($coursehash{'default_enrollment_start_date'}) ) { |
$startaccess = &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_start_date'}); |
$startaccess = &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_start_date'}); |
} |
} |
Line 315 sub courseinfo_row {
|
Line 325 sub courseinfo_row {
|
if ($endaccess) { |
if ($endaccess) { |
$accessdates .= &mt('To: ').$endaccess.'<br />'; |
$accessdates .= &mt('To: ').$endaccess.'<br />'; |
} |
} |
if (!defined($coursehash{'internal.autoadds'}) || $coursehash{'internal.autoadds'} == 0) { |
$autoenrolldates = &mt('Not enabled'); |
$autoenrolldates = &mt('Not enabled'); |
if (defined($coursehash{'internal.autoadds'}) && $coursehash{'internal.autoadds'} == 1) { |
} else { |
|
my ($autostart,$autoend); |
my ($autostart,$autoend); |
if ( defined($coursehash{'internal.autostart'}) ) { |
if ( defined($coursehash{'internal.autostart'}) ) { |
$autostart = &Apache::lonlocal::locallocaltime($coursehash{'internal.autostart'}); |
$autostart = &Apache::lonlocal::locallocaltime($coursehash{'internal.autostart'}); |
} |
} |
if ( defined($coursehash{'internal.autoend'}) ) { |
if ( defined($coursehash{'internal.autoend'}) ) { |
$autoend = &Apache::lonlocal::locallocaltime($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 '') { |
if ($coursehash{'internal.autostart'} > $now) { |
$autoenrolldates = &mt('No start or end date set'); |
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') { |
foreach my $status ('Active','Future','Expired') { |
$countslist .= '<nobr>'.$status_title{$status}.': '. |
$countslist .= '<nobr>'.$status_title{$status}.': '. |
$student_count{$status}.'</nobr><br />'; |
$student_count{$status}.'</nobr><br />'; |
} |
} |
|
if ($xlist_items eq '') { |
|
$xlist_items = &mt('No'); |
|
} |
$output = '<td>'.$coursehash{'internal.coursecode'}.'</td>'. |
$output = '<td>'.$coursehash{'internal.coursecode'}.'</td>'. |
'<td>'.$seclist.'</td>'. |
'<td>'.$seclist.'</td>'. |
'<td>'.$title.' <font size="-2">'. |
'<td>'.$xlist_items.'</td>'. |
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$cnum,$cdom). |
'<td>'.$title.' <font size="-2">'; |
'</font></td>'. |
if ($showsyllabus) { |
'<td>'.$owner.'</td>'. |
$output .= &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$cnum,$cdom); |
'<td>'.$countslist.'</td>'. |
} |
'<td>'.$accessdates.'</td>'. |
$output .= '</font></td>'. |
'<td>'.$autoenrolldates.'</td>'; |
'<td>'.$ownerlast.'</td>'. |
|
'<td>'.$countslist.'</td>'. |
|
'<td>'.$accessdates.'</td>'. |
|
'<td>'.$autoenrolldates.'</td>'; |
return $output; |
return $output; |
} |
} |
|
|
Line 358 sub identify_sections {
|
Line 387 sub identify_sections {
|
my ($seclist) = @_; |
my ($seclist) = @_; |
my @secnums; |
my @secnums; |
if ($seclist =~ /,/) { |
if ($seclist =~ /,/) { |
my @sections = split/,/,$seclist; |
my @sections = split(/,/,$seclist); |
foreach my $sec (@sections) { |
foreach my $sec (@sections) { |
$sec =~ s/:[^:]*$//; |
$sec =~ s/:[^:]*$//; |
push(@secnums,$sec); |
push(@secnums,$sec); |
Line 366 sub identify_sections {
|
Line 395 sub identify_sections {
|
} else { |
} else { |
if ($seclist =~ m/^([^:]+):/) { |
if ($seclist =~ m/^([^:]+):/) { |
my $sec = $1; |
my $sec = $1; |
if (!grep/^$sec$/,@secnums) { |
if (!grep(/^\Q$sec\E$/,@secnums)) { |
push (@secnums,$sec); |
push(@secnums,$sec); |
} |
} |
} |
} |
} |
} |
Line 376 sub identify_sections {
|
Line 405 sub identify_sections {
|
return $seclist; |
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'}}).'<br />'; |
|
} |
|
if (@{$validations{'xlists'}}) { |
|
$response .= &mt('Courses: '). |
|
join(',',@{$validations{'xlists'}}); |
|
} |
|
} |
|
return $response; |
|
} |
|
|
|
|
1; |
1; |
|
|
|
|