'."\n";
- return $Str;
-}
-
-#######################################################
-#######################################################
-
-=pod
-
-=item &CreateAndParseOutputSelector()
-
-Construct a selection list of options for output and parse output selections.
-The current output selected is indicated by the values of the two package
-variables $output_mode and $show. @OutputOptions holds the descriptions of
-the output options and the values for $output_mode and $show.
-
- Based on code from lonstudentassessment.pm.
-
-=cut
-
-#######################################################
-#######################################################
-my $output_mode;
-my $show;
-
-my @OutputOptions =
- (
- { name => 'problem statistics grouped by sequence',
- value => 'HTML problem statistics grouped',
- description => 'Output statistics for the problem parts.',
- mode => 'html',
- show => 'grouped',
- },
- { name => 'problem statistics ungrouped',
- value => 'HTML problem statistics ungrouped',
- description => 'Output statistics for the problem parts.',
- mode => 'html',
- show => 'ungrouped',
- },
- { name => 'problem statistics, Excel',
- value => 'Excel problem statistics',
- description => 'Output statistics for the problem parts '.
- 'in an Excel workbook',
- mode => 'excel',
- show => 'all',
- },
- { name => 'Degree of Difficulty Plot',
- value => 'plot deg diff',
- description => 'Generate a plot of the degree of difficulty of each '.
- 'problem part.',
- mode => 'plot',
- show => 'deg of diff',
- },
- { name => 'Percent Wrong Plot',
- value => 'plot per wrong',
- description => 'Generate a plot showing the percent of students who '.
- 'were unable to complete each problem part',
- mode => 'plot',
- show => 'per wrong',
- },
- );
-
-sub OutputDescriptions {
- my $Str = '';
- $Str .= "
Output Modes
\n";
- $Str .= "
\n";
- foreach my $outputmode (@OutputOptions) {
- $Str .="
".$outputmode->{'name'}."
\n";
- $Str .="
".$outputmode->{'description'}."
\n";
- }
- $Str .= "
\n";
- return $Str;
-}
-
-sub CreateAndParseOutputSelector {
- my $Str = '';
- my $elementname = 'statsoutputmode';
- #
- # Format for output options is 'mode, restrictions';
- my $selected = 'HTML problem statistics grouped';
- if (exists($ENV{'form.'.$elementname})) {
- if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
- $selected = $ENV{'form.'.$elementname}->[0];
- } else {
- $selected = $ENV{'form.'.$elementname};
- }
- }
#
- # Set package variables describing output mode
- $output_mode = 'html';
- $show = 'all';
- foreach my $option (@OutputOptions) {
- next if ($option->{'value'} ne $selected);
- $output_mode = $option->{'mode'};
- $show = $option->{'show'};
- }
+ $Str .= '
'.&mt('Status: [_1]',
+ ''
+ ).
+ '
';
+ #
+ $Str .= '';
+ $Str .= ' 'x5;
+ $Str .= 'Plot '.&plot_dropdown().(' 'x10);
#
- # Build the form element
- $Str = qq/";
return $Str;
}
@@ -209,44 +650,6 @@ sub CreateAndParseOutputSelector {
=pod
-=item &Gather_Student_Data()
-
-Ensures all student data is up to date.
-
-=cut
-
-###############################################
-###############################################
-sub Gather_Student_Data {
- my ($r) = @_;
- my $c = $r->connection();
- #
- my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
- #
- my @Students = @Apache::lonstatistics::Students;
- #
- # Open the progress window
- my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
- ($r,'Statistics Compilation Status',
- 'Statistics Compilation Progress', scalar(@Students));
- #
- while (my $student = shift @Students) {
- return if ($c->aborted());
- my ($status,undef) = &Apache::loncoursedata::ensure_current_data
- ($student->{'username'},$student->{'domain'},
- $ENV{'request.course.id'});
- &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
- 'last student');
- }
- &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
- $r->rflush();
-}
-
-###############################################
-###############################################
-
-=pod
-
=item &BuildProblemStatisticsPage()
Main interface to problem statistics.
@@ -255,358 +658,669 @@ Main interface to problem statistics.
###############################################
###############################################
+my $navmap;
+my @sequences;
+
sub BuildProblemStatisticsPage {
my ($r,$c)=@_;
+ undef($navmap);
+ undef(@sequences);
#
- $output_mode = 'html';
- $show = 'grouped';
- #
- $r->print(&CreateInterface());
- $r->print('');
+ my %Saveable_Parameters = ('Status' => 'scalar',
+ 'statsoutputmode' => 'scalar',
+ 'Section' => 'array',
+ 'StudentData' => 'array',
+ 'Maps' => 'array',
+ 'fieldselections'=> 'array');
+ &Apache::loncommon::store_course_settings('statistics',
+ \%Saveable_Parameters);
+ &Apache::loncommon::restore_course_settings('statistics',
+ \%Saveable_Parameters);
+ #
+ &Apache::lonstatistics::PrepareClasslist();
+ #
+ # Clear the package variables
+ undef(@StatsArray);
+ undef(%SeqStat);
+ #
+ # Finally let the user know we are here
+ my $interface = &CreateInterface($r);
+ $r->print($interface);
$r->print('');
- if (! exists($ENV{'form.statsfirstcall'})) {
- $r->print(<
-
-Please make your selections in the boxes above and hit
-the button marked "Update Display".
-
-
-ENDMSG
+ #
+ 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('
'.
+ &mt('Press "Generate Statistics" when you are ready.').
+ '
'.
+ &mt('It may take some time to update the student data '.
+ 'for the first analysis. Future analysis this session '.
+ ' will not have this delay.').
+ '
");
+ # This probably does not need to be done each time we are called, but
+ # it does not slow things down noticably.
+ &Apache::loncoursedata::populate_weight_table();
+ #
+ ($navmap,@sequences) =
+ &Apache::lonstatistics::selected_sequences_with_assessments();
+ if (! ref($navmap)) {
+ $r->print('
\n");
+ return;
+}
-Presents the statistics data as an html table organized by the order
-the assessments appear in the course.
+sub html_preamble {
+ my $Str='';
+ $Str .= "
\n";
+ my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
+ if (defined($starttime) || defined($endtime)) {
+ # Inform the user what the time limits on the data are.
+ $Str .= '
'.&mt('Statistics on submissions from [_1] to [_2]',
+ &Apache::lonlocal::locallocaltime($starttime),
+ &Apache::lonlocal::locallocaltime($endtime)
+ ).'
';
+ }
+ $Str .= "
".&mt('Compiled on [_1]',
+ &Apache::lonlocal::locallocaltime(time))."
";
+ return $Str;
+}
-=cut
###############################################
###############################################
-sub output_html_grouped_by_sequence {
- my ($r) = @_;
- my $problem_num = 0;
- #$r->print(&ProblemStatisticsLegend());
- my @Header = ("Title","Part","#Stdnts","Tries","Mod",
- "Mean","#YES","#yes","%Wrng","DoDiff",
- "S.D.","Skew.");#,"D.F.1st","D.F.2nd");
- # #FFFFE6 #EEFFCC #DDFFFF FFDDDD #DDFFDD #FFDDFF
- foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()) {
- next if ($sequence->{'num_assess'}<1);
- $r->print("
".$sequence->{'title'}."
");
- $r->print('
'."\n");
- $r->print('
'."\n");
- $r->print('
'.
- join("
",@Header)."
\n");
- foreach my $resource (@{$sequence->{'contents'}}) {
- next if ($resource->{'type'} ne 'assessment');
- foreach my $part (@{$resource->{'parts'}}) {
- $problem_num++;
- my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
- $SKEW) = &get_statistics($resource->{'symb'},$part);
- #
- $part = ' ' if ($part == 0);
- #
- my $wrongpercent = 0;
- if (defined($num) && $num > 0) {
- $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
- }
- my $option = '';
- $r->print('
';
+ foreach my $field (@SeqFields) {
+# next if ($field->{'selected'} ne 'yes');
+ $Str .= '
{'title'}.'
';
+ }
+ $Str .= '
';
+ return $Str;
+}
-=item &output_html_ungrouped()
-Presents the statistics data in a single html table which can be sorted by
-different columns.
+sub sequence_html_output {
+ my ($seq) = @_;
+ my $data = $SeqStat{$seq->symb};
+ my $row = '
';
+ foreach my $field (@SeqFields) {
+ next if ($field->{'selected'} ne 'yes');
+ $row .= '
'."\n";
+ return $row;
+}
-=cut
+####################################################
+####################################################
+##
+## Plotting Routines
+##
+####################################################
+####################################################
+sub make_plot {
+ my ($r,$plot) = @_;
+ &compute_all_statistics($r);
+ &sort_data($ENV{'form.sortby'});
+ if ($plot eq 'degrees') {
+ °rees_plot($r);
+ } elsif ($plot eq 'tries statistics') {
+ &tries_data_plot($r);
+ } else {
+ &make_single_stat_plot($r,$plot);
+ }
+ return;
+}
-###############################################
-###############################################
-sub output_html_ungrouped {
- my ($r,$option) = @_;
+sub make_single_stat_plot {
+ my ($r,$datafield) = @_;
#
- my $problem_num = 0;
- my $show_container = 0;
- my $show_part = 0;
- #$r->print(&ProblemStatisticsLegend());
- my @Header = ("Title","Part","#Stdnts","Tries","Mod",
- "Mean","#YES","#yes","%Wrng","DoDiff",
- "S.D.","Skew");#,"D.F.1st","D.F.2nd");
+ my $title; my $yaxis;
+ foreach my $field (@Fields) {
+ next if ($field->{'name'} ne $datafield);
+ $title = $field->{'long_title'};
+ $yaxis = $field->{'title'};
+ last;
+ }
+ if ($title eq '' || $yaxis eq '') {
+ # datafield is something we do not know enough about to plot
+ $r->print('
'.
+ &mt('Unable to plot the requested statistic.').
+ '
');
+ return;
+ }
#
- my $sortby = undef;
- foreach (@Header) {
- if ($ENV{'form.sortby'} eq $_) {
- $sortby = $_;
+ # Build up the data sets to plot
+ my @Labels;
+ my @Data;
+ my $max = 1;
+ foreach my $data (@StatsArray) {
+ push(@Labels,$data->{'problem_num'});
+ push(@Data,$data->{$datafield});
+ if ($data->{$datafield}>$max) {
+ $max = $data->{$datafield};
}
}
- if (! defined($sortby) || $sortby eq '') {
- $sortby = 'Container';
- }
- # If there is more than one sequence, list their titles
- my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
- if (@Sequences > 1) {
- unshift(@Header,"Container");
- $show_container = 1;
+ foreach (1,2,3,4,5,10,15,20,25,40,50,75,100,150,200,250,300,500,600,750,
+ 1000,1500,2000,2500,3000,3500,4000,5000,7500,10000,15000,20000) {
+ if ($max <= $_) {
+ $max = $_;
+ last;
+ }
}
- #
- # If the option for showing the problem number is needed, push that
- # on the list too
- if (defined($option) && $option =~ /show probnum/) {
- unshift(@Header,"P#");
+ if ($max > 20000) {
+ $max = 10000*(int($max/10000)+1);
}
#
- $r->print('
'."\n");
- $r->rflush();
- #
- # Compile the data
- my @Statsarray;
- foreach my $sequence (@Sequences) {
- next if ($sequence->{'num_assess'}<1);
- foreach my $resource (@{$sequence->{'contents'}}) {
- next if ($resource->{'type'} ne 'assessment');
- foreach my $part (@{$resource->{'parts'}}) {
- $problem_num++;
- my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
- $SKEW) = &get_statistics($resource->{'symb'},$part);
- #
- $show_part = 1 if ($part ne '0');
- $part = ' ' if ($part == 0);
- #
- my $wrongpercent = 0;
- if (defined($num) && $num > 0) {
- $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
- }
- push (@Statsarray,
- { 'sequence' => $sequence,
- 'resource' => $resource,
- 'Title' => $resource->{'title'},
- 'Part' => $part,
- '#Stdnts' => $num,
- 'Tries' => $tries,
- 'Mod' => $mod,
- 'Mean' => $mean,
- '#YES' => $Solved,
- '#yes' => $solved,
- '%Wrng' => $wrongpercent,
- 'DoDiff' => $DegOfDiff,
- 'S.D.' => $STD,
- 'Skew' => $SKEW,
- 'problem_num' => $problem_num,
- });
- }
+ $r->print("
\n");
+ return;
+}
+
+sub degrees_plot {
+ my ($r)=@_;
+ my $count = scalar(@StatsArray);
+ my $width = 50 + 10*$count;
+ $width = 300 if ($width < 300);
+ my $height = 300;
+ my $plot = '';
+ my $ymax = 0;
+ my $ymin = 0;
+ my @Disc; my @Diff; my @Labels;
+ foreach my $data (@StatsArray) {
+ push(@Labels,$data->{'problem_num'});
+ my $disc = $data->{'deg_of_disc'};
+ my $diff = $data->{'deg_of_diff'};
+ push(@Disc,$disc);
+ push(@Diff,$diff);
+ #
+ $ymin = $disc if ($ymin > $disc);
+ $ymin = $diff if ($ymin > $diff);
+ $ymax = $disc if ($ymax < $disc);
+ $ymax = $diff if ($ymax < $diff);
+ }
+ #
+ # Make sure we show relevant information.
+ if ($ymin < 0) {
+ if (abs($ymin) < 0.05) {
+ $ymin = 0;
+ } else {
+ $ymin = -1;
}
}
- #
- # Table Headers
- $r->print('
'."\n");
- my $Str = '';
- foreach (@Header) {
- next if ($_ eq 'Part' && !$show_part);
- # Do not allow sorting on some fields
- if ($_ eq $sortby || /^(Part|P\#)$/) {
- $Str .= '
\n");
#
- # Print out the data
- $ENV{'form.sortby'} = 'Contents';
- &output_html_ungrouped($r,'show probnum');
+ # Renumber the data set
+ my $count;
+ foreach my $data (@StatsArray) {
+ $data->{'problem_num'} = ++$count;
+ }
return;
}
-###############################################
-###############################################
+########################################################
+########################################################
-=pod
+=pod
-=item &DrawGraph()
+=item &get_statistics()
-=cut
+Wrapper routine from the call to loncoursedata::get_problem_statistics.
+Calls lonstathelpers::get_time_limits() to limit the data set by time
+and &compute_discrimination_factor
-###############################################
-###############################################
-sub DrawGraph {
- my ($values,$title,$xaxis,$yaxis,$Max)=@_;
- $title = '' if (! defined($title));
- $xaxis = '' if (! defined($xaxis));
- $yaxis = '' if (! defined($yaxis));
- #
- my $sendValues = join(',', @$values);
- my $sendCount = scalar(@$values);
- if ( $Max > 1 ) {
- if ($Max % 10) {
- if ( int($Max) < $Max ) {
- $Max++;
- $Max = int($Max);
- }
- }
- } else {
- $Max = 1;
- }
- my @GData = ($title,$xaxis,$yaxis,$Max,$sendCount,$sendValues);
- return '';
-}
+Inputs: $sequence, $resource, $part, $problem_num
+
+Returns: Hash reference with statistics data from
+loncoursedata::get_problem_statistics.
+=cut
+
+########################################################
+########################################################
sub get_statistics {
- my ($symb,$part) = @_;
+ my ($sequence,$resource,$part,$problem_num) = @_;
#
+ my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
+ my $symb = $resource->symb;
my $courseid = $ENV{'request.course.id'};
#
- my $students = \@Apache::lonstatistics::Students;
- if ($Apache::lonstatistics::SelectedSections[0] eq 'all') {
- $students = undef;
- }
- my @Results = &Apache::loncoursedata::get_problem_statistics
- ($students,$symb,$part,$courseid);
- return @Results;
+ my $data = &Apache::loncoursedata::get_problem_statistics
+ ([&Apache::lonstatistics::get_selected_sections()],
+ $Apache::lonstatistics::enrollment_status,
+ $symb,$part,$courseid,$starttime,$endtime);
+ $data->{'symb'} = $symb;
+ $data->{'part'} = $part;
+ $data->{'problem_num'} = $problem_num;
+ $data->{'container'} = $sequence->compTitle;
+ $data->{'title'} = $resource->compTitle;
+ $data->{'title.link'} = $resource->src.'?symb='.
+ &Apache::lonnet::escape($resource->symb);
+ #
+ if ($SelectedFields{'deg_of_disc'}) {
+ $data->{'deg_of_disc'} =
+ &compute_discrimination_factor($resource,$part,$sequence);
+ }
+ #
+ # Store in metadata if computations were done for all students
+ if ($data->{'num_students'} > 1) {
+ my @Sections = &Apache::lonstatistics::get_selected_sections();
+ my $sections = '"'.join(' ',@Sections).'"';
+ $sections =~ s/&+/_/g; # Ensure no special characters
+ $data->{'sections'}=$sections;
+ $data->{'course'} = $ENV{'request.course.id'};
+ my $urlres=(&Apache::lonnet::decode_symb($resource->symb))[2];
+ $data->{'urlres'}=$urlres;
+ my %storestats =
+ &LONCAPA::lonmetadata::dynamic_metadata_storage($data);
+ my ($dom,$user) = $urlres=~/^(\w+)\/(\w+)/;
+ &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;
}
###############################################
###############################################
-=pod
+=pod
+
+=item &compute_discrimination_factor()
+
+Inputs: $Resource, $Sequence
-=item &ProblemStatisticsLegend()
+Returns: integer between -1 and 1
=cut
###############################################
###############################################
-sub ProblemStatisticsLegend {
- my $Ptr = '';
- $Ptr = '
';
- $Ptr .= '
';
- $Ptr .= '#Stdnts
';
- $Ptr .= '
Total number of students attempted the problem.';
- $Ptr .= '
';
- $Ptr .= 'Tries
';
- $Ptr .= '
Total number of tries for solving the problem.';
- $Ptr .= '
';
- $Ptr .= 'Mod
';
- $Ptr .= '
Largest number of tries for solving the problem by a student.';
- $Ptr .= '
';
- $Ptr .= 'Mean
';
- $Ptr .= '
Average number of tries. [ Tries / #Stdnts ]';
- $Ptr .= '
';
- $Ptr .= '#YES
';
- $Ptr .= '
Number of students solved the problem correctly.';
- $Ptr .= '
';
- $Ptr .= '#yes
';
- $Ptr .= '
Number of students solved the problem by override.';
- $Ptr .= '
';
- $Ptr .= '%Wrong
';
- $Ptr .= '
Percentage of students who tried to solve the problem ';
- $Ptr .= 'but is still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]';
- $Ptr .= '
';
- $Ptr .= 'DoDiff
';
- $Ptr .= '
Degree of Difficulty of the problem. ';
- $Ptr .= '[ 1 - ((#YES+#yes) / Tries) ]';
- $Ptr .= '
';
- $Ptr .= 'S.D.
';
- $Ptr .= '
Standard Deviation of the tries. ';
- $Ptr .= '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1) ';
- $Ptr .= 'where Xi denotes every student\'s tries ]';
- $Ptr .= '
';
- $Ptr .= 'Skew.
';
- $Ptr .= '
Skewness of the students tries.';
- $Ptr .= '[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]';
- $Ptr .= '
';
- $Ptr .= 'Dis.F.
';
- $Ptr .= '
Discrimination Factor: A Standard for evaluating the ';
- $Ptr .= 'problem according to a Criterion ';
- $Ptr .= '[Criterion to group students into %27 Upper Students - ';
- $Ptr .= 'and %27 Lower Students] ';
- $Ptr .= '1st Criterion for Sorting the Students: ';
- $Ptr .= 'Sum of Partial Credit Awarded / Total Number of Tries ';
- $Ptr .= '2nd Criterion for Sorting the Students: ';
- $Ptr .= 'Total number of Correct Answers / Total Number of Tries';
- $Ptr .= '
';
- $Ptr .= '
Disc.
';
- $Ptr .= '
Number of Students had at least one discussion.';
- $Ptr .= '
';
- return $Ptr;
+sub compute_discrimination_factor {
+ my ($resource,$part,$seq) = @_;
+ my $symb = $resource->symb;
+ my @Resources;
+ foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq)){
+ next if ($res->symb eq $symb);
+ push (@Resources,$res->symb);
+ }
+ #
+ # rank
+ my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
+ my $ranking =
+ &Apache::loncoursedata::rank_students_by_scores_on_resources
+ (\@Resources,
+ [&Apache::lonstatistics::get_selected_sections()],
+ $Apache::lonstatistics::enrollment_status,undef,
+ $starttime,$endtime);
+ #
+ # 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)];
+ 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($symb,$part,\@BottomSet,
+ undef,$starttime,$endtime);
+ my ($top_sum,$top_max) =
+ &Apache::loncoursedata::get_sum_of_scores($symb,$part,\@TopSet,
+ undef,$starttime,$endtime);
+ 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;
}
-#---- END Problem Statistics Web Page ----------------------------------------
+###############################################
+###############################################
+##
+## Compute KR-21
+##
+## To compute KR-21, you need the following information:
+##
+## K=the number of items in your test
+## M=the mean score on the test
+## s=the standard deviation of the scores on your test
+##
+## then:
+##
+## KR-21 rk= [K/(K-1)] * [1- (M*(K-M))/(K*s^2))]
+##
+###############################################
+###############################################
+sub compute_sequence_statistics {
+ my ($seq) = @_;
+ my $symb = $seq->symb;
+ my @Resources;
+ my $part_count;
+ foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq)) {
+ push (@Resources,$res->symb);
+ $part_count += scalar(@{$res->parts});
+ }
+ my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
+ #
+ # First compute statistics based on student scores
+ my ($smin,$smax,$sMean,$sSTD,$scount,$sMAX) =
+ &Apache::loncoursedata::score_stats
+ ([&Apache::lonstatistics::get_selected_sections()],
+ $Apache::lonstatistics::enrollment_status,
+ \@Resources,$starttime,$endtime,undef);
+ $SeqStat{$symb}->{'title'} = $seq->compTitle;
+ $SeqStat{$symb}->{'scoremax'} = $smax;
+ $SeqStat{$symb}->{'scoremin'} = $smin;
+ $SeqStat{$symb}->{'scoremean'} = $sMean;
+ $SeqStat{$symb}->{'scorestd'} = $sSTD;
+ $SeqStat{$symb}->{'scorecount'} = $scount;
+ $SeqStat{$symb}->{'max_possible'} = $sMAX;
+ #
+ # Compute statistics based on the number of correct problems
+ # 'correct' is taken to mean
+ my ($cmin,$cmax,$cMean,$cSTD,$ccount)=
+ &Apache::loncoursedata::count_stats
+ ([&Apache::lonstatistics::get_selected_sections()],
+ $Apache::lonstatistics::enrollment_status,
+ \@Resources,$starttime,$endtime,undef);
+ my $K = $part_count;
+ my $kr_21;
+ if ($K > 1 && $cSTD > 0) {
+ $kr_21 = ($K/($K-1)) * (1 - $cMean*($K-$cMean)/($K*$cSTD**2));
+ } else {
+ $kr_21 = 'nan';
+ }
+ $SeqStat{$symb}->{'countmax'} = $cmax;
+ $SeqStat{$symb}->{'countmin'} = $cmin;
+ $SeqStat{$symb}->{'countstd'} = $cSTD;
+ $SeqStat{$symb}->{'countmean'} = $cMean;
+ $SeqStat{$symb}->{'count'} = $ccount;
+ $SeqStat{$symb}->{'items'} = $K;
+ $SeqStat{$symb}->{'KR-21'}=$kr_21;
+ return;
+}
+
+
+
+=pod
+
+=item ProblemStatisticsLegend
+
+=over 4
+
+=item #Stdnts
+Total number of students attempted the problem.
+
+=item Tries
+Total number of tries for solving the problem.
+
+=item Max Tries
+Largest number of tries for solving the problem by a student.
+
+=item Mean
+Average number of tries. [ Tries / #Stdnts ]
+
+=item #YES
+Number of students solved the problem correctly.
+
+=item #yes
+Number of students solved the problem by override.
+
+=item %Wrong
+Percentage of students who tried to solve the problem
+but is still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]
+
+=item DoDiff
+Degree of Difficulty of the problem.
+[ 1 - ((#YES+#yes) / Tries) ]
+
+=item S.D.
+Standard Deviation of the tries.
+[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1)
+where Xi denotes every student\'s tries ]
+
+=item Skew.
+Skewness of the students tries.
+[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]
+
+=item Dis.F.
+Discrimination Factor: A Standard for evaluating the
+problem according to a Criterion
+
+=item [Criterion to group students into %27 Upper Students -
+and %27 Lower Students]
+1st Criterion for Sorting the Students:
+Sum of Partial Credit Awarded / Total Number of Tries
+2nd Criterion for Sorting the Students:
+Total number of Correct Answers / Total Number of Tries
+
+=item Disc.
+Number of Students had at least one discussion.
+
+=back
+
+=cut
+
+############################################################
+############################################################
1;
__END__