Track corrected result points

This commit is contained in:
Wojtek
2026-10-15 21:11:30 +02:00
parent f3efb81af4
commit 1df6c6dfc3
9 changed files with 36 additions and 6 deletions
@@ -57,10 +57,16 @@ class ResultModel extends BaseDatabaseModel
}
unset($answer);
$pointsAfter = 0;
foreach ($item->answers as $answer) {
$pointsAfter += (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,
];
return (bool) $db->updateObject('#__testquestions_results', $row, 'id');