# The LearningOnline Network with CAPA # # $Id: loncorrectproblemplot.pm,v 1.28.2.1 2012/05/12 03:07:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # package Apache::loncorrectproblemplot; use strict; use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::loncoursedata(); use Apache::lonstatistics; use Apache::lonstathelpers; use Apache::lonlocal; my @SubmitButtons = ( { name => 'CreatePlot', text => 'Create Plot' }, ); ######################################################### ######################################################### =pod =item &BuildCorrectProblemsPage Entry point from lonstatistics to the correct problems plot page. =cut ######################################################### ######################################################### sub BuildCorrectProblemsPage { my ($r,$c)=@_; # my %Saveable_Parameters = ('Status' => 'scalar', 'Section' => 'array', 'Groups' => 'array'); &Apache::loncommon::store_course_settings('correct_problems_plot', \%Saveable_Parameters); &Apache::loncommon::restore_course_settings('correct_problems_plot', \%Saveable_Parameters); # &Apache::lonstatistics::PrepareClasslist(); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Correct Problems Plot')); # $r->print(&CreateInterface()); # my @Students = @Apache::lonstatistics::Students; # if (@Students < 1) { $r->print('
'. &Apache::lonstatistics::section_and_enrollment_description(). '
'); 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::get_selected_sections()], [&Apache::lonstatistics::get_selected_groups()], \@ProblemSymbs, $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; } ######################################################### ######################################################### =pod =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,$title,$maximum) = @_; # # Basic check first if (ref($score_data) ne 'ARRAY' || @$score_data < 1) { return ''.&mt('There is no data to plot').'
'; } # # Determine which bins to use my $lowest = $score_data->[0]->[0]; $lowest = 0; my $highest = $score_data->[-1]->[0]; my $binsize = 1; if ($highest > 50) { $binsize = 2; } if ($highest > 100) { $binsize = 5; } if ($highest > 200) { $binsize = 10; } if ($highest > 500) { $binsize = 20; } if ($highest > 1000) { $binsize = 50; } if ($highest > 2000) { $binsize = 100; } # # 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 = ''. &mt('Problem weights do not reflect individual student settings.') .'
'. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). '".
&Apache::loncommon::DrawBarGraph($title.' ('.$sum.' students)',
'Correct Problems (max possible = '.$maximum.')',
'Number of students',
$max,undef, # colors
\@Xdata,\@Ydata).
"\n
\n".$Str;
$Str .= '
'; # $Str .= &Apache::loncommon::start_data_table(); $Str .= &Apache::loncommon::start_data_table_header_row(); $Str .= '