Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed fix for issue #15 #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions calculator/webpa/classes/calculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ public function calculate($grades, $groupmark, $noncompletionpenalty = 0, $pawei
// Calculate the total scores.
foreach ($memberids as $memberid) {
foreach ($grades as $graderid => $gradesgiven) {
if (!isset($totalscores[$graderid])) {
$totalscores[$graderid] = [];
}

if (isset($gradesgiven[$memberid])) {
$sum = array_reduce($gradesgiven[$memberid], function($carry, $item) {
$carry += $item;
Expand All @@ -113,13 +109,24 @@ public function calculate($grades, $groupmark, $noncompletionpenalty = 0, $pawei

$totalscores[$graderid][$memberid] = $sum;
}
else {
$totalscores[$graderid][$memberid] = 0; // zero must be inserted if a grade is not set
}
}
}

// Calculate the fractional scores, and record whether scores were submitted.
foreach ($memberids as $memberid) {
$gradesgiven = $totalscores[$memberid];
$total = array_sum($gradesgiven);
if($total == 0) { // in the event of a non-submission...
foreach($gradesgiven as $key => $grade) {
if($memberid != $key || $selfgrade)
$gradesgiven[$key] = 1; // ...replace relevant grades given (all zeros) with ones
}
}
$total = array_sum($gradesgiven);
}

$fracscores[$memberid] = array_reduce(array_keys($gradesgiven), function($carry, $peerid) use ($total, $gradesgiven) {
$grade = $gradesgiven[$peerid];
Expand All @@ -145,7 +152,7 @@ public function calculate($grades, $groupmark, $noncompletionpenalty = 0, $pawei

// Apply the fudge factor to all scores received.
$nummembers = count($memberids);
$fudgefactor = $numsubmitted > 0 ? $nummembers / $numsubmitted : 1;
$fudgefactor = 1; //$numsubmitted > 0 ? $nummembers / $numsubmitted : 1; // "fudge factor" unfairly favors non-submitters - set it to one since non-submissions have been replaced with straight ones above
$webpascores = array_map(function($grade) use ($fudgefactor) {
return $grade * $fudgefactor;
}, $webpascores);
Expand Down