[LON-CAPA-cvs] cvs: loncom /interface lonstatistics.pm /interface/statistics lonproblemanalysis.pm lonproblemstatistics.pm
stredwic
lon-capa-cvs@mail.lon-capa.org
Wed, 14 Aug 2002 20:42:49 -0000
This is a MIME encoded message
--stredwic1029357769
Content-Type: text/plain
stredwic Wed Aug 14 16:42:49 2002 EDT
Modified files:
/loncom/interface lonstatistics.pm
/loncom/interface/statistics lonproblemanalysis.pm
lonproblemstatistics.pm
Log:
Fixed a problem with statistics calculations, acts funny when testing near
zero. Fixed sequence displays for problem statistics so that the sequences
are in the proper order. Same with problem analysis. Also removed
discussion column from statistics.
--stredwic1029357769
Content-Type: text/plain
Content-Disposition: attachment; filename="stredwic-20020814164249.txt"
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.45 loncom/interface/lonstatistics.pm:1.46
--- loncom/interface/lonstatistics.pm:1.45 Wed Aug 14 13:45:19 2002
+++ loncom/interface/lonstatistics.pm Wed Aug 14 16:42:48 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonstatistics.pm,v 1.45 2002/08/14 17:45:19 stredwic Exp $
+# $Id: lonstatistics.pm,v 1.46 2002/08/14 20:42:48 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -543,7 +543,7 @@
}
if(defined($cache{'OptionResponses'})) {
- $reports{'problem_analysis'} = 'Problem Analysis';
+ $reports{'problem_analysis'} = 'Option Response Analysis';
}
$r->print('<form name="Statistics" ');
@@ -563,7 +563,7 @@
$students,
$courseID,
$c,$r);
- } elsif($GoToPage eq 'Problem Analysis') {
+ } elsif($GoToPage eq 'Option Response Analysis') {
&Apache::lonproblemanalysis::BuildProblemAnalysisPage($cacheDB, $r);
} elsif($GoToPage eq 'Student Assessment') {
&Apache::lonstudentassessment::BuildStudentAssessmentPage($cacheDB,
Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.7 loncom/interface/statistics/lonproblemanalysis.pm:1.8
--- loncom/interface/statistics/lonproblemanalysis.pm:1.7 Wed Aug 14 12:18:55 2002
+++ loncom/interface/statistics/lonproblemanalysis.pm Wed Aug 14 16:42:49 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonproblemanalysis.pm,v 1.7 2002/08/14 16:18:55 stredwic Exp $
+# $Id: lonproblemanalysis.pm,v 1.8 2002/08/14 20:42:49 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -231,10 +231,12 @@
my @optionResponses=split(':::', $optionResponses);
my %partCount;
my %sequences;
+ my @orderedSequences=();
foreach(@optionResponses) {
my ($sequence, $problemId, $part, undef)=split(':',$_);
$partCount{$problemId.':'.$part}++;
if(!defined($sequences{$sequence})) {
+ push(@orderedSequences, $sequence);
$sequences{$sequence} = $_;
} else {
$sequences{$sequence} .= ':::'.$_;
@@ -243,7 +245,7 @@
my $Str = '';
- foreach my $sequence (sort(keys(%sequences))) {
+ foreach my $sequence (@orderedSequences) {
my @optionProblems = split(':::', $sequences{$sequence});
$Str .= '<b>'.$cache->{$sequence.':title'}.'</b>'."\n";
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.26 loncom/interface/statistics/lonproblemstatistics.pm:1.27
--- loncom/interface/statistics/lonproblemstatistics.pm:1.26 Wed Aug 14 13:45:19 2002
+++ loncom/interface/statistics/lonproblemstatistics.pm Wed Aug 14 16:42:49 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonproblemstatistics.pm,v 1.26 2002/08/14 17:45:19 stredwic Exp $
+# $Id: lonproblemstatistics.pm,v 1.27 2002/08/14 20:42:49 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -80,7 +80,6 @@
}
}
-# my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID);
my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ?
$cache{'StatisticsLastStatus'} : 'Nothing';
my $whichStudents = join(':::',sort(@$students));
@@ -149,7 +148,7 @@
my @Header = ("Homework Sets Order","#Stdnts","Tries","Mod",
"Mean","#YES","#yes","%Wrng","DoDiff",
- "S.D.","Skew.","D.F.1st","D.F.2nd","Disc.");
+ "S.D.","Skew.","D.F.1st","D.F.2nd");
my $color=&setbgcolor(0);
my %cache;
@@ -158,7 +157,7 @@
return;
}
my $Ptr = '';
- $Ptr .= '<table border="0"><tbody>';
+ $Ptr .= '<table border="0" cellspacing="5"><tbody>';
$Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n";
$Ptr .= '<td align="left">';
$Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'ProblemStatistics',
@@ -269,7 +268,8 @@
$Str .= '<tr>'."\n";
$Str .= '<th bgcolor="#ffffe6">P#</th>'."\n";
foreach(@$headings) {
- $Str .= '<th bgcolor="#ffffe6">'.'<a href="/adm/statistics?reportSelected=';
+ $Str .= '<th bgcolor="#ffffe6">';
+ $Str .= '<a href="/adm/statistics?reportSelected=';
$Str .= &Apache::lonnet::escape('Problem Statistics');
$Str .= '&ProblemStatisticsSort=';
$Str .= &Apache::lonnet::escape($_).'">'.$_.'</a> </th>'."\n";
@@ -283,20 +283,6 @@
my ($cache,$displayFormat,$sortProblems,$orderedProblems,$headings,
$r,$color)=@_;
-#6666666
-# my $file="/home/httpd/perl/tmp/183d.txt";
-# open(OUT, ">$file");
-#6666666
-## &Apache::lonstatistics::Create_PrgWin($r);
-##777777
-## my (%Activity) = &LoadActivityLog();
-## $r->print('<script>popwin.document.popremain.remaining.value="'.
-## 'Loading Discussion...";</script>');
-## my ($doDiffFile) = &LoadDoDiffFile();
-
-##777777
-## $Str .= &Classify($discriminantFactor, $students);
-
my $count = 1;
my $currentSequence = -1;
foreach(@$orderedProblems) {
@@ -332,21 +318,23 @@
my $ref = '<a href="'.$cache->{$problem.':source'}.
'" target="_blank">'.$cache->{$problem.':title'}.'</a>';
my $title = $cache->{$problem.':title'};
+ if($part != 0) {
+ $title .= ' Part '.$part;
+ }
my $source = $cache->{$problem.':source'};
my $tableData = join('&', $ref, $title, $source,
$cache->{$_.':studentCount'},
$cache->{$_.':totalTries'},
$cache->{$_.':maxTries'},
- sprintf("%.2f", $cache->{$_.':mean'}),
+ $cache->{$_.':mean'},
$cache->{$_.':correct'},
$cache->{$_.':correctByOverride'},
- sprintf("%.1f", $cache->{$_.':percentWrong'}),
- sprintf("%.2f", $cache->{$_.':degreeOfDifficulty'}),
- sprintf("%.1f", $cache->{$_.':standardDeviation'}),
- sprintf("%.1f", $cache->{$_.':skewness'}),
- sprintf("%.2f", $cache->{$_.':discriminationFactor1'}),
- sprintf("%.2f", $cache->{$_.':discriminationFactor2'}),
- 0); # 0 is for discussion, need to figure out
+ $cache->{$_.':percentWrong'},
+ $cache->{$_.':degreeOfDifficulty'},
+ $cache->{$_.':standardDeviation'},
+ $cache->{$_.':skewness'},
+ $cache->{$_.':discriminationFactor1'},
+ $cache->{$_.':discriminationFactor2'});
&TableRow($displayFormat,$tableData,$count,$r,$color);
@@ -358,21 +346,14 @@
} else {
$r->print('<br>');
}
-#6666666
-# $r->print('<br>'.$out.'&'.$DoD);
-# print (OUT $out.'@'.$DoD.'&');
-#6666666
-
-#6666666
-# close( OUT );
-#666666
+
return;
}
sub TableRow {
my ($displayFormat,$Str,$RealIdx,$r,$color)=@_;
my($ref,$title,$source,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,
- $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$DiscNo,$Prob)=split(/\&/,$Str);
+ $Wrng,$DoD,$SD,$Sk,$_D1,$_D2)=split(/\&/,$Str);
my $Ptr;
if($displayFormat eq 'Display CSV Format') {
$Ptr='"'.$RealIdx.'",'."\n".
@@ -390,7 +371,6 @@
'"'.$Sk.'",'."\n".
'"'.$_D1.'",'."\n".
'"'.$_D2.'"'."\n".
- '"'.$DiscNo.'"'."\n".
"<br>\n";
$r->print("\n".$Ptr);
@@ -409,8 +389,7 @@
'<td bgcolor='.$color->{"green"}.'> '.$SD.'</td>'."\n".
'<td bgcolor='.$color->{"green"}.'> '.$Sk.'</td>'."\n".
'<td bgcolor='.$color->{"purple"}.'> '.$_D1.'</td>'."\n".
- '<td bgcolor='.$color->{"purple"}.'> '.$_D2.'</td>'."\n".
- '<td bgcolor='.$color->{"yellow"}.'> '.$DiscNo.'</td>'."\n";
+ '<td bgcolor='.$color->{"purple"}.'> '.$_D2.'</td>'."\n";
$r->print($Ptr.'</tr>'."\n");
}
@@ -443,10 +422,10 @@
my $Ptr = '<tr><td></td><td align="left">';
$Ptr .= '<input type="submit" name="DoDiffGraph" ';
- $Ptr .= 'value="DoDiff Graph" />'."\n";
- $Ptr .= ' ';
+ $Ptr .= 'value="Degree of Difficulty" />'."\n";
+ $Ptr .= '</td><td align="left">';
$Ptr .= '<input type="submit" name="PercentWrongGraph" ';
- $Ptr .= 'value="%Wrong Graph" />'."\n";
+ $Ptr .= 'value="Percent Wrong" />'."\n";
$Ptr .= '</td></tr><tr><td></td><td>'."\n";
$Ptr .= '<input type="submit" name="SortProblems" ';
if($sortProblems eq 'Sort All Problems') {
@@ -454,14 +433,14 @@
} else {
$Ptr .= 'value="Sort All Problems" />'."\n";
}
- $Ptr .= ' ';
+ $Ptr .= '</td><td align="left">';
$Ptr .= '<input type="submit" name="DisplayLegend" ';
if($displayLegend eq 'Show Legend') {
$Ptr .= 'value="Hide Legend" />'."\n";
} else {
$Ptr .= 'value="Show Legend" />'."\n";
}
- $Ptr .= ' ';
+ $Ptr .= '</td><td align="left">';
$Ptr .= '<input type="submit" name="DisplayCSVFormat" ';
if($displayFormat eq 'Display CSV Format') {
$Ptr .= 'value="Display Table Format" />'."\n";
@@ -529,15 +508,9 @@
return $Ptr;
}
-#------- Processing upperlist and lowerlist according to each problem
-
sub ExtractStudentData {
my ($cache, $students)=@_;
-#$Apache::lonxml::debug=1;
-#&Apache::lonhomework::showhash(%$cache);
-#$Apache::lonxml::debug=0;
-
my @problemList=();
my %problemData;
foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
@@ -584,11 +557,12 @@
}
}
+ my $studentTriesJoined = join(':::', @studentTries);
$problemData{$id.':sequenceTitle'} =
$cache->{$sequence.':title'};
$problemData{$id.':studentCount'} = $studentCount;
$problemData{$id.':totalTries'} = $totalTries;
- $problemData{$id.':studentTries'} = \@studentTries;
+ $problemData{$id.':studentTries'} = $studentTriesJoined;
$problemData{$id.':totalAwarded'} = $totalAwarded;
$problemData{$id.':correct'} = $correct;
$problemData{$id.':correctByOverride'} = $correctByOverride;
@@ -627,11 +601,6 @@
$problemData{'studentsLowerListCriterion2'}=join(':::', @lowerStudents2);
$problemData{'problemList'} = join(':::', @problemList);
-# $Discussed=0;
-# if($Discuss->{"$name:$problem"}) {
-# $TotDiscuss++;
-# $Discussed=1;
-# }
return \%problemData;
}
@@ -668,23 +637,41 @@
elsif($sortBy eq "DoDiff") { $data = ':degreeOfDifficulty'; }
elsif($sortBy eq "S.D.") { $data = ':standardDeviation'; }
elsif($sortBy eq "Skew.") { $data = ':skewness'; }
- elsif($sortBy eq "D.F.1st") { $data = ':discriminantFactor1'; }
- elsif($sortBy eq "D.F.2nd") { $data = ':discriminantFactor2'; }
- elsif($sortBy eq "Disc.") { $data = ''; }
+ elsif($sortBy eq "D.F.1st") { $data = ':discriminationFactor1'; }
+ elsif($sortBy eq "D.F.2nd") { $data = ':discriminationFactor2'; }
else { return \@problems; }
my %temp;
+ my @sequenceList=();
foreach(@problems) {
my ($sequence) = split(':', $_);
- $temp{$_} = $sequence;
+
+ my @array=();
+ my $tempArray;
+ if(defined($temp{$sequence})) {
+ $tempArray = $temp{$sequence};
+ } else {
+ push(@sequenceList, $sequence);
+ $tempArray = \@array;
+ $temp{$sequence} = $tempArray;
+ }
+
+ push(@$tempArray, $_);
}
my @orderedProblems;
if($sortProblems eq "Sort Within Sequence") {
- @orderedProblems =
- sort { $temp{$a} cmp $temp{$b} ||
- $problemData->{$a.$data} <=> $problemData->{$b.$data} }
- @problems;
+ foreach(keys(%temp)) {
+ my $tempArray = $temp{$_};
+ my @tempOrder =
+ sort { $problemData->{$a.$data} <=> $problemData->{$b.$data} }
+ @$tempArray;
+ $temp{$_} = \@tempOrder;
+ }
+ foreach(@sequenceList) {
+ my $tempArray = $temp{$_};
+ @orderedProblems = (@orderedProblems, @$tempArray);
+ }
} else {
@orderedProblems =
sort { $problemData->{$a.$data} <=> $problemData->{$b.$data} }
@@ -704,27 +691,31 @@
my @problems = split(':::', $data->{'problemList'});
foreach(@problems) {
# Mean
- $data->{$_.':mean'} = ($data->{$_.':studentCount'}) ?
+ my $mean = ($data->{$_.':studentCount'}) ?
($data->{$_.':totalTries'} / $data->{$_.':studentCount'}) : 0;
+ $data->{$_.':mean'} = sprintf("%.2f", $mean);
# %Wrong
- $data->{$_.':percentWrong'} = ($data->{$_.':studentCount'}) ?
+ my $pw = ($data->{$_.':studentCount'}) ?
(($data->{$_.':wrong'} / $data->{$_.':studentCount'}) * 100.0) :
100.0;
+ $data->{$_.':percentWrong'} = sprintf("%.1f", $pw);
# Degree of Difficulty
- $data->{$_.':degreeOfDifficulty'} = ($data->{$_.':totalTries'}) ?
+ my $dod = ($data->{$_.':totalTries'}) ?
(1 - (($data->{$_.':correct'} + $data->{$_.':correctByOverride'}) /
$data->{$_.':totalTries'})) : 0;
+ $data->{$_.':degreeOfDifficulty'} = sprintf("%.2f", $dod);
+
# Factor in mean
- my $studentTries = $data->{$_.':studentTries'};
- foreach(my $index=0; $index < scalar(@$studentTries); $index++) {
- $studentTries->[$index] -= $data->{$_.':mean'};
+ my @studentTries = split(':::', $data->{$_.':studentTries'});
+ foreach(my $index=0; $index < scalar(@studentTries); $index++) {
+ $studentTries[$index] -= $mean;
}
my $sumSquared = 0;
my $sumCubed = 0;
- foreach(@$studentTries) {
+ foreach(@studentTries) {
my $squared = ($_ * $_);
my $cubed = ($squared * $_);
$sumSquared += $squared;
@@ -732,15 +723,27 @@
}
# Standard deviation
- $data->{$_.':standardDeviation'} = ($data->{$_.':studentCount'} - 1) ?
- ((sqrt($sumSquared)) / ($data->{$_.':studentCount'} - 1)) : 0;
+ my $standardDeviation;
+ if($data->{$_.':studentCount'} - 1 > 0) {
+ $standardDeviation = (sqrt($sumSquared)) /
+ ($data->{$_.':studentCount'} - 1);
+ } else {
+ $standardDeviation = 0.0;
+ }
+ $data->{$_.':standardDeviation'} = sprintf("%.1f", $standardDeviation);
# Skewness
- my $standardDeviation = $data->{$_.':standardDeviation'};
- $data->{$_.':skewness'} = ($data->{$_.':standardDeviation'}) ?
- (((sqrt($sumSquared)) / $data->{$_.':studentCount'}) /
- ($standardDeviation * $standardDeviation * $standardDeviation)) :
- 0;
+ my $skew;
+ if($standardDeviation > 0.0999 && $data->{$_.':studentCount'} > 0) {
+ $skew = (((sqrt($sumSquared)) / $data->{$_.':studentCount'}) /
+ ($standardDeviation *
+ $standardDeviation *
+ $standardDeviation));
+ } else {
+ $skew = 0.0;
+ }
+
+ $data->{$_.':skewness'} = sprintf("%.1f", $skew);
# Discrimination Factor 1
my ($sequence, $problem, $part) = split(':', $_);
@@ -760,7 +763,8 @@
}
$lower1Sum = (scalar(@lower1)) ? ($lower1Sum/(scalar(@lower1))) : 0;
- $data->{$_.':discriminationFactor1'} = $upper1Sum - $lower1Sum;
+ my $df1 = $upper1Sum - $lower1Sum;
+ $data->{$_.':discriminationFactor1'} = sprintf("%.2f", $df1);
# Discrimination Factor 2
my @upper2 = split(':::', $data->{'studentsUpperListCriterion2'});
@@ -778,7 +782,8 @@
}
$lower2Sum = (scalar(@lower2)) ? ($lower2Sum/(scalar(@lower2))) : 0;
- $data->{$_.':discriminationFactor2'} = $upper2Sum - $lower2Sum;
+ my $df2 = $upper2Sum - $lower2Sum;
+ $data->{$_.':discriminationFactor2'} = sprintf("%.2f", $df2);
}
return;
--stredwic1029357769--