--- loncom/interface/lonstatistics.pm 2003/02/25 20:47:47 1.60
+++ loncom/interface/lonstatistics.pm 2008/11/10 13:20:14 1.143
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstatistics.pm,v 1.60 2003/02/25 20:47:47 matthew Exp $
+# $Id: lonstatistics.pm,v 1.143 2008/11/10 13:20:14 jms Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,20 +38,8 @@ lonstatistics
Main handler for statistics and chart.
-=head1 PACKAGES USED
-
- use strict;
- use Apache::Constants qw(:common :http);
- use Apache::lonnet();
- use Apache::lonhomework;
- use Apache::loncommon;
- use Apache::loncoursedata;
- use Apache::lonhtmlcommon;
- use Apache::lonproblemanalysis;
- use Apache::lonproblemstatistics;
- use Apache::lonstudentassessment;
- use Apache::lonpercentage;
- use GDBM_File;
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
=over 4
@@ -61,20 +49,37 @@ package Apache::lonstatistics;
use strict;
use Apache::Constants qw(:common :http);
-use Apache::lonnet();
+use vars qw(
+ @FullClasslist
+ @Students
+ @Sections
+ @Groups
+ %StudentData
+ @StudentDataOrder
+ @SelectedStudentData
+ $enrollment_status);
+
+use Apache::lonnet;
use Apache::lonhomework;
use Apache::loncommon;
use Apache::loncoursedata;
use Apache::lonhtmlcommon;
-use Apache::lonproblemanalysis;
-use Apache::lonproblemstatistics;
-use Apache::lonstudentassessment;
+use Apache::lonmysql;
+use Apache::lonlocal;
+use Apache::longroup;
+use Time::HiRes;
+#
+# Statistics Packages
+use Apache::lonproblemanalysis();
+use Apache::lonsubmissiontimeanalysis();
+use Apache::loncorrectproblemplot();
+use Apache::lonproblemstatistics();
+use Apache::lonstudentassessment();
use Apache::lonpercentage;
-use GDBM_File;
-
-use vars qw/@FullClasslist @Students @Sections @SelectedSections
- $curr_student $prev_student $next_student
- $top_map @Sequences @Assessments /;
+use Apache::lonstudentsubmissions();
+use Apache::lonsurveyreports();
+use Apache::longradinganalysis();
+use LONCAPA;
#######################################################
#######################################################
@@ -89,6 +94,8 @@ use vars qw/@FullClasslist @Students @Se
=item @Sections The sections available in this class
+=item @Groups The groups available in the class
+
=item $curr_student The student currently being examined
=item $prev_student The student previous in the classlist
@@ -104,10 +111,6 @@ use vars qw/@FullClasslist @Students @Se
#
# Classlist variables
#
-my @FullClasslist;
-my @Students;
-my @Sections;
-my @SelectedSections;
my $curr_student;
my $prev_student;
my $next_student;
@@ -129,7 +132,13 @@ undef the following package variables:
=item @Sections
-=item @SelectedSections
+=item @Groups
+
+=item %StudentData
+
+=item @StudentDataOrder
+
+=item @SelectedStudentData
=item $curr_student
@@ -147,7 +156,9 @@ sub clear_classlist_variables {
undef(@FullClasslist);
undef(@Students);
undef(@Sections);
- undef(@SelectedSections);
+ undef(@Groups);
+ undef(%StudentData);
+ undef(@SelectedStudentData);
undef($curr_student);
undef($prev_student);
undef($next_student);
@@ -171,7 +182,11 @@ the following package variables:
=item @Sections
-=item @SelectedSections
+=item @Groups
+
+=item %StudentData
+
+=item @SelectedStudentData
=item $curr_student
@@ -189,38 +204,70 @@ upon the calling context.
#######################################################
#######################################################
sub PrepareClasslist {
- my $r = shift;
my %Sections;
&clear_classlist_variables();
#
# Retrieve the classlist
- my $cid = $ENV{'request.course.id'};
- my $cdom = $ENV{'course.'.$cid.'.domain'};
- my $cnum = $ENV{'course.'.$cid.'.num'};
- my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cid,
- $cdom,$cnum);
- if (exists($ENV{'form.Section'})) {
- if (ref($ENV{'form.Section'})) {
- @SelectedSections = @$ENV{'form.Section'};
- # Remove the empty sections
- for (my $i=0; $i<=$#SelectedSections; $i++) {
- if ($SelectedSections[$i] =~ /^\s*$/) {
- splice(@SelectedSections,$i,1);
- }
- }
- } else {
- if ($ENV{'form.Section'} !~ /^\s*$/) {
- @SelectedSections = ($ENV{'form.Section'});
- }
- }
+ my $cid = $env{'request.course.id'};
+ my $cdom = $env{'course.'.$cid.'.domain'};
+ my $cnum = $env{'course.'.$cid.'.num'};
+ my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cdom,
+ $cnum);
+ my @selected_sections = &get_selected_sections();
+ my @selected_groups = &get_selected_groups();
+ #
+ # Deal with instructors with restricted section access
+ if ($env{'request.course.sec'} !~ /^\s*$/) {
+ @selected_sections = ($env{'request.course.sec'});
+ }
+ #
+ # Set up %StudentData
+ @StudentDataOrder = qw/fullname username domain id section status groups comments/;
+ foreach my $field (@StudentDataOrder) {
+ $StudentData{$field}->{'title'} = &mt($field);
+ $StudentData{$field}->{'base_width'} = length(&mt($field));
+ $StudentData{$field}->{'width'} =
+ $StudentData{$field}->{'base_width'};
}
- @SelectedSections = ('any') if (! @SelectedSections);
#
+ # get the status requested
+ $enrollment_status = 'Active';
+ $enrollment_status = $env{'form.Status'} if (exists($env{'form.Status'}));
+ #
+ # Get groupmembership
+ my ($classgroups,$studentgroups);
+ my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
+ if (%curr_groups) {
+ ($classgroups,$studentgroups) =
+ &Apache::loncoursedata::get_group_memberships($classlist,
+ $field_names,
+ $cdom,$cnum);
+ }
+ my $now = time;
+
# Process the classlist
while (my ($student,$student_data) = each (%$classlist)) {
my $studenthash = ();
for (my $i=0; $i< scalar(@$field_names);$i++) {
- $studenthash->{$field_names->[$i]}=$student_data->[$i];
+ my $field = $field_names->[$i];
+ # Store the data
+ $studenthash->{$field}=$student_data->[$i];
+ # Keep track of the width of the fields
+ next if (! exists($StudentData{$field}));
+ my $length = length($student_data->[$i]);
+ if ($StudentData{$field}->{'width'} < $length) {
+ $StudentData{$field}->{'width'} = $length;
+ }
+ }
+ my @studentsgroups = &Apache::loncoursedata::get_students_groups
+ ($student,$enrollment_status,
+ $classgroups);
+ if (@studentsgroups) {
+ $studenthash->{'groups'} = join(', ',@studentsgroups);
+ $studenthash->{'groupref'} = \@studentsgroups;
+ } else {
+ $studenthash->{'groups'} = 'none';
+ $studenthash->{'groupref'} = [];
}
push (@FullClasslist,$studenthash);
#
@@ -233,29 +280,66 @@ sub PrepareClasslist {
$Sections{$section}++;
#
# Only put in the list those students we are interested in
- foreach my $sect (@SelectedSections) {
- if (($sect eq 'any') || ($section eq $sect)) {
- push (@Students,$studenthash);
- last;
+ foreach my $sect (@selected_sections) {
+ if ( (($sect eq 'all') ||
+ ($section eq $sect)) &&
+ (($studenthash->{'status'} eq $enrollment_status) ||
+ ($enrollment_status eq 'Any'))
+ ){
+ my $groupcheck = 0;
+ if (grep(/^all$/,@selected_groups)) {
+ push(@Students,$studenthash);
+ last;
+ } elsif (grep(/^none$/,@selected_groups)) {
+ if ($studenthash->{'groups'} eq 'none') {
+ push(@Students,$studenthash);
+ last;
+ }
+ } else {
+ foreach my $group (@selected_groups) {
+ if (grep(/^$group$/,@studentsgroups)) {
+ push(@Students,$studenthash);
+ $groupcheck = 1;
+ last;
+ }
+ }
+ if ($groupcheck) {
+ last;
+ }
+ }
}
}
}
#
# Put the consolidated section data in the right place
- @Sections = sort {$a cmp $b} keys(%Sections);
+ if ($env{'request.course.sec'} !~ /^\s*$/) {
+ @Sections = ($env{'request.course.sec'});
+ } else {
+ @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
+ @Groups = sort {$a cmp $b} keys(%{$studentgroups});
+ unshift(@Groups,'all'); # Put 'all' at the front of the list
+
#
# Sort the Students
my $sortby = 'fullname';
- $sortby = $ENV{'form.sort'} if (exists($ENV{'form.sort'}));
- my @TmpStudents = sort { $a->{$sortby} cmp $b->{$sortby} ||
- $a->{'fullname'} cmp $b->{'fullname'} } @Students;
-
+ $sortby = $env{'form.sort'} if (exists($env{'form.sort'}));
+ my @TmpStudents = sort { lc($a->{$sortby}) cmp lc($b->{$sortby}) ||
+ lc($a->{'fullname'}) cmp lc($b->{'fullname'}) ||
+ lc($a->{'username'}) cmp lc($b->{'username'}) } @Students;
@Students = @TmpStudents;
#
# Now deal with that current student thing....
- if (exists($ENV{'form.StudentAssessmentStudent'})) {
+ $curr_student = undef;
+ if (exists($env{'form.SelectedStudent'})) {
my ($current_uname,$current_dom) =
- split(':',$ENV{'form.StudentAssessmentStudent'});
+ split(':',$env{'form.SelectedStudent'});
my $i;
for ($i = 0; $i<=$#Students; $i++) {
next if (($Students[$i]->{'username'} ne $current_uname) ||
@@ -263,189 +347,255 @@ sub PrepareClasslist {
$curr_student = $Students[$i];
last; # If we get here, we have our student.
}
- if ($i == 0) {
- $prev_student = 'none';
- } else {
- $prev_student = $Students[$i-1];
+ if (defined($curr_student)) {
+ if ($i == 0) {
+ $prev_student = undef;
+ } else {
+ $prev_student = $Students[$i-1];
+ }
+ if ($i == $#Students) {
+ $next_student = undef;
+ } else {
+ $next_student = $Students[$i+1];
+ }
}
- if ($i == $#Students) {
- $next_student = 'none';
- } else {
- $next_student = $Students[$i+1];
+ }
+ #
+ if (exists($env{'form.StudentData'})) {
+ @SelectedStudentData =
+ &Apache::loncommon::get_env_multiple('form.StudentData');
+ } else {
+ @SelectedStudentData = ('username');
+ }
+ foreach (@SelectedStudentData) {
+ if ($_ eq 'all') {
+ @SelectedStudentData = ('all');
+ last;
}
}
+ #
+ return;
}
#######################################################
#######################################################
-#
-# Course Sequences variables
-#
-my $top_map;
-my @Sequences;
-my @Assessments;
+
+=pod
+
+=item get_selected_sections
+
+Returns an array of the selected sections
+
+=cut
#######################################################
#######################################################
+sub get_selected_sections {
+ my @selected_sections =
+ &Apache::loncommon::get_env_multiple('form.Section');
+ @selected_sections = ('all') if (! @selected_sections);
+ foreach (@selected_sections) {
+ if ($_ eq 'all') {
+ @selected_sections = ('all');
+ }
+ }
+ #
+ # Deal with instructors with restricted section access
+ if ($env{'request.course.sec'} !~ /^\s*$/) {
+ @selected_sections = ($env{'request.course.sec'});
+ }
+ return @selected_sections;
+}
+#######################################################
+#######################################################
+
+=pod
+
+=item get_selected_groups
+
+Returns an array of the selected groups
+
+=cut
+
+#######################################################
+#######################################################
+sub get_selected_groups {
+ my @selected_groups =
+ &Apache::loncommon::get_env_multiple('form.Group');
+ @selected_groups = ('all') if (! @selected_groups);
+ foreach my $grp (@selected_groups) {
+ if ($grp eq 'all') {
+ @selected_groups = ('all');
+ last;
+ }
+ }
+ return @selected_groups;
+}
+
=pod
-=item &clear_sequence_variables()
+=item §ion_and_enrollment_description
+
+Returns a string describing the currently selected section(s), group(s) and
+access status.
+
+Inputs: mode = 'plaintext' or 'localized' (defaults to 'localized')
+ 'plaintext' is used for example in Excel spreadsheets.
+Returns: scalar description string.
=cut
#######################################################
#######################################################
-sub clear_sequence_variables {
- undef($top_map);
- undef(@Sequences);
- undef(@Assessments);
+sub section_and_enrollment_description {
+ my ($mode) = @_;
+ if (! defined($mode)) { $mode = 'localized'; }
+ my @sections = &Apache::lonstatistics::get_selected_sections();
+ my @groups = &Apache::lonstatistics::get_selected_groups();
+ my $description;
+ if ($mode eq 'localized') {
+ $description = &mt('Unable to determine section, groups and access status');
+ } elsif ($mode eq 'plaintext') {
+ $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);
+ if ($mode eq 'localized') {
+ $description .= ' '.&mt($env{'form.Status'}.' access status.');
+ } elsif ($mode eq 'plaintext') {
+ $description .= ' '.$env{'form.Status'}.' access status.';
+ }
+ return $description;
}
#######################################################
#######################################################
+sub section_or_group_text {
+ my ($mode,$type,@items) = @_;
+ my $text;
+ my %phrases = ();
+ %{$phrases{'section'}} = (
+ single => 'Section',
+ all => 'All sections',
+ plural => 'Sections',
+ );
+ %{$phrases{'group'}} = (
+ single => 'Group',
+ all => 'All groups',
+ plural => 'Groups',
+ );
+ if (scalar(@items) == 1 && $items[0] ne 'all') {
+ if ($mode eq 'localized') {
+ $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($phrases{$type}{all}.'.');
+ } elsif ($mode eq 'plaintext') {
+ $text = $phrases{$type}{all}.'.';
+ }
+ } elsif (scalar(@items)) {
+ my $lastitem = pop(@items);
+ if ($mode eq 'localized') {
+ $text = &mt($phrases{$type}{plural}.' [_1] and [_2].',
+ join(', ',@items),$lastitem);
+ } elsif ($mode eq 'plaintext') {
+ $text = $phrases{$type}{plural}.' '.join(', ',@items).' and '.
+ $lastitem.'.';
+ }
+ }
+ return $text;
+}
+
+
=pod
-=item &PrepareCourseData($r)
+=item get_students
+
+Returns a list of the selected students
=cut
#######################################################
#######################################################
-sub PrepareCourseData {
- my ($r) = @_;
- &clear_sequence_variables();
- my ($top,$sequences,$assessments) = &Apache::loncoursedata::get_sequence_assessment_data();
- if (! defined($top) || ! ref($top)) {
- # There has been an error, better report it
- &Apache::lonnet::logthis('top is undefined');
- return;
+sub get_students {
+ if (! @Students) {
+ &PrepareClasslist()
}
- $top_map = $top if (ref($top));
- @Sequences = @{$sequences} if (ref($sequences) eq 'ARRAY');
- @Assessments = @{$assessments} if (ref($assessments) eq 'HASH');
+ return @Students;
+}
+
+#######################################################
+#######################################################
=pod
- ##
- ## Debugging code
- ##
- foreach my $s (@Sequences) {
- next if ($s->{'title'} ne 'Bioenergetics: Enzyme Regulation');
- &Apache::lonnet::logthis('-----------------------------------');
- &Apache::lonnet::logthis('title = '.$s->{'title'});
- &Apache::lonnet::logthis('symb = '.$s->{'symb'});
- &Apache::lonnet::logthis('num_assess = '.$s->{'num_assess'});
- foreach my $a (@{$s->{'contents'}}) {
- &Apache::lonnet::logthis(' --------------------------------');
- &Apache::lonnet::logthis(' title = '.$a->{'title'});
- &Apache::lonnet::logthis(' symb = '.$a->{'symb'});
- }
- }
+=item ¤t_student()
+
+Returns a pointer to a hash containing data about the currently
+selected student.
=cut
- return;
+#######################################################
+#######################################################
+sub current_student {
+ return $curr_student;
}
-##############################################
-##############################################
-
-=pod
+#######################################################
+#######################################################
-=item &MapSelect($elementname,$status,$numvisible,$selected,$restriction)
+=pod
-Returns html for a selection box allowing the user to choose one (or more)
-of the sequences in the course. The values of the sequences are the symbs.
-If the top sequence is selected, the value 'top' will result.
+=item &previous_student()
-=over 4
+Returns a pointer to a hash containing data about the student prior
+in the list of students. Or something.
-=item $elementname The name of the HTML form element
+=cut
-=item $status 'multiple' or 'single' selection box
+#######################################################
+#######################################################
+sub previous_student {
+ return $prev_student;
+}
-=item $numvisible The number of options to be visible
+#######################################################
+#######################################################
-=item $selected Array ref to the names of the already selected maps.
-If undef, $ENV{'form.'.$elementname} is used.
-If $ENV{'form.'.$elementname} is also empty, none will be selected.
+=pod
-=item $restriction Code reference to subroutine which returns true or
-false. The code must expect a reference to a sequence data structure.
+=item &next_student()
-=back
+Returns a pointer to a hash containing data about the next student
+to be viewed.
=cut
-##############################################
-##############################################
-sub MapSelect {
- my ($elementname,$status,$numvisible,$selected,$restriction)=@_;
- if ($numvisible < 1) {
- return;
- }
- #
- # Set up array of selected items
- my @Selected;
- if (! defined($selected)) {
- if (exists($ENV{'form.'.$elementname})) {
- if (ref($ENV{'form.'.$elementname})) {
- @Selected = @$ENV{'form.'.$elementname};
- } else {
- @Selected = ($ENV{'form.'.$elementname});
- }
- } else {
- @Selected = ();
- }
- } else {
- if (ref($selected)) {
- @Selected = @$selected;
- } else {
- @Selected = ($selected);
- }
- }
- #
- # Set up the restriction call
- if (! defined($restriction)) {
- $restriction = sub { 1; };
- }
- #
- # Build the form element
- my $Str = "\n";
- $Str .= '\n";
- return $Str;
+#######################################################
+#######################################################
+sub next_student {
+ return $next_student;
}
-
##############################################
##############################################
=pod
-=item &SectionSelect($elementname,$status,$numvisible)
+=item &StudentDataSelect($elementname,$status,$numvisible,$selected)
Returns html for a selection box allowing the user to choose one (or more)
-of the sections in the course.
+of the fields of student data available (fullname, username, id, section, etc)
=over 4
@@ -455,20 +605,13 @@ of the sections in the course.
=item $numvisible The number of options to be visible
-=item $selected Array ref to the names of the already selected sections.
-If undef, $ENV{'form.'.$elementname} is used.
-If $ENV{'form.'.$elementname} is also empty, none will be selected.
-
-=item $restriction Code reference to subroutine which returns true or
-false. The code must expect a reference to a sequence data structure.
-
=back
=cut
##############################################
##############################################
-sub SectionSelect {
+sub StudentDataSelect {
my ($elementname,$status,$numvisible)=@_;
if ($numvisible < 1) {
return;
@@ -482,430 +625,431 @@ sub SectionSelect {
}
$Str .= 'size="'.$numvisible.'" >'."\n";
#
- # Loop through the sequences
- foreach my $s (@Sections) {
- $Str .= ' \n";
}
$Str .= "\n";
return $Str;
}
-##############################################
-##############################################
+#######################################################
+#######################################################
-sub CheckFormElement {
- my ($cache, $ENVName, $cacheName, $default)=@_;
+=pod
- if(defined($ENV{'form.'.$ENVName})) {
- $cache->{$cacheName} = $ENV{'form.'.$ENVName};
- } elsif(!defined($cache->{$cacheName})) {
- $cache->{$cacheName} = $default;
- } else {
- $ENV{'form.'.$ENVName} = $cache->{$cacheName};
- }
- return;
-}
+=item &get_selected_maps($elementname)
-sub ProcessFormData{
- my ($cache)=@_;
+Input: Name of the
';
+ $Str .= '';
+ $r->print($Str);
+ $r->rflush();
+ #
+ my @Fields = ('fullname','username','domain','id','section','status','groups');
#
- my $Str='';
- $Str .= ''."\n";
- $Str .= ''."\n";
+ $Str = '';
+ my @selected_sections = &get_selected_sections();
+ if (! @Students) {
+ if ($selected_sections[0] eq 'all') {
+ 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 .= ''.
+ &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 {
+ 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 .= ''.
+ &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('Return to the chart').''
+ .' ';
+ $r->print($Str);
+ $r->rflush();
+ return;
+ }
+
+ $Str .= ''.&mt('Select One Student').''
+ .''.&mt("Click on a student's name or username to view their chart").' '
+ .&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table_header_row();
foreach my $field (@Fields) {
- $Str .= ''.$field.
+ $Str .= ' | '.&mt($field).
' | ';
}
- $Str .= ' '."\n";
+ $Str .= &Apache::loncommon::end_data_table_header_row();
#
- my $alternate = 0;
- foreach my $student (@Students) {
+ foreach my $student (@Students) { # @Students is a package variable
my $sname = $student->{'username'}.':'.$student->{'domain'};
- if($alternate) {
- $Str .= '';
- } else {
- $Str .= ' ';
- }
- $alternate = ($alternate + 1) % 2;
+ $Str .= &Apache::loncommon::start_data_table_row();
#
foreach my $field (@Fields) {
$Str .= '';
- if ($field eq 'fullname') {
+ if ($field eq 'fullname' || $field eq 'username') {
$Str .= '';
+ $Str .= &escape('student_assessment');
+ $Str .= '&sort='.&escape($env{'form.sort'});
+ $Str .= '&SelectedStudent=';
+ $Str .= &escape($sname).'">';
$Str .= $student->{$field}.' ';
$Str .= '';
+ } elsif ($field eq 'status') {
+ $Str .= &mt($student->{$field});
} else {
$Str .= $student->{$field};
}
$Str .= ' | ';
}
- $Str .= " \n";
+ $Str .= &Apache::loncommon::end_data_table_row();
}
- $Str .= '
|
'."\n";
+ $Str .= &Apache::loncommon::end_data_table();
#
$r->print($Str);
$r->rflush();
@@ -913,288 +1057,235 @@ sub DisplayClasslist {
return;
}
-sub BuildClasslist {
- my ($cacheDB,$students,$studentInformation,$headings,$r)=@_;
-
- my %cache;
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
- return 'Unable to tie database.';
- }
-
-# my $Ptr = '';
-# $Ptr .= '';
-# $Ptr .= 'Select Sections';
-# $Ptr .= ' | '."\n";
-# $Ptr .= ''."\n";
-# my @sectionsSelected = split(':',$cache{'sectionsSelected'});
-# my @sections = split(':',$cache{'sectionList'});
-# $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,
-# \@sectionsSelected,
-# 'Statistics');
-# $Ptr .= ' |
';
-# $r->print($Ptr);
-# $r->rflush();
-# my %mySections = ();
-# foreach (@sections) { $mySections{$_} = 'True'; }
-# $r->print("
$cache{'sectionsSelected'}
");
-
- my $Str='';
- $Str .= ''."\n";
- $Str .= ''."\n";
-
- my $displayString = 'DISPLAYDATA  | '."\n";
- $Str .= &Apache::lonhtmlcommon::CreateHeadings(\%cache,
- $studentInformation,
- $headings, $displayString);
- $Str .= ' '."\n";
-
- my $alternate=0;
- foreach (@$students) {
-# if ($mySections{$cache{$_.':'.'section'}} ne 'True') {next;}
- my ($username, $domain) = split(':', $_);
- if($alternate) {
- $Str .= '';
- } else {
- $Str .= ' ';
- }
- $alternate = ($alternate + 1) % 2;
- foreach my $data (@$studentInformation) {
- $Str .= '';
- if($data eq 'fullname') {
- $Str .= '';
- $Str .= $cache{$_.':'.$data}.' ';
- $Str .= '';
- } elsif($data eq 'updateTime') {
- $Str .= '';
- $Str .= $cache{$_.':'.$data}.' ';
- $Str .= ' ';
- } else {
- $Str .= $cache{$_.':'.$data}.' ';
- }
-
- $Str .= ' | '."\n";
- }
- }
-
- $Str .= ' '."\n";
- $Str .= '
|
'."\n";
- $r->print($Str);
- $r->rflush();
-
- untie(%cache);
-
- return;
-}
-
+##############################################
+##############################################
sub CreateMainMenu {
- my ($status, $reports)=@_;
-
- my $Str = '';
-
- $Str .= ''."\n";
- $Str .= '
'."\n";
-
- return $Str;
-}
-
-sub BuildStatistics {
- my ($r)=@_;
-
- my $c = $r->connection;
- my @studentInformation=('fullname','section','id','domain','username',
- 'updateTime');
- my @headings=('Full Name', 'Section', 'PID', 'Domain', 'User Name',
- 'Last Updated');
- my $spacing = ' ';
-
- my %reports = ('classlist' => 'Class list',
- 'problem_statistics' => 'Problem Statistics',
- 'student_assessment' => 'Student Assessment',
- 'percentage' => 'Correct-problems Plot',
-# 'activitylog' => 'Activity Log',
- 'reportSelected' => 'Class list');
-
- my %cache;
- my $courseID=$ENV{'request.course.id'};
- my $cacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
- "_$ENV{'user.domain'}_$courseID\_statistics.db";
-
- $r->print(&Apache::lonhtmlcommon::Title('Course Statistics and Charts'));
-
- my ($returnValue, $students) = &PrepareData($c, $cacheDB,
- \@studentInformation,
- \@headings,$r);
- if($returnValue ne 'OK') {
- $r->print($returnValue."\n".'