--- loncom/interface/coursecatalog.pm 2008/02/15 02:30:14 1.26 +++ loncom/interface/coursecatalog.pm 2008/03/08 04:00:53 1.27 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.26 2008/02/15 02:30:14 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.27 2008/03/08 04:00:53 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -261,12 +261,18 @@ function setCourseId(caller) { ''."\n".''."\n". '' ); + my $show_selfenroll_status; + if ($env{'form.showselfenroll'}) { + $show_selfenroll_status = 'checked="checked" '; + } if (&user_is_dc($codedom)) { my $showdetails_status; if ($env{'form.showdetails'}) { $showdetails_status = 'checked="checked" '; - } - $r->print(''.&mt('Show full details for each course (DC only)').''); + } + $r->print('
'); + } else { + $r->print('
'); } $r->print(''); if ($numtitles > 4) { @@ -414,7 +420,8 @@ sub search_courselist { } } my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.', - undef,undef,'Course',1); + undef,undef,'Course',1, + $env{'form.showselfenroll'}); return %courses; } @@ -448,13 +455,16 @@ sub print_course_listing { $output = &mt('Note for students: 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.

'); } } - $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']); return $output; } sub construct_data_table { - my ($knownuser,$courses,$details,$usersections) = @_; + my ($knownuser,$courses,$details,$usersections,$now,$domconfig) = @_; my %sortname; if (($details eq '') || ($env{'form.showdetails'})) { $sortname{'Code'} = 'code'; @@ -485,9 +495,10 @@ sub construct_data_table { ''.&mt('Student Counts').''. ''.&mt('Auto-enrollment of
registered students').''; } else { - $output .= ' '; + $output .= ''.&mt('Details').''; } } + $output .= ''.&mt('Self-enroll (if permitted)').''; &Apache::loncommon::end_data_table_header_row(); my %courseinfo = &build_courseinfo_hash($courses,$knownuser,$details, $usersections); @@ -516,7 +527,8 @@ sub construct_data_table { foreach my $item (@sorted_courses) { foreach my $course (@{$Sortby{$item}}) { $output.=&Apache::loncommon::start_data_table_row(); - $output.=&courseinfo_row($courseinfo{$course},$knownuser,$details,\$count); + $output.=&courseinfo_row($courseinfo{$course},$knownuser, + $details,\$count,$now,$course); $output.=&Apache::loncommon::end_data_table_row(); } } @@ -537,12 +549,16 @@ sub build_courseinfo_hash { $cleandesc=~s/'/\\'/g; $cleandesc =~ s/^\s+//; my ($cdom,$cnum)=split(/\_/,$course); - my ($descr,$instcode,$singleowner,$ttype,@owners,%ownernames); + my ($descr,$instcode,$singleowner,$ttype,$selfenroll_types, + $selfenroll_start,$selfenroll_end,@owners,%ownernames); if (ref($courses->{$course}) eq 'HASH') { $descr = $courses->{$course}{'description'}; $instcode = $courses->{$course}{'inst_code'}; $singleowner = $courses->{$course}{'owner'}; $ttype = $courses->{$course}{'type'}; + $selfenroll_types = $courses->{$course}{'selfenroll_types'}; + $selfenroll_start = $courses->{$course}{'selfenroll_start_date'}; + $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'}}) { @@ -577,6 +593,9 @@ sub build_courseinfo_hash { $courseinfo{$course}{'ownerlastnames'} = join(', ',sort(@lastnames)); $courseinfo{$course}{'title'} = $cleandesc; $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 @classids; @@ -660,7 +679,7 @@ sub count_students { } sub courseinfo_row { - my ($info,$knownuser,$details,$countref) = @_; + my ($info,$knownuser,$details,$countref,$now,$course) = @_; my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items, $accessdates,$showsyllabus,$counts,$autoenrollment,$output); if (ref($info) eq 'HASH') { @@ -703,6 +722,22 @@ sub courseinfo_row { $output .= "".&mt('Show more details').''; } } + 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 .= ''.&mt('Starts: [_1]',''.$showstart.'').'
'.&mt('Ends: [_1]',''.$showend.'').''; + } else { + $output .= ''.&mt('Enroll in course').''; + } + $selfenroll = 1; + } + } + if (!$selfenroll) { + $output .= ' '; + } $$countref ++; return $output; }