version 1.43, 2003/03/26 16:26:35
|
version 1.78, 2004/03/29 19:50:23
|
Line 26
|
Line 26
|
# |
# |
# (Navigate problems for statistical reports |
# (Navigate problems for statistical reports |
# |
# |
### |
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=head1 NAME |
|
|
|
lonproblemstatistics |
|
|
|
=head1 SYNOPSIS |
|
|
|
Routines to present problem statistics to instructors via tables, |
|
Excel files, and plots. |
|
|
|
=over 4 |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
|
package Apache::lonproblemstatistics; |
package Apache::lonproblemstatistics; |
|
|
use strict; |
use strict; |
use Apache::lonnet(); |
use Apache::lonnet(); |
|
use Apache::loncommon(); |
use Apache::lonhtmlcommon; |
use Apache::lonhtmlcommon; |
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use Apache::lonstatistics; |
use Apache::lonstatistics; |
|
use Apache::lonlocal; |
|
use Spreadsheet::WriteExcel; |
|
use Apache::lonstathelpers(); |
|
use Time::HiRes; |
|
|
|
my @StatsArray; |
|
|
|
## |
|
## Localization notes: |
|
## |
|
## in @Fields[0]->{'long_title'} is placed in Excel files and is used as the |
|
## header for plots created with Graph.pm, both of which more than likely do |
|
## not support localization. |
|
## |
|
my @Fields = ( |
|
{ name => 'problem_num', |
|
title => 'P#', |
|
align => 'right', |
|
color => '#FFFFE6', |
|
selectable => 'no', |
|
selected => 'yes', |
|
}, |
|
{ name => 'container', |
|
title => 'Sequence or Folder', |
|
align => 'left', |
|
color => '#FFFFE6', |
|
sortable => 'yes', |
|
selectable => 'no', |
|
selected => 'yes', |
|
}, |
|
{ name => 'title', |
|
title => 'Title', |
|
align => 'left', |
|
color => '#FFFFE6', |
|
special => 'link', |
|
sortable => 'yes', |
|
selectable => 'no', |
|
selected => 'yes', |
|
}, |
|
{ name => 'part', |
|
title => 'Part', |
|
align => 'left', |
|
color => '#FFFFE6', |
|
selectable => 'no', |
|
selected => 'yes', |
|
}, |
|
{ name => 'num_students', |
|
title => '#Stdnts', |
|
align => 'right', |
|
color => '#EEFFCC', |
|
format => '%d', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Number of Students Attempting Problem', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'tries', |
|
title => 'Tries', |
|
align => 'right', |
|
color => '#EEFFCC', |
|
format => '%d', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Total Number of Tries', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'max_tries', |
|
title => 'Max Tries', |
|
align => 'right', |
|
color => '#DDFFFF', |
|
format => '%d', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Maximum Number of Tries', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'min_tries', |
|
title => 'Min Tries', |
|
align => 'right', |
|
color => '#DDFFFF', |
|
format => '%d', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Minumum Number of Tries', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'mean_tries', |
|
title => 'Mean Tries', |
|
align => 'right', |
|
color => '#DDFFFF', |
|
format => '%5.2f', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Average Number of Tries', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'std_tries', |
|
title => 'S.D. tries', |
|
align => 'right', |
|
color => '#DDFFFF', |
|
format => '%5.2f', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Standard Deviation of Number of Tries', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'skew_tries', |
|
title => 'Skew Tries', |
|
align => 'right', |
|
color => '#DDFFFF', |
|
format => '%5.2f', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Skew of Number of Tries', |
|
selectable => 'yes', |
|
selected => 'no', |
|
}, |
|
{ name => 'num_solved', |
|
title => '#YES', |
|
align => 'right', |
|
color => '#FFDDDD', |
|
format => '%4.1f',# format => '%d', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Number of Students able to Solve', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'num_override', |
|
title => '#yes', |
|
align => 'right', |
|
color => '#FFDDDD', |
|
format => '%4.1f',# format => '%d', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Number of Students given Override', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'num_wrong', |
|
title => '#Wrng', |
|
align => 'right', |
|
color => '#FFDDDD', |
|
format => '%4.1f', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Percent of students whose final answer is wrong', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'deg_of_diff', |
|
title => 'DoDiff', |
|
align => 'right', |
|
color => '#FFFFE6', |
|
format => '%5.2f', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Degree of Difficulty'. |
|
'[ 1 - ((#YES+#yes) / Tries) ]', |
|
selectable => 'yes', |
|
selected => 'yes', |
|
}, |
|
{ name => 'deg_of_disc', |
|
title => 'DoDisc', |
|
align => 'right', |
|
color => '#FFFFE6', |
|
format => '%4.2f', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Degree of Discrimination', |
|
selectable => 'yes', |
|
selected => 'no', |
|
}, |
|
); |
|
|
|
my %SelectedFields; |
|
|
|
sub parse_field_selection { |
|
# |
|
# Pull out the defaults |
|
if (! defined($ENV{'form.fieldselections'})) { |
|
$ENV{'form.fieldselections'} = []; |
|
foreach my $field (@Fields) { |
|
next if ($field->{'selectable'} ne 'yes'); |
|
if ($field->{'selected'} eq 'yes') { |
|
push(@{$ENV{'form.fieldselections'}},$field->{'name'}); |
|
} |
|
} |
|
} |
|
# |
|
# This should not happen, but in case it does... |
|
if (ref($ENV{'form.fieldselections'}) ne 'ARRAY') { |
|
$ENV{'form.fieldselections'} = [$ENV{'form.fieldselections'}]; |
|
} |
|
# |
|
# Set the field data and the selected fields (for easier checking) |
|
undef(%SelectedFields); |
|
foreach my $field (@Fields) { |
|
next if ($field->{'selectable'} ne 'yes'); |
|
$field->{'selected'} = 'no'; |
|
foreach my $selection (@{$ENV{'form.fieldselections'}}) { |
|
if ($selection eq $field->{'name'} || $selection eq 'all') { |
|
$field->{'selected'} = 'yes'; |
|
$SelectedFields{$field->{'name'}}++; |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub field_selection_input { |
|
my $Str = '<select name="fieldselections" multiple size="5">'."\n"; |
|
$Str .= '<option value="all">all</option>'."\n"; |
|
foreach my $field (@Fields) { |
|
next if ($field->{'selectable'} ne 'yes'); |
|
$Str .= ' <option value="'.$field->{'name'}.'" '; |
|
if ($field->{'selected'} eq 'yes') { |
|
$Str .= 'selected '; |
|
} |
|
$Str .= '>'.$field->{'title'}.'</option>'."\n"; |
|
} |
|
$Str .= "</select>\n"; |
|
} |
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &CreateInterface() |
|
|
|
Create the main intereface for the statistics page. Allows the user to |
|
select sections, maps, and output. |
|
|
####################################################### |
=cut |
####################################################### |
|
|
|
|
############################################### |
|
############################################### |
sub CreateInterface { |
sub CreateInterface { |
|
&parse_field_selection(); |
my $Str = ''; |
my $Str = ''; |
|
$Str .= &Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Overall Problem Statistics','Statistics_Overall_Key'); |
$Str .= '<table cellspacing="5">'."\n"; |
$Str .= '<table cellspacing="5">'."\n"; |
$Str .= '<tr>'; |
$Str .= '<tr>'; |
$Str .= '<td align="center"><b>Sections</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>'; |
$Str .= '<td align="center"><b>Sequences and Folders</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>'; |
$Str .= '<td align="center"><b>Output</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b></td>'; |
|
$Str .= '<td align="center"><b>'.&mt('Statistics').'</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"; |
$Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); |
$Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); |
$Str .= '</td><td align="center">'; |
$Str .= '</td><td align="center">'; |
|
$Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5); |
|
$Str .= '</td><td align="center">'; |
# |
# |
my $only_seq_with_assessments = sub { |
my $only_seq_with_assessments = sub { |
my $s=shift; |
my $s=shift; |
Line 62 sub CreateInterface {
|
Line 330 sub CreateInterface {
|
}; |
}; |
$Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, |
$Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, |
$only_seq_with_assessments); |
$only_seq_with_assessments); |
$Str .= '</td><td>'."\n"; |
$Str .= '</td><td>'.&field_selection_input(); |
$Str .= &CreateAndParseOutputSelector(); |
|
$Str .= '</td></tr>'."\n"; |
$Str .= '</td></tr>'."\n"; |
$Str .= '</table>'."\n"; |
$Str .= '</table>'."\n"; |
|
$Str .= '<input type="submit" name="GenerateStatistics" value="'. |
|
&mt('Generate Statistics').'" />'; |
|
$Str .= ' 'x5; |
|
$Str .= 'Plot '.&plot_dropdown().(' 'x10); |
|
$Str .= '<input type="submit" name="ClearCache" value="'. |
|
&mt('Clear Caches').'" />'; |
|
$Str .= ' 'x5; |
|
$Str .= '<input type="submit" name="UpdateCache" value="'. |
|
&mt('Update Student Data').'" />'; |
|
$Str .= ' 'x5; |
|
$Str .= '<input type="submit" name="Excel" value="'. |
|
&mt('Produce Excel Output').'" />'; |
|
$Str .= ' 'x5; |
return $Str; |
return $Str; |
} |
} |
|
|
####################################################### |
############################################### |
####################################################### |
############################################### |
|
|
=pod |
=pod |
|
|
=item &CreateAndParseOutputSelector() |
=item &BuildProblemStatisticsPage() |
|
|
=cut |
Main interface to problem statistics. |
|
|
####################################################### |
=cut |
####################################################### |
|
my $output_mode; |
|
my $show; |
|
|
|
my @OutputOptions = |
|
( |
|
{ name => 'problem statistics grouped by sequence', |
|
value => 'HTML problem statistics grouped', |
|
description => 'Output statistics for the problem parts.', |
|
mode => 'html', |
|
show => 'grouped', |
|
}, |
|
{ name => 'problem statistics ungrouped', |
|
value => 'HTML problem statistics ungrouped', |
|
description => 'Output statistics for the problem parts.', |
|
mode => 'html', |
|
show => 'ungrouped', |
|
}, |
|
{ name => 'problem statistics, Excel', |
|
value => 'Excel problem statistics', |
|
description => 'Output statistics for the problem parts '. |
|
'in an Excel workbook', |
|
mode => 'excel', |
|
show => 'all', |
|
}, |
|
{ name => 'Degree of Difficulty Plot', |
|
value => 'plot deg diff', |
|
description => 'Generate a plot of the degree of difficulty of each '. |
|
'problem part.', |
|
mode => 'plot', |
|
show => 'deg of diff', |
|
}, |
|
{ name => 'Percent Wrong Plot', |
|
value => 'plot per wrong', |
|
description => 'Generate a plot showing the percent of students who '. |
|
'were unable to complete each problem part', |
|
mode => 'plot', |
|
show => 'per wrong', |
|
}, |
|
); |
|
|
|
sub OutputDescriptions { |
############################################### |
my $Str = ''; |
############################################### |
$Str .= "<h2>Output Modes</h2>\n"; |
sub BuildProblemStatisticsPage { |
$Str .= "<dl>\n"; |
my ($r,$c)=@_; |
foreach my $outputmode (@OutputOptions) { |
# |
$Str .=" <dt>".$outputmode->{'name'}."</dt>\n"; |
my %Saveable_Parameters = ('Status' => 'scalar', |
$Str .=" <dd>".$outputmode->{'description'}."</dd>\n"; |
'statsoutputmode' => 'scalar', |
|
'Section' => 'array', |
|
'StudentData' => 'array', |
|
'Maps' => 'array', |
|
'fieldselections'=> 'array'); |
|
&Apache::loncommon::store_course_settings('statistics', |
|
\%Saveable_Parameters); |
|
&Apache::loncommon::restore_course_settings('statistics', |
|
\%Saveable_Parameters); |
|
# |
|
&Apache::lonstatistics::PrepareClasslist(); |
|
# |
|
# Clear the package variables |
|
undef(@StatsArray); |
|
# |
|
# Finally let the user know we are here |
|
my $interface = &CreateInterface(); |
|
$r->print($interface); |
|
$r->print('<input type="hidden" name="sortby" value="'.$ENV{'form.sortby'}. |
|
'" />'); |
|
# |
|
if (! exists($ENV{'form.statsfirstcall'})) { |
|
$r->print('<input type="hidden" name="statsfirstcall" value="yes" />'); |
|
$r->print('<h3>'. |
|
&mt('Press "Generate Statistics" when you are ready.'). |
|
'</h3><p>'. |
|
&mt('It may take some time to update the student data '. |
|
'for the first analysis. Future analysis this session '. |
|
' will not have this delay.'). |
|
'</p>'); |
|
return; |
|
} elsif ($ENV{'form.statsfirstcall'} eq 'yes' || |
|
exists($ENV{'form.UpdateCache'}) || |
|
exists($ENV{'form.ClearCache'}) ) { |
|
$r->print('<input type="hidden" name="statsfirstcall" value="no" />'); |
|
&Apache::lonstatistics::Gather_Student_Data($r); |
|
} else { |
|
$r->print('<input type="hidden" name="statsfirstcall" value="no" />'); |
} |
} |
$Str .= "</dl>\n"; |
$r->rflush(); |
return $Str; |
# |
} |
# This probably does not need to be done each time we are called, but |
|
# it does not slow things down noticably. |
sub CreateAndParseOutputSelector { |
&Apache::loncoursedata::populate_weight_table(); |
my $Str = ''; |
|
my $elementname = 'outputmode'; |
|
# |
# |
# Format for output options is 'mode, restrictions'; |
if (exists($ENV{'form.Excel'})) { |
my $selected = 'html, with links'; |
&Excel_output($r); |
if (exists($ENV{'form.'.$elementname})) { |
} else { |
if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) { |
my $count = 0; |
$selected = $ENV{'form.'.$elementname}->[0]; |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
|
$count += $seq->{'num_assess_parts'}; |
|
} |
|
if ($count > 10) { |
|
$r->print('<h2>'. |
|
&mt('Compiling statistics for [_1] problems',$count). |
|
'</h2>'); |
|
if ($count > 30) { |
|
$r->print('<h3>'.&mt('This will take some time.').'</h3>'); |
|
} |
|
$r->rflush(); |
|
} |
|
# |
|
my $sortby = $ENV{'form.sortby'}; |
|
$sortby = 'container' if (! defined($sortby) || $sortby =~ /^\s*$/); |
|
my $plot = $ENV{'form.plot'}; |
|
if ($plot eq '' || $plot eq 'none') { |
|
undef($plot); |
|
} |
|
if ($sortby eq 'container' && ! defined($plot)) { |
|
&output_html_by_sequence($r); |
} else { |
} else { |
$selected = $ENV{'form.'.$elementname}; |
if (defined($plot)) { |
|
&make_plot($r,$plot); |
|
} |
|
&output_html_stats($r); |
} |
} |
} |
} |
|
return; |
|
} |
|
|
|
########################################################## |
|
########################################################## |
|
## |
|
## HTML output routines |
|
## |
|
########################################################## |
|
########################################################## |
|
sub output_html_by_sequence { |
|
my ($r) = @_; |
|
my $c = $r->connection(); |
|
$r->print(&html_preamble()); |
# |
# |
# Set package variables describing output mode |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
$output_mode = 'html'; |
last if ($c->aborted); |
$show = 'all'; |
next if ($seq->{'num_assess'} < 1); |
foreach my $option (@OutputOptions) { |
$r->print("<h3>".$seq->{'title'}."</h3>". |
next if ($option->{'value'} ne $selected); |
'<table border="0"><tr><td bgcolor="#777777">'."\n". |
$output_mode = $option->{'mode'}; |
'<table border="0" cellpadding="3">'."\n". |
$show = $option->{'show'}; |
'<tr bgcolor="#FFFFE6">'. |
|
&statistics_table_header('no container')."</tr>\n"); |
|
my @Data = &compute_statistics_on_sequence($seq); |
|
foreach my $data (@Data) { |
|
$r->print('<tr>'.&statistics_html_table_data($data, |
|
'no container'). |
|
"</tr>\n"); |
|
} |
|
$r->print('</table>'."\n".'</table>'."\n"); |
|
$r->rflush(); |
} |
} |
# |
return; |
# Build the form element |
} |
$Str = qq/<select size="5" name="$elementname">/; |
|
foreach my $option (@OutputOptions) { |
sub output_html_stats { |
$Str .= "\n".' <option value="'.$option->{'value'}.'"'; |
my ($r)=@_; |
$Str .= " selected " if ($option->{'value'} eq $selected); |
&compute_all_statistics($r); |
$Str .= ">".$option->{'name'}."<\/option>"; |
$r->print(&html_preamble()); |
|
&sort_data($ENV{'form.sortby'}); |
|
# |
|
my $count=0; |
|
foreach my $data (@StatsArray) { |
|
if ($count++ % 50 == 0) { |
|
$r->print("</table>\n</table>\n"); |
|
$r->print('<table border="0"><tr><td bgcolor="#777777">'."\n". |
|
'<table border="0" cellpadding="3">'."\n". |
|
'<tr bgcolor="#FFFFE6">'. |
|
'<tr bgcolor="#FFFFE6">'. |
|
&statistics_table_header(). |
|
"</tr>\n"); |
|
} |
|
$r->print('<tr>'.&statistics_html_table_data($data)."</tr>\n"); |
} |
} |
$Str .= "\n</select>"; |
$r->print("</table>\n</table>\n"); |
|
return; |
|
} |
|
|
|
sub html_preamble { |
|
my $Str=''; |
|
$Str .= "<h2>". |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}. |
|
"</h2>\n"; |
|
my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); |
|
if (defined($starttime) || defined($endtime)) { |
|
# Inform the user what the time limits on the data are. |
|
$Str .= '<h3>'.&mt('Statistics on submissions from [_1] to [_2]', |
|
&Apache::lonlocal::locallocaltime($starttime), |
|
&Apache::lonlocal::locallocaltime($endtime) |
|
).'</h3>'; |
|
} |
|
$Str .= "<h3>".&mt('Compiled on [_1]', |
|
&Apache::lonlocal::locallocaltime(time))."</h3>"; |
return $Str; |
return $Str; |
} |
} |
|
|
|
|
############################################### |
############################################### |
############################################### |
############################################### |
|
## |
|
## Misc HTML output routines |
|
## |
############################################### |
############################################### |
############################################### |
############################################### |
sub Gather_Student_Data { |
sub statistics_html_table_data { |
my ($r) = @_; |
my ($data,$options) = @_; |
my $c = $r->connection(); |
my $row = ''; |
# |
foreach my $field (@Fields) { |
my @Sequences = &Apache::lonstatistics::Sequences_with_Assess(); |
next if ($options =~ /no $field->{'name'}/); |
# |
next if ($field->{'selected'} ne 'yes'); |
my @Students = @Apache::lonstatistics::Students; |
$row .= '<td bgcolor="'.$field->{'color'}.'"'; |
# |
if (exists($field->{'align'})) { |
# Open the progress window |
$row .= ' align="'.$field->{'align'}.'"'; |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin |
} |
($r,'Statistics Compilation Status', |
$row .= '>'; |
'Statistics Compilation Progress', scalar(@Students)); |
if (exists($field->{'special'}) && $field->{'special'} eq 'link') { |
# |
$row .= '<a href="'.$data->{$field->{'name'}.'.link'}.'">'; |
while (my $student = shift @Students) { |
} |
return if ($c->aborted()); |
if (exists($field->{'format'})) { |
my ($status,undef) = &Apache::loncoursedata::ensure_current_data |
$row .= sprintf($field->{'format'},$data->{$field->{'name'}}); |
($student->{'username'},$student->{'domain'}, |
} else { |
$ENV{'request.course.id'}); |
$row .= $data->{$field->{'name'}}; |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
} |
'last student'); |
if (exists($field->{'special'}) && $field->{'special'} eq 'link') { |
|
$row.= '</a>'; |
|
} |
|
$row .= '</td>'; |
} |
} |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
return $row; |
$r->rflush(); |
|
} |
} |
|
|
############################################### |
sub statistics_table_header { |
############################################### |
my ($options) = @_; |
|
my $header_row; |
|
foreach my $field (@Fields) { |
|
next if ($options =~ /no $field->{'name'}/); |
|
next if ($field->{'selected'} ne 'yes'); |
|
$header_row .= '<th>'; |
|
if (exists($field->{'sortable'}) && $field->{'sortable'} eq 'yes') { |
|
$header_row .= '<a href="javascript:'. |
|
'document.Statistics.sortby.value='."'".$field->{'name'}."'". |
|
';document.Statistics.submit();">'; |
|
} |
|
$header_row .= &mt($field->{'title'}); |
|
if ($options =~ /sortable/) { |
|
$header_row.= '</a>'; |
|
} |
|
if ($options !~ /no plots/ && |
|
exists($field->{'graphable'}) && |
|
$field->{'graphable'} eq 'yes') { |
|
$header_row.=' ('; |
|
$header_row .= '<a href="javascript:'. |
|
"document.Statistics.plot.value='$field->{'name'}'". |
|
';document.Statistics.submit();">'; |
|
$header_row .= &mt('plot').'</a>)'; |
|
} |
|
$header_row .= '</th>'; |
|
} |
|
return $header_row; |
|
} |
|
|
############################################### |
#################################################### |
############################################### |
#################################################### |
sub BuildProblemStatisticsPage { |
## |
my ($r,$c)=@_; |
## Plotting Routines |
# |
## |
$output_mode = 'html'; |
#################################################### |
$show = 'grouped'; |
#################################################### |
|
sub make_plot { |
|
my ($r,$plot) = @_; |
|
&compute_all_statistics($r); |
|
&sort_data($ENV{'form.sortby'}); |
|
if ($plot eq 'degrees') { |
|
°rees_plot($r); |
|
} elsif ($plot eq 'tries statistics') { |
|
&tries_data_plot($r); |
|
} else { |
|
&make_single_stat_plot($r,$plot); |
|
} |
|
return; |
|
} |
|
|
|
sub make_single_stat_plot { |
|
my ($r,$datafield) = @_; |
# |
# |
$r->print(&CreateInterface()); |
my $title; my $yaxis; |
$r->print('<input type="hidden" name="statsfirstcall" value="no" />'); |
foreach my $field (@Fields) { |
$r->print('<input type="hidden" name="sortby" value="'.$ENV{'form.sortby'}. |
next if ($field->{'name'} ne $datafield); |
'" />'); |
$title = $field->{'long_title'}; |
if (! exists($ENV{'form.statsfirstcall'})) { |
$yaxis = $field->{'title'}; |
|
last; |
|
} |
|
if ($title eq '' || $yaxis eq '') { |
|
# datafield is something we do not know enough about to plot |
|
$r->print('<h3>'. |
|
&mt('Unable to plot the requested statistic.'). |
|
'</h3>'); |
return; |
return; |
} |
} |
# |
# |
&Gather_Student_Data($r); |
# Build up the data sets to plot |
|
my @Labels; |
|
my @Data; |
|
my $max = 1; |
|
foreach my $data (@StatsArray) { |
|
push(@Labels,$data->{'problem_num'}); |
|
push(@Data,$data->{$datafield}); |
|
if ($data->{$datafield}>$max) { |
|
$max = $data->{$datafield}; |
|
} |
|
} |
|
foreach (1,2,3,4,5,10,15,20,25,40,50,75,100,150,200,250,300,500,600,750, |
|
1000,1500,2000,2500,3000,3500,4000,5000,7500,10000,15000,20000) { |
|
if ($max <= $_) { |
|
$max = $_; |
|
last; |
|
} |
|
} |
|
if ($max > 20000) { |
|
$max = 10000*(int($max/10000)+1); |
|
} |
# |
# |
|
$r->print("<p>".&Apache::loncommon::DrawBarGraph($title, |
|
'Problem Number', |
|
$yaxis, |
|
$max, |
|
undef, # colors |
|
\@Labels, |
|
\@Data)."</p>\n"); |
|
return; |
|
} |
|
|
|
sub degrees_plot { |
|
my ($r)=@_; |
|
my $count = scalar(@StatsArray); |
|
my $width = 50 + 10*$count; |
|
$width = 300 if ($width < 300); |
|
my $height = 300; |
|
my $plot = ''; |
|
my $ymax = 0; |
|
my $ymin = 0; |
|
my @Disc; my @Diff; my @Labels; |
|
foreach my $data (@StatsArray) { |
|
push(@Labels,$data->{'problem_num'}); |
|
my $disc = $data->{'deg_of_disc'}; |
|
my $diff = $data->{'deg_of_diff'}; |
|
push(@Disc,$disc); |
|
push(@Diff,$diff); |
|
# |
|
$ymin = $disc if ($ymin > $disc); |
|
$ymin = $diff if ($ymin > $diff); |
|
$ymax = $disc if ($ymax < $disc); |
|
$ymax = $diff if ($ymax < $diff); |
|
} |
|
# |
|
# Make sure we show relevant information. |
|
if ($ymin < 0) { |
|
if (abs($ymin) < 0.05) { |
|
$ymin = 0; |
|
} else { |
|
$ymin = -1; |
|
} |
|
} |
|
if ($ymax > 0) { |
|
if (abs($ymax) < 0.05) { |
|
$ymax = 0; |
|
} else { |
|
$ymax = 1; |
|
} |
|
} |
# |
# |
if ($output_mode eq 'html') { |
my $xmax = $Labels[-1]; |
$r->print("<h2>". |
if ($xmax > 50) { |
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}. |
if ($xmax % 10 != 0) { |
"</h2>\n"); |
$xmax = 10 * (int($xmax/10)+1); |
$r->print("<h3>".localtime(time)."</h3>"); |
|
$r->rflush(); |
|
if ($show eq 'grouped') { |
|
&output_html_grouped_by_sequence($r); |
|
} elsif ($show eq 'ungrouped') { |
|
&output_html_ungrouped($r); |
|
} |
} |
} else { |
} else { |
$r->print("<h1>Not implemented</h1>"); |
if ($xmax % 5 != 0) { |
|
$xmax = 5 * (int($xmax/5)+1); |
|
} |
} |
} |
|
# |
|
my $discdata .= '<data>'.join(',',@Labels).'</data>'.$/. |
|
'<data>'.join(',',@Disc).'</data>'.$/; |
|
# |
|
my $diffdata .= '<data>'.join(',',@Labels).'</data>'.$/. |
|
'<data>'.join(',',@Diff).'</data>'.$/; |
|
# |
|
$plot=<<"END"; |
|
<gnuplot |
|
texfont="10" |
|
fgcolor="x000000" |
|
plottype="Cartesian" |
|
font="large" |
|
grid="on" |
|
align="center" |
|
border="on" |
|
transparent="on" |
|
alttag="Sample Plot" |
|
samples="100" |
|
bgcolor="xffffff" |
|
height="$height" |
|
width="$width"> |
|
<key |
|
pos="top right" |
|
title="" |
|
box="off" /> |
|
<title>Degree of Discrmination and Degree of Difficulty</title> |
|
<axis xmin="0" ymin="$ymin" xmax="$xmax" ymax="$ymax" color="x000000" /> |
|
<xlabel>Problem Number</xlabel> |
|
<curve |
|
linestyle="linespoints" |
|
name="DoDisc" |
|
pointtype="0" |
|
color="x000000"> |
|
$discdata |
|
</curve> |
|
<curve |
|
linestyle="linespoints" |
|
name="DoDiff" |
|
pointtype="0" |
|
color="xFF0000"> |
|
$diffdata |
|
</curve> |
|
</gnuplot> |
|
END |
|
my $plotresult = |
|
'<p>'.&Apache::lonxml::xmlparse($r,'web',$plot).'</p>'.$/; |
|
$r->print($plotresult); |
return; |
return; |
} |
} |
|
|
sub output_html_grouped_by_sequence { |
sub tries_data_plot { |
my ($r) = @_; |
my ($r)=@_; |
#$r->print(&ProblemStatisticsLegend()); |
my $count = scalar(@StatsArray); |
my @Header = ("Title","Part","#Stdnts","Tries","Mod", |
my $width = 50 + 10*$count; |
"Mean","#YES","#yes","%Wrng","DoDiff", |
$width = 300 if ($width < 300); |
"S.D.","Skew.");#,"D.F.1st","D.F.2nd"); |
my $height = 300; |
# #FFFFE6 #EEFFCC #DDFFFF FFDDDD #DDFFDD #FFDDFF |
my $plot = ''; |
foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()) { |
my @STD; my @Mean; my @Max; my @Min; |
my $show_part = 0; |
my @Labels; |
next if ($sequence->{'num_assess'}<1); |
my $ymax = 5; |
$r->print("<h3>".$sequence->{'title'}."</h3>"); |
foreach my $data (@StatsArray) { |
$r->print('<table border="0"><tr><td bgcolor="#777777">'."\n"); |
my $max = $data->{'mean_tries'} + $data->{'std_tries'}; |
$r->print('<table border="0" cellpadding="3">'."\n"); |
$ymax = $max if ($ymax < $max); |
$r->print('<tr bgcolor="#FFFFE6"><th>'. |
$ymax = $max if ($ymax < $max); |
join("</th><th>",@Header)."</th></tr>\n"); |
push(@Labels,$data->{'problem_num'}); |
foreach my $resource (@{$sequence->{'contents'}}) { |
push(@STD,$data->{'std_tries'}); |
next if ($resource->{'type'} ne 'assessment'); |
push(@Mean,$data->{'mean_tries'}); |
foreach my $part (@{$resource->{'parts'}}) { |
} |
my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD, |
# |
$SKEW) = &Apache::loncoursedata::get_problem_statistics |
# Make sure we show relevant information. |
(undef,$resource->{'symb'},$part, |
my $xmax = $Labels[-1]; |
$ENV{'request.course.id'}); |
if ($xmax > 50) { |
# |
if ($xmax % 10 != 0) { |
$show_part = 1 if ($part ne '0'); |
$xmax = 10 * (int($xmax/10)+1); |
$part = ' ' if ($part == 0); |
} |
# |
} else { |
my $wrongpercent = 0; |
if ($xmax % 5 != 0) { |
if (defined($num) && $num > 0) { |
$xmax = 5 * (int($xmax/5)+1); |
$wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10; |
|
} |
|
$r->print('<tr>'.&statistics_html_table_data |
|
($resource,$part,$num,$tries,$mod,$mean,$Solved, |
|
$solved,$wrongpercent,$DegOfDiff,$STD,$SKEW, |
|
$show_part). |
|
"</tr>\n"); |
|
} |
|
} |
} |
$r->print("</table>\n"); |
|
$r->print("</td></tr></table>\n"); |
|
$r->rflush(); |
|
} |
} |
|
$ymax = int($ymax)+1+2; |
|
# |
|
my $std_data .= '<data>'.join(',',@Labels).'</data>'.$/. |
|
'<data>'.join(',',@Mean).'</data>'.$/; |
# |
# |
|
my $std_error_data .= '<data>'.join(',',@Labels).'</data>'.$/. |
|
'<data>'.join(',',@Mean).'</data>'.$/. |
|
'<data>'.join(',',@STD).'</data>'.$/; |
|
# |
|
$plot=<<"END"; |
|
<gnuplot |
|
texfont="10" |
|
fgcolor="x000000" |
|
plottype="Cartesian" |
|
font="large" |
|
grid="on" |
|
align="center" |
|
border="on" |
|
transparent="on" |
|
alttag="Sample Plot" |
|
samples="100" |
|
bgcolor="xffffff" |
|
height="$height" |
|
width="$width"> |
|
<title>Mean and S.D. of Tries</title> |
|
<axis xmin="0" ymin="0" xmax="$xmax" ymax="$ymax" color="x000000" /> |
|
<xlabel>Problem Number</xlabel> |
|
<curve |
|
linestyle="yerrorbars" |
|
name="S.D. Tries" |
|
pointtype="1" |
|
color="x666666"> |
|
$std_error_data |
|
</curve> |
|
<curve |
|
linestyle="points" |
|
name="Mean Tries" |
|
pointtype="1" |
|
color="xCC4444"> |
|
$std_data |
|
</curve> |
|
</gnuplot> |
|
END |
|
my $plotresult = |
|
'<p>'.&Apache::lonxml::xmlparse($r,'web',$plot).'</p>'.$/; |
|
$r->print($plotresult); |
return; |
return; |
} |
} |
|
|
|
sub plot_dropdown { |
|
my $current = ''; |
|
# |
|
if (defined($ENV{'form.plot'})) { |
|
$current = $ENV{'form.plot'}; |
|
} |
|
# |
|
my @Additional_Plots = ( |
|
{ graphable=>'yes', |
|
name => 'degrees', |
|
title => 'DoDisc and DoDiff' }, |
|
{ graphable=>'yes', |
|
name => 'tries statistics', |
|
title => 'Mean and S.D. of Tries' }); |
|
# |
|
my $Str= "\n".'<select name="plot" size="1">'; |
|
$Str .= '<option name="none"></option>'."\n"; |
|
$Str .= '<option name="none2">none</option>'."\n"; |
|
foreach my $field (@Fields,@Additional_Plots) { |
|
if (! exists($field->{'graphable'}) || |
|
$field->{'graphable'} ne 'yes') { |
|
next; |
|
} |
|
$Str .= '<option value="'.$field->{'name'}.'"'; |
|
if ($field->{'name'} eq $current) { |
|
$Str .= ' selected '; |
|
} |
|
$Str.= '>'.&mt($field->{'title'}).'</option>'."\n"; |
|
} |
|
$Str .= '</select>'."\n"; |
|
return $Str; |
|
} |
|
|
############################################### |
############################################### |
############################################### |
############################################### |
|
## |
|
## Excel output routines |
|
## |
############################################### |
############################################### |
############################################### |
############################################### |
sub output_html_ungrouped { |
sub Excel_output { |
my ($r) = @_; |
my ($r) = @_; |
# |
$r->print('<h2>'.&mt('Preparing Excel Spreadsheet').'</h2>'); |
my $show_container = 0; |
## |
my $show_part = 0; |
## Compute the statistics |
#$r->print(&ProblemStatisticsLegend()); |
&compute_all_statistics($r); |
my @Header = ("Title","Part","#Stdnts","Tries","Mod", |
my $c = $r->connection; |
"Mean","#YES","#yes","%Wrng","DoDiff", |
return if ($c->aborted()); |
"S.D.","Skew");#,"D.F.1st","D.F.2nd"); |
## |
# |
## Create the excel workbook |
my $sortby = undef; |
my $filename = '/prtspool/'. |
foreach (@Header) { |
$ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. |
if ($ENV{'form.sortby'} eq $_) { |
time.'_'.rand(1000000000).'.xls'; |
$sortby = $_; |
my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); |
|
# |
|
# Create sheet |
|
my $excel_workbook = Spreadsheet::WriteExcel->new('/home/httpd'.$filename); |
|
# |
|
# Check for errors |
|
if (! defined($excel_workbook)) { |
|
$r->log_error("Error creating excel spreadsheet $filename: $!"); |
|
$r->print(&mt("Problems creating new Excel file. ". |
|
"This error has been logged. ". |
|
"Please alert your LON-CAPA administrator.")); |
|
return 0; |
|
} |
|
# |
|
# The excel spreadsheet stores temporary data in files, then put them |
|
# together. If needed we should be able to disable this (memory only). |
|
# The temporary directory must be specified before calling 'addworksheet'. |
|
# File::Temp is used to determine the temporary directory. |
|
$excel_workbook->set_tempdir($Apache::lonnet::tmpdir); |
|
# |
|
# Add a worksheet |
|
my $sheetname = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; |
|
if (length($sheetname) > 31) { |
|
$sheetname = substr($sheetname,0,31); |
|
} |
|
my $excel_sheet = $excel_workbook->addworksheet( |
|
&Apache::loncommon::clean_excel_name($sheetname)); |
|
## |
|
## Begin creating excel sheet |
|
## |
|
my ($rows_output,$cols_output) = (0,0); |
|
# |
|
# Put the course description in the header |
|
$excel_sheet->write($rows_output,$cols_output++, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}); |
|
$cols_output += 3; |
|
# |
|
# Put a description of the sections listed |
|
my $sectionstring = ''; |
|
my @Sections = @Apache::lonstatistics::SelectedSections; |
|
if (scalar(@Sections) > 1) { |
|
if (scalar(@Sections) > 2) { |
|
my $last = pop(@Sections); |
|
$sectionstring = "Sections ".join(', ',@Sections).', and '.$last; |
|
} else { |
|
$sectionstring = "Sections ".join(' and ',@Sections); |
|
} |
|
} else { |
|
if ($Sections[0] eq 'all') { |
|
$sectionstring = "All sections"; |
|
} else { |
|
$sectionstring = "Section ".$Sections[0]; |
} |
} |
} |
} |
if (! defined($sortby) || $sortby eq '') { |
$excel_sheet->write($rows_output,$cols_output++,$sectionstring); |
$sortby = 'Container'; |
$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)); |
|
# |
|
$rows_output++; |
|
$cols_output=0; |
|
# |
|
# Long Headers |
|
foreach my $field (@Fields) { |
|
next if ($field->{'name'} eq 'problem_num'); |
|
next if ($field->{'selected'} ne 'yes'); |
|
if (exists($field->{'long_title'})) { |
|
$excel_sheet->write($rows_output,$cols_output++, |
|
$field->{'long_title'}); |
|
} else { |
|
$excel_sheet->write($rows_output,$cols_output++,''); |
|
} |
} |
} |
# #FFFFE6 #EEFFCC #DDFFFF FFDDDD #DDFFDD #FFDDFF |
$rows_output++; |
my @Sequences = &Apache::lonstatistics::Sequences_with_Assess(); |
$cols_output=0; |
if (@Sequences > 1) { |
# Brief headers |
unshift(@Header,"Container"); |
foreach my $field (@Fields) { |
$show_container = 1; |
next if ($field->{'selected'} ne 'yes'); |
|
next if ($field->{'name'} eq 'problem_num'); |
|
# Use english for excel as I am not sure how well excel handles |
|
# other character sets.... |
|
$excel_sheet->write($rows_output,$cols_output++,$field->{'title'}); |
|
} |
|
$rows_output++; |
|
foreach my $data (@StatsArray) { |
|
$cols_output=0; |
|
foreach my $field (@Fields) { |
|
next if ($field->{'selected'} ne 'yes'); |
|
next if ($field->{'name'} eq 'problem_num'); |
|
$excel_sheet->write($rows_output,$cols_output++, |
|
$data->{$field->{'name'}}); |
|
} |
|
$rows_output++; |
} |
} |
# |
# |
$r->print('<table border="0"><tr><td bgcolor="#777777">'."\n"); |
$excel_workbook->close(); |
$r->rflush(); |
|
# |
# |
# Compile the data |
# Tell the user where to get their excel file |
my @Statsarray; |
$r->print('<br />'. |
foreach my $sequence (@Sequences) { |
'<a href="'.$filename.'">'. |
next if ($sequence->{'num_assess'}<1); |
&mt('Your Excel Spreadsheet').'</a>'."\n"); |
foreach my $resource (@{$sequence->{'contents'}}) { |
$r->rflush(); |
next if ($resource->{'type'} ne 'assessment'); |
return; |
foreach my $part (@{$resource->{'parts'}}) { |
} |
my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD, |
|
$SKEW) = &Apache::loncoursedata::get_problem_statistics |
################################################## |
(undef,$resource->{'symb'},$part, |
################################################## |
$ENV{'request.course.id'}); |
## |
# |
## Statistics Gathering and Manipulation Routines |
$show_part = 1 if ($part ne '0'); |
## |
$part = ' ' if ($part == 0); |
################################################## |
# |
################################################## |
my $wrongpercent = 0; |
sub compute_statistics_on_sequence { |
if (defined($num) && $num > 0) { |
my ($seq) = @_; |
$wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10; |
my @Data; |
} |
foreach my $res (@{$seq->{'contents'}}) { |
push (@Statsarray, |
next if ($res->{'type'} ne 'assessment'); |
{ 'sequence' => $sequence, |
foreach my $part (@{$res->{'parts'}}) { |
'resource' => $resource, |
# |
'Title' => $resource->{'title'}, |
# This is where all the work happens |
'Part' => $part, |
my $data = &get_statistics($seq,$res,$part,scalar(@StatsArray)+1); |
'#Stdnts' => $num, |
push (@Data,$data); |
'Tries' => $tries, |
push (@StatsArray,$data); |
'Mod' => $mod, |
|
'Mean' => $mean, |
|
'#YES' => $Solved, |
|
'#yes' => $solved, |
|
'%Wrng' => $wrongpercent, |
|
'DoDiff' => $DegOfDiff, |
|
'S.D.' => $STD, |
|
'Skew' => $SKEW, |
|
}); |
|
} |
|
} |
} |
} |
} |
# |
return @Data; |
# Table Headers |
} |
$r->print('<table border="0" cellpadding="3">'."\n"); |
|
my $Str = ''; |
sub compute_all_statistics { |
foreach (@Header) { |
my ($r) = @_; |
next if ($_ eq 'Part' && !$show_part); |
if (@StatsArray > 0) { |
# Do not allow sorting on some fields |
# Assume we have already computed the statistics |
if ($_ eq $sortby || /^(Part)$/) { |
return; |
$Str .= '<th>'.$_.'</th>'; |
} |
} else { |
my $c = $r->connection; |
$Str .= '<th>'. |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
'<a href="javascript:document.Statistics.sortby.value='."'$_'". |
last if ($c->aborted); |
';document.Statistics.submit();">'. |
next if ($seq->{'num_assess'} < 1); |
$_.'</a></th>'; |
&compute_statistics_on_sequence($seq); |
} |
|
} |
} |
$r->print('<tr bgcolor="#FFFFE6">'.$Str."</tr>\n"); |
} |
|
|
|
sub sort_data { |
|
my ($sortkey) = @_; |
|
return if (! @StatsArray); |
# |
# |
# Sort the data |
# Sort the data |
my @OutputOrder; |
my $sortby = undef; |
if ($sortby eq 'Container') { |
foreach my $field (@Fields) { |
@OutputOrder = @Statsarray; |
if ($sortkey eq $field->{'name'}) { |
} else { |
$sortby = $field->{'name'}; |
|
} |
|
} |
|
if (! defined($sortby) || $sortby eq '' || $sortby eq 'problem_num') { |
|
$sortby = 'container'; |
|
} |
|
if ($sortby ne 'container') { |
# $sortby is already defined, so we can charge ahead |
# $sortby is already defined, so we can charge ahead |
if ($sortby =~ /^(title|part)$/i) { |
if ($sortby =~ /^(title|part)$/i) { |
# Alpha comparison |
# Alpha comparison |
@OutputOrder = sort { |
@StatsArray = sort { |
lc($a->{$sortby}) cmp lc($b->{$sortby}) || |
lc($a->{$sortby}) cmp lc($b->{$sortby}) || |
lc($a->{'Title'}) cmp lc($b->{'Title'}) || |
lc($a->{'title'}) cmp lc($b->{'title'}) || |
lc($a->{'Part'}) cmp lc($b->{'Part'}); |
lc($a->{'part'}) cmp lc($b->{'part'}); |
} @Statsarray; |
} @StatsArray; |
} else { |
} else { |
# Numerical comparison |
# Numerical comparison |
@OutputOrder = sort { |
@StatsArray = sort { |
my $retvalue = 0; |
my $retvalue = 0; |
if ($b->{$sortby} eq 'nan') { |
if ($b->{$sortby} eq 'nan') { |
if ($a->{$sortby} ne 'nan') { |
if ($a->{$sortby} ne 'nan') { |
Line 401 sub output_html_ungrouped {
|
Line 1086 sub output_html_ungrouped {
|
} |
} |
} |
} |
if ($retvalue eq '0') { |
if ($retvalue eq '0') { |
$retvalue = $b->{$sortby} <=> $a->{$sortby} || |
$retvalue = $b->{$sortby} <=> $a->{$sortby} || |
lc($a->{'Title'}) <=> lc($b->{'Title'}) || |
lc($a->{'title'}) <=> lc($b->{'title'}) || |
lc($a->{'Part'}) <=> lc($b->{'Part'}); |
lc($a->{'part'}) <=> lc($b->{'part'}); |
} |
} |
$retvalue; |
$retvalue; |
} @Statsarray; |
} @StatsArray; |
} |
|
} |
|
foreach my $row (@OutputOrder) { |
|
$r->print('<tr>'); |
|
if ($show_container) { |
|
$r->print('<td bgcolor="#FFFFE6">' |
|
.$row->{'sequence'}->{'title'}.'</td>'); |
|
} |
} |
$r->print(&stats_row_from_hash($row,$show_part)); |
|
$r->print("</tr>\n"); |
|
} |
} |
$r->print("</table>\n"); |
|
$r->print("</td></tr></table>\n"); |
|
$r->rflush(); |
|
# |
# |
|
# Renumber the data set |
|
my $count; |
|
foreach my $data (@StatsArray) { |
|
$data->{'problem_num'} = ++$count; |
|
} |
return; |
return; |
} |
} |
|
|
sub stats_row_from_hash { |
######################################################## |
my ($data,$show_part) = @_; |
######################################################## |
return &statistics_html_table_data($data->{'resource'},$data->{'Part'}, |
|
$data->{'#Stdnts'}, $data->{'Tries'}, |
=pod |
$data->{'Mod'}, $data->{'Mean'}, |
|
$data->{'#YES'}, $data->{'#yes'}, |
=item &get_statistics() |
$data->{"\%Wrng"}, $data->{'DoDiff'}, |
|
$data->{'S.D.'}, $data->{'Skew'}, |
Wrapper routine from the call to loncoursedata::get_problem_statistics. |
$show_part); |
Calls lonstathelpers::get_time_limits() to limit the data set by time |
|
and &compute_discrimination_factor |
|
|
|
Inputs: $sequence, $resource, $part, $problem_num |
|
|
|
Returns: Hash reference with statistics data from |
|
loncoursedata::get_problem_statistics. |
|
|
|
=cut |
|
|
|
######################################################## |
|
######################################################## |
|
sub get_statistics { |
|
my ($sequence,$resource,$part,$problem_num) = @_; |
|
# |
|
my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); |
|
my $symb = $resource->{'symb'}; |
|
my $courseid = $ENV{'request.course.id'}; |
|
# |
|
my $data = &Apache::loncoursedata::get_problem_statistics |
|
(\@Apache::lonstatistics::SelectedSections, |
|
$Apache::lonstatistics::enrollment_status, |
|
$symb,$part,$courseid,$starttime,$endtime); |
|
$data->{'part'} = $part; |
|
$data->{'problem_num'} = $problem_num; |
|
$data->{'container'} = $sequence->{'title'}; |
|
$data->{'title'} = $resource->{'title'}; |
|
$data->{'title.link'} = $resource->{'src'}.'?symb='. |
|
&Apache::lonnet::escape($resource->{'symb'}); |
|
# |
|
if ($SelectedFields{'deg_of_disc'}) { |
|
$data->{'deg_of_disc'} = |
|
&compute_discrimination_factor($resource,$part,$sequence); |
|
} |
|
return $data; |
} |
} |
|
|
|
|
############################################### |
############################################### |
############################################### |
############################################### |
|
|
|
=pod |
|
|
|
=item &compute_discrimination_factor() |
|
|
|
Inputs: $Resource, $Sequence |
|
|
|
Returns: integer between -1 and 1 |
|
|
|
=cut |
|
|
############################################### |
############################################### |
############################################### |
############################################### |
sub statistics_html_table_data { |
sub compute_discrimination_factor { |
my ($resource,$part,$num,$tries,$mod,$mean,$Solved,$solved,$wrongpercent, |
my ($resource,$part,$sequence) = @_; |
$DegOfDiff,$STD,$SKEW,$show_part) = @_; |
my @Resources; |
my $row = ''; |
foreach my $res (@{$sequence->{'contents'}}) { |
$row .= '<td bgcolor="#FFFFE6">'. |
next if ($res->{'symb'} eq $resource->{'symb'}); |
'<a href="'.$resource->{'src'}.'" target="_blank" >'. |
push (@Resources,$res->{'symb'}); |
$resource->{'title'}.'</a>'. |
} |
'</td>'; |
# |
$row .= '<td bgcolor="#FFFFE6">'.$part.'</td>' if ($show_part); |
# rank |
foreach ($num,$tries) { |
my $ranking = |
$row .= '<td bgcolor="#EEFFCC" align="right">'.$_.'</td>'; |
&Apache::loncoursedata::rank_students_by_scores_on_resources |
} |
(\@Resources, |
foreach ($mod,$mean) { |
\@Apache::lonstatistics::SelectedSections, |
$row .= '<td bgcolor="#DDFFFF" align="right">'. |
$Apache::lonstatistics::enrollment_status,undef); |
sprintf("%5.2f",$_).'</td>'; |
# |
} |
# compute their percent scores on the problems in the sequence, |
foreach ($Solved,$solved) { |
my $number_to_grab = int(scalar(@{$ranking})/4); |
$row .= '<td bgcolor="#DDFFFF" align="right">'.$_.'</td>'; |
my $num_students = scalar(@{$ranking}); |
} |
my @BottomSet = map { $_->[&Apache::loncoursedata::RNK_student()]; |
foreach ($wrongpercent) { |
} @{$ranking}[0..$number_to_grab]; |
$row .= '<td bgcolor="#DDFFFF" align="right">'. |
my @TopSet = |
sprintf("%5.1f",$_).'</td>'; |
map { |
} |
$_->[&Apache::loncoursedata::RNK_student()]; |
foreach ($DegOfDiff,$STD,$SKEW) { |
} @{$ranking}[($num_students-$number_to_grab)..($num_students-1)]; |
$row .= '<td bgcolor="#FFDDDD" align="right">'. |
my ($bottom_sum,$bottom_max) = |
sprintf("%5.2f",$_).'</td>'; |
&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); |
} |
} |
return $row; |
#&Apache::lonnet::logthis(' '.$top_sum.'/'.$top_max. |
|
# ' - '.$bottom_sum.'/'.$bottom_max); |
|
return $deg_of_disc; |
} |
} |
|
|
|
|
############################################### |
############################################### |
############################################### |
############################################### |
|
|
sub BuildGraphicChart { |
=pod |
my ($graph,$cacheDB,$courseDescription,$students,$courseID,$r,$c)=@_; |
|
my %cache; |
=item ProblemStatisticsLegend |
my $max; |
|
my $title = ''; |
=over 4 |
if($graph eq 'DoDiffGraph') { |
|
$title = 'Degree-of-Difficulty'; |
=item #Stdnts |
} else { |
Total number of students attempted the problem. |
$title = 'Wrong-Percentage'; |
|
} |
=item Tries |
my $currentSequence = -1; |
Total number of tries for solving the problem. |
my $sortProblems = 'Sort Within Sequence'; |
|
my ($result, $orderedProblems) = |
=item Max Tries |
&InitializeProblemStatistics($cacheDB, $students, $courseID, $c, $r); |
Largest number of tries for solving the problem by a student. |
if($result ne 'OK') { |
|
|
=item Mean |
|
Average number of tries. [ Tries / #Stdnts ] |
|
|
|
=item #YES |
|
Number of students solved the problem correctly. |
|
|
|
=item #yes |
|
Number of students solved the problem by override. |
|
|
|
=item %Wrong |
|
Percentage of students who tried to solve the problem |
|
but is still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ] |
|
|
|
=item DoDiff |
|
Degree of Difficulty of the problem. |
|
[ 1 - ((#YES+#yes) / Tries) ] |
|
|
|
=item S.D. |
|
Standard Deviation of the tries. |
|
[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1) |
|
where Xi denotes every student\'s tries ] |
|
|
|
=item Skew. |
|
Skewness of the students tries. |
|
[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)] |
|
|
|
=item Dis.F. |
|
Discrimination Factor: A Standard for evaluating the |
|
problem according to a Criterion<br> |
|
|
|
=item [Criterion to group students into %27 Upper Students - |
|
and %27 Lower Students] |
|
1st Criterion for Sorting the Students: |
|
Sum of Partial Credit Awarded / Total Number of Tries |
|
2nd Criterion for Sorting the Students: |
|
Total number of Correct Answers / Total Number of Tries |
|
|
|
=item Disc. |
|
Number of Students had at least one discussion. |
|
|
|
=back |
|
|
|
=cut |
|
|
|
|
|
############################################################ |
|
############################################################ |
|
## |
|
## How this all works: |
|
## Statistics are computed by calling &get_statistics with the sequence, |
|
## resource, and part id to run statistics on. At various places within |
|
## the loops which compute the statistics, as well as before and after |
|
## the entire process, subroutines can be called. The subroutines are |
|
## registered to the following hooks: |
|
## |
|
## hook subroutine inputs |
|
## ---------------------------------------------------------- |
|
## pre $r,$count |
|
## pre_seq $r,$count,$seq |
|
## pre_res $r,$count,$seq,$res |
|
## calc $r,$count,$seq,$res,$data |
|
## post_res $r,$count,$seq,$res |
|
## post_seq $r,$count,$seq |
|
## post $r,$count |
|
## |
|
## abort $r |
|
## |
|
## subroutines will be called in the order in which they are registered. |
|
## |
|
############################################################ |
|
############################################################ |
|
{ |
|
|
|
my %hooks; |
|
my $aborted = 0; |
|
|
|
sub abort_computation { |
|
$aborted = 1; |
|
} |
|
|
|
sub clear_hooks { |
|
$aborted = 0; |
|
undef(%hooks); |
|
} |
|
|
|
sub register_hook { |
|
my ($hookname,$subref)=@_; |
|
if ($hookname !~ /^(pre|pre_seq|pre_res|post|post_seq|post_res|calc)$/){ |
return; |
return; |
} |
} |
my @values = (); |
if (ref($subref) ne 'CODE') { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
&Apache::lonnet::logthis('attempt to register hook to non-code: '. |
return 'Unable to tie database.7'; |
$hookname,' = '.$subref); |
} |
} else { |
foreach(@$orderedProblems) { |
if (exists($hooks{$hookname})) { |
my ($sequence,$problem,$part)=split(':', $_); |
push(@{$hooks{$hookname}},$subref); |
if($cache{'StatisticsMaps'} ne 'All Maps' && |
|
$cache{'StatisticsMaps'} ne $cache{$sequence.':title'}) { |
|
next; |
|
} |
|
if( $currentSequence == -1 || |
|
($sortProblems eq 'Sort Within Sequence' && |
|
$currentSequence != $sequence)) { |
|
if($currentSequence != -1) { |
|
&DrawGraph(\@values,$courseDescription,$title,$max,$r); |
|
} |
|
if($sortProblems eq 'Sort Within Sequence') { |
|
$r->print('<br><b>'.$cache{$sequence.':title'}.'</b>'."\n"); |
|
} |
|
$currentSequence = $sequence; |
|
@values = (); |
|
$max=0; |
|
} |
|
my $data = 0; |
|
if($graph eq 'DoDiffGraph') { |
|
$data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}), |
|
} else { |
} else { |
$data = sprintf("%.1f", $cache{$_.':percentWrong'}), |
$hooks{$hookname} = [$subref]; |
} |
|
if($max < $data) { |
|
$max = $data; |
|
} |
} |
push(@values, $data); |
|
} |
} |
untie(%cache); |
|
&DrawGraph(\@values,$courseDescription,$title,$max,$r); |
|
return; |
return; |
} |
} |
|
|
sub DrawGraph { |
sub run_hooks { |
my ($values,$courseDescription,$title,$Max,$r)=@_; |
my $context = shift(); |
my $sendValues = join(',', @$values); |
foreach my $hook (@{$hooks{$context}}) { |
my $sendCount = scalar(@$values); |
if ($aborted && $context ne 'abort') { |
$r->print("<br>The Maximum Value is: $Max"); |
last; |
if ( $Max > 1 ) { |
} |
if ($Max % 10) { |
my $retvalue = $hook->(@_); |
if ( int($Max) < $Max ) { |
if (defined($retvalue) && $retvalue eq '0') { |
$Max++; |
$aborted = 1 if (! $aborted); |
$Max = int($Max); |
} |
} |
|
} |
|
#(10 - $Max % 10); |
|
} else { $Max = 1; } |
|
my @GData = ('','Problem_number',$title,$Max,$sendCount,$sendValues); |
|
# $r->print('</form>'."\n"); |
|
$r->print('<br>'."\n"); |
|
$r->print('<IMG src="/cgi-bin/graph.png?'. |
|
(join('&', @GData)).'" border="1" />'); |
|
# $r->print('<form>'."\n"); |
|
$r->print('<br>'."\n"); |
|
} |
|
|
|
#---- Problem Statistics Web Page --------------------------------------- |
|
sub CreateProblemStatisticsTableHeading { |
|
my ($headings,$r)=@_; |
|
my $Str=''; |
|
$Str .= '<tr>'."\n"; |
|
$Str .= '<th bgcolor="#ffffe6">P#</th>'."\n"; |
|
foreach(@$headings) { |
|
$Str .= '<th bgcolor="#ffffe6">'; |
|
$Str .= '<a href="/adm/statistics?reportSelected='; |
|
$Str .= &Apache::lonnet::escape('Problem Statistics'); |
|
$Str .= '&ProblemStatisticsSort='; |
|
$Str .= &Apache::lonnet::escape($_).'">'.$_.'</a> </th>'."\n"; |
|
} |
} |
$Str .= "\n".'</tr>'."\n"; |
|
return $Str; |
|
} |
} |
|
|
sub BuildStatisticsTable { |
sub run_statistics { |
my ($cache,$displayFormat,$sortProblems,$orderedProblems,$headings, |
my ($r) = @_; |
$r,$color)=@_; |
my $count = 0; |
my $count = 1; |
&run_hooks('pre',$r,$count); |
my $currentSequence = -1; |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
foreach(@$orderedProblems) { |
last if ($aborted); |
my ($sequence,$problem,$part)=split(':', $_); |
next if ($seq->{'num_assess'}<1); |
if($cache->{'StatisticsMaps'} ne 'All Maps' && |
&run_hooks('pre_seq',$r,$count,$seq); |
$cache->{'StatisticsMaps'} ne $cache->{$sequence.':title'}) { |
foreach my $res (@{$seq->{'contents'}}) { |
next; |
last if ($aborted); |
} |
next if ($res->{'type'} ne 'assessment'); |
if($currentSequence == -1 || |
&run_hooks('pre_res',$r,$count,$seq,$res); |
($sortProblems eq 'Sort Within Sequence' && |
foreach my $part (@{$res->{'parts'}}) { |
$currentSequence != $sequence)) { |
last if ($aborted); |
if($displayFormat ne 'Display CSV Format') { |
# |
if($currentSequence ne -1) { |
# This is where all the work happens |
$r->print('</table>'); |
my $data = &get_statistics($seq,$res,$part,++$count); |
$r->print('</td></tr></table><br>'); |
&run_hooks('calc',$r,$count,$seq,$res,$part,$data); |
} |
|
if($sortProblems eq 'Sort Within Sequence') { |
|
$r->print('<b>'.$cache->{$sequence.':title'}.'</b>'); |
|
} |
|
$r->print('<table border="0"><tr><td bgcolor="#777777">'."\n"); |
|
$r->print('<table border="0" cellpadding="3">'."\n"); |
|
$r->print(&CreateProblemStatisticsTableHeading($headings, $r)); |
|
} else { |
|
if($sortProblems eq 'Sort Within Sequence') { |
|
$r->print('"'.$cache->{$sequence.':title'}.'"'); |
|
} |
|
$r->print('<br>'); |
|
} |
} |
$currentSequence = $sequence; |
&run_hooks('post_res',$r,$count,$seq,$res); |
} |
} |
my $ref = '<a href="'.$cache->{$problem.':source'}. |
&run_hooks('post_seq',$r,$count,$seq); |
'" target="_blank">'.$cache->{$problem.':title'}.'</a>'; |
|
my $title = $cache->{$problem.':title'}; |
|
if($part != 0) { |
|
$title .= ' Part '.$part; |
|
} |
|
my $source = $cache->{$problem.':source'}; |
|
my $tableData = join('&', $ref, $title, $source, |
|
$cache->{$_.':studentCount'}, |
|
$cache->{$_.':totalTries'}, |
|
$cache->{$_.':maxTries'}, |
|
$cache->{$_.':mean'}, |
|
$cache->{$_.':correct'}, |
|
$cache->{$_.':correctByOverride'}, |
|
$cache->{$_.':percentWrong'}, |
|
$cache->{$_.':degreeOfDifficulty'}, |
|
$cache->{$_.':standardDeviation'}, |
|
$cache->{$_.':skewness'}, |
|
$cache->{$_.':discriminationFactor1'}, |
|
$cache->{$_.':discriminationFactor2'}); |
|
&TableRow($displayFormat,$tableData,$count,$r,$color); |
|
$count++; |
|
} |
|
if($displayFormat ne 'Display CSV Format') { |
|
$r->print('</table>'."\n"); |
|
$r->print('</td></tr></table>'); |
|
} else { |
|
$r->print('<br>'); |
|
} |
} |
return; |
if ($aborted) { |
} |
&run_hooks('abort',$r); |
|
|
sub TableRow { |
|
my ($displayFormat,$Str,$RealIdx,$r,$color)=@_; |
|
my($ref,$title,$source,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override, |
|
$Wrng,$DoD,$SD,$Sk,$_D1,$_D2)=split(/\&/,$Str); |
|
my $Ptr; |
|
if($displayFormat eq 'Display CSV Format') { |
|
$Ptr='"'.$RealIdx.'",'."\n". |
|
'"'.$title.'",'."\n". |
|
'"'.$source.'",'."\n". |
|
'"'.$StdNo.'",'."\n". |
|
'"'.$TotalTries.'",'."\n". |
|
'"'.$MxTries.'",'."\n". |
|
'"'.$Avg.'",'."\n". |
|
'"'.$YES.'",'."\n". |
|
'"'.$Override.'",'."\n". |
|
'"'.$Wrng.'",'."\n". |
|
'"'.$DoD.'",'."\n". |
|
'"'.$SD.'",'."\n". |
|
'"'.$Sk.'",'."\n". |
|
'"'.$_D1.'",'."\n". |
|
'"'.$_D2.'"'."\n". |
|
"<br>\n"; |
|
$r->print("\n".$Ptr); |
|
} else { |
} else { |
$Ptr='<tr>'."\n". |
&run_hooks('post',$r,$count); |
'<td bgcolor="#ffffe6">'.$RealIdx.'</td>'."\n". |
|
'<td bgcolor="#ffffe6">'.$ref.'</td>'."\n". |
|
'<td bgcolor='.$color->{"yellow"}.'> '.$StdNo.'</td>'."\n". |
|
'<td bgcolor='.$color->{"yellow"}.'>'.$TotalTries.'</td>'."\n". |
|
'<td bgcolor='.$color->{"yellow"}.'>'.$MxTries.'</td>'."\n". |
|
'<td bgcolor='.$color->{"gb"}.'>'.$Avg.'</td>'."\n". |
|
'<td bgcolor='.$color->{"gb"}.'> '.$YES.'</td>'."\n". |
|
'<td bgcolor='.$color->{"gb"}.'> '.$Override.'</td>'."\n". |
|
'<td bgcolor='.$color->{"red"}.'> '.$Wrng.'</td>'."\n". |
|
'<td bgcolor='.$color->{"red"}.'> '.$DoD.'</td>'."\n". |
|
'<td bgcolor='.$color->{"green"}.'> '.$SD.'</td>'."\n". |
|
'<td bgcolor='.$color->{"green"}.'> '.$Sk.'</td>'."\n". |
|
'<td bgcolor='.$color->{"purple"}.'> '.$_D1.'</td>'."\n". |
|
'<td bgcolor='.$color->{"purple"}.'> '.$_D2.'</td>'."\n"; |
|
$r->print($Ptr.'</tr>'."\n"); |
|
} |
} |
return; |
return; |
} |
} |
|
|
# For loading the colored table for display or un-colored for print |
} # End of %hooks scope |
sub setbgcolor { |
|
my $PrintTable=shift; |
|
my %color; |
|
if ($PrintTable){ |
|
$color{"gb"}="#FFFFFF"; |
|
$color{"red"}="#FFFFFF"; |
|
$color{"yellow"}="#FFFFFF"; |
|
$color{"green"}="#FFFFFF"; |
|
$color{"purple"}="#FFFFFF"; |
|
} else { |
|
$color{"gb"}="#DDFFFF"; |
|
$color{"red"}="#FFDDDD"; |
|
$color{"yellow"}="#EEFFCC"; |
|
$color{"green"}="#DDFFDD"; |
|
$color{"purple"}="#FFDDFF"; |
|
} |
|
return \%color; |
|
} |
|
|
|
sub ProblemStatisticsButtons { |
|
my ($displayFormat, $displayLegend, $sortProblems)=@_; |
|
my $Ptr = '<tr><td></td><td align="left">'; |
|
$Ptr .= '<input type="submit" name="DoDiffGraph" '; |
|
$Ptr .= 'value="Plot Degree of Difficulty" />'."\n"; |
|
$Ptr .= '</td><td align="left">'; |
|
$Ptr .= '<input type="submit" name="PercentWrongGraph" '; |
|
$Ptr .= 'value="Plot Percent Wrong" />'."\n"; |
|
$Ptr .= '</td></tr><tr><td></td><td>'."\n"; |
|
$Ptr .= '<input type="submit" name="SortProblems" '; |
|
if($sortProblems eq 'Sort All Problems') { |
|
$Ptr .= 'value="Sort Within Sequence" />'."\n"; |
|
} else { |
|
$Ptr .= 'value="Sort All Problems" />'."\n"; |
|
} |
|
$Ptr .= '</td><td align="left">'; |
|
$Ptr .= '<input type="submit" name="DisplayLegend" '; |
|
if($displayLegend eq 'Show Legend') { |
|
$Ptr .= 'value="Hide Legend" />'."\n"; |
|
} else { |
|
$Ptr .= 'value="Show Legend" />'."\n"; |
|
} |
|
$Ptr .= '</td><td align="left">'; |
|
$Ptr .= '<input type="submit" name="DisplayCSVFormat" '; |
|
if($displayFormat eq 'Display CSV Format') { |
|
$Ptr .= 'value="Display Table Format" />'."\n"; |
|
} else { |
|
$Ptr .= 'value="Display CSV Format" />'."\n"; |
|
} |
|
$Ptr .= '</td></tr>'; |
|
return $Ptr; |
|
} |
|
|
|
sub ProblemStatisticsLegend { |
|
my $Ptr = ''; |
|
$Ptr = '<table border="0">'; |
|
$Ptr .= '<tr><td>'; |
|
$Ptr .= '<b>#Stdnts</b></td>'; |
|
$Ptr .= '<td>Total number of students attempted the problem.'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>Tries</b></td>'; |
|
$Ptr .= '<td>Total number of tries for solving the problem.'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>Mod</b></td>'; |
|
$Ptr .= '<td>Largest number of tries for solving the problem by a student.'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>Mean</b></td>'; |
|
$Ptr .= '<td>Average number of tries. [ Tries / #Stdnts ]'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>#YES</b></td>'; |
|
$Ptr .= '<td>Number of students solved the problem correctly.'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>#yes</b></td>'; |
|
$Ptr .= '<td>Number of students solved the problem by override.'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>%Wrong</b></td>'; |
|
$Ptr .= '<td>Percentage of students who tried to solve the problem '; |
|
$Ptr .= 'but is still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>DoDiff</b></td>'; |
|
$Ptr .= '<td>Degree of Difficulty of the problem. '; |
|
$Ptr .= '[ 1 - ((#YES+#yes) / Tries) ]'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>S.D.</b></td>'; |
|
$Ptr .= '<td>Standard Deviation of the tries. '; |
|
$Ptr .= '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1) '; |
|
$Ptr .= 'where Xi denotes every student\'s tries ]'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>Skew.</b></td>'; |
|
$Ptr .= '<td>Skewness of the students tries.'; |
|
$Ptr .= '[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]'; |
|
$Ptr .= '</td></tr><tr><td>'; |
|
$Ptr .= '<b>Dis.F.</b></td>'; |
|
$Ptr .= '<td>Discrimination Factor: A Standard for evaluating the '; |
|
$Ptr .= 'problem according to a Criterion<br>'; |
|
$Ptr .= '<b>[Criterion to group students into %27 Upper Students - '; |
|
$Ptr .= 'and %27 Lower Students]</b><br>'; |
|
$Ptr .= '<b>1st Criterion</b> for Sorting the Students: '; |
|
$Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>'; |
|
$Ptr .= '<b>2nd Criterion</b> for Sorting the Students: '; |
|
$Ptr .= '<b>Total number of Correct Answers / Total Number of Tries</b>'; |
|
$Ptr .= '</td></tr>'; |
|
$Ptr .= '<tr><td><b>Disc.</b></td>'; |
|
$Ptr .= '<td>Number of Students had at least one discussion.'; |
|
$Ptr .= '</td></tr></table>'; |
|
return $Ptr; |
|
} |
|
|
|
#---- END Problem Statistics Web Page ---------------------------------------- |
############################################################ |
|
############################################################ |
|
|
1; |
1; |
__END__ |
__END__ |