--- loncom/interface/statistics/lonproblemstatistics.pm	2004/06/16 14:21:16	1.88
+++ loncom/interface/statistics/lonproblemstatistics.pm	2005/01/11 19:45:18	1.96
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemstatistics.pm,v 1.88 2004/06/16 14:21:16 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.96 2005/01/11 19:45:18 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -231,6 +231,17 @@ my @Fields = (
              selectable => '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',
              title  => '#Wrng',
              align  => 'right',
@@ -238,6 +249,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 +285,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',
@@ -309,6 +331,39 @@ my @Fields = (
 #             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 = (
@@ -704,7 +759,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">');
@@ -817,7 +874,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'}};
@@ -1529,11 +1586,20 @@ sub get_statistics {
         &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;
 }
@@ -1579,6 +1645,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);