--- loncom/interface/statistics/lonproblemstatistics.pm 2023/09/08 00:07:30 1.122.2.4.2.1 +++ loncom/interface/statistics/lonproblemstatistics.pm 2013/12/30 13:51:37 1.124 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemstatistics.pm,v 1.122.2.4.2.1 2023/09/08 00:07:30 raeburn Exp $ +# $Id: lonproblemstatistics.pm,v 1.124 2013/12/30 13:51:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -52,6 +52,7 @@ package Apache::lonproblemstatistics; use strict; use Apache::lonnet; use Apache::loncommon(); +use Apache::lonquickgrades(); use Apache::lonhtmlcommon; use Apache::loncoursedata; use Apache::lonstatistics; @@ -182,7 +183,7 @@ my @Fields = ( format => '%d', sortable => 'yes', graphable => 'yes', - long_title => 'Minimum Number of Tries', + long_title => 'Minumum Number of Tries', selectable => 'yes', defaultselected => 'yes', }, @@ -438,7 +439,7 @@ my @SeqFields = ( format => '%4.2f', sortable => 'no', graphable => 'no', - long_title => 'Minimum Sequence Score', + long_title => 'Minumum Sequence Score', selectable => 'yes', defaultselected => 'no', }, @@ -493,7 +494,7 @@ my @SeqFields = ( format => '%4.2f', sortable => 'no', graphable => 'no', - long_title => 'Minimum Number of Correct Problems', + long_title => 'Minumum Number of Correct Problems', selectable => 'yes', defaultselected => 'no', }, @@ -586,14 +587,14 @@ sub parse_field_selection { sub field_selection_input { my $Str = '<select name="fieldselections" multiple="multiple" size="5">'."\n"; - $Str .= '<option value="all">'.&mt('all').'</option>'."\n"; + $Str .= '<option value="all">all</option>'."\n"; foreach my $field (@Fields) { next if ($field->{'selectable'} ne 'yes'); - $Str .= ' <option value="'.$field->{'name'}.'"'; + $Str .= ' <option value="'.$field->{'name'}.'" '; if ($field->{'selected'} eq 'yes') { - $Str .= ' selected="selected"'; + $Str .= 'selected '; } - $Str .= '>'.&mt($field->{'title'}).'</option>'."\n"; + $Str .= '>'.$field->{'title'}.'</option>'."\n"; } $Str .= "</select>\n"; } @@ -618,6 +619,7 @@ sub CreateInterface { &parse_field_selection(); # my $Str = ''; + $Str .= '<p>'; $Str .= &Apache::loncommon::start_data_table(); $Str .= &Apache::loncommon::start_data_table_header_row(); $Str .= '<th>'.&mt('Sections').'</th>'; @@ -643,13 +645,14 @@ sub CreateInterface { $Str .= &field_selection_input(); $Str .= '</td><td align="center" valign="top">'; $Str .= &plot_dropdown(); - $Str .= "\n"; + $Str .= '</td>'."\n"; $Str .= '</td><td align="center" valign="top">'; $Str .= &Apache::lonstathelpers::limit_by_time_form(); $Str .= '</td>'."\n"; $Str .= &Apache::loncommon::end_data_table_row(); $Str .= &Apache::loncommon::end_data_table(); # + $Str .= '</p>'; $Str .= '<input type="submit" name="GenerateStatistics" value="'. &mt('Generate Statistics').'" />'; $Str .= (' 'x10); @@ -704,6 +707,7 @@ sub BuildProblemStatisticsPage { # Finally let the user know we are here $r->print(&Apache::lonhtmlcommon::breadcrumbs('Overall Problem Statistics', 'Statistics_Overall_Key')); + &Apache::lonquickgrades::startGradeScreen($r,'statistics'); my $interface = &CreateInterface($r); $r->print($interface); @@ -757,10 +761,9 @@ sub BuildProblemStatisticsPage { &Apache::lonstatistics::section_and_enrollment_description(). '</p>'); my $count = 0; - my $include_tools = 1; foreach my $seq (@sequences) { my @resources = - &Apache::lonstathelpers::get_resources($navmap,$seq,$include_tools); + &Apache::lonstathelpers::get_resources($navmap,$seq); $count += scalar(@resources); } if ($count > 10) { @@ -800,8 +803,9 @@ sub output_sequence_statistics { $r->print('<h2>'.&mt('Sequence Statistics'). &Apache::loncommon::help_open_topic('Statistics_Sequence'). '</h2>'); - $r->print(&Apache::loncommon::start_data_table()); + $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row()); $r->print(&sequence_html_header()); + $r->print(&Apache::loncommon::end_data_table_header_row()); foreach my $seq (@sequences) { last if ($c->aborted); &compute_sequence_statistics($seq); @@ -823,7 +827,7 @@ sub output_sequence_statistics { sub output_html_by_sequence { my ($r) = @_; my $c = $r->connection(); - $r->print('<br />'.&html_preamble()); + $r->print('<br>'.&html_preamble()); # foreach my $seq (@sequences) { last if ($c->aborted); @@ -927,16 +931,14 @@ sub statistics_table_header { next if ($options =~ /no $field->{'name'}/); next if ($field->{'selected'} ne 'yes'); $header_row .= '<th>'; - my $header_row_text = &mt($field->{'title'}); if (exists($field->{'sortable'}) && $field->{'sortable'} eq 'yes') { - $header_row .= - '<a href="javascript:'. + $header_row .= '<a href="javascript:'. 'document.Statistics.sortby.value='."'".$field->{'name'}."'". - ';document.Statistics.submit();">'. - $header_row_text. - '</a>'; - } else { - $header_row .= $header_row_text; + ';document.Statistics.submit();">'; + } + $header_row .= &mt($field->{'title'}); + if ($options =~ /sortable/) { + $header_row.= '</a>'; } if ($options !~ /no plots/ && exists($field->{'graphable'}) && @@ -953,13 +955,13 @@ sub statistics_table_header { } sub sequence_html_header { - my $Str .= &Apache::loncommon::start_data_table_header_row(); + my $Str .= '<tr>'; foreach my $field (@SeqFields) { # next if ($field->{'selected'} ne 'yes'); $Str .= '<th bgcolor="'.$field->{'color'}.'"'; - $Str .= '>'.&mt($field->{'title'}).'</th>'; + $Str .= '>'.$field->{'title'}.'</th>'; } - $Str .= &Apache::loncommon::end_data_table_header_row(); + $Str .= '</tr>'; return $Str; } @@ -967,7 +969,7 @@ sub sequence_html_header { sub sequence_html_output { my ($seq) = @_; my $data = $SeqStat{$seq->symb}; - my $row = &Apache::loncommon::start_data_table_row(); + my $row = '<tr>'; foreach my $field (@SeqFields) { next if ($field->{'selected'} ne 'yes'); $row .= '<td bgcolor="'.$field->{'color'}.'"'; @@ -982,7 +984,7 @@ sub sequence_html_output { } $row .= '</td>'; } - $row .= &Apache::loncommon::end_data_table_row()."\n"; + $row .= '</tr>'."\n"; return $row; } @@ -1344,17 +1346,16 @@ sub Excel_output { # 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 .= &mt('Data collected from [_1] to [_2]', - &Apache::lonlocal::locallocaltime($starttime), - &Apache::lonlocal::locallocaltime($endtime)); - } else { - $time_string .= &mt('Data collected from [_1]', - &Apache::lonlocal::locallocaltime($starttime)); + $time_string .= ' to '.localtime($endtime); } + $time_string .= '.'; } elsif (defined($endtime)) { - $time_string .= &mt('Data collected before [_1]', - &Apache::lonlocal::locallocaltime($endtime)); + # See note above about lonlocal:locallocaltime + $time_string .= 'Data collected before '.localtime($endtime).'.'; } if (defined($time_string)) { $excel_sheet->write($rows_output,$cols_output++,$time_string); @@ -1363,7 +1364,7 @@ sub Excel_output { # # Put the date in there too $excel_sheet->write($rows_output,$cols_output++, - &mt('Compiled on [_1]',&Apache::lonlocal::locallocaltime(time))); + 'Compiled on '.localtime(time)); # $rows_output++; $cols_output=0; @@ -1468,9 +1469,8 @@ sub write_headers { ################################################## sub compute_statistics_on_sequence { my ($seq) = @_; - my $include_tools = 1; my @Data; - foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq,$include_tools)) { + foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq)) { foreach my $part (@{$res->parts}) { next if (($res->is_survey($part)) || ($res->is_anonsurvey($part))) ; # @@ -1648,10 +1648,9 @@ Returns: integer between -1 and 1 ############################################### sub compute_discrimination_factor { my ($resource,$part,$seq) = @_; - my $include_tools = 1; my $symb = $resource->symb; my @Resources; - foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq,$include_tools)){ + foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq)){ next if ($res->symb eq $symb); push (@Resources,$res->symb); } @@ -1670,11 +1669,11 @@ sub compute_discrimination_factor { my $number_to_grab = int(scalar(@{$ranking})/4); my $num_students = scalar(@{$ranking}); my @BottomSet = map { $_->[&Apache::loncoursedata::RNK_student()]; - } @{$ranking}[0..$number_to_grab-1]; + } @{$ranking}[0..$number_to_grab]; my @TopSet = map { $_->[&Apache::loncoursedata::RNK_student()]; - } @{$ranking}[-$number_to_grab..-1]; + } @{$ranking}[-$number_to_grab..0]; if (! @BottomSet || (@BottomSet == 1 && $BottomSet[0] eq '') || ! @TopSet || (@TopSet == 1 && $TopSet[0] eq '')) { return 'nan'; @@ -1715,11 +1714,10 @@ sub compute_discrimination_factor { ############################################### sub compute_sequence_statistics { my ($seq) = @_; - my $include_tools = 1; my $symb = $seq->symb; my @Resources; my $part_count; - foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq,$include_tools)) { + foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq)) { push (@Resources,$res->symb); $part_count += scalar(@{$res->parts}); }