Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct results coloring #142

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions server/moodle/mod/livequiz/classes/output/results_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,20 @@ public function export_for_template(renderer_base $output): stdClass {
foreach ($data->questions as $qindex => $question) {
// Get the student's answer for this question.
foreach ($question->answers as $aindex => $answer) {
// Check if the answer is correct.
$correct = $data->questions[$qindex]->answers[$aindex]['answercorrect'];

// Check if the answer was selected by the student.
$data->questions[$qindex]->answers[$aindex]['chosen'] =
in_array($answer['answerid'], $participationanswerids);

// Check if the answer is correct and was selected by the student.
$data->questions[$qindex]->answers[$aindex]['correct'] =
$data->questions[$qindex]->answers[$aindex]['chosen'] && $correct;

// Check if the answer is correct and was not selected by the student.
$data->questions[$qindex]->answers[$aindex]['correctnotchosen'] =
!$data->questions[$qindex]->answers[$aindex]['chosen'] && $correct;
}
}
return $data;
Expand Down
1 change: 1 addition & 0 deletions server/moodle/mod/livequiz/results.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
$index = $participationnumber - 1; // Index is 0-based.

$instance = $DB->get_record('livequiz', ['id' => $cm->instance], '*', MUST_EXIST);
$PAGE->requires->css('/mod/livequiz/style.css'); // Adds styling to the page.

$livequizservice = livequiz_services::get_singleton_service_instance();
$currentquiz = $livequizservice->get_livequiz_instance($instance->id);
Expand Down
Loading
Loading