Track corrected result points
This commit is contained in:
@@ -48,7 +48,7 @@ class SetModel extends BaseDatabaseModel
|
||||
|
||||
return $db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->select(['q.id', 'q.question_type', 'q.question', 'q.answer_a', 'q.answer_b', 'q.answer_c', 'q.answer_d', 'q.answer_open', 'q.correct_answer', 'q.image'])
|
||||
->select(['q.id', 'q.question_type', 'q.question', 'q.answer_a', 'q.answer_b', 'q.answer_c', 'q.answer_d', 'q.answer_open', 'q.correct_answer', 'q.points', 'q.image'])
|
||||
->from($db->quoteName('#__testquestions_set_questions', 'sq'))
|
||||
->innerJoin($db->quoteName('#__testquestions_questions', 'q') . ' ON q.id = sq.question_id')
|
||||
->where('sq.set_id = ' . $setId)
|
||||
@@ -81,6 +81,13 @@ class SetModel extends BaseDatabaseModel
|
||||
return false;
|
||||
}
|
||||
|
||||
$pointsBefore = 0;
|
||||
foreach (($result['items'] ?? []) as $item) {
|
||||
if (!empty($item['correct'])) {
|
||||
$pointsBefore += (int) ($item['points'] ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
$row = (object) [
|
||||
'set_id' => $setId,
|
||||
'participant_name' => trim($participantName),
|
||||
@@ -90,6 +97,8 @@ class SetModel extends BaseDatabaseModel
|
||||
'correct_count' => (int) ($result['correct'] ?? 0),
|
||||
'total_count' => (int) ($result['total'] ?? 0),
|
||||
'percentage' => (float) ($result['percentage'] ?? 0),
|
||||
'points_before' => $pointsBefore,
|
||||
'points_after' => $pointsBefore,
|
||||
'answers' => json_encode($result['items'] ?? [], JSON_UNESCAPED_UNICODE),
|
||||
'created' => Factory::getDate()->toSql(),
|
||||
'created_by' => $user ? (int) $user->id : 0,
|
||||
|
||||
Reference in New Issue
Block a user