fix: Fix question usage and display total quiz grade

Corrects variable reference to ensure proper retrieval of question
usages for quiz attempts. Enhances grade display by adding total
possible quiz grade for clarity.

No related issues mentioned.
This commit is contained in:
Kumi 2024-11-21 20:44:27 +01:00
parent 7321ed9c1d
commit 52680853a3
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -55,7 +55,7 @@ if ($mform->is_cancelled()) {
$attempt_table = new html_table();
$attempt_table->head = array(get_string('question', 'report_usergrades'), get_string('response', 'report_usergrades'), get_string('grade', 'report_usergrades'));
$question_usages = $DB->get_records('question_usages', array('id' => $quiz_attempt->uniqueid));
$question_usages = $DB->get_records('question_usages', array('id' => $attempt->uniqueid));
foreach ($question_usages as $question_usage) {
$question_attempt = $DB->get_record('question_attempts', array('questionusageid' => $question_usage->id));
@ -71,7 +71,7 @@ if ($mform->is_cancelled()) {
$total_grade = $DB->get_record('quiz_grades', array('quiz' => $quiz->id, 'userid' => $user->id));
echo $OUTPUT->heading(get_string('totalgrade', 'report_usergrades') . ': ' . $total_grade->grade, 6);
echo $OUTPUT->heading(get_string('totalgrade', 'report_usergrades') . ': ' . $total_grade->grade . ' / ' . $quiz->grade, 6);
}
}