--- loncom/interface/coursecatalog.pm 2013/01/23 15:23:19 1.72 +++ loncom/interface/coursecatalog.pm 2013/12/30 01:33:21 1.77 @@ -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.77 2013/12/30 01:33:21 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,12 +638,12 @@ 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 .= ''; + $output .= ''; if ($checked) { $output .= &get_wasactive_text(); } @@ -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,21 @@ 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,$deftextbook); + my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); + unless ($env{'form.currcat_0'} eq 'communities::0') { + if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) { + $showcredits = 1; + $defofficial = $domdefaults{'officialcredits'}; + $defunofficial = $domdefaults{'unofficialcredits'}; + $deftextbook = $domdefaults{'textbookcredits'}; + } + } my %courseinfo = &build_courseinfo_hash($courses,$knownuser,$domain,$details, $usersections,\@fields,\%fieldtitles, - $wasactiveon,\%numbers); + $wasactiveon,\%numbers,\%creditsum, + $showcredits,$defofficial,$defunofficial,$deftextbook); my %Sortby; foreach my $course (sort(keys(%{$courses}))) { if ($env{'form.sortby'} eq 'code') { @@ -992,33 +1007,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 .= ''. ' '. - ''. + ''. ''; foreach my $item ('courses','sections','xlists') { $output .= ''. - ''. + ''. ''. ''."\n"; } if (@fields > 0) { foreach my $status (@fields) { $output .= ''. - ''. + ''. ''. ''."\n"; } } - $output .= '
'.$lt{$item}.''.$lt{$item}.' '.$numbers{$item}.'
'.$lt{$status}.''.$lt{$status}.' '.$numbers{$status}.'
'; + $output .= ''; + if ($showcredits) { + $output .= ''; + foreach my $status (@fields) { + $output .= ''. + ''. + ''; + } + $output .= '
'.$lt{'cr_'.$status}.' '.$creditsum{$status}.'
'; + } } } $output .= &Apache::loncommon::end_data_table(); @@ -1027,14 +1060,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 +1149,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 +1179,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 +1244,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 +1260,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 +1304,9 @@ sub count_students { $countslist .= ''.$titles{$status}.': '. $student_count{$status}.'
'; $numbers->{$status} += $student_count{$status}; + if ($showcredits) { + $creditsum->{$status} += $credit_count{$status}; + } } } return $countslist;