MDL-40992 qbehaviour: new type method, can Qs can finish naturally

This commit is contained in:
Tim Hunt 2015-03-09 18:51:02 +00:00
parent 1700bd4dea
commit 47be39ef41
17 changed files with 76 additions and 25 deletions

View File

@ -56,6 +56,10 @@ class qbehaviour_adaptive_type_test extends basic_testcase {
$this->behaviourtype->get_unused_display_options());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertFalse($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_adjust_random_guess_score() {
$this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0));
$this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1));

View File

@ -59,6 +59,15 @@ abstract class question_behaviour_type {
return array();
}
/**
* With this behaviour, is it possible that a question might finish as the student
* interacts with it, without a call to the {@link question_attempt::finish()} method?
* @return bool whether with this behaviour, questions may finish naturally.
*/
public function can_questions_finish_during_the_attempt() {
return false;
}
/**
* Adjust a random guess score for a question using this model. You have to
* do this without knowing details of the specific question, or which usage
@ -102,14 +111,6 @@ abstract class question_behaviour_type {
public function allows_multiple_submitted_responses() {
return false;
}
/**
* Allow user to reattmpt graded question during a quiz attempt
* @return boolean
*/
public function user_can_reattempt_graded_question() {
return false;
}
}

View File

@ -57,6 +57,10 @@ class qbehaviour_deferredcbm_type_test extends qbehaviour_walkthrough_test_base
$this->behaviourtype->get_unused_display_options());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertFalse($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_adjust_random_guess_score() {
$this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0));
$this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1));

View File

@ -51,6 +51,10 @@ class qbehaviour_deferredfeedback_type_test extends qbehaviour_walkthrough_test_
$this->assertTrue($this->behaviourtype->is_archetypal());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertFalse($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_get_unused_display_options() {
$this->assertEquals(array('correctness', 'marks', 'specificfeedback', 'generalfeedback', 'rightanswer'),
$this->behaviourtype->get_unused_display_options());

View File

@ -40,10 +40,7 @@ class qbehaviour_immediatecbm_type extends qbehaviour_deferredcbm_type {
return array();
}
/**
* Allow user to re-attempt graded questions during a quiz attempt
*/
public function user_can_reattempt_graded_question() {
public function can_questions_finish_during_the_attempt() {
return true;
}
}

View File

@ -56,6 +56,10 @@ class qbehaviour_immediatecbm_type_test extends qbehaviour_walkthrough_test_base
$this->behaviourtype->get_unused_display_options());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertTrue($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_adjust_random_guess_score() {
$this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0));
$this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1));

View File

@ -37,10 +37,7 @@ class qbehaviour_immediatefeedback_type extends question_behaviour_type {
return true;
}
/**
* Allow user to re-attempt graded questions during a quiz attempt
*/
public function user_can_reattempt_graded_question() {
public function can_questions_finish_during_the_attempt() {
return true;
}
}

View File

@ -56,6 +56,10 @@ class qbehaviour_immediatefeedback_type_test extends basic_testcase {
$this->behaviourtype->get_unused_display_options());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertTrue($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_adjust_random_guess_score() {
$this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0));
$this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1));

View File

@ -56,6 +56,10 @@ class qbehaviour_informationitem_type_test extends basic_testcase {
$this->behaviourtype->get_unused_display_options());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertFalse($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_adjust_random_guess_score() {
$this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0));
$this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1));

View File

@ -41,12 +41,7 @@ class qbehaviour_interactive_type extends question_behaviour_type {
return true;
}
/**
* Allow user to re-attempt graded questions during a quiz attempt
*/
public function user_can_reattempt_graded_question() {
public function can_questions_finish_during_the_attempt() {
return true;
}
}

View File

@ -56,6 +56,10 @@ class qbehaviour_interactive_type_test extends basic_testcase {
$this->behaviourtype->get_unused_display_options());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertTrue($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_adjust_random_guess_score() {
$this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0));
$this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1));

View File

@ -56,6 +56,10 @@ class qbehaviour_interactivecountback_type_test extends basic_testcase {
$this->behaviourtype->get_unused_display_options());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertTrue($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_adjust_random_guess_score() {
$this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0));
$this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1));

View File

@ -56,6 +56,10 @@ class qbehaviour_manualgraded_type_test extends basic_testcase {
$this->behaviourtype->get_unused_display_options());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertFalse($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_adjust_random_guess_score() {
$this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0));
$this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1));

View File

@ -56,6 +56,10 @@ class qbehaviour_missing_type_test extends basic_testcase {
$this->behaviourtype->get_unused_display_options());
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertFalse($this->behaviourtype->can_questions_finish_during_the_attempt());
}
public function test_adjust_random_guess_score() {
$this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0));
$this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1));

View File

@ -2,10 +2,16 @@ 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
1) There are new methods question_behaviour::can_finish_during_attempt and
question_behaviour_type::can_finish_during_attempt. These methods both return
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.)
Check button within the question).
The behaviour type method answers the the question for this behaviour in
general, without reference to a specific question. The method on the
behaviour class answers the question for a specific attempt at a specific
question.
=== 2.7 ===

View File

@ -200,6 +200,16 @@ abstract class question_engine {
return self::get_behaviour_type($behaviour)->get_unused_display_options();
}
/**
* With this behaviour, is it possible that a question might finish as the student
* interacts with it, without a call to the {@link question_attempt::finish()} method?
* @param string $behaviour the name of a behaviour. E.g. 'deferredfeedback'.
* @return bool whether with this behaviour, questions may finish naturally.
*/
public static function can_questions_finish_during_the_attempt($behaviour) {
return self::get_behaviour_type($behaviour)->can_questions_finish_during_the_attempt();
}
/**
* Create a behaviour for a particular type. If that type cannot be
* found, return an instance of qbehaviour_missing.

View File

@ -62,6 +62,11 @@ class question_engine_test extends advanced_testcase {
question_engine::get_behaviour_unused_display_options('manualgraded'));
}
public function test_can_questions_finish_during_the_attempt() {
$this->assertFalse(question_engine::can_questions_finish_during_the_attempt('deferredfeedback'));
$this->assertTrue(question_engine::can_questions_finish_during_the_attempt('interactive'));
}
public function test_sort_behaviours() {
$in = array('b1' => 'Behave 1', 'b2' => 'Behave 2', 'b3' => 'Behave 3', 'b4' => 'Behave 4', 'b5' => 'Behave 5', 'b6' => 'Behave 6');