--- loncom/interface/statistics/loncorrectproblemplot.pm 2004/02/02 21:54:13 1.4
+++ loncom/interface/statistics/loncorrectproblemplot.pm 2004/03/08 18:42:58 1.10
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncorrectproblemplot.pm,v 1.4 2004/02/02 21:54:13 matthew Exp $
+# $Id: loncorrectproblemplot.pm,v 1.10 2004/03/08 18:42:58 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -71,7 +71,6 @@ sub BuildCorrectProblemsPage {
#
&Apache::lonstatistics::PrepareClasslist();
#
- $r->print('
'.&mt('Number of Correct Problems Plot').'
');
$r->print(&CreateInterface());
#
my @Students = @Apache::lonstatistics::Students;
@@ -104,22 +103,38 @@ sub BuildCorrectProblemsPage {
# Determine which problem symbs we are to sum over
if (exists($ENV{'form.CreatePlot'})) {
my @ProblemSymbs;
+ my $total_parts = 0;
+ my $title = '';
if ($Apache::lonstatistics::SelectedMaps[0] ne 'all') {
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()){
+ if ($title eq '') {
+ $title = $seq->{'title'};
+ } else {
+ $title = 'Multiple Sequences';
+ }
foreach my $res (@{$seq->{'contents'}}) {
next if ($res->{'type'} ne 'assessment');
foreach my $part (@{$res->{'parts'}}) {
+ $total_parts++;
push(@ProblemSymbs,{symb=>$res->{'symb'},
part=>$part});
}
}
}
}
+ my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
+ if (defined($starttime) || defined($endtime)) {
+ # Inform the user what the time limits on the data are.
+ $r->print(&mt('Statistics on submissions from [_1] to [_2]',
+ &Apache::lonlocal::locallocaltime($starttime),
+ &Apache::lonlocal::locallocaltime($endtime)));
+ }
my $score_data = &Apache::loncoursedata::get_student_scores
(\@Apache::lonstatistics::SelectedSections,
\@ProblemSymbs,
- $Apache::lonstatistics::enrollment_status);
- $r->print(&AnalyzeScoreData($score_data));
+ $Apache::lonstatistics::enrollment_status,undef,
+ $starttime,$endtime);
+ $r->print(&AnalyzeScoreData($score_data,$title,$total_parts));
}
return;
}
@@ -139,7 +154,7 @@ return html with a plot of the data and
#########################################################
#########################################################
sub AnalyzeScoreData {
- my ($score_data) = @_;
+ my ($score_data,$title,$total_parts) = @_;
#
# Basic check first
if (@$score_data < 1) {
@@ -150,6 +165,7 @@ sub AnalyzeScoreData {
my $lowest = $score_data->[0]->[0];
$lowest = 0;
my $highest = $score_data->[-1]->[0];
+ &Apache::lonnet::logthis('highest = '.$highest);
my $binsize = 1;
if ($highest > 50) { $binsize = 2; }
if ($highest > 100) { $binsize = 5; }
@@ -162,19 +178,23 @@ sub AnalyzeScoreData {
my @Bins = &bin_data($score_data,$binsize,$lowest,$highest);
my @Xdata; my @Ydata; my $max;
my $Str = ''."\n".'Range | Count |
'."\n";
+ my $sum = 0;
while (my $bin = shift(@Bins)) {
push (@Xdata,$bin->{'start'});
push (@Ydata,$bin->{'count'});
+ $sum += $bin->{'count'};
if ($bin->{'count'} > $max) {
$max = $bin->{'count'};
}
$Str.= ''.$bin->{'start'}.' - '.$bin->{'end'}.' | '.
''.$bin->{'count'}.' |
'."\n";
}
- my $title = '';
+ # scale max to an integer.
+ $max = 5*(int($max/5)+1);
$Str .= "
\n";
- $Str = "
\n".&Apache::loncommon::DrawBarGraph($title,
- 'Num Correct Problems',
+ $title = &HTML::Entities::decode($title);
+ $Str = "
\n".&Apache::loncommon::DrawBarGraph($title.' N = '.$sum,
+ 'Num Correct Problems (max:'.$total_parts.')',
'Number of students',
$max,
undef, # colors
@@ -217,10 +237,10 @@ sub bin_data {
my @Bins;
my $count=0;
my $idx=0;
- while ($idx < scalar(@$data) && ($binend-$endbin)<$binsize) {
+ while ($idx < scalar(@$data) && ($endbin-$binend + $binsize)>0) {
my $dataset = $data->[$idx++];
my ($x,$y) = @{$dataset};
- while ($x > $binend) {
+ while ($x > ($binend-.001)) {
# store the old data
push (@Bins,{ start => $binstart,
count => $count,
@@ -232,6 +252,11 @@ sub bin_data {
}
$count+=$y;
}
+ if ($count > 0) {
+ push (@Bins,{ start => $binstart,
+ count => $count,
+ end => $binend });
+ }
return @Bins;
}
@@ -254,11 +279,15 @@ sub CreateInterface {
##
## Environment variable initialization
my $Str;
+ $Str .= &Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Correct Problems Plot');
$Str .= ''."\n";
$Str .= '';
$Str .= ''.&mt('Sections').' | ';
$Str .= ''.&mt('Enrollment Status').' | ';
$Str .= ''.&mt('Sequences and Folders').' | ';
+ $Str .= ''.
+ &Apache::lonstathelpers::limit_by_time_form().' | ';
$Str .= '
'."\n";
##
##
@@ -280,7 +309,8 @@ sub CreateInterface {
};
$Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
$only_seq_with_assessments);
- $Str .= ''."\n";
+ $Str .= ' | ';
+ #
##
$Str .= ''."\n";
$Str .= '
'."\n";