--- loncom/interface/coursecatalog.pm 2013/01/23 15:23:19 1.72
+++ loncom/interface/coursecatalog.pm 2013/11/20 18:40:09 1.75
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.72 2013/01/23 15:23:19 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.75 2013/11/20 18:40:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -66,13 +66,20 @@ sub handler {
}
my $formname = 'coursecatalog';
if ($env{'form.showdom'} ne '') {
+ $env{'form.showdom'} = &LONCAPA::clean_domain($env{'form.showdom'});
if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') {
$codedom = $env{'form.showdom'};
+ } else {
+ $env{'form.showdom'} = '';
}
}
my $domdesc = &Apache::lonnet::domain($codedom,'description');
&Apache::lonhtmlcommon::clear_breadcrumbs();
+ if ($env{'form.catalog_maxdepth'} ne '') {
+ $env{'form.catalog_maxdepth'} =~ s{\D}{}g;
+ }
+
my %domconfig =
&Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom);
my (@cats,@trails,%allitems,%idx,@jsarray,%subcathash,$cathash);
@@ -405,8 +412,6 @@ sub category_breadcrumbs {
if (($env{'form.currcat_0'} ne '') &&
($env{'form.currcat_0'} ne 'instcode::0')) {
$catlinks .= $crumbsymbol;
- } else {
- $catlinks .= '';
}
}
} else {
@@ -633,9 +638,9 @@ sub additional_filters {
' />'.$title.'';
if ($type eq 'Previous') {
my %milestonetext = &Apache::lonlocal::texthash (
- accessend => 'prior to default end access date',
- enrollend => 'prior to end date for auto-enrollment',
- date => 'prior to specific date:',
+ accessend => 'immediately prior to default end access date',
+ enrollend => 'immediately prior to end date for auto-enrollment',
+ date => 'immediately prior to specific date:',
);
my @statuses = &Apache::loncommon::get_env_multiple('form.showcounts');
$output .= '';
@@ -736,11 +741,10 @@ sub get_statustitles {
sub get_wasactive_text {
my $wasacctext = ' -- ';
if ($env{'form.currcat_0'} eq 'communities::0') {
- $wasacctext .= &mt('where members had access ...');
+ $wasacctext .= &mt('where member access status was current ...');
} else {
- $wasacctext .= &mt('where students had access ...');
+ $wasacctext .= &mt('where student access status was current ...');
}
- $wasacctext .= '
';
return $wasacctext;
}
@@ -946,10 +950,20 @@ sub construct_data_table {
}
$output .= '
'.&mt('Self-enroll (if permitted)').' | ';
&Apache::loncommon::end_data_table_header_row();
- my %numbers;
+ my (%numbers,%creditsum);
+ my ($showcredits,$defofficial,$defunofficial);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
+ unless ($env{'form.currcat_0'} eq 'communities::0') {
+ if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) {
+ $showcredits = 1;
+ $defofficial = $domdefaults{'officialcredits'};
+ $defunofficial = $domdefaults{'unofficialcredits'};
+ }
+ }
my %courseinfo = &build_courseinfo_hash($courses,$knownuser,$domain,$details,
$usersections,\@fields,\%fieldtitles,
- $wasactiveon,\%numbers);
+ $wasactiveon,\%numbers,\%creditsum,
+ $showcredits,$defofficial,$defunofficial);
my %Sortby;
foreach my $course (sort(keys(%{$courses}))) {
if ($env{'form.sortby'} eq 'code') {
@@ -992,33 +1006,51 @@ sub construct_data_table {
'Previous' => 'Total previous students',
'courses' => 'Total unique codes and courses without codes',
'sections' => 'Total sections',
- 'xlists' => 'Total cross-listings',
+ 'xlists' => 'Total cross-listings',
);
+ if ($showcredits) {
+ $lt{'cr_Active'} = &mt('Total current student credit hours');
+ $lt{'cr_Future'} = &mt('Total future student credit hours');
+ $lt{'cr_Previous'} = &mt('Total previous student credit hours');
+ }
if ($env{'form.currcat_0'} eq 'communities::0') {
$lt{'courses'} = &mt('Total communities');
$lt{'Active'} = &mt('Total current members');
$lt{'Future'} = &mt('Total future members');
$lt{'Previous'} = &mt('Total previous members');
- }
+ }
+ my $colspan = 8;
+ if ($showcredits) {
+ $colspan = 4;
+ }
$output .= '';
+ $output .= '';
+ if ($showcredits) {
+ $output .= '';
+ foreach my $status (@fields) {
+ $output .= ''.
+ ''.$lt{'cr_'.$status}.' | | '.
+ ''.$creditsum{$status}.' | ';
+ }
+ $output .= ' | ';
+ }
}
}
$output .= &Apache::loncommon::end_data_table();
@@ -1027,14 +1059,14 @@ sub construct_data_table {
sub build_courseinfo_hash {
my ($courses,$knownuser,$domain,$details,$usersections,$fields,$fieldtitles,
- $wasactiveon,$numbers) = @_;
+ $wasactiveon,$numbers,$creditsum,$showcredits,$defofficial,$defunofficial) = @_;
my %courseinfo;
my $now = time;
my $gettotals;
if ((keys(%{$courses}) > 0) && (&user_is_dc($domain)) && ($details)) {
$gettotals = 1;
}
- my (%uniquecodes,$nocodes),;
+ my (%uniquecodes,$nocodes,$defcreds);
foreach my $course (keys(%{$courses})) {
my $descr;
if (ref($courses->{$course}) eq 'HASH') {
@@ -1116,6 +1148,16 @@ sub build_courseinfo_hash {
$showsyllabus = $coursehash{'showsyllabus'};
}
$courseinfo{$course}{'showsyllabus'} = $showsyllabus;
+ if ($showcredits) {
+ if ($coursehash{'internal.defaultcredits'}) {
+ $courseinfo{$course}{'defaultcredits'} = $coursehash{'internal.defaultcredits'};
+ } elsif ($instcode ne '') {
+ $courseinfo{$course}{'defaultcredits'} = $defofficial;
+ } else {
+ $courseinfo{$course}{'defaultcredits'} = $defunofficial;
+ }
+ $defcreds = $courseinfo{$course}{'defaultcredits'};
+ }
if (((defined($env{'form.coursenum'}) && ($cnum eq $env{'form.coursenum'}))) ||
($knownuser && ($details == 1))) {
my $milestone;
@@ -1136,7 +1178,7 @@ sub build_courseinfo_hash {
}
$courseinfo{$course}{'counts'} =
&count_students($cdom,$cnum,$numsec,$fields,$fieldtitles,$gettotals,
- $numbers,$milestone);
+ $numbers,$creditsum,$showcredits,$defcreds,$milestone);
if ($instcode ne '') {
$courseinfo{$course}{'autoenrollment'} =
&autoenroll_info(\%coursehash,$now,$seclist,$xlist_items,
@@ -1201,7 +1243,8 @@ sub build_courseinfo_hash {
}
sub count_students {
- my ($cdom,$cnum,$numsec,$fieldsref,$titlesref,$getcounts,$numbers,$wasactiveon) = @_;
+ my ($cdom,$cnum,$numsec,$fieldsref,$titlesref,$getcounts,$numbers,$creditsum,
+ $showcredits,$defcreds,$wasactiveon) = @_;
my $countslist = ''.
&mt('[quant,_1,section,sections,No sections]',$numsec).'';
my (@fields,%titles,$showexpired);
@@ -1216,23 +1259,42 @@ sub count_students {
return;
}
my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
- my %student_count = (
+ my (%student_count,%credit_count);
+ %student_count = (
Active => 0,
Future => 0,
Previous => 0,
- );
+ );
+ if ($showcredits) {
+ %credit_count = (
+ Active => 0,
+ Future => 0,
+ Previous => 0,
+ );
+ }
my %idx;
$idx{'status'} = &Apache::loncoursedata::CL_STATUS();
$idx{'end'} = &Apache::loncoursedata::CL_END();
+ $idx{'credits'} = &Apache::loncoursedata::CL_CREDITS();
while (my ($student,$data) = each(%$classlist)) {
my $status = $data->[$idx{'status'}];
+ my $credits = $data->[$idx{'credits'}];
+ if ($credits eq '') {
+ $credits = $defcreds;
+ }
if ($status eq 'Expired') {
if (($showexpired) &&
($data->[$idx{'end'}] >= $wasactiveon)) {
$student_count{'Previous'} ++;
+ if ($showcredits) {
+ $credit_count{'Previous'} += $credits;
+ }
}
} else {
$student_count{$status} ++;
+ if ($showcredits) {
+ $credit_count{$status} += $credits;
+ }
}
}
if (@fields) {
@@ -1241,6 +1303,9 @@ sub count_students {
$countslist .= ''.$titles{$status}.': '.
$student_count{$status}.'
';
$numbers->{$status} += $student_count{$status};
+ if ($showcredits) {
+ $creditsum->{$status} += $credit_count{$status};
+ }
}
}
return $countslist;