--- loncom/interface/statistics/lonproblemstatistics.pm 2004/05/14 20:30:17 1.85 +++ loncom/interface/statistics/lonproblemstatistics.pm 2004/10/06 15:37:59 1.94 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemstatistics.pm,v 1.85 2004/05/14 20:30:17 matthew Exp $ +# $Id: lonproblemstatistics.pm,v 1.94 2004/10/06 15:37:59 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -238,6 +238,17 @@ my @Fields = ( format => '%4.1f', sortable => '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', selectable => 'yes', defaultselected => 'yes', @@ -263,7 +274,7 @@ my @Fields = ( graphable => 'yes', long_title => 'Degree of Discrimination', selectable => 'yes', - defaultselected => 'no', + defaultselected => 'yes', }, ## duedate included for research purposes. Commented out most of the time. # { name => 'duedate', @@ -298,6 +309,39 @@ my @Fields = ( # 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', +# }, ); my @SeqFields = ( @@ -536,6 +580,7 @@ select sections, maps, and output. ############################################### ############################################### sub CreateInterface { + my ($r) = @_; # &parse_field_selection(); # @@ -571,19 +616,18 @@ sub CreateInterface { $Str .= '</td><td>'.&field_selection_input(); $Str .= '</td></tr>'."\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="'. &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; } @@ -621,13 +665,20 @@ sub BuildProblemStatisticsPage { undef(%SeqStat); # # Finally let the user know we are here - my $interface = &CreateInterface(); + my $interface = &CreateInterface($r); $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" />'); + my @CacheButtonHTML = + &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>'. &mt('Press "Generate Statistics" when you are ready.'). '</h3><p>'. @@ -636,13 +687,6 @@ sub BuildProblemStatisticsPage { ' 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" />'); } $r->rflush(); # @@ -652,7 +696,10 @@ sub BuildProblemStatisticsPage { # if (exists($ENV{'form.Excel'})) { &Excel_output($r); - } else { + } else { + $r->print('<input type="submit" name="Excel" value="'. + &mt('Produce Excel Output').'" />'.' 'x5); + $r->rflush(); my $count = 0; foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { $count += $seq->{'num_assess_parts'}; @@ -690,7 +737,9 @@ sub BuildProblemStatisticsPage { sub output_sequence_statistics { my ($r) = @_; 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". '<table border="0" cellpadding="3">'."\n". '<tr bgcolor="#FFFFE6">'); @@ -803,7 +852,7 @@ sub statistics_html_table_data { if (exists($field->{'special'}) && $field->{'special'} eq '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'}}); } else { $row .= $data->{$field->{'name'}}; @@ -1373,6 +1422,7 @@ sub compute_statistics_on_sequence { foreach my $res (@{$seq->{'contents'}}) { next if ($res->{'type'} ne 'assessment'); foreach my $part (@{$res->{'parts'}}) { + next if ($res->{'partdata'}->{$part}->{'Survey'}); # # This is where all the work happens my $data = &get_statistics($seq,$res,$part,scalar(@StatsArray)+1); @@ -1519,6 +1569,11 @@ sub get_statistics { # &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->{'resptypes'} = join(',',@{$resource->{'partdata'}->{$part}->{'ResponseTypes'}}); return $data; } @@ -1563,6 +1618,10 @@ sub compute_discrimination_factor { map { $_->[&Apache::loncoursedata::RNK_student()]; } @{$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) = &Apache::loncoursedata::get_sum_of_scores($resource,$part,\@BottomSet, undef,$starttime,$endtime);