Include correction points in final score

This commit is contained in:
Wojtek
2026-10-15 21:15:00 +02:00
parent 1df6c6dfc3
commit 5721370ea1
5 changed files with 8 additions and 5 deletions
@@ -57,16 +57,16 @@ class ResultModel extends BaseDatabaseModel
}
unset($answer);
$pointsAfter = 0;
$correctionPoints = 0;
foreach ($item->answers as $answer) {
$pointsAfter += (int) ($answer['awarded_points'] ?? 0);
$correctionPoints += (int) ($answer['awarded_points'] ?? 0);
}
$db = Factory::getContainer()->get('DatabaseDriver');
$row = (object) [
'id' => $id,
'answers' => json_encode($item->answers, JSON_UNESCAPED_UNICODE),
'points_after' => $pointsAfter,
'points_after' => (int) $item->points_before + $correctionPoints,
];
return (bool) $db->updateObject('#__testquestions_results', $row, 'id');