version 1.66, 2004/02/03 20:44:06
|
version 1.72, 2004/03/23 20:08:58
|
Line 57 use Apache::loncoursedata;
|
Line 57 use Apache::loncoursedata;
|
use Apache::lonstatistics; |
use Apache::lonstatistics; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Spreadsheet::WriteExcel; |
use Spreadsheet::WriteExcel; |
|
use Apache::lonstathelpers(); |
|
use Time::HiRes; |
## |
## |
## Localization notes: |
## Localization notes: |
## |
## |
Line 167 my @Fields = (
|
Line 168 my @Fields = (
|
sortable => 'yes', |
sortable => 'yes', |
graphable => 'yes', |
graphable => 'yes', |
long_title => 'Percent of students whose final answer is wrong' }, |
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' }, |
|
|
); |
); |
|
|
############################################### |
############################################### |
Line 185 select sections, maps, and output.
|
Line 195 select sections, maps, and output.
|
############################################### |
############################################### |
my @OutputOptions = |
my @OutputOptions = |
( |
( |
{ name => 'problem statistics grouped by sequence', |
{ name => 'grouped by sequence', |
value => 'HTML problem statistics grouped', |
value => 'HTML problem statistics grouped', |
description => 'Output statistics for the problem parts.', |
description => 'Output statistics for the problem parts.', |
mode => 'html', |
mode => 'html', |
show => 'grouped', |
show => 'grouped', |
}, |
}, |
{ name => 'problem statistics ungrouped', |
{ name => 'ungrouped', |
value => 'HTML problem statistics ungrouped', |
value => 'HTML problem statistics ungrouped', |
description => 'Output statistics for the problem parts.', |
description => 'Output statistics for the problem parts.', |
mode => 'html', |
mode => 'html', |
show => 'ungrouped', |
show => 'ungrouped', |
}, |
}, |
{ name => 'problem statistics, Excel', |
{ name => 'Excel', |
value => 'Excel problem statistics', |
value => 'Excel problem statistics', |
description => 'Output statistics for the problem parts '. |
description => 'Output statistics for the problem parts '. |
'in an Excel workbook', |
'in an Excel workbook', |
Line 208 my @OutputOptions =
|
Line 218 my @OutputOptions =
|
|
|
sub CreateInterface { |
sub CreateInterface { |
my $Str = ''; |
my $Str = ''; |
$Str .= '<h2>Overall Problem Statistics'. |
$Str .= &Apache::lonhtmlcommon::breadcrumbs |
&Apache::loncommon::help_open_topic('Statistics_Overall_Key'). |
(undef,'Overall Problem Statistics','Statistics_Overall_Key'); |
'</h2>'."\n"; |
|
$Str .= '<table cellspacing="5">'."\n"; |
$Str .= '<table cellspacing="5">'."\n"; |
$Str .= '<tr>'; |
$Str .= '<tr>'; |
$Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Output').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Output').'</b></td>'; |
|
$Str .= '<td rowspan="2">'. |
|
&Apache::lonstathelpers::limit_by_time_form().'</td>'; |
$Str .= '</tr>'."\n"; |
$Str .= '</tr>'."\n"; |
# |
# |
$Str .= '<tr><td align="center">'."\n"; |
$Str .= '<tr><td align="center">'."\n"; |
Line 281 sub BuildProblemStatisticsPage {
|
Line 292 sub BuildProblemStatisticsPage {
|
# |
# |
&Apache::lonstatistics::PrepareClasslist(); |
&Apache::lonstatistics::PrepareClasslist(); |
# |
# |
|
&Apache::loncoursedata::populate_weight_table(); |
|
# |
my ($interface,$output_mode,$show) = &CreateInterface(); |
my ($interface,$output_mode,$show) = &CreateInterface(); |
$r->print($interface); |
$r->print($interface); |
$r->print('<input type="hidden" name="statsfirstcall" value="no" />'); |
$r->print('<input type="hidden" name="statsfirstcall" value="no" />'); |
Line 298 sub BuildProblemStatisticsPage {
|
Line 311 sub BuildProblemStatisticsPage {
|
$r->print("<h2>". |
$r->print("<h2>". |
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}. |
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}. |
"</h2>\n"); |
"</h2>\n"); |
$r->print("<h3>".localtime(time)."</h3>"); |
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('<h3>'.&mt('Statistics on submissions from [_1] to [_2]', |
|
&Apache::lonlocal::locallocaltime($starttime), |
|
&Apache::lonlocal::locallocaltime($endtime)). |
|
'</h3>'); |
|
} |
|
$r->print("<h3>".&mt('Compiled on [_1]', |
|
&Apache::lonlocal::locallocaltime(time))."</h3>"); |
$r->rflush(); |
$r->rflush(); |
if ($show eq 'grouped') { |
if ($show eq 'grouped') { |
&output_html_grouped_by_sequence($r); |
&output_html_grouped_by_sequence($r); |
Line 504 sub output_excel {
|
Line 526 sub output_excel {
|
$ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. |
$ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. |
time.'_'.rand(1000000000).'.xls'; |
time.'_'.rand(1000000000).'.xls'; |
# |
# |
|
my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); |
|
# |
my $excel_workbook = undef; |
my $excel_workbook = undef; |
my $excel_sheet = undef; |
my $excel_sheet = undef; |
# |
# |
Line 562 sub output_excel {
|
Line 586 sub output_excel {
|
$excel_sheet->write($rows_output,$cols_output++,$sectionstring); |
$excel_sheet->write($rows_output,$cols_output++,$sectionstring); |
$cols_output += scalar(@Sections); |
$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 |
# Put the date in there too |
$excel_sheet->write($rows_output,$cols_output++, |
$excel_sheet->write($rows_output,$cols_output++, |
'Compiled on '.localtime(time)); |
'Compiled on '.localtime(time)); |
Line 783 sub plot_statistics {
|
Line 823 sub plot_statistics {
|
return; |
return; |
} |
} |
|
|
|
######################################################## |
|
######################################################## |
|
|
|
=pod |
|
|
|
=item &get_statistics() |
|
|
|
Wrapper routine from the call to loncoursedata::get_problem_statistics. |
|
Calls lonstathelpers::get_time_limits() to limit the data set by time. |
|
|
|
Inputs: $sequence, $resource, $part, $problem_num |
|
|
|
Returns: Hash reference with statistics data from |
|
loncoursedata::get_problem_statistics. |
|
|
|
=cut |
|
|
|
######################################################## |
|
######################################################## |
sub get_statistics { |
sub get_statistics { |
my ($sequence,$resource,$part,$problem_num) = @_; |
my ($sequence,$resource,$part,$problem_num) = @_; |
# |
# |
|
my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); |
my $symb = $resource->{'symb'}; |
my $symb = $resource->{'symb'}; |
my $courseid = $ENV{'request.course.id'}; |
my $courseid = $ENV{'request.course.id'}; |
# |
# |
my $data = &Apache::loncoursedata::get_problem_statistics |
my $data = &Apache::loncoursedata::get_problem_statistics |
(\@Apache::lonstatistics::SelectedSections, |
(\@Apache::lonstatistics::SelectedSections, |
$Apache::lonstatistics::enrollment_status, |
$Apache::lonstatistics::enrollment_status, |
$symb,$part,$courseid); |
$symb,$part,$courseid,$starttime,$endtime); |
$data->{'part'} = $part; |
$data->{'part'} = $part; |
$data->{'problem_num'} = $problem_num; |
$data->{'problem_num'} = $problem_num; |
$data->{'container'} = $sequence->{'title'}; |
$data->{'container'} = $sequence->{'title'}; |
Line 800 sub get_statistics {
|
Line 860 sub get_statistics {
|
$data->{'title.link'} = $resource->{'src'}.'?symb='. |
$data->{'title.link'} = $resource->{'src'}.'?symb='. |
&Apache::lonnet::escape($resource->{'symb'}); |
&Apache::lonnet::escape($resource->{'symb'}); |
# |
# |
|
$data->{'deg_of_disc'} = &compute_discrimination_factor($resource,$part,$sequence); |
return $data; |
return $data; |
} |
} |
|
|
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &compute_discrimination_factor() |
|
|
|
Inputs: $Resource, $Sequence |
|
|
|
Returns: integer between -1 and 1 |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
sub compute_discrimination_factor { |
|
my ($resource,$part,$sequence) = @_; |
|
my @Resources; |
|
foreach my $res (@{$sequence->{'contents'}}) { |
|
next if ($res->{'symb'} eq $resource->{'symb'}); |
|
push (@Resources,$res->{'symb'}); |
|
} |
|
# |
|
# rank |
|
my $ranking = |
|
&Apache::loncoursedata::rank_students_by_scores_on_resources |
|
(\@Resources, |
|
\@Apache::lonstatistics::SelectedSections, |
|
$Apache::lonstatistics::enrollment_status,undef); |
|
# |
|
# compute their percent scores on the problems in the sequence, |
|
my $number_to_grab = int(scalar(@{$ranking})/4); |
|
my $num_students = scalar(@{$ranking}); |
|
my @BottomSet = map { $_->[&Apache::loncoursedata::RNK_student()]; |
|
} @{$ranking}[0..$number_to_grab]; |
|
my @TopSet = |
|
map { |
|
$_->[&Apache::loncoursedata::RNK_student()]; |
|
} @{$ranking}[($num_students-$number_to_grab)..($num_students-1)]; |
|
my ($bottom_sum,$bottom_max) = |
|
&Apache::loncoursedata::get_sum_of_scores($resource,$part,\@BottomSet); |
|
my ($top_sum,$top_max) = |
|
&Apache::loncoursedata::get_sum_of_scores($resource,$part,\@TopSet); |
|
my $deg_of_disc; |
|
if ($top_max == 0 || $bottom_max==0) { |
|
$deg_of_disc = 'nan'; |
|
} else { |
|
$deg_of_disc = ($top_sum/$top_max) - ($bottom_sum/$bottom_max); |
|
} |
|
#&Apache::lonnet::logthis(' '.$top_sum.'/'.$top_max. |
|
# ' - '.$bottom_sum.'/'.$bottom_max); |
|
return $deg_of_disc; |
|
} |
|
|
############################################### |
############################################### |
############################################### |
############################################### |
|
|