version 1.50, 2003/05/12 22:07:17
|
version 1.58, 2003/09/03 16:07:06
|
Line 62 my @Fields = (
|
Line 62 my @Fields = (
|
align => 'right', |
align => 'right', |
color => '#FFFFE6' }, |
color => '#FFFFE6' }, |
{ name => 'container', |
{ name => 'container', |
title => 'Container', |
title => 'Sequence or Folder', |
align => 'left', |
align => 'left', |
color => '#FFFFE6', |
color => '#FFFFE6', |
sortable => 'yes' }, |
sortable => 'yes' }, |
Line 75 my @Fields = (
|
Line 75 my @Fields = (
|
{ name => 'part', |
{ name => 'part', |
title => 'Part', |
title => 'Part', |
align => 'left', |
align => 'left', |
color => '#FFFFE6' }, |
color => '#FFFFE6', |
|
}, |
{ name => 'num_students', |
{ name => 'num_students', |
title => '#Stdnts', |
title => '#Stdnts', |
align => 'right', |
align => 'right', |
Line 131 my @Fields = (
|
Line 132 my @Fields = (
|
format => '%5.2f', |
format => '%5.2f', |
sortable => 'yes', |
sortable => 'yes', |
graphable => 'yes', |
graphable => 'yes', |
long_title => 'Degree of Difficulty' }, |
long_title => 'Degree of Difficulty'. |
|
'[ 1 - ((#YES+#yes) / Tries) ]'}, |
{ name => 'num_solved', |
{ name => 'num_solved', |
title => '#YES', |
title => '#YES', |
align => 'right', |
align => 'right', |
Line 155 my @Fields = (
|
Line 157 my @Fields = (
|
format => '%4.1f', |
format => '%4.1f', |
sortable => 'yes', |
sortable => 'yes', |
graphable => 'yes', |
graphable => 'yes', |
long_title => 'Percent Wrong' }, |
long_title => 'Percent of students whose final answer is wrong' }, |
); |
); |
|
|
############################################### |
############################################### |
Line 172 select sections, maps, and output.
|
Line 174 select sections, maps, and output.
|
|
|
############################################### |
############################################### |
############################################### |
############################################### |
|
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', |
|
}, |
|
); |
|
|
sub CreateInterface { |
sub CreateInterface { |
my $Str = ''; |
my $Str = ''; |
$Str .= '<table cellspacing="5">'."\n"; |
$Str .= '<table cellspacing="5">'."\n"; |
Line 199 sub CreateInterface {
|
Line 224 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>'."\n"; |
$Str .= &CreateAndParseOutputSelector(); |
my ($html,$outputmode,$show) = |
|
&Apache::lonstatistics::CreateAndParseOutputSelector( |
|
'statsoutputmode', |
|
'HTML problem statistics grouped', |
|
@OutputOptions); |
|
$Str .= $html; |
$Str .= '</td></tr>'."\n"; |
$Str .= '</td></tr>'."\n"; |
$Str .= '</table>'."\n"; |
$Str .= '</table>'."\n"; |
return $Str; |
$Str .= '<input type="submit" value="Generate Statistics" />'; |
} |
$Str .= ' 'x5; |
|
$Str .= '<input type="submit" name="ClearCache" value="Clear Caches" />'; |
####################################################### |
$Str .= ' 'x5; |
####################################################### |
return ($Str,$outputmode,$show); |
|
|
=pod |
|
|
|
=item &CreateAndParseOutputSelector() |
|
|
|
Construct a selection list of options for output and parse output selections. |
|
The current output selected is indicated by the values of the two package |
|
variables $output_mode and $show. @OutputOptions holds the descriptions of |
|
the output options and the values for $output_mode and $show. |
|
|
|
Based on code from lonstudentassessment.pm. |
|
|
|
=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', |
|
}, |
|
); |
|
|
|
sub OutputDescriptions { |
|
my $Str = ''; |
|
$Str .= "<h2>Output Modes</h2>\n"; |
|
$Str .= "<dl>\n"; |
|
foreach my $outputmode (@OutputOptions) { |
|
$Str .=" <dt>".$outputmode->{'name'}."</dt>\n"; |
|
$Str .=" <dd>".$outputmode->{'description'}."</dd>\n"; |
|
} |
|
$Str .= "</dl>\n"; |
|
return $Str; |
|
} |
|
|
|
sub CreateAndParseOutputSelector { |
|
my $Str = ''; |
|
my $elementname = 'statsoutputmode'; |
|
# |
|
# Format for output options is 'mode, restrictions'; |
|
my $selected = 'HTML problem statistics grouped'; |
|
if (exists($ENV{'form.'.$elementname})) { |
|
if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) { |
|
$selected = $ENV{'form.'.$elementname}->[0]; |
|
} else { |
|
$selected = $ENV{'form.'.$elementname}; |
|
} |
|
} |
|
# |
|
# Set package variables describing output mode |
|
$output_mode = 'html'; |
|
$show = 'all'; |
|
foreach my $option (@OutputOptions) { |
|
next if ($option->{'value'} ne $selected); |
|
$output_mode = $option->{'mode'}; |
|
$show = $option->{'show'}; |
|
} |
|
# |
|
# Build the form element |
|
$Str = qq/<select size="5" name="$elementname">/; |
|
foreach my $option (@OutputOptions) { |
|
if (exists($option->{'special'}) && |
|
$option->{'special'} =~ /do not show/) { |
|
next; |
|
} |
|
$Str .= "\n".' <option value="'.$option->{'value'}.'"'; |
|
$Str .= " selected " if ($option->{'value'} eq $selected); |
|
$Str .= ">".$option->{'name'}."<\/option>"; |
|
} |
|
$Str .= "\n</select>"; |
|
return $Str; |
|
} |
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &Gather_Student_Data() |
|
|
|
Ensures all student data is up to date. |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
sub Gather_Student_Data { |
|
my ($r) = @_; |
|
my $c = $r->connection(); |
|
# |
|
my @Sequences = &Apache::lonstatistics::Sequences_with_Assess(); |
|
# |
|
my @Students = @Apache::lonstatistics::Students; |
|
# |
|
# Open the progress window |
|
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin |
|
($r,'Statistics Compilation Status', |
|
'Statistics Compilation Progress', scalar(@Students)); |
|
# |
|
while (my $student = shift @Students) { |
|
return if ($c->aborted()); |
|
my ($status,undef) = &Apache::loncoursedata::ensure_current_data |
|
($student->{'username'},$student->{'domain'}, |
|
$ENV{'request.course.id'}); |
|
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
|
'last student'); |
|
} |
|
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
|
$r->rflush(); |
|
} |
} |
|
|
############################################### |
############################################### |
Line 353 Main interface to problem statistics.
|
Line 255 Main interface to problem statistics.
|
sub BuildProblemStatisticsPage { |
sub BuildProblemStatisticsPage { |
my ($r,$c)=@_; |
my ($r,$c)=@_; |
# |
# |
$output_mode = 'html'; |
my ($interface,$output_mode,$show) = &CreateInterface(); |
$show = 'grouped'; |
$r->print($interface); |
# |
|
$r->print(&CreateInterface()); |
|
$r->print('<input type="hidden" name="statsfirstcall" value="no" />'); |
$r->print('<input type="hidden" name="statsfirstcall" value="no" />'); |
$r->print('<input type="hidden" name="sortby" value="'.$ENV{'form.sortby'}. |
$r->print('<input type="hidden" name="sortby" value="'.$ENV{'form.sortby'}. |
'" />'); |
'" />'); |
$r->print('<input type="hidden" name="plot" value="" />'); |
$r->print('<input type="hidden" name="plot" value="" />'); |
if (! exists($ENV{'form.statsfirstcall'})) { |
if (! exists($ENV{'form.statsfirstcall'})) { |
$r->print(<<ENDMSG); |
|
<p> |
|
<font size="+1"> |
|
Please make your selections in the boxes above and hit |
|
the button marked "Update Display". |
|
</font> |
|
</p> |
|
ENDMSG |
|
return; |
return; |
} |
} |
# |
# |
&Gather_Student_Data($r); |
&Apache::lonstatistics::Gather_Student_Data($r); |
# |
# |
# |
# |
if ($output_mode eq 'html') { |
if ($output_mode eq 'html') { |
Line 649 sub output_excel {
|
Line 541 sub output_excel {
|
$rows_output++; |
$rows_output++; |
$cols_output=0; |
$cols_output=0; |
# |
# |
# Add the headers |
# Long Headersheaders |
|
foreach my $field (@Fields) { |
|
next if ($field->{'name'} eq 'problem_num'); |
|
if (exists($field->{'long_title'})) { |
|
$excel_sheet->write($rows_output,$cols_output++, |
|
$field->{'long_title'}); |
|
} else { |
|
$excel_sheet->write($rows_output,$cols_output++,''); |
|
} |
|
} |
|
$rows_output++; |
|
$cols_output=0; |
|
# Brief headers |
foreach my $field (@Fields) { |
foreach my $field (@Fields) { |
next if ($field->{'name'} eq 'problem_num'); |
next if ($field->{'name'} eq 'problem_num'); |
$excel_sheet->write($rows_output,$cols_output++,$field->{'title'}); |
$excel_sheet->write($rows_output,$cols_output++,$field->{'title'}); |
Line 714 sub statistics_html_table_data {
|
Line 618 sub statistics_html_table_data {
|
} |
} |
$row .= '>'; |
$row .= '>'; |
if (exists($field->{'special'}) && $field->{'special'} eq 'link') { |
if (exists($field->{'special'}) && $field->{'special'} eq 'link') { |
$row .= '<a href="'.$data->{$field->{'name'}.'.link'}. |
$row .= '<a href="'.$data->{$field->{'name'}.'.link'}.'">'; |
' target="_blank">'; |
|
} |
} |
if (exists($field->{'format'})) { |
if (exists($field->{'format'})) { |
$row .= sprintf($field->{'format'},$data->{$field->{'name'}}); |
$row .= sprintf($field->{'format'},$data->{$field->{'name'}}); |
Line 786 sub plot_statistics {
|
Line 689 sub plot_statistics {
|
} |
} |
} |
} |
return if (! defined($sortfield) || $sortfield eq ''); |
return if (! defined($sortfield) || $sortfield eq ''); |
&Apache::lonnet::logthis('data field = '.$datafield); |
|
# |
# |
my $Max = 0; |
my $Max = 0; |
my $problem_num = 0; |
my $problem_num = 0; |
Line 861 sub DrawGraph {
|
Line 763 sub DrawGraph {
|
$title = '' if (! defined($title)); |
$title = '' if (! defined($title)); |
$xaxis = '' if (! defined($xaxis)); |
$xaxis = '' if (! defined($xaxis)); |
$yaxis = '' if (! defined($yaxis)); |
$yaxis = '' if (! defined($yaxis)); |
|
$title = &Apache::lonnet::escape($title); |
|
$xaxis = &Apache::lonnet::escape($xaxis); |
|
$yaxis = &Apache::lonnet::escape($yaxis); |
# |
# |
my $sendValues = join(',', @$values); |
my $sendValues = join(',', @$values); |
my $sendCount = scalar(@$values); |
my $sendCount = scalar(@$values); |
Line 890 sub get_statistics {
|
Line 795 sub get_statistics {
|
$data->{'problem_num'} = $problem_num; |
$data->{'problem_num'} = $problem_num; |
$data->{'container'} = $sequence->{'title'}; |
$data->{'container'} = $sequence->{'title'}; |
$data->{'title'} = $resource->{'title'}; |
$data->{'title'} = $resource->{'title'}; |
$data->{'title.link'} = $resource->{'src'}; |
$data->{'title.link'} = $resource->{'src'}.'?symb='. |
|
&Apache::lonnet::escape($resource->{'symb'}); |
# |
# |
return $data; |
return $data; |
} |
} |