--- loncom/interface/coursecatalog.pm 2013/01/23 15:23:19 1.72
+++ loncom/interface/coursecatalog.pm 2013/03/01 18:09:16 1.73
@@ -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.73 2013/03/01 18:09:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -405,8 +405,6 @@ sub category_breadcrumbs {
if (($env{'form.currcat_0'} ne '') &&
($env{'form.currcat_0'} ne 'instcode::0')) {
$catlinks .= $crumbsymbol;
- } else {
- $catlinks .= '';
}
}
} else {
@@ -740,7 +738,6 @@ sub get_wasactive_text {
} else {
$wasacctext .= &mt('where students had access ...');
}
- $wasacctext .= '
';
return $wasacctext;
}
@@ -946,10 +943,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 +999,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 +1052,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 +1141,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 +1171,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 +1236,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 +1252,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 +1296,9 @@ sub count_students {
$countslist .= ''.$titles{$status}.': '.
$student_count{$status}.'
';
$numbers->{$status} += $student_count{$status};
+ if ($showcredits) {
+ $creditsum->{$status} += $credit_count{$status};
+ }
}
}
return $countslist;