Diff for /loncom/interface/statistics/lonproblemstatistics.pm between versions 1.122.2.4 and 1.123

version 1.122.2.4, 2018/03/07 13:32:56 version 1.123, 2013/10/01 17:52:03
Line 52  package Apache::lonproblemstatistics; Line 52  package Apache::lonproblemstatistics;
 use strict;  use strict;
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon();  use Apache::loncommon();
   use Apache::lonquickgrades();
 use Apache::lonhtmlcommon;  use Apache::lonhtmlcommon;
 use Apache::loncoursedata;  use Apache::loncoursedata;
 use Apache::lonstatistics;  use Apache::lonstatistics;
Line 182  my @Fields = ( Line 183  my @Fields = (
              format => '%d',               format => '%d',
              sortable  => 'yes',               sortable  => 'yes',
              graphable => 'yes',               graphable => 'yes',
              long_title => 'Minimum Number of Tries',               long_title => 'Minumum Number of Tries',
              selectable => 'yes',               selectable => 'yes',
              defaultselected => 'yes',               defaultselected => 'yes',
            },             },
Line 282  my @Fields = ( Line 283  my @Fields = (
              sortable  => 'yes',               sortable  => 'yes',
              graphable => 'yes',               graphable => 'yes',
              long_title => 'Degree of Difficulty'.               long_title => 'Degree of Difficulty'.
                            ' ~[ 1 - ((#YES+#yes) / Tries) ~]',                             ' { 1 - ((#YES+#yes) / Tries) }',
              selectable => 'yes',               selectable => 'yes',
              defaultselected => 'yes',               defaultselected => 'yes',
            },             },
Line 438  my @SeqFields = ( Line 439  my @SeqFields = (
              format => '%4.2f',               format => '%4.2f',
              sortable  => 'no',               sortable  => 'no',
              graphable => 'no',               graphable => 'no',
              long_title => 'Minimum Sequence Score',               long_title => 'Minumum Sequence Score',
              selectable => 'yes',               selectable => 'yes',
              defaultselected => 'no',               defaultselected => 'no',
            },             },
Line 493  my @SeqFields = ( Line 494  my @SeqFields = (
              format => '%4.2f',               format => '%4.2f',
              sortable  => 'no',               sortable  => 'no',
              graphable => 'no',               graphable => 'no',
              long_title => 'Minimum Number of Correct Problems',               long_title => 'Minumum Number of Correct Problems',
              selectable => 'yes',               selectable => 'yes',
              defaultselected => 'no',               defaultselected => 'no',
            },             },
