'."\n";
+ return $Str;
}
+#######################################################
+#######################################################
+
+=pod
-#---- Problem Statistics Web Page ---------------------------------------
+=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.
-sub NumericSort {
- $a <=> $b;
-}
+Based on code from lonstudentassessment.pm.
+=cut
-sub CreateProblemStatisticsTableHeading {
- my ($displayFormat,$sequenceSource,$sequenceTitle,$headings,$r)=@_;
- if($displayFormat eq 'Display CSV Format') {
- $r->print(' "'.$sequenceTitle.'","');
- $r->print($sequenceSource.'"');
- return;
+#######################################################
+#######################################################
+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',
+ },
+ );
+
+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'};
+ }
+ #
+ # Build the form element
+ $Str = qq/";
+ return $Str;
+}
- $r->print(' '.$sequenceTitle.'');
+###############################################
+###############################################
+
+=pod
+
+=item &Gather_Student_Data()
+
+Ensures all student data is up to date.
+
+=cut
- my $Result = "\n".'
");
+ }
+ return;
}
+###############################################
+###############################################
+
+=pod
+
+=item &output_html_grouped_by_sequence()
+
+Presents the statistics data as an html table organized by the order
+the assessments appear in the course.
-
-# ------ Dump the Student's DB file and handling the data for statistics table
-sub ExtractStudentData {
- my ($cache,$name,$list,$Discuss,$r)=@_;
- my %discriminantFactor;
-
- my $totalTries = 0;
- my $totalAwarded = 0;
- my $tempProblemOrder=0;
- my $spent=0;
- my $spent_yes=0;
- my $TotDiscuss=0;
- my $TotalOpend = 0;
- my $ProbSolved = 0;
- my $ProbTot = 0;
- my $TotFirst = 0;
- my $TimeTot = 0;
- my $Discussed=0;
-
-$Apache::lonxml::debug=1;
-#&Apache::lonhomework::showhash(%$cache);
-$Apache::lonxml::debug=0;
-
- foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
-# if($cache->{'ProblemStatisticsMap'} ne 'All Maps' &&
-# $cache->{'ProblemStatisticsMap'} ne $cache->{$sequence.':title'}) {
-# $r->print(" $name --- $sequence");
-# $r->print(" ".$cache->{$sequence.':title'});
-# next;
-# }
-
- my $Dis = '';
- foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
- my $problem = $cache->{$problemID.':problem'};
- $r->print(" $problemID === $problem");
- my $LatestVersion = $cache->{$name.':version:'.$problem};
- # Output dashes for all the parts of this problem if there
- # is no version information about the current problem.
- #if(!$LatestVersion) {
- # foreach my $part (split(/\:/,$cache->{$sequence.':'.
- # $problemID.
- # ':parts'})) {
- # $codes .= "-,";
- # $attempts .= "0,";
- # }
- # next;
- #}
-
- my %partData=undef;
- # Initialize part data, display skips correctly
- # Skip refers to when a student made no submissions on that
- # part/problem.
- foreach my $part (split(/\:/,$cache->{$sequence.':'.
- $problemID.
- ':parts'})) {
- $partData{$part.':tries'}=0;
- $partData{$part.':code'}='-';
+=cut
+
+###############################################
+###############################################
+sub output_html_grouped_by_sequence {
+ my ($r) = @_;
+ my $problem_num = 0;
+ #$r->print(&ProblemStatisticsLegend());
+ 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('
');
+ my $Str = &statistics_table_header('no container no plots');
+ $r->print('
'.$Str."
\n");
+ foreach my $resource (@{$sequence->{'contents'}}) {
+ next if ($resource->{'type'} ne 'assessment');
+ foreach my $part (@{$resource->{'parts'}}) {
+ $problem_num++;
+ my $data = &get_statistics($sequence,$resource,$part,
+ $problem_num);
+ my $option = '';
+ $r->print('
\n");
+ #
+ # Print out the data
+ $ENV{'form.sortby'} = 'Contents';
+# &output_html_ungrouped($r);
+ return;
}
-sub AscendOrderOptions {
- my ($order)=@_;
+###############################################
+###############################################
- my $OpSel1 = '';
- my $OpSel2 = '';
+=pod
- if($order eq 'Ascending') {
- $OpSel1 = ' selected';
- } else {
- $OpSel2 = ' selected';
- }
+=item &DrawGraph()
- my $Ptr = '';
- $Ptr .= '
Sorting Type:
'."\n";
- $Ptr .= '
'."\n";
+=cut
- return $Ptr;
+###############################################
+###############################################
+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);
+ $Max =1 if ($Max < 1);
+ if ( int($Max) < $Max ) {
+ $Max++;
+ $Max = int($Max);
+ }
+ my @GData = ($title,$xaxis,$yaxis,$Max,$sendCount,$sendValues);
+ return '';
+}
+
+sub get_statistics {
+ my ($sequence,$resource,$part,$problem_num) = @_;
+ #
+ 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 $data = &Apache::loncoursedata::get_problem_statistics
+ ($students,$symb,$part,$courseid);
+ $data->{'part'} = $part;
+ $data->{'problem_num'} = $problem_num;
+ $data->{'container'} = $sequence->{'title'};
+ $data->{'title'} = $resource->{'title'};
+ $data->{'title.link'} = $resource->{'src'};
+ #
+ return $data;
}
-sub ProblemStatisticsButtons {
- my ($displayFormat)=@_;
+###############################################
+###############################################
- my $Ptr = '
';
- $Ptr .= '';
$Ptr .= '
';
- $Ptr .= '#Stdnts:
';
- $Ptr .= '
Total Number of Students opened the problem.';
+ $Ptr .= '#Stdnts
';
+ $Ptr .= '
Total number of students attempted the problem.';
$Ptr .= '
';
- $Ptr .= 'Tries:
';
- $Ptr .= '
Total Number of Tries for solving the problem.';
+ $Ptr .= 'Tries
';
+ $Ptr .= '
Total number of tries for solving the problem.';
$Ptr .= '
';
- $Ptr .= 'Mod:
';
- $Ptr .= '
Maximunm Number of Tries for solving the problem.';
+ $Ptr .= 'Max Tries
';
+ $Ptr .= '
Largest number of tries for solving the problem by a student.';
$Ptr .= '
';
- $Ptr .= 'Mean:
';
- $Ptr .= '
Average Number of the tries. [ Tries / #Stdnts ]';
+ $Ptr .= 'Mean
';
+ $Ptr .= '
Average number of tries. [ Tries / #Stdnts ]';
$Ptr .= '
';
- $Ptr .= '#YES:
';
+ $Ptr .= '#YES';
$Ptr .= '
Number of students solved the problem correctly.';
$Ptr .= '
';
- $Ptr .= '#yes:
';
+ $Ptr .= '#yes';
$Ptr .= '
Number of students solved the problem by override.';
$Ptr .= '
';
- $Ptr .= '%Wrng:
';
- $Ptr .= '
Percentage of students tried to solve the problem ';
- $Ptr .= 'but still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]';
+ $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 .= 'DoDiff';
$Ptr .= '
Degree of Difficulty of the problem. ';
$Ptr .= '[ 1 - ((#YES+#yes) / Tries) ]';
$Ptr .= '
';
- $Ptr .= 'S.D.:
';
+ $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 .= 'Skew.';
$Ptr .= '
Skewness of the students tries.';
$Ptr .= '[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]';
$Ptr .= '
';
- $Ptr .= 'Dis.F.:
';
+ $Ptr .= 'Dis.F.';
$Ptr .= '
Discrimination Factor: A Standard for evaluating the ';
$Ptr .= 'problem according to a Criterion ';
- $Ptr .= '[Applied Criterion in %27 Upper Students - ';
- $Ptr .= 'Applied the same Criterion in %27 Lower Students] ';
+ $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: ';
@@ -743,146 +955,10 @@ sub ProblemStatisticsLegend {
$Ptr .= '
Disc.
';
$Ptr .= '
Number of Students had at least one discussion.';
$Ptr .= '
';
-
return $Ptr;
}
-#------- Processing upperlist and lowerlist according to each problem
-sub ProcessDiscriminant {
- my ($List) = @_;
- my @sortedList = sort (@$List);
- my $Count = scalar @sortedList;
- my $Problem;
- my @Dis;
- my $Slvd=0;
- my $tmp;
- my $Sum1=0;
- my $Sum2=0;
- my $nIndex=0;
- my $nStudent=0;
- my %Proc=undef;
- while ($nIndex<$Count) {
- ($Problem,$tmp)=split(/\=/,$sortedList[$nIndex]);
- @Dis=split(/\+/,$tmp);
- my $Temp = $Problem;
- do {
- $nIndex++;
- $nStudent++;
- $Sum1 += $Dis[0];
- $Sum2 += $Dis[1];
- ($Problem,$tmp)=split(/\=/,$sortedList[$nIndex]);
- @Dis=split(/\+/,$tmp);
- } while ( $Problem eq $Temp && $nIndex < $Count );
-# $Proc{$Temp}=($Sum1/$nStudent).':'.$nStudent;
- $Proc{$Temp}=($Sum1/$nStudent).':'.($Sum2/$nStudent);
-# $r->print("$nIndex) $Temp --> ($nStudent) $Proc{$Temp} ");
- $Sum1=0;
- $Sum2=0;
- $nStudent=0;
- }
-
- return %Proc;
-}
-
-#------- Creating Discimination factor
-sub Discriminant {
- my ($discriminantFactor)=@_;
- my @discriminantKeys=keys(%$discriminantFactor);
- my $Count = scalar @discriminantKeys;
-
- my $UpCnt = int(0.27*$Count);
- my $low=0;
- my $up=$Count-$UpCnt;
- my @UpList=();
- my @LowList=();
-
- $Count=0;
- foreach my $key (sort(@discriminantKeys)) {
- $Count++;
- if($low < $UpCnt || $Count > $up) {
- $low++;
- my $str=$discriminantFactor->{$key};
- foreach(split(/\:/,$str)){
- if($_) {
- if($low<$UpCnt) { push(@LowList,$_); }
- else { push(@UpList,$_); }
- }
- }
- }
- }
- my %DisUp = &ProcessDiscriminant(\@UpList);
- my %DisLow = &ProcessDiscriminant(\@LowList);
-
- return (\%DisUp, \%DisLow);
-}
-
-
-
#---- END Problem Statistics Web Page ----------------------------------------
-#---- Problem Statistics Graph Web Page --------------------------------------
-
-# ------------------------------------------- Prepare data for Graphical chart
-
-sub BuildDiffGraph {
- my ($r)=@_;
-
- my $graphData = &GetGraphData('DiffGraph', $r);
- return '';
-}
-
-sub BuildWrongGraph {
- my ($r)=@_;
-
- my $graphData = &GetGraphData('WrongGraph', $r);
- return '';
-}
-
-
-sub GetGraphData {
- my ($ylab,$r,%GraphDat)=@_;
- my $Col;
- my $data='';
- my $count = 0;
- my $Max = 0;
- my $cid=$ENV{'request.course.id'};
- my $GraphDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
- "_$ENV{'user.domain'}_$cid\_graph.db";
- foreach (keys %GraphDat) {delete $GraphDat{$_};}
- if (-e "$GraphDB") {
- if (tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) {
- if ( $ylab eq 'DoDiff Graph' ) {
- $ylab = 'Degree-of-Difficulty';
- $Col = 0;
- }
- else {
- $ylab = 'Wrong-Percentage';
- $Col = 1;
- }
- foreach (sort NumericSort keys %GraphDat) {
- my @Temp=split(/\:/,$GraphDat{$_});
- my $inf = $Temp[$Col];
- if ( $Max < $inf ) {$Max = $inf;}
- $data .= $inf.',';
- $count++;
- }
- if ( $Max > 1 ) {
- $Max += (10 - $Max % 10);
- $Max = int($Max);
- }
- else { $Max = 1; }
- untie(%GraphDat);
- my $Course = $ENV{'course.'.$cid.'.description'};
- $Course =~ s/\ /"_"/eg;
- my $GData=$Course.'&'.'Problems'.'&'.$ylab.'&'.
- $Max.'&'.$count.'&'.$data;
- }
- else {
- $r->print("Unable to tie hash to db file");
- }
- }
-}
-
-
1;
__END__