--- loncom/interface/Attic/lonchart.pm 2002/07/01 13:59:13 1.47 +++ loncom/interface/Attic/lonchart.pm 2002/07/02 21:48:36 1.52 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonchart.pm,v 1.47 2002/07/01 13:59:13 stredwic Exp $ +# $Id: lonchart.pm,v 1.52 2002/07/02 21:48:36 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,6 +46,10 @@ # ### +=pod + +=cut + package Apache::lonchart; use strict; @@ -55,20 +59,24 @@ use Apache::loncommon(); use HTML::TokeParser; use GDBM_File; -my $jr; +#my $jr; # ----- FORMAT PRINT DATA ---------------------------------------------- sub FormatStudentInformation { my ($cache,$name,$studentInformation,$spacePadding)=@_; - my $Str='
'; + my $Str=''; - foreach (@$studentInformation) { - my $data=$cache->{$name.':'.$_}; + for(my $index=0; $index<(scalar @$studentInformation); $index++) { + if(!&ShouldShowColumn($cache, 'heading'.$index)) { + next; + } + my $data=$cache->{$name.':'.$studentInformation->[$index]}; $Str .= $data; my @dataLength=split(//,$data); my $length=scalar @dataLength; - $Str .= (' 'x($cache->{$_.'Length'}-$length)); + $Str .= (' 'x($cache->{$studentInformation->[$index].'Length'}- + $length)); $Str .= $spacePadding; } @@ -91,22 +99,15 @@ sub FormatStudentData { # Handle errors if($CacheData{$name.':error'} =~ /environment/) { + $Str .= ''; return $Str; -# my $errorMessage = $CacheData{$name.':error'}; -# return '
'; untie(%CacheData); - $Str .= '
'; for(my $index=0; $index<(scalar @$headings); $index++) { + if(!&ShouldShowColumn($CacheData, 'heading'.$index)) { + next; + } + my $data=$$headings[$index]; $Str .= $data; @@ -230,7 +241,12 @@ sub CreateTableHeadings { } foreach my $sequence (split(/\:/,$CacheData->{'orderedSequences'})) { - $Str .= $CacheData->{$sequence.':title'}; + if(!&ShouldShowColumn($CacheData, 'sequence'.$sequence)) { + next; + } + + my $name = $CacheData->{$sequence.':title'}; + $Str .= $name; my @titleLength=split(//,$CacheData->{$sequence.':title'}); my $leftover=$CacheData->{$sequence.':columnWidth'}- (scalar @titleLength); @@ -244,83 +260,145 @@ sub CreateTableHeadings { return $Str; } -sub CreateColumnSelectors { +sub CreateColumnSelectionBox { my ($CacheData,$studentInformation,$headings,$spacePadding)=@_; - my $Str=''; - $Str .= ''."\n"; - return $Str; + my $missing=0; + my $notThere='
'; + for(my $index=0; $index<(scalar @$headings); $index++) { + if(!&ShouldShowColumn($CacheData, 'heading'.$index)) { + next; + } + $name = $headings->[$index]; + $length=$CacheData->{$$studentInformation[$index].'Length'}; + $position=int($length/2); + $present .= (' 'x($position)); + $present .= ''; + $position+=2; + $present .= (' 'x($length-$position)); + $present .= $spacePadding; + $found++; } foreach my $sequence (split(/\:/,$CacheData->{'orderedSequences'})) { - $Str .= $CacheData->{$sequence.':title'}; - my @titleLength=split(//,$CacheData->{$sequence.':title'}); - my $leftover=$CacheData->{$sequence.':columnWidth'}- - (scalar @titleLength); - $Str .= (' 'x$leftover); - $Str .= $spacePadding; + if(!&ShouldShowColumn($CacheData, 'sequence'.$sequence)) { + next; + } + $name = $CacheData->{$sequence.':title'}; + $length=$CacheData->{$sequence.':columnWidth'}; + $position=int($length/2); + $present .= (' 'x($position)); + $present .= ''; + $position+=2; + $present .= (' 'x($length-$position)); + $present .= $spacePadding; + $found++; } - return $Str; + if($found) { + $present .= ''; + $present = $present; + } else { + $present = ''; + } + + return $present.''."\n";; } sub CreateForm { + my ($CacheData)=@_; my $OpSel1=''; my $OpSel2=''; my $OpSel3=''; - my $Status = $ENV{'form.status'}; + my $Status = $CacheData->{'form.status'}; if ( $Status eq 'Any' ) { $OpSel3='selected'; } elsif ($Status eq 'Expired' ) { $OpSel2 = 'selected'; } else { $OpSel1 = 'selected'; } - my $Ptr = '