version 1.83, 2004/04/06 15:45:13
|
version 1.96, 2005/01/11 19:45:18
|
Line 55 use Apache::loncommon();
|
Line 55 use Apache::loncommon();
|
use Apache::lonhtmlcommon; |
use Apache::lonhtmlcommon; |
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use Apache::lonstatistics; |
use Apache::lonstatistics; |
|
use LONCAPA::lonmetadata(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Spreadsheet::WriteExcel; |
use Spreadsheet::WriteExcel; |
use Apache::lonstathelpers(); |
use Apache::lonstathelpers(); |
Line 95 my %SeqStat; # keys are symbs, values
|
Line 96 my %SeqStat; # keys are symbs, values
|
## statistics display? |
## statistics display? |
## selected yes (yes|no) Is the column selected by default? |
## selected yes (yes|no) Is the column selected by default? |
## |
## |
|
## format no sprintf format string |
|
## |
|
## excel_format no excel format type |
|
## (see &Apache::loncommon::define_excel_formats |
my @Fields = ( |
my @Fields = ( |
{ name => 'problem_num', |
{ name => 'problem_num', |
title => 'P#', |
title => 'P#', |
Line 226 my @Fields = (
|
Line 231 my @Fields = (
|
selectable => 'yes', |
selectable => 'yes', |
defaultselected => 'yes', |
defaultselected => 'yes', |
}, |
}, |
|
{ name => 'tries_per_correct', |
|
title => 'tries/correct', |
|
align => 'right', |
|
color => '#FFDDDD', |
|
format => '%4.1f', |
|
sortable => 'yes', |
|
graphable => 'yes', |
|
long_title => 'Tries per Correct Answer', |
|
selectable => 'yes', |
|
defaultselected => 'yes', |
|
}, |
{ name => 'num_wrong', |
{ name => 'num_wrong', |
title => '#Wrng', |
title => '#Wrng', |
align => 'right', |
align => 'right', |
Line 233 my @Fields = (
|
Line 249 my @Fields = (
|
format => '%4.1f', |
format => '%4.1f', |
sortable => 'yes', |
sortable => 'yes', |
graphable => 'yes', |
graphable => 'yes', |
|
long_title => 'Number of students whose final answer is wrong', |
|
selectable => 'yes', |
|
defaultselected => 'yes', |
|
}, |
|
{ name => 'per_wrong', |
|
title => '%Wrng', |
|
align => 'right', |
|
color => '#FFDDDD', |
|
format => '%4.1f', |
|
sortable => 'yes', |
|
graphable => 'yes', |
long_title => 'Percent of students whose final answer is wrong', |
long_title => 'Percent of students whose final answer is wrong', |
selectable => 'yes', |
selectable => 'yes', |
defaultselected => 'yes', |
defaultselected => 'yes', |
Line 258 my @Fields = (
|
Line 285 my @Fields = (
|
graphable => 'yes', |
graphable => 'yes', |
long_title => 'Degree of Discrimination', |
long_title => 'Degree of Discrimination', |
selectable => 'yes', |
selectable => 'yes', |
defaultselected => 'no', |
defaultselected => 'yes', |
}, |
}, |
|
## duedate included for research purposes. Commented out most of the time. |
|
# { name => 'duedate', |
|
# title => 'Due Date', |
|
# align => 'left', |
|
# color => '#FFFFFF', |
|
# sortable => 'yes', |
|
# graphable => 'no', |
|
# long_title => 'Due date of resource for instructor', |
|
# selectable => 'no', |
|
# defaultselected => 'yes', |
|
# }, |
|
## opendate included for research purposes. Commented out most of the time. |
|
# { name => 'opendate', |
|
# title => 'Open Date', |
|
# align => 'left', |
|
# color => '#FFFFFF', |
|
# sortable => 'yes', |
|
# graphable => 'no', |
|
# long_title => 'date resource became answerable', |
|
# selectable => 'no', |
|
# defaultselected => 'yes', |
|
# }, |
|
## symb included for research purposes. Commented out most of the time. |
|
# { name => 'symb', |
|
# title => 'Symb', |
|
# align => 'left', |
|
# color => '#FFFFFF', |
|
# sortable => 'yes', |
|
# graphable => 'no', |
|
# long_title => 'Unique LON-CAPA identifier for problem', |
|
# selectable => 'no', |
|
# defaultselected => 'yes', |
|
# }, |
|
## resptypes included for research purposes. Commented out most of the time. |
|
# { name => 'resptypes', |
|
# title => 'Response Types', |
|
# align => 'left', |
|
# color => '#FFFFFF', |
|
# sortable => 'no', |
|
# graphable => 'no', |
|
# long_title => 'Response Types used in this problem', |
|
# selectable => 'no', |
|
# defaultselected => 'yes', |
|
# }, |
|
## maxtries included for research purposes. Commented out most of the time. |
|
# { name => 'maxtries', |
|
# title => 'Maxtries', |
|
# align => 'left', |
|
# color => '#FFFFFF', |
|
# sortable => 'no', |
|
# graphable => 'no', |
|
# long_title => 'Maximum number of tries', |
|
# selectable => 'no', |
|
# defaultselected => 'yes', |
|
# }, |
|
## hinttries included for research purposes. Commented out most of the time. |
|
# { name => 'hinttries', |
|
# title => 'hinttries', |
|
# align => 'left', |
|
# color => '#FFFFFF', |
|
# sortable => 'no', |
|
# graphable => 'no', |
|
# long_title => 'Number of tries before a hint appears', |
|
# selectable => 'no', |
|
# defaultselected => 'yes', |
|
# }, |
|
## weight included for research purposes. Commented out most of the time. |
|
# { name => 'weight', |
|
# title => 'weight', |
|
# align => 'right', |
|
# color => '#FFFFFF', |
|
# sortable => 'no', |
|
# graphable => 'no', |
|
# long_title => 'Problem weight (for instructor)', |
|
# selectable => 'no', |
|
# defaultselected => 'yes', |
|
# }, |
); |
); |
|
|
my @SeqFields = ( |
my @SeqFields = ( |
Line 498 select sections, maps, and output.
|
Line 602 select sections, maps, and output.
|
############################################### |
############################################### |
############################################### |
############################################### |
sub CreateInterface { |
sub CreateInterface { |
|
my ($r) = @_; |
# |
# |
&parse_field_selection(); |
&parse_field_selection(); |
# |
# |
Line 533 sub CreateInterface {
|
Line 638 sub CreateInterface {
|
$Str .= '</td><td>'.&field_selection_input(); |
$Str .= '</td><td>'.&field_selection_input(); |
$Str .= '</td></tr>'."\n"; |
$Str .= '</td></tr>'."\n"; |
$Str .= '</table>'."\n"; |
$Str .= '</table>'."\n"; |
|
# |
|
$Str .= '<p>'.&mt('Status: [_1]', |
|
'<input type="text" '. |
|
'name="stats_status" size="60" value="" />' |
|
). |
|
'</nobr></p>'; |
|
# |
$Str .= '<input type="submit" name="GenerateStatistics" value="'. |
$Str .= '<input type="submit" name="GenerateStatistics" value="'. |
&mt('Generate Statistics').'" />'; |
&mt('Generate Statistics').'" />'; |
$Str .= ' 'x5; |
$Str .= ' 'x5; |
$Str .= 'Plot '.&plot_dropdown().(' 'x10); |
$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; |
} |
} |
|
|
Line 583 sub BuildProblemStatisticsPage {
|
Line 687 sub BuildProblemStatisticsPage {
|
undef(%SeqStat); |
undef(%SeqStat); |
# |
# |
# Finally let the user know we are here |
# Finally let the user know we are here |
my $interface = &CreateInterface(); |
my $interface = &CreateInterface($r); |
$r->print($interface); |
$r->print($interface); |
$r->print('<input type="hidden" name="sortby" value="'.$ENV{'form.sortby'}. |
$r->print('<input type="hidden" name="sortby" value="'.$ENV{'form.sortby'}. |
'" />'); |
'" />'); |
# |
# |
if (! exists($ENV{'form.statsfirstcall'})) { |
my @CacheButtonHTML = |
$r->print('<input type="hidden" name="statsfirstcall" value="yes" />'); |
&Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status'); |
|
my $Str; |
|
foreach my $html (@CacheButtonHTML) { |
|
$Str.=$html.(' 'x5); |
|
} |
|
# |
|
$r->print($Str); |
|
if (! exists($ENV{'form.firstrun'})) { |
$r->print('<h3>'. |
$r->print('<h3>'. |
&mt('Press "Generate Statistics" when you are ready.'). |
&mt('Press "Generate Statistics" when you are ready.'). |
'</h3><p>'. |
'</h3><p>'. |
Line 598 sub BuildProblemStatisticsPage {
|
Line 709 sub BuildProblemStatisticsPage {
|
' will not have this delay.'). |
' will not have this delay.'). |
'</p>'); |
'</p>'); |
return; |
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" />'); |
|
} |
} |
$r->rflush(); |
$r->rflush(); |
# |
# |
Line 614 sub BuildProblemStatisticsPage {
|
Line 718 sub BuildProblemStatisticsPage {
|
# |
# |
if (exists($ENV{'form.Excel'})) { |
if (exists($ENV{'form.Excel'})) { |
&Excel_output($r); |
&Excel_output($r); |
} else { |
} else { |
|
$r->print('<input type="submit" name="Excel" value="'. |
|
&mt('Produce Excel Output').'" />'.' 'x5); |
|
$r->rflush(); |
my $count = 0; |
my $count = 0; |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
$count += $seq->{'num_assess_parts'}; |
$count += $seq->{'num_assess_parts'}; |
Line 652 sub BuildProblemStatisticsPage {
|
Line 759 sub BuildProblemStatisticsPage {
|
sub output_sequence_statistics { |
sub output_sequence_statistics { |
my ($r) = @_; |
my ($r) = @_; |
my $c=$r->connection(); |
my $c=$r->connection(); |
$r->print('<h2>'.&mt('Sequence Statistics').'</h2>'); |
$r->print('<h2>'.&mt('Sequence Statistics'). |
|
&Apache::loncommon::help_open_topic('Statistics_Sequence'). |
|
'</h2>'); |
$r->print('<table border="0"><tr><td bgcolor="#777777">'."\n". |
$r->print('<table border="0"><tr><td bgcolor="#777777">'."\n". |
'<table border="0" cellpadding="3">'."\n". |
'<table border="0" cellpadding="3">'."\n". |
'<tr bgcolor="#FFFFE6">'); |
'<tr bgcolor="#FFFFE6">'); |
Line 765 sub statistics_html_table_data {
|
Line 874 sub statistics_html_table_data {
|
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'}.'">'; |
} |
} |
if (exists($field->{'format'})) { |
if (exists($field->{'format'}) && $data->{$field->{'name'}} !~ /[A-Z]/i) { |
$row .= sprintf($field->{'format'},$data->{$field->{'name'}}); |
$row .= sprintf($field->{'format'},$data->{$field->{'name'}}); |
} else { |
} else { |
$row .= $data->{$field->{'name'}}; |
$row .= $data->{$field->{'name'}}; |
Line 1240 sub Excel_output {
|
Line 1349 sub Excel_output {
|
$cols_output=0; |
$cols_output=0; |
foreach my $field (@SeqFields) { |
foreach my $field (@SeqFields) { |
next if ($field->{'selected'} ne 'yes'); |
next if ($field->{'selected'} ne 'yes'); |
|
my $fieldformat = undef; |
|
if (exists($field->{'excel_format'})) { |
|
$fieldformat = $format->{$field->{'excel_format'}}; |
|
} |
$excel_sheet->write($rows_output,$cols_output++, |
$excel_sheet->write($rows_output,$cols_output++, |
$data->{$field->{'name'}}); |
$data->{$field->{'name'}},$fieldformat); |
} |
} |
$rows_output++; |
$rows_output++; |
$cols_output=0; |
$cols_output=0; |
Line 1259 sub Excel_output {
|
Line 1372 sub Excel_output {
|
foreach my $field (@Fields) { |
foreach my $field (@Fields) { |
next if ($field->{'selected'} ne 'yes'); |
next if ($field->{'selected'} ne 'yes'); |
next if ($field->{'name'} eq 'problem_num'); |
next if ($field->{'name'} eq 'problem_num'); |
|
my $fieldformat = undef; |
|
if (exists($field->{'excel_format'})) { |
|
$fieldformat = $format->{$field->{'excel_format'}}; |
|
} |
$excel_sheet->write($rows_output,$cols_output++, |
$excel_sheet->write($rows_output,$cols_output++, |
$data->{$field->{'name'}}); |
$data->{$field->{'name'}},$fieldformat); |
} |
} |
$rows_output++; |
$rows_output++; |
$cols_output=0; |
$cols_output=0; |
Line 1327 sub compute_statistics_on_sequence {
|
Line 1444 sub compute_statistics_on_sequence {
|
foreach my $res (@{$seq->{'contents'}}) { |
foreach my $res (@{$seq->{'contents'}}) { |
next if ($res->{'type'} ne 'assessment'); |
next if ($res->{'type'} ne 'assessment'); |
foreach my $part (@{$res->{'parts'}}) { |
foreach my $part (@{$res->{'parts'}}) { |
|
next if ($res->{'partdata'}->{$part}->{'Survey'}); |
# |
# |
# This is where all the work happens |
# This is where all the work happens |
my $data = &get_statistics($seq,$res,$part,scalar(@StatsArray)+1); |
my $data = &get_statistics($seq,$res,$part,scalar(@StatsArray)+1); |
Line 1440 sub get_statistics {
|
Line 1558 sub get_statistics {
|
(\@Apache::lonstatistics::SelectedSections, |
(\@Apache::lonstatistics::SelectedSections, |
$Apache::lonstatistics::enrollment_status, |
$Apache::lonstatistics::enrollment_status, |
$symb,$part,$courseid,$starttime,$endtime); |
$symb,$part,$courseid,$starttime,$endtime); |
|
$data->{'symb'} = $symb; |
$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 1453 sub get_statistics {
|
Line 1572 sub get_statistics {
|
} |
} |
# |
# |
# Store in metadata if computations were done for all students |
# Store in metadata if computations were done for all students |
if ($Apache::lonstatistics::SelectedSections[0] eq 'all' && |
if ($data->{'num_students'} > 1) { |
$data->{'num_students'} > 1) { |
my @Sections = @Apache::lonstatistics::SelectedSections; |
my %storestats; |
my $sections = '"'.join(' ',@Sections).'"'; |
# |
$sections =~ s/&+/_/g; # Ensure no special characters |
|
$data->{'sections'}=$sections; |
|
$data->{'course'} = $ENV{'request.course.id'}; |
my $urlres=(&Apache::lonnet::decode_symb($resource->{'symb'}))[2]; |
my $urlres=(&Apache::lonnet::decode_symb($resource->{'symb'}))[2]; |
|
$data->{'urlres'}=$urlres; |
|
my %storestats = |
|
&LONCAPA::lonmetadata::dynamic_metadata_storage($data); |
my ($dom,$user) = $urlres=~/^(\w+)\/(\w+)/; |
my ($dom,$user) = $urlres=~/^(\w+)\/(\w+)/; |
my $preamble = $courseid.'___'.$urlres.'___'; |
|
# |
|
$storestats{$preamble.'timestamp'} = time; |
|
$storestats{$preamble.'stdno'} = $data->{'num_students'}; |
|
$storestats{$preamble.'avetries'} = $data->{'mean_tries'}; |
|
$storestats{$preamble.'difficulty'} = $data->{'deg_of_diff'}; |
|
if ($SelectedFields{'deg_of_disc'}) { |
|
$storestats{$preamble.'discrimination'} = $data->{'deg_of_disc'}; |
|
} |
|
# |
|
&Apache::lonnet::put('nohist_resevaldata',\%storestats,$dom,$user); |
&Apache::lonnet::put('nohist_resevaldata',\%storestats,$dom,$user); |
} |
} |
|
# |
|
$data->{'tries_per_correct'} = $data->{'tries'} / |
|
($data->{'num_solved'}+0.1); |
|
# |
|
# Get the due date for research purposes (commented out most of the time) |
|
# $data->{'duedate'} = |
|
# &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb); |
|
# $data->{'opendate'} = |
|
# &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb); |
|
# $data->{'maxtries'} = |
|
# &Apache::lonnet::EXT('resource.'.$part.'.maxtries',$symb); |
|
# $data->{'hinttries'} = |
|
# &Apache::lonnet::EXT('resource.'.$part.'.hinttries',$symb); |
|
# $data->{'weight'} = |
|
# &Apache::lonnet::EXT('resource.'.$part.'.weight',$symb); |
|
# $data->{'resptypes'} = join(',',@{$resource->{'partdata'}->{$part}->{'ResponseTypes'}}); |
return $data; |
return $data; |
} |
} |
|
|
Line 1515 sub compute_discrimination_factor {
|
Line 1645 sub compute_discrimination_factor {
|
map { |
map { |
$_->[&Apache::loncoursedata::RNK_student()]; |
$_->[&Apache::loncoursedata::RNK_student()]; |
} @{$ranking}[($num_students-$number_to_grab)..($num_students-1)]; |
} @{$ranking}[($num_students-$number_to_grab)..($num_students-1)]; |
|
if (! @BottomSet || (@BottomSet == 1 && $BottomSet[0] eq '') || |
|
! @TopSet || (@TopSet == 1 && $TopSet[0] eq '')) { |
|
return 'nan'; |
|
} |
my ($bottom_sum,$bottom_max) = |
my ($bottom_sum,$bottom_max) = |
&Apache::loncoursedata::get_sum_of_scores($resource,$part,\@BottomSet, |
&Apache::loncoursedata::get_sum_of_scores($resource,$part,\@BottomSet, |
undef,$starttime,$endtime); |
undef,$starttime,$endtime); |