--- loncom/interface/lonstatistics.pm 2006/05/01 05:39:44 1.130 +++ loncom/interface/lonstatistics.pm 2008/10/22 10:53:21 1.142 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstatistics.pm,v 1.130 2006/05/01 05:39:44 raeburn Exp $ +# $Id: lonstatistics.pm,v 1.142 2008/10/22 10:53:21 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -63,6 +63,7 @@ use Apache::loncoursedata; use Apache::lonhtmlcommon; use Apache::lonmysql; use Apache::lonlocal; +use Apache::longroup; use Time::HiRes; # # Statistics Packages @@ -75,6 +76,7 @@ use Apache::lonpercentage; use Apache::lonstudentsubmissions(); use Apache::lonsurveyreports(); use Apache::longradinganalysis(); +use LONCAPA; ####################################################### ####################################################### @@ -230,12 +232,13 @@ sub PrepareClasslist { $enrollment_status = $env{'form.Status'} if (exists($env{'form.Status'})); # # Get groupmembership - my (%curr_groups,$classgroups,$studentgroups); - my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum); - if ($numgroups) { + my ($classgroups,$studentgroups); + my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); + if (%curr_groups) { ($classgroups,$studentgroups) = - &Apache::loncoursedata::get_group_memberships($classlist, - $cdom,$cnum); + &Apache::loncoursedata::get_group_memberships($classlist, + $field_names, + $cdom,$cnum); } my $now = time; @@ -281,18 +284,18 @@ sub PrepareClasslist { ($enrollment_status eq 'Any')) ){ my $groupcheck = 0; - if (grep/^all$/,@selected_groups) { - push (@Students,$studenthash); + if (grep(/^all$/,@selected_groups)) { + push(@Students,$studenthash); last; - } elsif (grep/^none$/,@selected_groups) { + } elsif (grep(/^none$/,@selected_groups)) { if ($studenthash->{'groups'} eq 'none') { - push (@Students,$studenthash); + push(@Students,$studenthash); last; } } else { foreach my $group (@selected_groups) { - if (grep/^$group$/,@studentsgroups) { - push (@Students,$studenthash); + if (grep(/^$group$/,@studentsgroups)) { + push(@Students,$studenthash); $groupcheck = 1; last; } @@ -309,7 +312,11 @@ sub PrepareClasslist { if ($env{'request.course.sec'} !~ /^\s*$/) { @Sections = ($env{'request.course.sec'}); } else { - @Sections = sort {$a cmp $b} keys(%Sections); + @Sections = sort { + if ($a == $a && $b == $b ) { return $a <=> $b; } + return $a cmp $b; + } keys(%Sections); + unshift(@Sections,'all'); # Put 'all' at the front of the list } # Sort the groups @@ -428,7 +435,7 @@ sub get_selected_groups { =item §ion_and_enrollment_description Returns a string describing the currently selected section(s), group(s) and -enrollment status. +access status. Inputs: mode = 'plaintext' or 'localized' (defaults to 'localized') 'plaintext' is used for example in Excel spreadsheets. @@ -445,19 +452,19 @@ sub section_and_enrollment_description { my @groups = &Apache::lonstatistics::get_selected_groups(); my $description; if ($mode eq 'localized') { - $description = &mt('Unable to determine section, groups and enrollment'); + $description = &mt('Unable to determine section, groups and access status'); } elsif ($mode eq 'plaintext') { - $description = 'Unable to determine section, groups and enrollment'; + $description = 'Unable to determine section, groups and access status'; } else { $description = 'Bad parameter passed to lonstatistics::section_and_enrollment_description'; &Apache::lonnet::logthis($description); } $description = §ion_or_group_text($mode,'section',@sections). - ' '.§ion_or_group_text($mode,'group',@groups); + ' '.§ion_or_group_text($mode,'group',@groups); if ($mode eq 'localized') { - $description .= &mt(' [_1] enrollment status.',$env{'form.Status'}); + $description .= ' '.&mt($env{'form.Status'}.' access status.'); } elsif ($mode eq 'plaintext') { - $description .= ' '.$env{'form.Status'}.' enrollment status.'; + $description .= ' '.$env{'form.Status'}.' access status.'; } return $description; } @@ -481,21 +488,21 @@ sub section_or_group_text { ); if (scalar(@items) == 1 && $items[0] ne 'all') { if ($mode eq 'localized') { - $text = &mt('[_1] [_2].',$phrases{$type}{single},$items[0]); + $text = &mt($phrases{$type}{single}.' [_1].',$items[0]); } elsif ($mode eq 'plaintext') { $text = $phrases{$type}{single}.' '.$items[0].'.'; } } elsif (scalar(@items) && $items[0] eq 'all') { if ($mode eq 'localized') { - $text = &mt('[_1].',$phrases{$type}{all}); + $text = &mt($phrases{$type}{all}.'.'); } elsif ($mode eq 'plaintext') { $text = $phrases{$type}{all}.'.'; } } elsif (scalar(@items)) { my $lastitem = pop(@items); if ($mode eq 'localized') { - $text = &mt('[_1] [_2] and [_3].',$phrases{$type}{plural}, + $text = &mt($phrases{$type}{plural}.' [_1] and [_2].', join(', ',@items),$lastitem); } elsif ($mode eq 'plaintext') { $text = $phrases{$type}{plural}.' '.join(', ',@items).' and '. @@ -700,8 +707,13 @@ sub selected_sequences_with_assessments # my @sequences = $navmap->retrieveResources(undef, sub { shift->is_map(); },1,0,1); + my $toplevelseq = $navmap->getById('0.0'); + if (!grep(/^\Q$toplevelseq\E$/,@sequences)) { + unshift(@sequences,$toplevelseq); + } + my @sequences_with_assessments; - for my $sequence ($navmap->getById('0.0'), @sequences) { + foreach my $sequence (@sequences) { if ($navmap->hasResource($sequence,sub { shift->is_problem(); },0,1)){ push(@sequences_with_assessments,$sequence); } @@ -922,12 +934,12 @@ sub DisplayClasslist { # # Output some of the standard interface components my $Str; - $Str .= &Apache::lonhtmlcommon::breadcrumbs(undef,'Select One Student'); + $Str .= &Apache::lonhtmlcommon::breadcrumbs('Select One Student'); $Str .= '
'.&mt('Sections').' | '; $Str .= ''.&mt('Groups').' | '; - $Str .= ''.&mt('Enrollment Status').' | '; + $Str .= ''.&mt('Access Status').' | '; $Str .= '
---|---|---|---|
'.
@@ -953,46 +965,55 @@ sub DisplayClasslist {
my @selected_sections = &get_selected_sections();
if (! @Students) {
if ($selected_sections[0] eq 'all') {
- if (lc($env{'form.Status'}) eq 'any') {
- $Str .= ''. - &mt('There are no students in the course.'). - ''; - } elsif (lc($env{'form.Status'}) eq 'active') { - $Str .= ''. + if (lc($env{'form.Status'}) eq 'active') { + $Str .= ''. &mt('There are no currently enrolled students in the course.'). - ''; + ' '; } elsif (lc($env{'form.Status'}) eq 'expired') { - $Str .= ''. + $Str .= ''. &mt('There are no previously enrolled students in the course.'). - ''; + ' '; + } elsif (lc($env{'form.Status'}) eq 'future') { + $Str .= ''. + &mt('There are no students with future access in the course.'). + ' '; + } else { # 'any' and any others + $Str .= ''. + &mt('There are no students in the course.'). + ' '; } } else { - my $sections; - if (lc($env{'form.Status'}) eq 'any') { - $Str .= ''. - &mt('There are no students in the selected sections.'). - ''; - } elsif (lc($env{'form.Status'}) eq 'active') { - $Str .= ''. + if (lc($env{'form.Status'}) eq 'active') { + $Str .= ''. &mt('There are no currently enrolled students in the selected sections.'). - ''; + ' '; } elsif (lc($env{'form.Status'}) eq 'expired') { - $Str .= ''. + $Str .= ''. &mt('There are no previously enrolled students in the selected sections.'). - ''; + ' '; + } elsif (lc($env{'form.Status'}) eq 'future') { + $Str .= ''. + &mt('There are no students with future access in the selected sections.'). + ' '; + } else { # 'any' and any others + $Str .= ''. + &mt('There are no students in the selected sections.'). + ' '; } } - $Str.= ''. - &mt('Click here to return to the chart').''; + $Str.= '' + .'' + .&mt('Return to the chart').'' + .' '; $r->print($Str); $r->rflush(); return; } - # "Click" is asinine but it is probably not my place to change the world. - $Str .= 'Click on a students name or username to view their chart'; - $Str .= '
'.
+ $r->print('');
- $r->print(' |