--- loncom/interface/statistics/lonproblemstatistics.pm 2003/09/29 16:20:18 1.59 +++ loncom/interface/statistics/lonproblemstatistics.pm 2004/03/23 20:08:58 1.72 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemstatistics.pm,v 1.59 2003/09/29 16:20:18 matthew Exp $ +# $Id: lonproblemstatistics.pm,v 1.72 2004/03/23 20:08:58 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,12 +51,14 @@ package Apache::lonproblemstatistics; use strict; use Apache::lonnet(); +use Apache::loncommon(); use Apache::lonhtmlcommon; use Apache::loncoursedata; use Apache::lonstatistics; use Apache::lonlocal; use Spreadsheet::WriteExcel; - +use Apache::lonstathelpers(); +use Time::HiRes; ## ## Localization notes: ## @@ -146,7 +148,7 @@ my @Fields = ( title => '#YES', align => 'right', color => '#FFDDDD', - format => '%d', + format => '%4.1f',# format => '%d', sortable => 'yes', graphable => 'yes', long_title => 'Number of Students able to Solve' }, @@ -154,7 +156,7 @@ my @Fields = ( title => '#yes', align => 'right', color => '#FFDDDD', - format => '%d', + format => '%4.1f',# format => '%d', sortable => 'yes', graphable => 'yes', long_title => 'Number of Students given Override' }, @@ -166,6 +168,15 @@ my @Fields = ( sortable => 'yes', graphable => 'yes', long_title => 'Percent of students whose final answer is wrong' }, + { name => 'deg_of_disc', + title => 'Deg of Disc', + align => 'right', + color => '#FFFFE6', + format => '%4.2f', + sortable => 'yes', + graphable => 'yes', + long_title => 'Degree of Discrimination' }, + ); ############################################### @@ -184,19 +195,19 @@ select sections, maps, and output. ############################################### my @OutputOptions = ( - { name => 'problem statistics grouped by sequence', + { name => 'grouped by sequence', value => 'HTML problem statistics grouped', description => 'Output statistics for the problem parts.', mode => 'html', show => 'grouped', }, - { name => 'problem statistics ungrouped', + { name => 'ungrouped', value => 'HTML problem statistics ungrouped', description => 'Output statistics for the problem parts.', mode => 'html', show => 'ungrouped', }, - { name => 'problem statistics, Excel', + { name => 'Excel', value => 'Excel problem statistics', description => 'Output statistics for the problem parts '. 'in an Excel workbook', @@ -207,12 +218,16 @@ my @OutputOptions = sub CreateInterface { my $Str = ''; + $Str .= &Apache::lonhtmlcommon::breadcrumbs + (undef,'Overall Problem Statistics','Statistics_Overall_Key'); $Str .= '
'.&mt('Sections').' | '; $Str .= ''.&mt('Enrollment Status').' | '; $Str .= ''.&mt('Sequences and Folders').' | '; $Str .= ''.&mt('Output').' | '; + $Str .= ''. + &Apache::lonstathelpers::limit_by_time_form().' | '; $Str .= '
'."\n";
@@ -265,6 +280,20 @@ Main interface to problem statistics.
sub BuildProblemStatisticsPage {
my ($r,$c)=@_;
#
+ my %Saveable_Parameters = ('Status' => 'scalar',
+ 'statsoutputmode' => 'scalar',
+ 'Section' => 'array',
+ 'StudentData' => 'array',
+ 'Maps' => 'array');
+ &Apache::loncommon::store_course_settings('statistics',
+ \%Saveable_Parameters);
+ &Apache::loncommon::restore_course_settings('statistics',
+ \%Saveable_Parameters);
+ #
+ &Apache::lonstatistics::PrepareClasslist();
+ #
+ &Apache::loncoursedata::populate_weight_table();
+ #
my ($interface,$output_mode,$show) = &CreateInterface();
$r->print($interface);
$r->print('');
@@ -282,7 +311,16 @@ sub BuildProblemStatisticsPage {
$r->print("". $ENV{'course.'.$ENV{'request.course.id'}.'.description'}. "\n"); - $r->print("".localtime(time).""); + 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)). + ''); + } + $r->print("".&mt('Compiled on [_1]', + &Apache::lonlocal::locallocaltime(time)).""); $r->rflush(); if ($show eq 'grouped') { &output_html_grouped_by_sequence($r); @@ -488,6 +526,8 @@ sub output_excel { $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. time.'_'.rand(1000000000).'.xls'; # + my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); + # my $excel_workbook = undef; my $excel_sheet = undef; # @@ -517,7 +557,9 @@ sub output_excel { if (length($sheetname) > 31) { $sheetname = substr($sheetname,0,31); } - $excel_sheet = $excel_workbook->addworksheet($sheetname); + $excel_sheet = $excel_workbook->addworksheet( + &Apache::loncommon::clean_excel_name($sheetname) + ); # # Put the course description in the header $excel_sheet->write($rows_output,$cols_output++, @@ -544,6 +586,22 @@ sub output_excel { $excel_sheet->write($rows_output,$cols_output++,$sectionstring); $cols_output += scalar(@Sections); # + # Time restrictions + my $time_string; + if (defined($starttime)) { + # call localtime but not lonlocal:locallocaltime because excel probably + # cannot handle localized text. Probably. + $time_string .= 'Data collected from '.localtime($time_string); + if (defined($endtime)) { + $time_string .= ' to '.localtime($endtime); + } + $time_string .= '.'; + } elsif (defined($endtime)) { + # See note above about lonlocal:locallocaltime + $time_string .= 'Data collected before '.localtime($endtime).'.'; + } + + # # Put the date in there too $excel_sheet->write($rows_output,$cols_output++, 'Compiled on '.localtime(time)); @@ -751,8 +809,13 @@ sub plot_statistics { } } - $r->print("".&DrawGraph(\@Data,$title,'Problem Number',$yaxis, - $Max)." \n"); + $r->print("".&Apache::loncommon::DrawBarGraph($title, + 'Problem Number', + $yaxis, + $Max, + undef, # colors + undef, # labels + \@Data)." \n"); # # Print out the data $ENV{'form.sortby'} = 'Contents'; @@ -760,50 +823,36 @@ sub plot_statistics { return; } -############################################### -############################################### +######################################################## +######################################################## -=pod +=pod -=item &DrawGraph() +=item &get_statistics() -=cut +Wrapper routine from the call to loncoursedata::get_problem_statistics. +Calls lonstathelpers::get_time_limits() to limit the data set by time. -############################################### -############################################### -sub DrawGraph { - my ($values,$title,$xaxis,$yaxis,$Max)=@_; - $title = '' if (! defined($title)); - $xaxis = '' if (! defined($xaxis)); - $yaxis = '' if (! defined($yaxis)); - $title = &Apache::lonnet::escape($title); - $xaxis = &Apache::lonnet::escape($xaxis); - $yaxis = &Apache::lonnet::escape($yaxis); - # - my $sendValues = join(',', @$values); - my $sendCount = scalar(@$values); - $Max =1 if ($Max < 1); - if ( int($Max) < $Max ) { - $Max++; - $Max = int($Max); - } - my @GData = ($title,$xaxis,$yaxis,$Max,$sendCount,$sendValues); - return '![]() |