MDL-40992 quiz: let students to redo questions within an attempt
This commit is contained in:
@@ -822,6 +822,22 @@ class question_usage_by_activity {
|
||||
$this->observer->notify_attempt_modified($newqa);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace a question in this usage.
|
||||
* @param int $slot the number used to identify this question within this usage.*
|
||||
*/
|
||||
public function replace_question($slot) {
|
||||
global $OUTPUT;
|
||||
$oldqa = $this->get_question_attempt($slot);
|
||||
$newqa = new question_attempt($oldqa->get_question(), $oldqa->get_usage_id(), $this->observer);
|
||||
$newqa->set_database_id($oldqa->get_database_id());
|
||||
$newqa->set_slot($oldqa->get_slot());
|
||||
$this->questionattempts[$slot] = $newqa;
|
||||
$this->observer->notify_attempt_deleted($oldqa);
|
||||
$this->observer->notify_attempt_added($newqa);
|
||||
$this->start_question($slot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regrade all the questions in this usage (without changing their max mark).
|
||||
* @param bool $finished whether each question should be forced to be finished
|
||||
@@ -979,6 +995,12 @@ interface question_usage_observer {
|
||||
*/
|
||||
public function notify_attempt_added(question_attempt $qa);
|
||||
|
||||
/**
|
||||
* Called when the fields of a question attempt in this usage are deleted.
|
||||
* @param question_attempt $qa
|
||||
*/
|
||||
public function notify_attempt_deleted(question_attempt $qa);
|
||||
|
||||
/**
|
||||
* Called when a new step is added to a question attempt in this usage.
|
||||
* @param question_attempt_step $step the new step.
|
||||
@@ -1017,6 +1039,8 @@ class question_usage_null_observer implements question_usage_observer {
|
||||
}
|
||||
public function notify_attempt_modified(question_attempt $qa) {
|
||||
}
|
||||
public function notify_attempt_deleted(question_attempt $qa) {
|
||||
}
|
||||
public function notify_attempt_added(question_attempt $qa) {
|
||||
}
|
||||
public function notify_step_added(question_attempt_step $step, question_attempt $qa, $seq) {
|
||||
|
||||
Reference in New Issue
Block a user