[LON-CAPA-cvs] cvs: loncom /interface coursecatalog.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sun, 06 Jul 2008 17:59:25 -0000
This is a MIME encoded message
--raeburn1215367165
Content-Type: text/plain
raeburn Sun Jul 6 13:59:25 2008 EDT
Modified files:
/loncom/interface coursecatalog.pm
Log:
- Course listings for searches based on categories include categories for each course instead of institutional code.
--raeburn1215367165
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080706135925.txt"
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.34 loncom/interface/coursecatalog.pm:1.35
--- loncom/interface/coursecatalog.pm:1.34 Fri Jul 4 11:40:04 2008
+++ loncom/interface/coursecatalog.pm Sun Jul 6 13:59:25 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.34 2008/07/04 15:40:04 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.35 2008/07/06 17:59:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -71,10 +71,21 @@
}
my $domdesc = &Apache::lonnet::domain($codedom,'description');
&Apache::lonhtmlcommon::clear_breadcrumbs();
+
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom);
+ my (@cats,@trails,%allitems,%idx,@jsarray,$cathash);
+ if (ref($domconfig{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconfig{'coursecategories'}{'cats'};
+ } else {
+ $cathash = {};
+ }
+ &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,
+ \%idx,\@jsarray);
if ($env{'form.coursenum'} ne '' && &user_is_known()) {
- &course_details($r,$codedom,$formname,$domdesc);
+ &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems);
} else {
- my $catlinks = &category_breadcrumbs($codedom);
+ my $catlinks = &category_breadcrumbs($codedom,@cats);
my $catjs = <<"ENDSCRIPT";
function setCatDepth(depth) {
@@ -125,7 +136,7 @@
&mt('Display courses').'" /></form><br /><br />');
}
if ($env{'form.state'} eq 'listing') {
- $r->print(&print_course_listing($codedom));
+ $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems));
}
}
}
@@ -134,7 +145,7 @@
}
sub course_details {
- my ($r,$codedom,$formname,$domdesc) = @_;
+ my ($r,$codedom,$formname,$domdesc,$trails,$allitems) = @_;
my $output;
my %add_entries = (topmargin => "0",
marginheight => "0",);
@@ -156,7 +167,8 @@
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Details'));
$r->print('<br />'.&mt('Detailed course information:').'<br /><br />'.
'<form name="'.$formname.'" method="post">'.
- &print_course_listing($codedom).'<br /><br />');
+ &print_course_listing($codedom,undef,$trails,$allitems).
+ '<br /><br />');
$r->print('<a href = "javascript:document.coursecatalog.submit()">'.
&mt('Back to course listing').'</a>'.
'<input type="hidden" name="sortby" value="'.
@@ -351,17 +363,7 @@
}
sub category_breadcrumbs {
- my ($dom) = @_;
- my %domconfig =
- &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
- my (@cats,@trails,%allitems,%idx,@jsarray,$cathash);
- if (ref($domconfig{'coursecategories'}) eq 'HASH') {
- $cathash = $domconfig{'coursecategories'}{'cats'};
- } else {
- $cathash = {};
- }
- &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx,
- \@jsarray);
+ my ($dom,@cats) = @_;
my ($currdepth,$deeper) = &get_depth_values();
my $currcat_str = '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" /><input type="hidden" name="showdom" value="'.$dom.'" />';
my $catlinks = '<td valign="top"><b>'.&mt('Catalog:').'</b></td><td><table><tr>';
@@ -649,7 +651,7 @@
}
sub print_course_listing {
- my ($domain,$numtitles) = @_;
+ my ($domain,$numtitles,$trails,$allitems) = @_;
my $output;
my %courses;
my $knownuser = &user_is_known();
@@ -686,22 +688,30 @@
my $now = time;
my %domconfig =
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
- $output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig);
+ $output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig,$trails,$allitems);
$output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']);
return $output;
}
sub construct_data_table {
- my ($knownuser,$courses,$details,$usersections,$now,$domconfig) = @_;
+ my ($knownuser,$courses,$details,$usersections,$now,$domconfig,$trails,
+ $allitems) = @_;
my %sortname;
if (($details eq '') || ($env{'form.showdetails'})) {
$sortname{'Code'} = 'code';
+ $sortname{'Categories'} = 'cats';
$sortname{'Title'} = 'title';
$sortname{'Owner(s)'} = 'owner';
}
my $output = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row();
- my @coltitles = ('Count','Code','Sections','Crosslisted','Title','Owner(s)');
+ my @coltitles = ('Count');
+ if ($env{'form.currcat_0'} eq 'instcode::0') {
+ push(@coltitles,'Code');
+ } else {
+ push(@coltitles,'Categories');
+ }
+ push(@coltitles,('Sections','Crosslisted','Title','Owner(s)'));
if (ref($usersections) eq 'HASH') {
$coltitles[1] = 'Your Section';
}
@@ -734,6 +744,8 @@
foreach my $course (sort(keys(%{$courses}))) {
if ($env{'form.sortby'} eq 'code') {
push(@{$Sortby{$courseinfo{$course}{'code'}}},$course);
+ } elsif ($env{'form.sortby'} eq 'cats') {
+ push(@{$Sortby{$courseinfo{$course}{'categories'}}},$course);
} elsif ($env{'form.sortby'} eq 'owner') {
push(@{$Sortby{$courseinfo{$course}{'ownerlastnames'}}},$course);
} else {
@@ -746,7 +758,8 @@
}
}
my @sorted_courses;
- if (($env{'form.sortby'} eq 'code') || ($env{'form.sortby'} eq 'owner')) {
+ if (($env{'form.sortby'} eq 'code') || ($env{'form.sortby'} eq 'owner') ||
+ ($env{'form.sortby'} eq 'cats')) {
@sorted_courses = sort(keys(%Sortby));
} else {
@sorted_courses = sort { lc($a) cmp lc($b) } (keys(%Sortby));
@@ -755,8 +768,8 @@
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,$now,$course);
+ $output.=&courseinfo_row($courseinfo{$course},$knownuser,$details,
+ \$count,$now,$course,$trails,$allitems);
$output.=&Apache::loncommon::end_data_table_row();
}
}
@@ -778,7 +791,7 @@
$cleandesc =~ s/^\s+//;
my ($cdom,$cnum)=split(/\_/,$course);
my ($descr,$instcode,$singleowner,$ttype,$selfenroll_types,
- $selfenroll_start,$selfenroll_end,@owners,%ownernames);
+ $selfenroll_start,$selfenroll_end,@owners,%ownernames,$categories);
if (ref($courses->{$course}) eq 'HASH') {
$descr = $courses->{$course}{'description'};
$instcode = $courses->{$course}{'inst_code'};
@@ -787,6 +800,7 @@
$selfenroll_types = $courses->{$course}{'selfenroll_types'};
$selfenroll_start = $courses->{$course}{'selfenroll_start_date'};
$selfenroll_end = $courses->{$course}{'selfenroll_end_date'};
+ $categories = $courses->{$course}{'categories'};
push(@owners,$singleowner);
if (ref($courses->{$course}{'co-owners'}) eq 'ARRAY') {
foreach my $item (@{$courses->{$course}{'co-owners'}}) {
@@ -824,6 +838,7 @@
$courseinfo{$course}{'selfenroll_types'} = $selfenroll_types;
$courseinfo{$course}{'selfenroll_start'} = $selfenroll_start;
$courseinfo{$course}{'selfenroll_end'} = $selfenroll_end;
+ $courseinfo{$course}{'categories'} = $categories;
my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum);
my @classids;
@@ -934,9 +949,9 @@
}
sub courseinfo_row {
- my ($info,$knownuser,$details,$countref,$now,$course) = @_;
+ my ($info,$knownuser,$details,$countref,$now,$course,$trails,$allitems) = @_;
my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items,
- $accessdates,$showsyllabus,$counts,$autoenrollment,$output);
+ $accessdates,$showsyllabus,$counts,$autoenrollment,$output,$categories);
if (ref($info) eq 'HASH') {
$cdom = $info->{'cdom'};
$cnum = $info->{'cnum'};
@@ -950,14 +965,30 @@
$counts = $info->{'counts'};
$autoenrollment = $info->{'autoenrollment'};
$showsyllabus = $info->{'showsyllabus'};
+ $categories = $info->{'categories'};
} else {
$output = '<td colspan="8">'.&mt('No information available for [_1].',
$code).'</td>';
return $output;
}
- $output .= '<td>'.$$countref.'</td>'.
- '<td>'.$code.'</td>'.
- '<td>'.$seclist.'</td>'.
+ $output .= '<td>'.$$countref.'</td>';
+ if ($env{'form.currcat_0'} eq 'instcode::0') {
+ $output .= '<td>'.$code.'</td>';
+ } else {
+ my ($categorylist,@cats);
+ if ($categories ne '') {
+ @cats = split('&',$categories);
+ }
+ if ((ref($trails) eq 'ARRAY') && (ref($allitems) eq 'HASH')) {
+ my @categories = map { $trails->[$allitems->{$_}]; } @cats;
+ $categorylist = join('<br />',@categories);
+ }
+ if ($categorylist eq '') {
+ $categorylist = ' ';
+ }
+ $output .= '<td>'.$categorylist.'</td>';
+ }
+ $output .= '<td>'.$seclist.'</td>'.
'<td>'.$xlist_items.'</td>'.
'<td>'.$title.' <font size="-2">';
if ($showsyllabus) {
--raeburn1215367165--