Line 586  sub parse_field_selection { Line 587  sub parse_field_selection {
   
 sub field_selection_input {  sub field_selection_input {
     my $Str = '<select name="fieldselections" multiple="multiple" size="5">'."\n";      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) {      foreach my $field (@Fields) {
         next if ($field->{'selectable'} ne 'yes');          next if ($field->{'selectable'} ne 'yes');
         $Str .= '    <option value="'.$field->{'name'}.'"';          $Str .= '    <option value="'.$field->{'name'}.'" ';
         if ($field->{'selected'} eq 'yes') {          if ($field->{'selected'} eq 'yes') {
             $Str .= ' selected="selected"';              $Str .= 'selected ';
         }          }
         $Str .= '>'.&mt($field->{'title'}).'</option>'."\n";          $Str .= '>'.$field->{'title'}.'</option>'."\n";
     }      }
     $Str .= "</select>\n";      $Str .= "</select>\n";
 }  }
Line 618  sub CreateInterface { Line 619  sub CreateInterface {
     &parse_field_selection();      &parse_field_selection();
     #      #
     my $Str = '';      my $Str = '';
       $Str .= '<p>';
     $Str .= &Apache::loncommon::start_data_table();      $Str .= &Apache::loncommon::start_data_table();
     $Str .= &Apache::loncommon::start_data_table_header_row();      $Str .= &Apache::loncommon::start_data_table_header_row();
     $Str .= '<th>'.&mt('Sections').'</th>';      $Str .= '<th>'.&mt('Sections').'</th>';
Line 643  sub CreateInterface { Line 645  sub CreateInterface {
     $Str .= &field_selection_input();      $Str .= &field_selection_input();
     $Str .= '</td><td align="center" valign="top">';      $Str .= '</td><td align="center" valign="top">';
     $Str .= &plot_dropdown();      $Str .= &plot_dropdown();
     $Str .= "\n";      $Str .= '</td>'."\n";
     $Str .= '</td><td align="center" valign="top">';      $Str .= '</td><td align="center" valign="top">';
     $Str .= &Apache::lonstathelpers::limit_by_time_form();      $Str .= &Apache::lonstathelpers::limit_by_time_form();
     $Str .= '</td>'."\n";      $Str .= '</td>'."\n";
     $Str .=  &Apache::loncommon::end_data_table_row();      $Str .=  &Apache::loncommon::end_data_table_row();
     $Str .= &Apache::loncommon::end_data_table();      $Str .= &Apache::loncommon::end_data_table();
     #      #
       $Str .= '</p>';
     $Str .= '<input type="submit" name="GenerateStatistics" value="'.      $Str .= '<input type="submit" name="GenerateStatistics" value="'.
         &mt('Generate Statistics').'" />';          &mt('Generate Statistics').'" />';
     $Str .= ('&nbsp;'x10);      $Str .= ('&nbsp;'x10);
Line 704  sub BuildProblemStatisticsPage { Line 707  sub BuildProblemStatisticsPage {
     # Finally let the user know we are here      # Finally let the user know we are here
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Overall Problem Statistics',      $r->print(&Apache::lonhtmlcommon::breadcrumbs('Overall Problem Statistics',
                                                 'Statistics_Overall_Key'));                                                  'Statistics_Overall_Key'));
       &Apache::lonquickgrades::startGradeScreen($r,'statistics');
   
     my $interface = &CreateInterface($r);      my $interface = &CreateInterface($r);
     $r->print($interface);      $r->print($interface);
Line 799  sub output_sequence_statistics { Line 803  sub output_sequence_statistics {
     $r->print('<h2>'.&mt('Sequence Statistics').      $r->print('<h2>'.&mt('Sequence Statistics').
       &Apache::loncommon::help_open_topic('Statistics_Sequence').        &Apache::loncommon::help_open_topic('Statistics_Sequence').
       '</h2>');        '</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(&sequence_html_header());
       $r->print(&Apache::loncommon::end_data_table_header_row());
     foreach my $seq (@sequences) {      foreach my $seq (@sequences) {
         last if ($c->aborted);          last if ($c->aborted);
         &compute_sequence_statistics($seq);          &compute_sequence_statistics($seq);
Line 822  sub output_sequence_statistics { Line 827  sub output_sequence_statistics {
 sub output_html_by_sequence {  sub output_html_by_sequence {
     my ($r) = @_;      my ($r) = @_;
     my $c = $r->connection();      my $c = $r->connection();
     $r->print('<br />'.&html_preamble());      $r->print('<br>'.&html_preamble());
     #      #
     foreach my $seq (@sequences) {      foreach my $seq (@sequences) {
         last if ($c->aborted);          last if ($c->aborted);
Line 926  sub statistics_table_header { Line 931  sub statistics_table_header {
         next if ($options =~ /no $field->{'name'}/);          next if ($options =~ /no $field->{'name'}/);
         next if ($field->{'selected'} ne 'yes');          next if ($field->{'selected'} ne 'yes');
         $header_row .= '<th>';          $header_row .= '<th>';
         my $header_row_text = &mt($field->{'title'});  
         if (exists($field->{'sortable'}) && $field->{'sortable'} eq 'yes') {          if (exists($field->{'sortable'}) && $field->{'sortable'} eq 'yes') {
             $header_row .=              $header_row .= '<a href="javascript:'.
                 '<a href="javascript:'.  
                 'document.Statistics.sortby.value='."'".$field->{'name'}."'".                  'document.Statistics.sortby.value='."'".$field->{'name'}."'".
                 ';document.Statistics.submit();">'.                      ';document.Statistics.submit();">';
                 $header_row_text.          }
                 '</a>';          $header_row .= &mt($field->{'title'});
         } else {          if ($options =~ /sortable/) {
             $header_row .= $header_row_text;              $header_row.= '</a>';
         }          }
         if ($options !~ /no plots/        &&           if ($options !~ /no plots/        && 
             exists($field->{'graphable'}) &&               exists($field->{'graphable'}) && 
Line 952  sub statistics_table_header { Line 955  sub statistics_table_header {
 }  }
   
 sub sequence_html_header {  sub sequence_html_header {
     my $Str .= &Apache::loncommon::start_data_table_header_row();      my $Str .= '<tr>';
     foreach my $field (@SeqFields) {      foreach my $field (@SeqFields) {
 #        next if ($field->{'selected'} ne 'yes');  #        next if ($field->{'selected'} ne 'yes');
         $Str .= '<th bgcolor="'.$field->{'color'}.'"';          $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;      return $Str;
 }  }
   
Line 966  sub sequence_html_header { Line 969  sub sequence_html_header {
 sub sequence_html_output {  sub sequence_html_output {
     my ($seq) = @_;      my ($seq) = @_;
     my $data = $SeqStat{$seq->symb};      my $data = $SeqStat{$seq->symb};
     my $row = &Apache::loncommon::start_data_table_row();      my $row = '<tr>';
     foreach my $field (@SeqFields) {      foreach my $field (@SeqFields) {
         next if ($field->{'selected'} ne 'yes');          next if ($field->{'selected'} ne 'yes');
         $row .= '<td bgcolor="'.$field->{'color'}.'"';          $row .= '<td bgcolor="'.$field->{'color'}.'"';
Line 981  sub sequence_html_output { Line 984  sub sequence_html_output {
         }          }
         $row .= '</td>';          $row .= '</td>';
     }      }
     $row .= &Apache::loncommon::end_data_table_row()."\n";      $row .= '</tr>'."\n";
     return $row;      return $row;
 }  }
   
Line 1343  sub Excel_output { Line 1346  sub Excel_output {
     # Time restrictions      # Time restrictions
     my $time_string;      my $time_string;
     if (defined($starttime)) {      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)) {          if (defined($endtime)) {
             $time_string .=  &mt('Data collected from [_1] to [_2]',              $time_string .= ' to '.localtime($endtime);
                                  &Apache::lonlocal::locallocaltime($starttime),  
                                  &Apache::lonlocal::locallocaltime($endtime));  
         } else {  
             $time_string .=  &mt('Data collected from [_1]',  
                                  &Apache::lonlocal::locallocaltime($starttime));  
         }          }
           $time_string .= '.';
     } elsif (defined($endtime)) {      } elsif (defined($endtime)) {
         $time_string .=  &mt('Data collected before [_1]',          # See note above about lonlocal:locallocaltime
                              &Apache::lonlocal::locallocaltime($endtime));          $time_string .= 'Data collected before '.localtime($endtime).'.';
     }      }
     if (defined($time_string)) {      if (defined($time_string)) {
         $excel_sheet->write($rows_output,$cols_output++,$time_string);          $excel_sheet->write($rows_output,$cols_output++,$time_string);
Line 1362  sub Excel_output { Line 1364  sub Excel_output {
     #      #
     # Put the date in there too      # Put the date in there too
     $excel_sheet->write($rows_output,$cols_output++,      $excel_sheet->write($rows_output,$cols_output++,
                         &mt('Compiled on [_1]',&Apache::lonlocal::locallocaltime(time)));                          'Compiled on '.localtime(time));
     #      #
     $rows_output++;      $rows_output++;
     $cols_output=0;      $cols_output=0;
Line 1667  sub compute_discrimination_factor { Line 1669  sub compute_discrimination_factor {
     my $number_to_grab = int(scalar(@{$ranking})/4);      my $number_to_grab = int(scalar(@{$ranking})/4);
     my $num_students = scalar(@{$ranking});      my $num_students = scalar(@{$ranking});
     my @BottomSet = map { $_->[&Apache::loncoursedata::RNK_student()];      my @BottomSet = map { $_->[&Apache::loncoursedata::RNK_student()];
                       } @{$ranking}[0..$number_to_grab-1];                        } @{$ranking}[0..$number_to_grab];
     my @TopSet    =      my @TopSet    =
         map {          map {
             $_->[&Apache::loncoursedata::RNK_student()];              $_->[&Apache::loncoursedata::RNK_student()];
           } @{$ranking}[-$number_to_grab..-1];            } @{$ranking}[-$number_to_grab..0];
     if (! @BottomSet || (@BottomSet == 1 && $BottomSet[0] eq '') ||      if (! @BottomSet || (@BottomSet == 1 && $BottomSet[0] eq '') ||
         ! @TopSet    || (@TopSet    == 1 && $TopSet[0]    eq '')) {          ! @TopSet    || (@TopSet    == 1 && $TopSet[0]    eq '')) {
         return 'nan';          return 'nan';

Removed from v.1.122.2.4  
changed lines
  Added in v.1.123


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>