--- loncom/interface/statistics/loncorrectproblemplot.pm 2004/02/02 21:45:12 1.1
+++ loncom/interface/statistics/loncorrectproblemplot.pm 2005/03/07 20:12:08 1.16
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncorrectproblemplot.pm,v 1.1 2004/02/02 21:45:12 matthew Exp $
+# $Id: loncorrectproblemplot.pm,v 1.16 2005/03/07 20:12:08 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,24 +35,26 @@ use Apache::loncoursedata();
use Apache::lonstatistics;
use Apache::lonstathelpers;
use Apache::lonlocal;
-use HTML::Entities();
-use Time::Local();
-use Spreadsheet::WriteExcel();
-
-my $plotcolors = ['#33ff00',
- '#ff33cc', '#990000', '#aaaa66', '#663399', '#ff9933',
- '#66ccff', '#ff9999', '#cccc33', '#660000', '#33cc66',
- ];
my @SubmitButtons = (
{ name => 'CreatePlot',
text => 'Create Plot' },
- { name => 'ClearCache',
- text => 'Clear Caches' },
- { name => 'updatecaches',
- text => 'Update Student Data' },
);
+#########################################################
+#########################################################
+
+=pod
+
+=item &BuildCorrectProblemsPage
+
+Entry point from lonstatistics to the correct problems plot page.
+
+=cut
+
+#########################################################
+#########################################################
+
sub BuildCorrectProblemsPage {
my ($r,$c)=@_;
#
@@ -65,7 +67,6 @@ sub BuildCorrectProblemsPage {
#
&Apache::lonstatistics::PrepareClasslist();
#
- $r->print('
'.&mt('Number of Correct Problems Plot').'
');
$r->print(&CreateInterface());
#
my @Students = @Apache::lonstatistics::Students;
@@ -76,44 +77,67 @@ sub BuildCorrectProblemsPage {
'');
}
#
- &Apache::loncoursedata::clear_internal_caches();
- if (exists($ENV{'form.ClearCache'}) ||
- exists($ENV{'form.updatecaches'}) ||
- (exists($ENV{'form.firstanalysis'}) &&
- $ENV{'form.firstanalysis'} ne 'no')) {
- &Apache::lonstatistics::Gather_Full_Student_Data($r);
- }
- if (! exists($ENV{'form.firstanalysis'})) {
- $r->print('');
- } else {
- $r->print('');
- }
+ my @CacheButtonHTML =
+ &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status');
foreach my $button (@SubmitButtons) {
$r->print('{'text'}).'" />');
$r->print(' 'x5);
}
+ foreach my $html (@CacheButtonHTML) {
+ $r->print($html.(' 'x5));
+ }
$r->rflush();
#
# Determine which problem symbs we are to sum over
if (exists($ENV{'form.CreatePlot'})) {
my @ProblemSymbs;
- if ($Apache::lonstatistics::SelectedMaps[0] ne 'all') {
- foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()){
- foreach my $res (@{$seq->{'contents'}}) {
- next if ($res->{'type'} ne 'assessment');
- foreach my $part (@{$res->{'parts'}}) {
- push(@ProblemSymbs,{symb=>$res->{'symb'},
- part=>$part});
- }
+ my $total_weights = 0;
+ my $title = '';
+ my @maps = &Apache::lonstatistics::get_selected_maps('Maps');
+ my ($navmap,@sequences) =
+ &Apache::lonstatistics::selected_sequences_with_assessments();
+ if ($maps[0] ne 'all') {
+ foreach my $seq (@sequences) {
+ if ($title eq '') {
+ $title = $seq->compTitle;
+ } else {
+ $title = 'Multiple Sequences';
}
}
+ } else {
+ $title = 'All Problems';
}
+ foreach my $seq (@sequences) {
+ my @resources =
+ &Apache::lonstathelpers::get_resources($navmap,$seq);
+ foreach my $res (@resources) {
+ foreach my $partid (@{$res->parts}) {
+ push(@ProblemSymbs,{symb=>$res->symb,
+ part=>$partid});
+ $total_weights +=
+ &Apache::lonnet::EXT('resource.'.$partid.'.weight',
+ $res->symb,
+ undef,undef,undef);
+ }
+ }
+ }
+ 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)));
+ }
+ &Apache::loncoursedata::populate_weight_table();
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_weights));
+ } else {
+ $r->print('
'.&mt('Make a sequence selection from the "Sequences and Folders" menu and hit "Create Plot" to begin').'
');
}
return;
}
@@ -123,18 +147,21 @@ sub BuildCorrectProblemsPage {
=pod
-=item
+=item & AnalyzeScoreData($score_data)
+
+Analyze the result of &Apache::loncoursedata::get_student_scores() and
+return html with a plot of the data and a table of the values and bins.
=cut
#########################################################
#########################################################
sub AnalyzeScoreData {
- my ($score_data) = @_;
+ my ($score_data,$title,$maximum) = @_;
#
# Basic check first
- if (@$score_data < 1) {
- return '
There is no data to plot
';
+ if (ref($score_data) ne 'ARRAY' || @$score_data < 1) {
+ return '
'.&mt('There is no data to plot').'
';
}
#
# Determine which bins to use
@@ -152,26 +179,34 @@ sub AnalyzeScoreData {
# Get the data into the bins (destroying $score_data in the process)
my @Bins = &bin_data($score_data,$binsize,$lowest,$highest);
my @Xdata; my @Ydata; my $max;
- my $Str = '
'."\n".'
Range
Count
'."\n";
+ my $Str =
+ '
'.
+ &mt('Problem weights do not reflect individual student settings.')
+ .'