--- loncom/interface/coursecatalog.pm 2007/10/03 19:57:29 1.22 +++ loncom/interface/coursecatalog.pm 2008/01/12 22:32:04 1.25 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.22 2007/10/03 19:57:29 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.25 2008/01/12 22:32:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -461,7 +461,7 @@ sub construct_data_table { } my $output = &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(); - my @coltitles = ('Code','Sections','Crosslisted','Title','Owner(s)'); + my @coltitles = ('Count','Code','Sections','Crosslisted','Title','Owner(s)'); if (ref($usersections) eq 'HASH') { $coltitles[1] = 'Your Section'; } @@ -469,6 +469,8 @@ sub construct_data_table { $output .= ''; if (defined($sortname{$item})) { $output .= ''.&mt($item).''; + } elsif ($item eq 'Count') { + $output .= '  '; } else { $output .= &mt($item); } @@ -494,7 +496,12 @@ sub construct_data_table { } elsif ($env{'form.sortby'} eq 'owner') { push(@{$Sortby{$courseinfo{$course}{'ownerlastnames'}}},$course); } 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; @@ -503,10 +510,11 @@ sub construct_data_table { } else { @sorted_courses = sort { lc($a) cmp lc($b) } (keys(%Sortby)); } + my $count = 1; foreach my $item (@sorted_courses) { foreach my $course (@{$Sortby{$item}}) { $output.=&Apache::loncommon::start_data_table_row(); - $output.=&courseinfo_row($courseinfo{$course},$knownuser,$details); + $output.=&courseinfo_row($courseinfo{$course},$knownuser,$details,\$count); $output.=&Apache::loncommon::end_data_table_row(); } } @@ -522,10 +530,6 @@ sub build_courseinfo_hash { my $descr; if (ref($courses->{$course}) eq 'HASH') { $descr = $courses->{$course}{'description'}; - } elsif ($courses->{$course} =~ m/^([^:]*):/i) { - $descr = &unescape($1); - } else { - $descr = &unescape($courses->{$course}); } my $cleandesc=&HTML::Entities::encode($descr,'<>&"'); $cleandesc=~s/'/\\'/g; @@ -534,7 +538,7 @@ sub build_courseinfo_hash { my ($descr,$instcode,$singleowner,$ttype,@owners,%ownernames); if (ref($courses->{$course}) eq 'HASH') { $descr = $courses->{$course}{'description'}; - $instcode = $courses->{$course}{'instcode'}; + $instcode = $courses->{$course}{'inst_code'}; $singleowner = $courses->{$course}{'owner'}; $ttype = $courses->{$course}{'type'}; push(@owners,$singleowner); @@ -543,10 +547,6 @@ sub build_courseinfo_hash { push(@owners,$item); } } - } else { - ($descr,$instcode,$singleowner,$ttype) = - split(/:/,$courses->{$course}); - push(@owners,$singleowner); } foreach my $owner (@owners) { my ($ownername,$ownerdom) = @_; @@ -658,7 +658,7 @@ sub count_students { } sub courseinfo_row { - my ($info,$knownuser,$details) = @_; + my ($info,$knownuser,$details,$countref) = @_; my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items, $accessdates,$showsyllabus,$counts,$autoenrollment,$output); if (ref($info) eq 'HASH') { @@ -679,7 +679,8 @@ sub courseinfo_row { $code).''; return $output; } - $output .= ''.$code.''. + $output .= ''.$$countref.''. + ''.$code.''. ''.$seclist.''. ''.$xlist_items.''. ''.$title.' '; @@ -700,6 +701,7 @@ sub courseinfo_row { $output .= "".&mt('Show more details').''; } } + $$countref ++; return $output; }