--- loncom/interface/statistics/lonproblemstatistics.pm 2005/04/07 06:56:24 1.104
+++ loncom/interface/statistics/lonproblemstatistics.pm 2009/01/20 16:38:44 1.116
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemstatistics.pm,v 1.104 2005/04/07 06:56:24 albertel Exp $
+# $Id: lonproblemstatistics.pm,v 1.116 2009/01/20 16:38:44 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,6 +60,8 @@ use Apache::lonlocal;
use Spreadsheet::WriteExcel;
use Apache::lonstathelpers();
use Time::HiRes;
+use LONCAPA;
+
my @StatsArray;
my %SeqStat; # keys are symbs, values are hash refs
@@ -575,7 +577,7 @@ sub parse_field_selection {
}
sub field_selection_input {
- my $Str = ''."\n";
+ my $Str = ''."\n";
$Str .= 'all '."\n";
foreach my $field (@Fields) {
next if ($field->{'selectable'} ne 'yes');
@@ -608,39 +610,51 @@ sub CreateInterface {
&parse_field_selection();
#
my $Str = '';
- $Str .= &Apache::lonhtmlcommon::breadcrumbs
- (undef,'Overall Problem Statistics','Statistics_Overall_Key');
- $Str .= ''."\n";
- $Str .= '';
- $Str .= ''.&mt('Sections').' ';
- $Str .= ''.&mt('Enrollment Status').' ';
- $Str .= ''.&mt('Sequences and Folders').' ';
- $Str .= ''.&mt('Statistics').' ';
- $Str .= ''.
- &Apache::lonstathelpers::limit_by_time_form().' ';
- $Str .= ' '."\n";
+ $Str .= &Apache::lonhtmlcommon::breadcrumbs('Overall Problem Statistics',
+ 'Statistics_Overall_Key');
+ $Str .= '';
+ $Str .= &Apache::loncommon::start_data_table();
+ $Str .= &Apache::loncommon::start_data_table_header_row();
+ $Str .= '
'.&mt('Sections').' ';
+ $Str .= ''.&mt('Groups').' ';
+ $Str .= ''.&mt('Access Status').' ';
+ $Str .= ''.&mt('Sequences and Folders').' ';
+ $Str .= ''.&mt('Statistics').' ';
+ $Str .= ''.&mt('Plot Graph').' ';
+ $Str .= ''.&mt('Time Period').' ';
+ $Str .= &Apache::loncommon::end_data_table_header_row();
#
- $Str .= ''."\n";
+ $Str .= &Apache::loncommon::start_data_table_row();
+ $Str .= ' '."\n";
$Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
- $Str .= ' ';
+ $Str .= ' ';
+ $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
+ $Str .= ' ';
$Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
- $Str .= ' ';
+ $Str .= ' ';
#
$Str .= &Apache::lonstatistics::map_select('Maps','multiple,all',5);
- $Str .= ' '.&field_selection_input();
- $Str .= ' '."\n";
- $Str .= '
'."\n";
- #
- $Str .= ''.&mt('Status: [_1]',
- ' '
- ).
- '
';
+ $Str .= '';
+ $Str .= &field_selection_input();
+ $Str .= ' ';
+ $Str .= &plot_dropdown();
+ $Str .= ' '."\n";
+ $Str .= '';
+ $Str .= &Apache::lonstathelpers::limit_by_time_form();
+ $Str .= ' '."\n";
+ $Str .= &Apache::loncommon::end_data_table_row();
+ $Str .= &Apache::loncommon::end_data_table();
+ #
+ $Str .= ''
+ .&mt('Status: [_1]',
+ ' ')
+ .'
';
#
+ $Str .= '
';
$Str .= ' ';
- $Str .= ' 'x5;
- $Str .= 'Plot '.&plot_dropdown().(' 'x10);
+ $Str .= (' 'x10);
#
return $Str;
}
@@ -661,6 +675,11 @@ Main interface to problem statistics.
my $navmap;
my @sequences;
+sub clean_up {
+ undef($navmap);
+ undef(@sequences);
+}
+
sub BuildProblemStatisticsPage {
my ($r,$c)=@_;
undef($navmap);
@@ -669,6 +688,7 @@ sub BuildProblemStatisticsPage {
my %Saveable_Parameters = ('Status' => 'scalar',
'statsoutputmode' => 'scalar',
'Section' => 'array',
+ 'Groups' => 'array',
'StudentData' => 'array',
'Maps' => 'array',
'fieldselections'=> 'array');
@@ -703,8 +723,9 @@ sub BuildProblemStatisticsPage {
''.
&mt('It may take some time to update the student data '.
'for the first analysis. Future analysis this session '.
- ' will not have this delay.').
+ 'will not have this delay.').
'
');
+ &clean_up();
return;
}
$r->rflush();
@@ -716,8 +737,9 @@ sub BuildProblemStatisticsPage {
($navmap,@sequences) =
&Apache::lonstatistics::selected_sequences_with_assessments();
if (! ref($navmap)) {
- $r->print(''.&mt('A course-wide error occured.').' '.
+ $r->print(''.&mt('A course-wide error occurred.').'
'.
''.$navmap.' ');
+ &clean_up();
return;
}
if (exists($env{'form.Excel'})) {
@@ -765,6 +787,7 @@ sub BuildProblemStatisticsPage {
&output_sequence_statistics($r);
}
}
+ &clean_up();
return;
}
@@ -1302,6 +1325,7 @@ sub Excel_output {
&Apache::lonstatistics::section_and_enrollment_description('plaintext'),
$format->{'h3'});
$cols_output += scalar(&Apache::lonstatistics::get_selected_sections());
+ $cols_output += scalar(&Apache::lonstatistics::get_selected_groups());
#
# Time restrictions
my $time_string;
@@ -1543,6 +1567,7 @@ sub get_statistics {
#
my $data = &Apache::loncoursedata::get_problem_statistics
([&Apache::lonstatistics::get_selected_sections()],
+ [&Apache::lonstatistics::get_selected_groups()],
$Apache::lonstatistics::enrollment_status,
$symb,$part,$courseid,$starttime,$endtime);
$data->{'symb'} = $symb;
@@ -1551,7 +1576,7 @@ sub get_statistics {
$data->{'container'} = $sequence->compTitle;
$data->{'title'} = $resource->compTitle;
$data->{'title.link'} = $resource->src.'?symb='.
- &Apache::lonnet::escape($resource->symb);
+ &escape($resource->symb);
#
if ($SelectedFields{'deg_of_disc'}) {
$data->{'deg_of_disc'} =
@@ -1569,7 +1594,7 @@ sub get_statistics {
$data->{'urlres'}=$urlres;
my %storestats =
&LONCAPA::lonmetadata::dynamic_metadata_storage($data);
- my ($dom,$user) = $urlres=~/^(\w+)\/(\w+)/;
+ my ($dom,$user) = ($urlres=~m{^($LONCAPA::domain_re)/($LONCAPA::username_re)});
&Apache::lonnet::put('nohist_resevaldata',\%storestats,$dom,$user);
}
#
@@ -1577,16 +1602,16 @@ sub get_statistics {
($data->{'num_solved'}+0.1);
#
# Get the due date for research purposes (commented out most of the time)
-# $data->{'duedate'} =
-# &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb);
-# $data->{'opendate'} =
-# &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb);
-# $data->{'maxtries'} =
-# &Apache::lonnet::EXT('resource.'.$part.'.maxtries',$symb);
-# $data->{'hinttries'} =
-# &Apache::lonnet::EXT('resource.'.$part.'.hinttries',$symb);
- $data->{'weight'} =
- &Apache::lonnet::EXT('resource.'.$part.'.weight',$symb);
+# my $duedate = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb);;
+# my $opendate = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb);
+# my $maxtries = &Apache::lonnet::EXT('resource.'.$part.'.maxtries',$symb);
+# my $hinttries = &Apache::lonnet::EXT('resource.'.$part.'.hinttries',$symb);
+ my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',$symb);
+ $data->{'weight'} = $weight;
+# $data->{'duedate'} = $duedate;
+# $data->{'opendate'} = $opendate;
+# $data->{'maxtries'} = $maxtries;
+# $data->{'hinttries'} = $hinttries;
# $data->{'resptypes'} = join(',',@{$resource->{'partdata'}->{$part}->{'ResponseTypes'}});
return $data;
}
@@ -1621,8 +1646,9 @@ sub compute_discrimination_factor {
&Apache::loncoursedata::rank_students_by_scores_on_resources
(\@Resources,
[&Apache::lonstatistics::get_selected_sections()],
+ [&Apache::lonstatistics::get_selected_groups()],
$Apache::lonstatistics::enrollment_status,undef,
- $starttime,$endtime);
+ $starttime,$endtime, $symb);
#
# compute their percent scores on the problems in the sequence,
my $number_to_grab = int(scalar(@{$ranking})/4);
@@ -1632,7 +1658,7 @@ sub compute_discrimination_factor {
my @TopSet =
map {
$_->[&Apache::loncoursedata::RNK_student()];
- } @{$ranking}[($num_students-$number_to_grab)..($num_students-1)];
+ } @{$ranking}[-$number_to_grab..0];
if (! @BottomSet || (@BottomSet == 1 && $BottomSet[0] eq '') ||
! @TopSet || (@TopSet == 1 && $TopSet[0] eq '')) {
return 'nan';
@@ -1686,6 +1712,7 @@ sub compute_sequence_statistics {
my ($smin,$smax,$sMean,$sSTD,$scount,$sMAX) =
&Apache::loncoursedata::score_stats
([&Apache::lonstatistics::get_selected_sections()],
+ [&Apache::lonstatistics::get_selected_groups()],
$Apache::lonstatistics::enrollment_status,
\@Resources,$starttime,$endtime,undef);
$SeqStat{$symb}->{'title'} = $seq->compTitle;
@@ -1701,6 +1728,7 @@ sub compute_sequence_statistics {
my ($cmin,$cmax,$cMean,$cSTD,$ccount)=
&Apache::loncoursedata::count_stats
([&Apache::lonstatistics::get_selected_sections()],
+ [&Apache::lonstatistics::get_selected_groups()],
$Apache::lonstatistics::enrollment_status,
\@Resources,$starttime,$endtime,undef);
my $K = $part_count;