fix: Refactors question processing logic
Updates the question handling mechanism to use question usages and attempts, replacing the previous reliance on question states and attempt steps. This change enhances the accuracy of response and grading information by aligning with the current database structure. Improves performance and maintainability by streamlining data retrieval from the database.
This commit is contained in:
parent
afb5e818ad
commit
d983f550bf
1 changed files with 8 additions and 5 deletions
13
details.php
13
details.php
|
@ -55,13 +55,16 @@ 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'));
|
||||
|
||||
foreach ($quiz_questions as $quiz_question) {
|
||||
$question = $questions[$quiz_question->question];
|
||||
$question_usages = $DB->get_records('question_usages', array('id' => $quiz_attempt->uniqueid));
|
||||
|
||||
$response = $DB->get_record('question_states', array('attempt' => $attempt->id, 'question' => $question->id));
|
||||
$grade = $DB->get_record('question_attempt_steps', array('questionattemptid' => $response->id));
|
||||
foreach ($question_usages as $question_usage) {
|
||||
$question_attempt = $DB->get_record('question_attempts', array('questionusageid' => $question_usage->id));
|
||||
$question = $questions[$question_attempt->questionid];
|
||||
$response = $question_attempt->responsesummary;
|
||||
|
||||
$attempt_table->data[] = array($question->name, $response->answer, $grade->fraction);
|
||||
$question_grade = $DB->get_record('question_attempt_steps', array('questionattemptid' => $question_attempt->id));
|
||||
|
||||
$attempt_table->data[] = array($question->name, $response, $question_grade->fraction);
|
||||
}
|
||||
|
||||
echo html_writer::table($attempt_table);
|
||||
|
|
Loading…
Reference in a new issue