version 1.21, 2007/10/02 01:10:27
|
version 1.27, 2008/03/08 04:00:53
|
Line 128 sub course_selector {
|
Line 128 sub course_selector {
|
my $totcodes = 0; |
my $totcodes = 0; |
my $jscript = ''; |
my $jscript = ''; |
my ($numtitles,$lasttitle); |
my ($numtitles,$lasttitle); |
$totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes); |
$totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom); |
if ($totcodes > 0) { |
if ($totcodes > 0) { |
$format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order); |
$format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order); |
if ($format_reply eq 'ok') { |
if ($format_reply eq 'ok') { |
Line 231 function setCourseId(caller) {
|
Line 231 function setCourseId(caller) {
|
$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('<table><tr>'); |
$r->print('<table><tr>'); |
for (my $k=0; $k<$lasttitle-1; $k++) { |
for (my $k=0; $k<$lasttitle-1; $k++) { |
my @unsorted = @{$cat_items{$codetitles[$k]}}; |
my (@items,@unsorted); |
my @items; |
if (ref($cat_items{$codetitles[$k]}) eq 'ARRAY') { |
|
@unsorted = @{$cat_items{$codetitles[$k]}}; |
|
} |
&Apache::courseclassifier::sort_cats($k,\%cat_order,\@codetitles,\@unsorted,\@items); |
&Apache::courseclassifier::sort_cats($k,\%cat_order,\@codetitles,\@unsorted,\@items); |
my @longitems; |
my @longitems; |
if (defined($cat_titles{$codetitles[$k]})) { |
if (defined($cat_titles{$codetitles[$k]})) { |
Line 259 function setCourseId(caller) {
|
Line 261 function setCourseId(caller) {
|
'</option>'."\n".'</select>'."\n". |
'</option>'."\n".'</select>'."\n". |
'</td>' |
'</td>' |
); |
); |
|
my $show_selfenroll_status; |
|
if ($env{'form.showselfenroll'}) { |
|
$show_selfenroll_status = 'checked="checked" '; |
|
} |
if (&user_is_dc($codedom)) { |
if (&user_is_dc($codedom)) { |
my $showdetails_status; |
my $showdetails_status; |
if ($env{'form.showdetails'}) { |
if ($env{'form.showdetails'}) { |
$showdetails_status = 'checked="checked" '; |
$showdetails_status = 'checked="checked" '; |
} |
} |
$r->print('<td></td><td><input type="checkbox" name="showdetails" value="1" '.$showdetails_status.'/>'.&mt('Show full details for each course (DC only)').'</td>'); |
$r->print('<td></td><td><label><input type="checkbox" name="showdetails" value="1" '.$showdetails_status.'/>'.&mt('Show full details for each course (DC only)').'</label><br /><label><input type="checkbox" name="showselfenroll" value="1" '.$show_selfenroll_status.'/>'.&mt('Only show courses which allow self-enrollment').'</label></td>'); |
|
} else { |
|
$r->print('<td></td><td><br /><label><input type="checkbox" name="showselfenroll" value="1" '.$show_selfenroll_status.'/>'.&mt('Only show courses which allow self-enrollment').'</label></td>'); |
} |
} |
$r->print('</tr></table>'); |
$r->print('</tr></table>'); |
if ($numtitles > 4) { |
if ($numtitles > 4) { |
Line 412 sub search_courselist {
|
Line 420 sub search_courselist {
|
} |
} |
} |
} |
my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.', |
my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.', |
undef,undef,'Course',1); |
undef,undef,'Course',1, |
|
$env{'form.showselfenroll'}); |
return %courses; |
return %courses; |
} |
} |
|
|
Line 431 sub print_course_listing {
|
Line 440 sub print_course_listing {
|
if ($env{'form.coursenum'} ne '') { |
if ($env{'form.coursenum'} ne '') { |
%courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.', |
%courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.', |
$env{'form.coursenum'}, |
$env{'form.coursenum'}, |
undef,undef,'Course'); |
undef,undef,'Course',1); |
if (keys(%courses) == 0) { |
if (keys(%courses) == 0) { |
$output .= &mt('The courseID provided does not match a course in this domain.'); |
$output .= &mt('The courseID provided does not match a course in this domain.'); |
return $output; |
return $output; |
Line 446 sub print_course_listing {
|
Line 455 sub print_course_listing {
|
$output = &mt('<b>Note for students:</b> If you are officially enrolled in a course but the course is not listed in your LON-CAPA courses, click the "Show more details" link for the specific course and check the default access dates and/or automated enrollment settings.<br /><br />'); |
$output = &mt('<b>Note for students:</b> If you are officially enrolled in a course but the course is not listed in your LON-CAPA courses, click the "Show more details" link for the specific course and check the default access dates and/or automated enrollment settings.<br /><br />'); |
} |
} |
} |
} |
$output .= &construct_data_table($knownuser,\%courses,$details); |
my $now = time; |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
|
$output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig); |
$output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']); |
$output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']); |
return $output; |
return $output; |
} |
} |
|
|
sub construct_data_table { |
sub construct_data_table { |
my ($knownuser,$courses,$details,$usersections) = @_; |
my ($knownuser,$courses,$details,$usersections,$now,$domconfig) = @_; |
my %sortname; |
my %sortname; |
if (($details eq '') || ($env{'form.showdetails'})) { |
if (($details eq '') || ($env{'form.showdetails'})) { |
$sortname{'Code'} = 'code'; |
$sortname{'Code'} = 'code'; |
$sortname{'Title'} = 'title'; |
$sortname{'Title'} = 'title'; |
$sortname{'Owner'} = 'owner'; |
$sortname{'Owner(s)'} = 'owner'; |
} |
} |
my $output = &Apache::loncommon::start_data_table(). |
my $output = &Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(); |
&Apache::loncommon::start_data_table_header_row(); |
my @coltitles = ('Code','Sections','Crosslisted','Title','Owner'); |
my @coltitles = ('Count','Code','Sections','Crosslisted','Title','Owner(s)'); |
if (ref($usersections) eq 'HASH') { |
if (ref($usersections) eq 'HASH') { |
$coltitles[1] = 'Your Section'; |
$coltitles[1] = 'Your Section'; |
} |
} |
Line 469 sub construct_data_table {
|
Line 481 sub construct_data_table {
|
$output .= '<th>'; |
$output .= '<th>'; |
if (defined($sortname{$item})) { |
if (defined($sortname{$item})) { |
$output .= '<a href="javascript:changeSort('."'$sortname{$item}'".')">'.&mt($item).'</a>'; |
$output .= '<a href="javascript:changeSort('."'$sortname{$item}'".')">'.&mt($item).'</a>'; |
|
} elsif ($item eq 'Count') { |
|
$output .= ' '; |
} else { |
} else { |
$output .= &mt($item); |
$output .= &mt($item); |
} |
} |
Line 481 sub construct_data_table {
|
Line 495 sub construct_data_table {
|
'<th>'.&mt('Student Counts').'</th>'. |
'<th>'.&mt('Student Counts').'</th>'. |
'<th>'.&mt('Auto-enrollment of <br />registered students').'</th>'; |
'<th>'.&mt('Auto-enrollment of <br />registered students').'</th>'; |
} else { |
} else { |
$output .= '<th> </th>'; |
$output .= '<th>'.&mt('Details').'</th>'; |
} |
} |
} |
} |
|
$output .= '<th>'.&mt('Self-enroll (if permitted)').'</th>'; |
&Apache::loncommon::end_data_table_header_row(); |
&Apache::loncommon::end_data_table_header_row(); |
my %courseinfo = &build_courseinfo_hash($courses,$knownuser,$details, |
my %courseinfo = &build_courseinfo_hash($courses,$knownuser,$details, |
$usersections); |
$usersections); |
Line 492 sub construct_data_table {
|
Line 507 sub construct_data_table {
|
if ($env{'form.sortby'} eq 'code') { |
if ($env{'form.sortby'} eq 'code') { |
push(@{$Sortby{$courseinfo{$course}{'code'}}},$course); |
push(@{$Sortby{$courseinfo{$course}{'code'}}},$course); |
} elsif ($env{'form.sortby'} eq 'owner') { |
} elsif ($env{'form.sortby'} eq 'owner') { |
push(@{$Sortby{$courseinfo{$course}{'ownerlastname'}}},$course); |
push(@{$Sortby{$courseinfo{$course}{'ownerlastnames'}}},$course); |
} else { |
} else { |
push(@{$Sortby{$courseinfo{$course}{'title'}}},$course); |
my $clean_title = $courseinfo{$course}{'title'}; |
|
$clean_title =~ s/\W+//g; |
|
if ($clean_title eq '') { |
|
$clean_title = $courseinfo{$course}{'title'}; |
|
} |
|
push(@{$Sortby{$clean_title}},$course); |
} |
} |
} |
} |
my @sorted_courses; |
my @sorted_courses; |
Line 503 sub construct_data_table {
|
Line 523 sub construct_data_table {
|
} else { |
} else { |
@sorted_courses = sort { lc($a) cmp lc($b) } (keys(%Sortby)); |
@sorted_courses = sort { lc($a) cmp lc($b) } (keys(%Sortby)); |
} |
} |
|
my $count = 1; |
foreach my $item (@sorted_courses) { |
foreach my $item (@sorted_courses) { |
foreach my $course (@{$Sortby{$item}}) { |
foreach my $course (@{$Sortby{$item}}) { |
$output.=&Apache::loncommon::start_data_table_row(); |
$output.=&Apache::loncommon::start_data_table_row(); |
$output.=&courseinfo_row($courseinfo{$course},$knownuser,$details); |
$output.=&courseinfo_row($courseinfo{$course},$knownuser, |
|
$details,\$count,$now,$course); |
$output.=&Apache::loncommon::end_data_table_row(); |
$output.=&Apache::loncommon::end_data_table_row(); |
} |
} |
} |
} |
Line 520 sub build_courseinfo_hash {
|
Line 542 sub build_courseinfo_hash {
|
my $now = time; |
my $now = time; |
foreach my $course (keys(%{$courses})) { |
foreach my $course (keys(%{$courses})) { |
my $descr; |
my $descr; |
if ($courses->{$course} =~ m/^([^:]*):/i) { |
if (ref($courses->{$course}) eq 'HASH') { |
$descr = &unescape($1); |
$descr = $courses->{$course}{'description'}; |
} else { |
|
$descr = &unescape($courses->{$course}); |
|
} |
} |
my $cleandesc=&HTML::Entities::encode($descr,'<>&"'); |
my $cleandesc=&HTML::Entities::encode($descr,'<>&"'); |
$cleandesc=~s/'/\\'/g; |
$cleandesc=~s/'/\\'/g; |
$cleandesc =~ s/^\s+//; |
$cleandesc =~ s/^\s+//; |
my ($cdom,$cnum)=split(/\_/,$course); |
my ($cdom,$cnum)=split(/\_/,$course); |
|
my ($descr,$instcode,$singleowner,$ttype,$selfenroll_types, |
my ($desc,$instcode,$owner,$ttype) = split(/:/,$courses->{$course}); |
$selfenroll_start,$selfenroll_end,@owners,%ownernames); |
$owner = &unescape($owner); |
if (ref($courses->{$course}) eq 'HASH') { |
my ($ownername,$ownerdom); |
$descr = $courses->{$course}{'description'}; |
if ($owner =~ /:/) { |
$instcode = $courses->{$course}{'inst_code'}; |
($ownername,$ownerdom) = split(/:/,$owner); |
$singleowner = $courses->{$course}{'owner'}; |
} else { |
$ttype = $courses->{$course}{'type'}; |
$ownername = $owner; |
$selfenroll_types = $courses->{$course}{'selfenroll_types'}; |
if ($owner ne '') { |
$selfenroll_start = $courses->{$course}{'selfenroll_start_date'}; |
$ownerdom = $cdom; |
$selfenroll_end = $courses->{$course}{'selfenroll_end_date'}; |
|
push(@owners,$singleowner); |
|
if (ref($courses->{$course}{'co-owners'}) eq 'ARRAY') { |
|
foreach my $item (@{$courses->{$course}{'co-owners'}}) { |
|
push(@owners,$item); |
|
} |
} |
} |
} |
} |
my %ownernames; |
foreach my $owner (@owners) { |
if ($ownername ne '' && $ownerdom ne '') { |
my ($ownername,$ownerdom) = @_; |
%ownernames = &Apache::loncommon::getnames($ownername,$ownerdom); |
if ($owner =~ /:/) { |
|
($ownername,$ownerdom) = split(/:/,$owner); |
|
} else { |
|
$ownername = $owner; |
|
if ($owner ne '') { |
|
$ownerdom = $cdom; |
|
} |
|
} |
|
if ($ownername ne '' && $ownerdom ne '') { |
|
my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom); |
|
$ownernames{$ownername.':'.$ownerdom} = \%namehash; |
|
} |
} |
} |
$courseinfo{$course}{'cdom'} = $cdom; |
$courseinfo{$course}{'cdom'} = $cdom; |
$courseinfo{$course}{'cnum'} = $cnum; |
$courseinfo{$course}{'cnum'} = $cnum; |
$courseinfo{$course}{'code'} = $instcode; |
$courseinfo{$course}{'code'} = $instcode; |
$courseinfo{$course}{'ownerlastname'} = $ownernames{'lastname'}; |
my @lastnames; |
|
foreach my $owner (keys(%ownernames)) { |
|
if (ref($ownernames{$owner}) eq 'HASH') { |
|
push(@lastnames,$ownernames{$owner}{'lastname'}); |
|
} |
|
} |
|
$courseinfo{$course}{'ownerlastnames'} = join(', ',sort(@lastnames)); |
$courseinfo{$course}{'title'} = $cleandesc; |
$courseinfo{$course}{'title'} = $cleandesc; |
$courseinfo{$course}{'owner'} = $owner; |
$courseinfo{$course}{'owner'} = $singleowner; |
|
$courseinfo{$course}{'selfenroll_types'} = $selfenroll_types; |
|
$courseinfo{$course}{'selfenroll_start'} = $selfenroll_start; |
|
$courseinfo{$course}{'selfenroll_end'} = $selfenroll_end; |
|
|
my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum); |
my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum); |
my @classids; |
my @classids; |
Line 571 sub build_courseinfo_hash {
|
Line 616 sub build_courseinfo_hash {
|
} |
} |
$courseinfo{$course}{'showsyllabus'} = $showsyllabus; |
$courseinfo{$course}{'showsyllabus'} = $showsyllabus; |
if (((defined($env{'form.coursenum'}) && ($cnum eq $env{'form.coursenum'}))) || |
if (((defined($env{'form.coursenum'}) && ($cnum eq $env{'form.coursenum'}))) || |
($knownuser && ($details == 1))) { |
($knownuser && ($details == 1))) { |
$courseinfo{$course}{'counts'} = &count_students($cdom,$cnum,$numsec); |
$courseinfo{$course}{'counts'} = &count_students($cdom,$cnum,$numsec); |
$courseinfo{$course}{'autoenrollment'} = |
$courseinfo{$course}{'autoenrollment'} = |
&autoenroll_info(\%coursehash,$now,$seclist,$xlist_items, |
&autoenroll_info(\%coursehash,$now,$seclist,$xlist_items, |
$instcode,$owner,$cdom,$cnum); |
$instcode,\@owners,$cdom,$cnum); |
|
|
my $startaccess = ''; |
my $startaccess = ''; |
my $endaccess = ''; |
my $endaccess = ''; |
Line 634 sub count_students {
|
Line 679 sub count_students {
|
} |
} |
|
|
sub courseinfo_row { |
sub courseinfo_row { |
my ($info,$knownuser,$details) = @_; |
my ($info,$knownuser,$details,$countref,$now,$course) = @_; |
my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items, |
my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items, |
$accessdates,$showsyllabus,$counts,$autoenrollment,$output); |
$accessdates,$showsyllabus,$counts,$autoenrollment,$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'}; |
$ownerlast = $info->{'ownerlastname'}; |
$ownerlast = $info->{'ownerlastnames'}; |
$code = $info->{'code'}; |
$code = $info->{'code'}; |
$owner = $info->{'owner'}; |
$owner = $info->{'owner'}; |
$seclist = $info->{'seclist'}; |
$seclist = $info->{'seclist'}; |
Line 655 sub courseinfo_row {
|
Line 700 sub courseinfo_row {
|
$code).'</td>'; |
$code).'</td>'; |
return $output; |
return $output; |
} |
} |
$output .= '<td>'.$code.'</td>'. |
$output .= '<td>'.$$countref.'</td>'. |
|
'<td>'.$code.'</td>'. |
'<td>'.$seclist.'</td>'. |
'<td>'.$seclist.'</td>'. |
'<td>'.$xlist_items.'</td>'. |
'<td>'.$xlist_items.'</td>'. |
'<td>'.$title.' <font size="-2">'; |
'<td>'.$title.' <font size="-2">'; |
Line 676 sub courseinfo_row {
|
Line 722 sub courseinfo_row {
|
$output .= "<td><a href=\"javascript:setCourseId('$cnum')\">".&mt('Show more details').'</a></td>'; |
$output .= "<td><a href=\"javascript:setCourseId('$cnum')\">".&mt('Show more details').'</a></td>'; |
} |
} |
} |
} |
|
my $selfenroll; |
|
if ($info->{'selfenroll_types'}) { |
|
my $showstart = &Apache::lonlocal::locallocaltime($info->{'selfenroll_start'}); |
|
my $showend = &Apache::lonlocal::locallocaltime($info->{'selfenroll_end'}); |
|
if (($info->{'selfenroll_end'} > 0) && ($info->{'selfenroll_end'} > $now)) { |
|
if (($info->{'selfenroll_start'} > 0) && ($info->{'selfenroll_start'} > $now)) { |
|
$output .= '<td>'.&mt('Starts: [_1]','<span class="LC_cusr_emph">'.$showstart.'</span>').'<br />'.&mt('Ends: [_1]','<span class="LC_cusr_emph">'.$showend.'</span>').'</td>'; |
|
} else { |
|
$output .= '<td><a href="/adm/selfenroll?cid='.$course.'">'.&mt('Enroll in course').'</a></td>'; |
|
} |
|
$selfenroll = 1; |
|
} |
|
} |
|
if (!$selfenroll) { |
|
$output .= '<td> </td>'; |
|
} |
|
$$countref ++; |
return $output; |
return $output; |
} |
} |
|
|
Line 703 sub identify_sections {
|
Line 766 sub identify_sections {
|
} |
} |
|
|
sub get_valid_classes { |
sub get_valid_classes { |
my ($seclist,$xlist_items,$crscode,$owner,$cdom,$cnum) = @_; |
my ($seclist,$xlist_items,$crscode,$owners,$cdom,$cnum) = @_; |
my $response; |
my $response; |
my %validations; |
my %validations; |
@{$validations{'sections'}} = (); |
@{$validations{'sections'}} = (); |
Line 712 sub get_valid_classes {
|
Line 775 sub get_valid_classes {
|
if ($seclist) { |
if ($seclist) { |
foreach my $sec (split(/, /,$seclist)) { |
foreach my $sec (split(/, /,$seclist)) { |
my $class = $crscode.$sec; |
my $class = $crscode.$sec; |
if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owner, |
if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owners, |
$class) eq 'ok') { |
$class) eq 'ok') { |
if (!grep(/^\Q$sec$\E/,@{$validations{'sections'}})) { |
if (!grep(/^\Q$sec$\E/,@{$validations{'sections'}})) { |
push(@{$validations{'sections'}},$sec); |
push(@{$validations{'sections'}},$sec); |
Line 723 sub get_valid_classes {
|
Line 786 sub get_valid_classes {
|
} |
} |
if ($xlist_items) { |
if ($xlist_items) { |
foreach my $item (split(/, /,$xlist_items)) { |
foreach my $item (split(/, /,$xlist_items)) { |
if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owner, |
if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owners, |
$item) eq 'ok') { |
$item) eq 'ok') { |
if (!grep(/^\Q$item$\E/,@{$validations{'xlists'}})) { |
if (!grep(/^\Q$item$\E/,@{$validations{'xlists'}})) { |
push(@{$validations{'xlists'}},$item); |
push(@{$validations{'xlists'}},$item); |
Line 885 END
|
Line 948 END
|
} |
} |
|
|
sub autoenroll_info { |
sub autoenroll_info { |
my ($coursehash,$now,$seclist,$xlist_items,$code,$owner,$cdom,$cnum) = @_; |
my ($coursehash,$now,$seclist,$xlist_items,$code,$owners,$cdom,$cnum) = @_; |
my $autoenrolldates = &mt('Not enabled'); |
my $autoenrolldates = &mt('Not enabled'); |
if (defined($coursehash->{'internal.autoadds'}) && $coursehash->{'internal.autoadds'} == 1) { |
if (defined($coursehash->{'internal.autoadds'}) && $coursehash->{'internal.autoadds'} == 1) { |
my ($autostart,$autoend); |
my ($autostart,$autoend); |
Line 901 sub autoenroll_info {
|
Line 964 sub autoenroll_info {
|
} else { |
} else { |
my $valid_classes = |
my $valid_classes = |
&get_valid_classes($seclist,$xlist_items,$code, |
&get_valid_classes($seclist,$xlist_items,$code, |
$owner,$cdom,$cnum); |
$owners,$cdom,$cnum); |
if ($valid_classes ne '') { |
if ($valid_classes ne '') { |
$autoenrolldates = &mt('Not enabled<br />Starts: '). |
$autoenrolldates = &mt('Not enabled<br />Starts: '). |
$autostart.'<br />'.$valid_classes; } |
$autostart.'<br />'.$valid_classes; } |
Line 911 sub autoenroll_info {
|
Line 974 sub autoenroll_info {
|
$autoenrolldates = &mt('Not enabled<br />Ended: ').$autoend; |
$autoenrolldates = &mt('Not enabled<br />Ended: ').$autoend; |
} else { |
} else { |
my $valid_classes = &get_valid_classes($seclist,$xlist_items, |
my $valid_classes = &get_valid_classes($seclist,$xlist_items, |
$code,$owner,$cdom,$cnum); |
$code,$owners,$cdom,$cnum); |
if ($valid_classes ne '') { |
if ($valid_classes ne '') { |
$autoenrolldates = &mt('Currently enabled<br />'). |
$autoenrolldates = &mt('Currently enabled<br />'). |
$valid_classes; |
$valid_classes; |