mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
MDL-30300 qbehaviours: convert to the new is_compatible_question API.
This commit is contained in:
parent
15d660a8fd
commit
3d17cd3f1c
@ -38,8 +38,8 @@ defined('MOODLE_INTERNAL') || die();
|
||||
class qbehaviour_adaptive extends question_behaviour_with_save {
|
||||
const IS_ARCHETYPAL = true;
|
||||
|
||||
public function required_question_definition_type() {
|
||||
return 'question_automatically_gradable';
|
||||
public function is_compatible_question(question_definition $question) {
|
||||
return $question instanceof question_automatically_gradable;
|
||||
}
|
||||
|
||||
public function get_expected_data() {
|
||||
|
@ -79,6 +79,10 @@ abstract class question_behaviour {
|
||||
/**
|
||||
* Some behaviours can only work with certing types of question. This method
|
||||
* allows the behaviour to verify that a question is compatible.
|
||||
*
|
||||
* This implementation is only provided for backwards-compatibility. You should
|
||||
* override this method if you are implementing a behaviour.
|
||||
*
|
||||
* @param question_definition $question the question.
|
||||
*/
|
||||
public function is_compatible_question(question_definition $question) {
|
||||
@ -91,6 +95,9 @@ abstract class question_behaviour {
|
||||
* of a particular subtype, or that implement a particular interface.
|
||||
* This method lets the behaviour document that. The type of
|
||||
* question passed to the constructor is then checked against this type.
|
||||
*
|
||||
* @deprecated since 2.2. Please use/override {@link is_compatible_question()} instead.
|
||||
*
|
||||
* @return string class/interface name.
|
||||
*/
|
||||
protected function required_question_definition_type() {
|
||||
|
@ -40,8 +40,8 @@ defined('MOODLE_INTERNAL') || die();
|
||||
class qbehaviour_deferredfeedback extends question_behaviour_with_save {
|
||||
const IS_ARCHETYPAL = true;
|
||||
|
||||
public function required_question_definition_type() {
|
||||
return 'question_automatically_gradable';
|
||||
public function is_compatible_question(question_definition $question) {
|
||||
return $question instanceof question_automatically_gradable;
|
||||
}
|
||||
|
||||
public static function get_unused_display_options() {
|
||||
|
@ -42,8 +42,8 @@ defined('MOODLE_INTERNAL') || die();
|
||||
class qbehaviour_immediatefeedback extends question_behaviour_with_save {
|
||||
const IS_ARCHETYPAL = true;
|
||||
|
||||
public function required_question_definition_type() {
|
||||
return 'question_automatically_gradable';
|
||||
public function is_compatible_question(question_definition $question) {
|
||||
return $question instanceof question_automatically_gradable;
|
||||
}
|
||||
|
||||
public function get_min_fraction() {
|
||||
|
@ -39,8 +39,8 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class qbehaviour_informationitem extends question_behaviour {
|
||||
|
||||
public function required_question_definition_type() {
|
||||
return 'question_definition';
|
||||
public function is_compatible_question(question_definition $question) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get_expected_data() {
|
||||
|
@ -52,8 +52,8 @@ class qbehaviour_interactive extends question_behaviour_with_save {
|
||||
*/
|
||||
const READONLY_EXCEPT_TRY_AGAIN = 23485299;
|
||||
|
||||
public function required_question_definition_type() {
|
||||
return 'question_automatically_gradable';
|
||||
public function is_compatible_question(question_definition $question) {
|
||||
return $question instanceof question_automatically_gradable;
|
||||
}
|
||||
|
||||
public function get_right_answer_summary() {
|
||||
|
@ -64,8 +64,8 @@ require_once(dirname(__FILE__) . '/../interactive/behaviour.php');
|
||||
class qbehaviour_interactivecountback extends qbehaviour_interactive {
|
||||
const IS_ARCHETYPAL = false;
|
||||
|
||||
public function required_question_definition_type() {
|
||||
return 'question_automatically_gradable_with_countback';
|
||||
public function is_compatible_question(question_definition $question) {
|
||||
return $question instanceof question_automatically_gradable_with_countback;
|
||||
}
|
||||
|
||||
protected function adjust_fraction($fraction, question_attempt_pending_step $pendingstep) {
|
||||
|
@ -45,8 +45,9 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qbehaviour_missing extends question_behaviour {
|
||||
public function required_question_definition_type() {
|
||||
return 'question_definition';
|
||||
|
||||
public function is_compatible_question(question_definition $question) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function summarise_action(question_attempt_step $step) {
|
||||
|
@ -2,10 +2,15 @@ This files describes API changes for question behaviour plugins.
|
||||
|
||||
=== 2.2 ===
|
||||
|
||||
* The old
|
||||
1) The old
|
||||
public static function get_required_behaviours()
|
||||
method is no more. Instead use the ->dependencies facility in version.php. E.g.
|
||||
$plugin->dependencies = array(
|
||||
'qbehaviour_immediatefeedback' => 2011102700,
|
||||
'qbehaviour_deferredcbm' => 2011102700
|
||||
);
|
||||
|
||||
2) The old required_question_definition_type method has been replaced by a new
|
||||
is_compatible_question method. You should change your behaviour to override the
|
||||
new method, not the old one. This change has been implemented in a
|
||||
backwards-compatible way, so behaviours will not break.
|
||||
|
Loading…
x
Reference in New Issue
Block a user