MDL-31226: quiz: Fix message for attempts built on previous.
At the moment, when attempt is built on the last one, "not yet answered" message is shown, which confuses many people. This patch modifies the state to "complete" for attempt based on previous and modifies the output string. Many thanks to Tim Hunt for guiding me through quiz infrastructure and some code suggestions.
This commit is contained in:
@@ -347,8 +347,8 @@ abstract class question_behaviour {
|
||||
* Initialise the first step in a question attempt when a new
|
||||
* {@link question_attempt} is being started.
|
||||
*
|
||||
* This method must call $this->question->start_attempt($step), and may
|
||||
* perform additional processing if the model requries it.
|
||||
* This method must call $this->question->start_attempt($step, $variant), and may
|
||||
* perform additional processing if the behaviour requries it.
|
||||
*
|
||||
* @param question_attempt_step $step the first step of the
|
||||
* question_attempt being started.
|
||||
@@ -356,6 +356,23 @@ abstract class question_behaviour {
|
||||
*/
|
||||
public function init_first_step(question_attempt_step $step, $variant) {
|
||||
$this->question->start_attempt($step, $variant);
|
||||
$step->set_state(question_state::$todo);
|
||||
}
|
||||
|
||||
/**
|
||||
* When an attempt is started based on a previous attempt (see
|
||||
* {@link question_attempt::start_based_on}) this method is called to setup
|
||||
* the new attempt.
|
||||
*
|
||||
* This method must call $this->question->apply_attempt_state($step), and may
|
||||
* perform additional processing if the behaviour requries it.
|
||||
*
|
||||
* @param question_attempt_step The first step of the {@link question_attempt}
|
||||
* being loaded.
|
||||
*/
|
||||
public function apply_attempt_state(question_attempt_step $step) {
|
||||
$this->question->apply_attempt_state($step);
|
||||
$step->set_state(question_state::$todo);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,6 +563,13 @@ abstract class question_behaviour_with_save extends question_behaviour {
|
||||
return 'question_manually_gradable';
|
||||
}
|
||||
|
||||
public function apply_attempt_state(question_attempt_step $step) {
|
||||
parent::apply_attempt_state($step);
|
||||
if ($this->question->is_complete_response($step->get_qt_data())) {
|
||||
$step->set_state(question_state::$complete);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Work out whether the response in $pendingstep are significantly different
|
||||
* from the last set of responses we have stored.
|
||||
|
||||
Reference in New Issue
Block a user