--- loncom/interface/statistics/lonproblemstatistics.pm 2004/03/07 21:42:19 1.70 +++ loncom/interface/statistics/lonproblemstatistics.pm 2004/03/23 16:35:15 1.71 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemstatistics.pm,v 1.70 2004/03/07 21:42:19 matthew Exp $ +# $Id: lonproblemstatistics.pm,v 1.71 2004/03/23 16:35:15 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -58,7 +58,7 @@ use Apache::lonstatistics; use Apache::lonlocal; use Spreadsheet::WriteExcel; use Apache::lonstathelpers(); - +use Time::HiRes; ## ## Localization notes: ## @@ -168,6 +168,15 @@ my @Fields = ( sortable => 'yes', graphable => 'yes', long_title => 'Percent of students whose final answer is wrong' }, + { name => 'deg_of_disc', + title => 'Deg of Disc', + align => 'right', + color => '#FFFFE6', + format => '%4.2f', + sortable => 'yes', + graphable => 'yes', + long_title => 'Degree of Discrimination' }, + ); ############################################### @@ -283,6 +292,8 @@ sub BuildProblemStatisticsPage { # &Apache::lonstatistics::PrepareClasslist(); # + &Apache::loncoursedata::populate_weight_table(); + # my ($interface,$output_mode,$show) = &CreateInterface(); $r->print($interface); $r->print(''); @@ -849,9 +860,66 @@ sub get_statistics { $data->{'title.link'} = $resource->{'src'}.'?symb='. &Apache::lonnet::escape($resource->{'symb'}); # + $data->{'deg_of_disc'} = &compute_discrimination_factor($resource,$part,$sequence); return $data; } + +############################################### +############################################### + +=pod + +=item &compute_discrimination_factor() + +Inputs: $Resource, $Sequence + +Returns: integer between -1 and 1 + +=cut + +############################################### +############################################### +sub compute_discrimination_factor { + my ($resource,$part,$sequence) = @_; + &Apache::lonnet::logthis($sequence->{'title'}.' '.$resource->{'title'}); + my @Resources; + foreach my $res (@{$sequence->{'contents'}}) { + next if ($res->{'symb'} eq $resource->{'symb'}); + push (@Resources,$res->{'symb'}); + } + # + # rank + my $ranking = + &Apache::loncoursedata::rank_students_by_scores_on_resources + (\@Resources, + \@Apache::lonstatistics::SelectedSections, + $Apache::lonstatistics::enrollment_status,undef); + # + # compute their percent scores on the problems in the sequence, + 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]; + my @TopSet = + map { + $_->[&Apache::loncoursedata::RNK_student()]; + } @{$ranking}[($num_students-$number_to_grab)..($num_students-1)]; + my ($bottom_sum,$bottom_max) = + &Apache::loncoursedata::get_sum_of_scores($resource,$part,\@BottomSet); + my ($top_sum,$top_max) = + &Apache::loncoursedata::get_sum_of_scores($resource,$part,\@TopSet); + my $deg_of_disc; + if ($top_max == 0 || $bottom_max==0) { + $deg_of_disc = 'nan'; + } else { + $deg_of_disc = ($top_sum/$top_max) - ($bottom_sum/$bottom_max); + } + #&Apache::lonnet::logthis(' '.$top_sum.'/'.$top_max. + # ' - '.$bottom_sum.'/'.$bottom_max); + return $deg_of_disc; +} + ############################################### ###############################################