--- loncom/interface/statistics/lonproblemstatistics.pm 2002/07/25 19:29:23 1.2 +++ loncom/interface/statistics/lonproblemstatistics.pm 2003/03/26 21:55:18 1.46 @@ -1,7 +1,6 @@ # The LearningOnline Network with CAPA -# (Publication Handler # -# $Id: lonproblemstatistics.pm,v 1.2 2002/07/25 19:29:23 minaeibi Exp $ +# $Id: lonproblemstatistics.pm,v 1.46 2003/03/26 21:55:18 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,978 +25,769 @@ # http://www.lon-capa.org/ # # (Navigate problems for statistical reports -# YEAR=2001 -# 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei -# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei -# YEAR=2002 -# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei -# 5/12,5/14,5/15,5/19,5/26,7/16,7/25 Behrouz Minaei # ### -package Apache::lonproblemstatistics; +package Apache::lonproblemstatistics; use strict; use Apache::lonnet(); use Apache::lonhtmlcommon; use Apache::loncoursedata; -use GDBM_File; +use Apache::lonstatistics; +use Spreadsheet::WriteExcel; -my %mapsort; +####################################################### +####################################################### -sub BuildProblemStatisticsPage { - my ($cacheDB, $students, $courseID, $c, $r,%color)=@_; - my %cache; - #my %DoDiff; - unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { - return '
Unable to tie database.'; - } - - my $Ptr = ''; - $Ptr .= 'Select Map | '."\n"; - $Ptr .= ''; - $Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'ProblemStatistics'); - $Ptr .= ' |
Sections | '; + $Str .= 'Sequences and Folders | '; + $Str .= 'Output | '; + $Str .= '
'."\n"; + $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); + $Str .= ' | '; + # + my $only_seq_with_assessments = sub { + my $s=shift; + if ($s->{'num_assess'} < 1) { + return 0; + } else { + return 1; } - } - if($c->aborted()) { return $Ptr; } - - unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { - return 'Unable to tie database.'; - } - my $discriminantFactor; - my @list=(); - my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID); - my $index=0; - foreach (@$students) { - #&Apache::lonstatistics::Update_PrgWin(++$index,$r); - $discriminantFactor = &ExtractStudentData(\%cache, $_, \@list,\%Discuss); - } - #&Apache::lonstatistics::Close_PrgWin($r); - - return $Ptr; - my ($upper, $lower) = &Discriminant($discriminantFactor); - my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod", - 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff", - 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd", 13, "Disc."); - - my %GraphDat= &BuildStatisticsTable(\%cache, $discriminantFactor, \@list, - \%Header, $students, $r, \%color); - - untie(%cache); - - return $Ptr; + }; + $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, + $only_seq_with_assessments); + $Str .= ' | '."\n"; + $Str .= &CreateAndParseOutputSelector(); + $Str .= ' |
'."\n");
+ $r->print('
|
'."\n");
+ $r->rflush();
+ #
+ # Compile the data
+ my @Statsarray;
+ foreach my $sequence (@Sequences) {
+ next if ($sequence->{'num_assess'}<1);
+ foreach my $resource (@{$sequence->{'contents'}}) {
+ next if ($resource->{'type'} ne 'assessment');
+ foreach my $part (@{$resource->{'parts'}}) {
+ $problem_num++;
+ my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
+ $SKEW) = &Apache::loncoursedata::get_problem_statistics
+ (undef,$resource->{'symb'},$part,
+ $ENV{'request.course.id'});
+ #
+ $show_part = 1 if ($part ne '0');
+ $part = ' ' if ($part == 0);
+ #
+ my $wrongpercent = 0;
+ if (defined($num) && $num > 0) {
+ $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
}
+ push (@Statsarray,
+ { 'sequence' => $sequence,
+ 'resource' => $resource,
+ 'Title' => $resource->{'title'},
+ 'Part' => $part,
+ '#Stdnts' => $num,
+ 'Tries' => $tries,
+ 'Mod' => $mod,
+ 'Mean' => $mean,
+ '#YES' => $Solved,
+ '#yes' => $solved,
+ '%Wrng' => $wrongpercent,
+ 'DoDiff' => $DegOfDiff,
+ 'S.D.' => $STD,
+ 'Skew' => $SKEW,
+ 'problem_num' => $problem_num,
+ });
}
}
}
- my %DisUp = &ProcessDiscriminant(\@UpList);
- my %DisLow = &ProcessDiscriminant(\@LowList);
-
- return (\%DisUp, \%DisLow);
-}
-
-
-sub NumericSort {
- $a <=> $b;
-}
-
+ #
+ # Table Headers
+ $r->print('
|
".&DrawGraph(\@Data,$title,'Problem Number',$yaxis, + $Max)."
\n"); + # + # Print out the data + $ENV{'form.sortby'} = 'Contents'; + &output_html_ungrouped($r,'show probnum'); + return; +} + +############################################### +############################################### + +############################################### +############################################### +sub DrawGraph { + my ($values,$title,$xaxis,$yaxis,$Max)=@_; + $title = '' if (! defined($title)); + $xaxis = '' if (! defined($xaxis)); + $yaxis = '' if (! defined($yaxis)); + # + my $sendValues = join(',', @$values); + my $sendCount = scalar(@$values); + if ( $Max > 1 ) { + if ($Max % 10) { + if ( int($Max) < $Max ) { + $Max++; + $Max = int($Max); } - &CloseTable($cache); } + } else { + $Max = 1; } - else { - &CreateProblemStatisticsTableHeading($cache,0); - for ( my $nIndex = 0; $nIndex < $p_count; $nIndex++ ) { - my($Pre, $Post) = split(/\@/,$list[$nIndex]); - &TableRow($cache,$Post,$nIndex,$nIndex,\%color,\%GraphDat); - } - &CloseTable($cache); - } -} -=cut - -sub TableRow { - my ($cache,$Str,$Idx,$RealIdx,$r,$color,$GraphDat)=@_; - my($PrOrd,$Temp,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override, - $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$DiscNo,$Prob)=split(/\&/,$Str); - if ($ENV{'form.showcsv'}) { - my ($ResId,$Dummy)=split(/\*/,$Prob); - my $Ptr = "\n".'