--- loncom/interface/lonstatistics.pm 2002/07/25 19:30:24 1.31 +++ loncom/interface/lonstatistics.pm 2002/07/25 21:23:51 1.32 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonstatistics.pm,v 1.31 2002/07/25 19:30:24 minaeibi Exp $ +# $Id: lonstatistics.pm,v 1.32 2002/07/25 21:23:51 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -94,8 +94,6 @@ sub ProcessFormData{ } else { $cache->{'StudentAssessmentMove'} = 'selected'; } - &CheckFormElement($cache, 'StudentAssessmentMap', 'StudentAssessmentMap', - 'All Maps'); &CheckFormElement($cache, 'StudentAssessmentStudent', 'StudentAssessmentStudent', 'All Students'); $cache->{'StudentAssessmentStudent'} = @@ -195,8 +193,57 @@ sub SortStudents { return \@order; } +=pod + +=item &SpaceColumns() + +Determines the width of all the columns in the chart. It is based on +the max of the data for that column and its header. + +=over 4 + +Input: $students, $studentInformation, $headings, $ChartDB + +$students: An array pointer to a list of students (username:domain) + +$studentInformatin: The type of data for the student information. It is +used as part of the key in $CacheData. + +$headings: The name of the student information columns. + +$ChartDB: The name of the cache database which is opened for read/write. + +Output: None - All data stored in cache. + +=back + +=cut + +sub SpaceColumns { + my ($students,$studentInformation,$headings,$cache)=@_; + + # Initialize Lengths + for(my $index=0; $index<(scalar @$headings); $index++) { + my @titleLength=split(//,$headings->[$index]); + $cache->{$studentInformation->[$index].':columnWidth'}= + scalar @titleLength; + } + + foreach my $name (@$students) { + foreach (@$studentInformation) { + my @dataLength=split(//,$cache->{$name.':'.$_}); + my $length=(scalar @dataLength); + if($length > $cache->{$_.':columnWidth'}) { + $cache->{$_.':columnWidth'}=$length; + } + } + } + + return; +} + sub PrepareData { - my ($c, $cacheDB)=@_; + my ($c, $cacheDB, $studentInformation, $headings)=@_; # Test for access to the cache data my $courseID=$ENV{'request.course.id'}; @@ -255,6 +302,8 @@ sub PrepareData { &ProcessFormData(\%cache); my $students = &SortStudents(\%cache); + &SpaceColumns($students, $studentInformation, $headings, \%cache); + $cache{'updateTime:columnWidth'}=24; if($cache{'download'} ne 'false') { my $who = $cache{'download'}; @@ -291,11 +340,6 @@ sub PrepareData { return 'aborted'; } - if($c->aborted()) { - untie(%cache); - return 'aborted'; - } - untie(%cache); return ('OK', $students); @@ -359,7 +403,7 @@ sub setbgcolor { } sub BuildClasslist { - my ($cacheDB,$students,$studentInformation,$headings,$spacePadding)=@_; + my ($cacheDB,$students,$studentInformation,$headings)=@_; my %cache; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { @@ -372,51 +416,42 @@ sub BuildClasslist { my $displayString = '