mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-67830 quiz: notice in grade details redirect script
This commit is contained in:
parent
4e41ace0be
commit
a33e0b4d84
@ -576,25 +576,12 @@ class quiz_attempt {
|
||||
* of the state of each question. Else just set up the basic details of the attempt.
|
||||
*/
|
||||
public function __construct($attempt, $quiz, $cm, $course, $loadquestions = true) {
|
||||
global $DB;
|
||||
|
||||
$this->attempt = $attempt;
|
||||
$this->quizobj = new quiz($quiz, $cm, $course);
|
||||
|
||||
if (!$loadquestions) {
|
||||
return;
|
||||
if ($loadquestions) {
|
||||
$this->load_questions();
|
||||
}
|
||||
|
||||
$this->quba = question_engine::load_questions_usage_by_activity($this->attempt->uniqueid);
|
||||
$this->slots = $DB->get_records('quiz_slots',
|
||||
array('quizid' => $this->get_quizid()), 'slot',
|
||||
'slot, id, requireprevious, questionid, includingsubcategories');
|
||||
$this->sections = array_values($DB->get_records('quiz_sections',
|
||||
array('quizid' => $this->get_quizid()), 'firstslot'));
|
||||
|
||||
$this->link_sections_and_slots();
|
||||
$this->determine_layout();
|
||||
$this->number_questions();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -643,6 +630,28 @@ class quiz_attempt {
|
||||
return quiz_attempt_state_name($state);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method can be called later if the object was constructed with $loadqusetions = false.
|
||||
*/
|
||||
public function load_questions() {
|
||||
global $DB;
|
||||
|
||||
if (isset($this->quba)) {
|
||||
throw new coding_exception('This quiz attempt has already had the questions loaded.');
|
||||
}
|
||||
|
||||
$this->quba = question_engine::load_questions_usage_by_activity($this->attempt->uniqueid);
|
||||
$this->slots = $DB->get_records('quiz_slots',
|
||||
array('quizid' => $this->get_quizid()), 'slot',
|
||||
'slot, id, requireprevious, questionid, includingsubcategories');
|
||||
$this->sections = array_values($DB->get_records('quiz_sections',
|
||||
array('quizid' => $this->get_quizid()), 'firstslot'));
|
||||
|
||||
$this->link_sections_and_slots();
|
||||
$this->determine_layout();
|
||||
$this->number_questions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Let each slot know which section it is part of.
|
||||
*/
|
||||
|
@ -81,6 +81,7 @@ if ($userid) {
|
||||
if ($attempt) {
|
||||
$attemptobj = new quiz_attempt($attempt, $quiz, $cm, $course, false);
|
||||
if ($attemptobj->is_review_allowed()) {
|
||||
$attemptobj->load_questions();
|
||||
redirect($attemptobj->review_url());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user