|
|
|
|
@ -969,10 +969,8 @@ class Category implements GradebookItem |
|
|
|
|
|
|
|
|
|
$linkres = $link->calc_score($stud_id, null); |
|
|
|
|
if (!empty($linkres) && $link->get_weight() != 0) { |
|
|
|
|
$students[$stud_id] = $linkres[0]; |
|
|
|
|
$linkweight = $link->get_weight(); |
|
|
|
|
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1]; |
|
|
|
|
$count++; |
|
|
|
|
$weightsum += $linkweight; |
|
|
|
|
$ressum += $linkres[0] / $link_res_denom * $linkweight; |
|
|
|
|
} else { |
|
|
|
|
@ -1000,10 +998,10 @@ class Category implements GradebookItem |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Calculate score |
|
|
|
|
$count = 0; |
|
|
|
|
$ressum = 0; |
|
|
|
|
$weightsum = 0; |
|
|
|
|
$bestResult = 0; |
|
|
|
|
$totalScorePerStudent = []; |
|
|
|
|
|
|
|
|
|
if (!empty($cats)) { |
|
|
|
|
/** @var Category $cat */ |
|
|
|
|
@ -1033,6 +1031,23 @@ class Category implements GradebookItem |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($evals)) { |
|
|
|
|
if ($type === 'best') { |
|
|
|
|
$studentList = $this->getStudentList(); |
|
|
|
|
foreach ($studentList as $student) { |
|
|
|
|
$studentId = $student['user_id']; |
|
|
|
|
foreach ($evals as $eval) { |
|
|
|
|
$linkres = $eval->calc_score($studentId, null); |
|
|
|
|
$linkweight = $eval->get_weight(); |
|
|
|
|
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1]; |
|
|
|
|
$ressum = $linkres[0] / $link_res_denom * $linkweight; |
|
|
|
|
|
|
|
|
|
if (!isset($totalScorePerStudent[$studentId])) { |
|
|
|
|
$totalScorePerStudent[$studentId] = 0; |
|
|
|
|
} |
|
|
|
|
$totalScorePerStudent[$studentId] += $ressum; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/** @var Evaluation $eval */ |
|
|
|
|
foreach ($evals as $eval) { |
|
|
|
|
$evalres = $eval->calc_score(null, $type); |
|
|
|
|
@ -1041,7 +1056,6 @@ class Category implements GradebookItem |
|
|
|
|
if (isset($evalres) && $eval->get_weight() != 0) { |
|
|
|
|
$evalweight = $eval->get_weight(); |
|
|
|
|
$weightsum += $evalweight; |
|
|
|
|
$count++; |
|
|
|
|
if (!empty($evalres[1])) { |
|
|
|
|
$ressum += $evalres[0] / $evalres[1] * $evalweight; |
|
|
|
|
} |
|
|
|
|
@ -1057,7 +1071,26 @@ class Category implements GradebookItem |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($links)) { |
|
|
|
|
$studentList = $this->getStudentList(); |
|
|
|
|
if ($type === 'best') { |
|
|
|
|
foreach ($studentList as $student) { |
|
|
|
|
$studentId = $student['user_id']; |
|
|
|
|
foreach ($links as $link) { |
|
|
|
|
$linkres = $link->calc_score($studentId, null); |
|
|
|
|
$linkweight = $link->get_weight(); |
|
|
|
|
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1]; |
|
|
|
|
$ressum = $linkres[0] / $link_res_denom * $linkweight; |
|
|
|
|
|
|
|
|
|
if (!isset($totalScorePerStudent[$studentId])) { |
|
|
|
|
$totalScorePerStudent[$studentId] = 0; |
|
|
|
|
} |
|
|
|
|
$totalScorePerStudent[$studentId] += $ressum; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/** @var EvalLink|ExerciseLink $link */ |
|
|
|
|
foreach ($links as $link) { |
|
|
|
|
$link->setStudentList($this->getStudentList()); |
|
|
|
|
@ -1067,15 +1100,13 @@ class Category implements GradebookItem |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$linkres = $link->calc_score($stud_id, $type); |
|
|
|
|
|
|
|
|
|
if (!empty($linkres) && $link->get_weight() != 0) { |
|
|
|
|
$students[$stud_id] = $linkres[0]; |
|
|
|
|
$linkweight = $link->get_weight(); |
|
|
|
|
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1]; |
|
|
|
|
|
|
|
|
|
$count++; |
|
|
|
|
$weightsum += $linkweight; |
|
|
|
|
$ressum += $linkres[0] / $link_res_denom * $linkweight; |
|
|
|
|
|
|
|
|
|
if ($ressum > $bestResult) { |
|
|
|
|
$bestResult = $ressum; |
|
|
|
|
} |
|
|
|
|
@ -1089,9 +1120,14 @@ class Category implements GradebookItem |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch ($type) { |
|
|
|
|
case 'best': |
|
|
|
|
arsort($totalScorePerStudent); |
|
|
|
|
$maxScore = current($totalScorePerStudent); |
|
|
|
|
|
|
|
|
|
return [$maxScore, $this->get_weight()]; |
|
|
|
|
if (empty($bestResult)) { |
|
|
|
|
if ($cacheAvailable) { |
|
|
|
|
$cacheDriver->save($key, null); |
|
|
|
|
|