| ';
$Ptr .= '{'orderedSequences'})) {
@@ -494,11 +570,12 @@ sub ExtractStudentData {
}
}
+ 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;
@@ -537,11 +614,6 @@ sub ExtractStudentData {
$problemData{'studentsLowerListCriterion2'}=join(':::', @lowerStudents2);
$problemData{'problemList'} = join(':::', @problemList);
-# $Discussed=0;
-# if($Discuss->{"$name:$problem"}) {
-# $TotDiscuss++;
-# $Discussed=1;
-# }
return \%problemData;
}
@@ -559,7 +631,7 @@ sub SortDivideByTries {
}
sub SortProblems {
- my ($problemData,$sortBy,$ascend)=@_;
+ my ($problemData,$sortBy,$sortProblems,$ascend)=@_;
my @problems = split(':::', $problemData->{'problemList'});
if($sortBy eq "Homework Sets Order") {
@@ -578,14 +650,47 @@ sub SortProblems {
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 @orderedProblems =
- sort { $problemData->{$a.$data} <=> $problemData->{$b.$data} }
- @problems;
+ my %temp;
+ my @sequenceList=();
+ foreach(@problems) {
+ my ($sequence) = split(':', $_);
+
+ 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") {
+ 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} }
+ @problems;
+ }
+
if($ascend eq 'Descending') {
@orderedProblems = reverse(@orderedProblems);
}
@@ -594,32 +699,36 @@ sub SortProblems {
}
sub CalculateStatistics {
- my ($data, $cache)=@_;
+ my ($data, $cache, $courseID)=@_;
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;
@@ -627,15 +736,27 @@ sub CalculateStatistics {
}
# 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(':', $_);
@@ -647,15 +768,16 @@ sub CalculateStatistics {
foreach my $name (@upper1) {
$upper1Sum += $cache->{"$name:$problem:$part:awarded"};
}
- $upper1Sum /= (scalar(@upper1)) ? (scalar(@upper1)) : 0;
+ $upper1Sum = (scalar(@upper1)) ? ($upper1Sum/(scalar(@upper1))) : 0;
my $lower1Sum=0;
foreach my $name (@lower1) {
$lower1Sum += $cache->{"$name:$problem:$part:awarded"};
}
- $lower1Sum /= (scalar(@lower1)) ? (scalar(@lower1)) : 0;
+ $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'});
@@ -665,15 +787,32 @@ sub CalculateStatistics {
foreach my $name (@upper2) {
$upper2Sum += $cache->{"$name:$problem:$part:awarded"};
}
- $upper2Sum /= (scalar(@upper2)) ? (scalar(@upper2)) : 0;
+ $upper2Sum = (scalar(@upper2)) ? ($upper2Sum/(scalar(@upper2))) : 0;
my $lower2Sum=0;
foreach my $name (@lower2) {
$lower2Sum += $cache->{"$name:$problem:$part:awarded"};
}
- $lower2Sum /= (scalar(@lower2)) ? (scalar(@lower2)) : 0;
+ $lower2Sum = (scalar(@lower2)) ? ($lower2Sum/(scalar(@lower2))) : 0;
+
+ my $df2 = $upper2Sum - $lower2Sum;
+ $data->{$_.':discriminationFactor2'} = sprintf("%.2f", $df2);
- $data->{$_.':discriminationFactor2'} = $upper2Sum - $lower2Sum;
+ my %storestats;
+ my $Average = ($data->{$_.':studentCount'}) ?
+ $data->{$_.':totalTries'}/$data->{$_.':studentCount'} : 0;
+ $storestats{$courseID.'___'.$cache->{$sequence.':source'}.
+ '___timestamp'}=time;
+ $storestats{$courseID.'___'.$cache->{$sequence.':source'}.
+ '___stdno'}=$data->{$_.':studentCount'};
+ $storestats{$courseID.'___'.$cache->{$sequence.':source'}.
+ '___avetries'}=$Average;
+ $storestats{$courseID.'___'.$cache->{$sequence.':source'}.
+ '___difficulty'}=$data->{$_.':degreeOfDifficulty'};
+ $cache->{$sequence.':source'} =~ /^(\w+)\/(\w+)/;
+ if($data->{$_.':studentCount'}) {
+ &Apache::lonnet::put('resevaldata',\%storestats,$1,$2);
+ }
}
return;
|