MDL-40990 qbehaviours: method to say if attempts can finish naturally

This commit is contained in:
Tim Hunt
2015-03-13 14:23:02 +00:00
parent 06122e46fd
commit fd7a8af50b
6 changed files with 58 additions and 7 deletions
+10
View File
@@ -84,6 +84,16 @@ abstract class question_behaviour {
return substr(get_class($this), 11);
}
/**
* Whether the current attempt at this question could be completed just by the
* student interacting with the question, before $qa->finish() is called.
*
* @return boolean whether the attempt can finish naturally.
*/
public function can_finish_during_attempt() {
return false;
}
/**
* Cause the question to be renderered. This gets the appropriate behaviour
* renderer using {@link get_renderer()}, and adjusts the display
@@ -46,6 +46,10 @@ class qbehaviour_immediatefeedback extends question_behaviour_with_save {
return $question instanceof question_automatically_gradable;
}
public function can_finish_during_attempt() {
return true;
}
public function get_min_fraction() {
return $this->question->get_min_fraction();
}
@@ -54,6 +54,10 @@ class qbehaviour_interactive extends question_behaviour_with_multiple_tries {
return $question instanceof question_automatically_gradable;
}
public function can_finish_during_attempt() {
return true;
}
public function get_right_answer_summary() {
return $this->question->get_right_answer_summary();
}
+19 -7
View File
@@ -1,14 +1,26 @@
This files describes API changes for question behaviour plugins.
=== 2.9 ===
1) New method question_behaviour::can_finish_during_attempt. This returns false
by default. You should override it if, with your behaviour, questions may
finish just through the student interacting with them (e.g. by clicking the
Check button within the question.)
=== 2.7 ===
1) question_behaviour_type has a new method allows_multiple_submitted_responses which defaults to false but should return
true if this question behaviour accepts multiple submissions of responses within one attempt eg. multiple tries for the
interactive or adaptive question behaviours.
question_behaviour has a new method step_has_a_submitted_response($step). For question behaviours where it is not only the
final response that is submitted by the student, you need to override this method to return true for other steps where a
student has submitted a response. See question_behaviour_with_multiple_tries::step_has_a_submitted_response($step) for
example. This method only needs to be overriden if you are returning true from allows_multiple_response_submissions
1) question_behaviour_type has a new method allows_multiple_submitted_responses
which defaults to false but should return true if this question behaviour
accepts multiple submissions of responses within one attempt eg. multiple
tries for the interactive or adaptive question behaviours.
question_behaviour has a new method step_has_a_submitted_response($step). For
question behaviours where it is not only the final response that is
submitted by the student, you need to override this method to return true
for other steps where a student has submitted a response. See
question_behaviour_with_multiple_tries::step_has_a_submitted_response($step)
for example. This method only needs to be overriden if you are returning
true from allows_multiple_response_submissions.
=== 2.6 ===
+10
View File
@@ -1163,6 +1163,16 @@ class question_attempt {
return $this->rightanswer;
}
/**
* Whether this attempt at this question could be completed just by the
* student interacting with the question, before {@link finish()} is called.
*
* @return boolean whether this attempt can finish naturally.
*/
public function can_finish_during_attempt() {
return $this->behaviour->can_finish_during_attempt();
}
/**
* Perform the action described by $submitteddata.
* @param array $submitteddata the submitted data the determines the action.
+11
View File
@@ -271,6 +271,17 @@ class question_usage_by_activity {
return $this->get_question_attempt($slot)->get_state_class($showcorrectness);
}
/**
* Whether this attempt at a given question could be completed just by the
* student interacting with the question, before {@link finish_question()} is called.
*
* @param int $slot the number used to identify this question within this usage.
* @return boolean whether the attempt at the given question can finish naturally.
*/
public function can_question_finish_during_attempt($slot) {
return $this->get_question_attempt($slot)->can_finish_during_attempt();
}
/**
* Get the time of the most recent action performed on a question.
* @param int $slot the number used to identify this question within this usage.