MDL-49315 questions: unit tests for each behaviour type class
authorTim Hunt <T.J.Hunt@open.ac.uk>
Thu, 26 Feb 2015 17:08:57 +0000 (17:08 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Thu, 5 Mar 2015 12:19:23 +0000 (12:19 +0000)
question/behaviour/adaptive/tests/behaviourtype_test.php [new file with mode: 0644]
question/behaviour/deferredfeedback/tests/behaviourtype_test.php [new file with mode: 0644]
question/behaviour/immediatecbm/tests/behaviourtype_test.php [new file with mode: 0644]
question/behaviour/immediatefeedback/tests/behaviourtype_test.php [new file with mode: 0644]
question/behaviour/informationitem/tests/behaviourtype_test.php [new file with mode: 0644]
question/behaviour/interactive/tests/behaviourtype_test.php [new file with mode: 0644]
question/behaviour/interactivecountback/tests/behaviourtype_test.php [new file with mode: 0644]
question/behaviour/manualgraded/tests/behaviourtype_test.php [new file with mode: 0644]
question/behaviour/missing/tests/behaviourtype_test.php [new file with mode: 0644]

diff --git a/question/behaviour/adaptive/tests/behaviourtype_test.php b/question/behaviour/adaptive/tests/behaviourtype_test.php
new file mode 100644 (file)
index 0000000..4b44ac7
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains tests for the adaptive behaviour type class.
+ *
+ * @package   qbehaviour_adaptive
+ * @category  test
+ * @copyright 2015 The Open University
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once(dirname(__FILE__) . '/../../../engine/lib.php');
+require_once(dirname(__FILE__) . '/../../../engine/tests/helpers.php');
+
+
+/**
+ * Unit tests for the adaptive behaviour type class.
+ *
+ * @copyright  2015 The Open University
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qbehaviour_adaptive_type_test extends basic_testcase {
+
+    /** @var qbehaviour_adaptive_type */
+    protected $behaviourtype;
+
+    public function setUp() {
+        parent::setUp();
+        $this->behaviourtype = question_engine::get_behaviour_type('adaptive');
+    }
+
+    public function test_is_archetypal() {
+        $this->assertTrue($this->behaviourtype->is_archetypal());
+    }
+
+    public function test_get_unused_display_options() {
+        $this->assertEquals(array(),
+                $this->behaviourtype->get_unused_display_options());
+    }
+
+    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));
+    }
+}
diff --git a/question/behaviour/deferredfeedback/tests/behaviourtype_test.php b/question/behaviour/deferredfeedback/tests/behaviourtype_test.php
new file mode 100644 (file)
index 0000000..8522505
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains tests for the deferred feedback behaviour type class.
+ *
+ * @package   qbehaviour_deferredfeedback
+ * @category  test
+ * @copyright 2015 The Open University
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once(dirname(__FILE__) . '/../../../engine/lib.php');
+require_once(dirname(__FILE__) . '/../../../engine/tests/helpers.php');
+
+
+/**
+ * Unit tests for the deferred feedback behaviour type class.
+ *
+ * @copyright  2015 The Open University
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qbehaviour_deferredfeedback_type_test extends qbehaviour_walkthrough_test_base {
+
+    /** @var qbehaviour_deferredfeedback_type */
+    protected $behaviourtype;
+
+    public function setUp() {
+        parent::setUp();
+        $this->behaviourtype = question_engine::get_behaviour_type('deferredfeedback');
+    }
+
+    public function test_is_archetypal() {
+        $this->assertTrue($this->behaviourtype->is_archetypal());
+    }
+
+    public function test_get_unused_display_options() {
+        $this->assertEquals(array('correctness', 'marks', 'specificfeedback', 'generalfeedback', 'rightanswer'),
+                $this->behaviourtype->get_unused_display_options());
+    }
+
+    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));
+    }
+}
diff --git a/question/behaviour/immediatecbm/tests/behaviourtype_test.php b/question/behaviour/immediatecbm/tests/behaviourtype_test.php
new file mode 100644 (file)
index 0000000..009bf12
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains tests for the immediate feedback with CBM behaviour type class.
+ *
+ * @package   qbehaviour_immediatecbm
+ * @category  test
+ * @copyright 2015 The Open University
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once(dirname(__FILE__) . '/../../../engine/lib.php');
+require_once(dirname(__FILE__) . '/../../../engine/tests/helpers.php');
+
+
+/**
+ * Unit tests for the immediate feedback with CBM behaviour type class.
+ *
+ * @copyright  2015 The Open University
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qbehaviour_immediatecbm_type_test extends qbehaviour_walkthrough_test_base {
+
+    /** @var qbehaviour_immediatecbm_type */
+    protected $behaviourtype;
+
+    public function setUp() {
+        parent::setUp();
+        $this->behaviourtype = question_engine::get_behaviour_type('immediatecbm');
+    }
+
+    public function test_is_archetypal() {
+        $this->assertTrue($this->behaviourtype->is_archetypal());
+    }
+
+    public function test_get_unused_display_options() {
+        $this->assertEquals(array(),
+                $this->behaviourtype->get_unused_display_options());
+    }
+
+    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));
+    }
+}
diff --git a/question/behaviour/immediatefeedback/tests/behaviourtype_test.php b/question/behaviour/immediatefeedback/tests/behaviourtype_test.php
new file mode 100644 (file)
index 0000000..cdbf324
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains tests for the immediate feedback behaviour type class.
+ *
+ * @package   qbehaviour_immediatefeedback
+ * @category  test
+ * @copyright 2015 The Open University
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once(dirname(__FILE__) . '/../../../engine/lib.php');
+require_once(dirname(__FILE__) . '/../../../engine/tests/helpers.php');
+
+
+/**
+ * Unit tests for the immediate feedback behaviour type class.
+ *
+ * @copyright  2015 The Open University
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qbehaviour_immediatefeedback_type_test extends basic_testcase {
+
+    /** @var qbehaviour_immediatefeedback_type */
+    protected $behaviourtype;
+
+    public function setUp() {
+        parent::setUp();
+        $this->behaviourtype = question_engine::get_behaviour_type('immediatefeedback');
+    }
+
+    public function test_is_archetypal() {
+        $this->assertTrue($this->behaviourtype->is_archetypal());
+    }
+
+    public function test_get_unused_display_options() {
+        $this->assertEquals(array(),
+                $this->behaviourtype->get_unused_display_options());
+    }
+
+    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));
+    }
+}
diff --git a/question/behaviour/informationitem/tests/behaviourtype_test.php b/question/behaviour/informationitem/tests/behaviourtype_test.php
new file mode 100644 (file)
index 0000000..8fca870
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains tests for the information item behaviour type class.
+ *
+ * @package   qbehaviour_informationitem
+ * @category  test
+ * @copyright 2015 The Open University
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once(dirname(__FILE__) . '/../../../engine/lib.php');
+require_once(dirname(__FILE__) . '/../../../engine/tests/helpers.php');
+
+
+/**
+ * Unit tests for the information item behaviour type class.
+ *
+ * @copyright  2015 The Open University
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qbehaviour_informationitem_type_test extends basic_testcase {
+
+    /** @var qbehaviour_informationitem_type */
+    protected $behaviourtype;
+
+    public function setUp() {
+        parent::setUp();
+        $this->behaviourtype = question_engine::get_behaviour_type('informationitem');
+    }
+
+    public function test_is_archetypal() {
+        $this->assertFalse($this->behaviourtype->is_archetypal());
+    }
+
+    public function test_get_unused_display_options() {
+        $this->assertEquals(array(),
+                $this->behaviourtype->get_unused_display_options());
+    }
+
+    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));
+    }
+}
diff --git a/question/behaviour/interactive/tests/behaviourtype_test.php b/question/behaviour/interactive/tests/behaviourtype_test.php
new file mode 100644 (file)
index 0000000..353dfe0
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains tests for the interactive with multiple tries behaviour type class.
+ *
+ * @package   qbehaviour_interactive
+ * @category  test
+ * @copyright 2015 The Open University
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once(dirname(__FILE__) . '/../../../engine/lib.php');
+require_once(dirname(__FILE__) . '/../../../engine/tests/helpers.php');
+
+
+/**
+ * Unit tests for the interactive with multiple tries behaviour type class.
+ *
+ * @copyright  2015 The Open University
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qbehaviour_interactive_type_test extends basic_testcase {
+
+    /** @var qbehaviour_interactive_type */
+    protected $behaviourtype;
+
+    public function setUp() {
+        parent::setUp();
+        $this->behaviourtype = question_engine::get_behaviour_type('interactive');
+    }
+
+    public function test_is_archetypal() {
+        $this->assertTrue($this->behaviourtype->is_archetypal());
+    }
+
+    public function test_get_unused_display_options() {
+        $this->assertEquals(array(),
+                $this->behaviourtype->get_unused_display_options());
+    }
+
+    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));
+    }
+}
diff --git a/question/behaviour/interactivecountback/tests/behaviourtype_test.php b/question/behaviour/interactivecountback/tests/behaviourtype_test.php
new file mode 100644 (file)
index 0000000..7b937e2
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains tests for the interactive with multiple tries and countback scoring behaviour type class.
+ *
+ * @package   qbehaviour_interactivecountback
+ * @category  test
+ * @copyright 2015 The Open University
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once(dirname(__FILE__) . '/../../../engine/lib.php');
+require_once(dirname(__FILE__) . '/../../../engine/tests/helpers.php');
+
+
+/**
+ * Unit tests for the interactive with multiple tries and countback scoring behaviour type class.
+ *
+ * @copyright  2015 The Open University
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qbehaviour_interactivecountback_type_test extends basic_testcase {
+
+    /** @var qbehaviour_interactivecountback_type */
+    protected $behaviourtype;
+
+    public function setUp() {
+        parent::setUp();
+        $this->behaviourtype = question_engine::get_behaviour_type('interactivecountback');
+    }
+
+    public function test_is_archetypal() {
+        $this->assertFalse($this->behaviourtype->is_archetypal());
+    }
+
+    public function test_get_unused_display_options() {
+        $this->assertEquals(array(),
+                $this->behaviourtype->get_unused_display_options());
+    }
+
+    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));
+    }
+}
diff --git a/question/behaviour/manualgraded/tests/behaviourtype_test.php b/question/behaviour/manualgraded/tests/behaviourtype_test.php
new file mode 100644 (file)
index 0000000..9957a8a
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains tests for the manually graded behaviour type class.
+ *
+ * @package   qbehaviour_manualgraded
+ * @category  test
+ * @copyright 2015 The Open University
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once(dirname(__FILE__) . '/../../../engine/lib.php');
+require_once(dirname(__FILE__) . '/../../../engine/tests/helpers.php');
+
+
+/**
+ * Unit tests for the manually graded behaviour type class.
+ *
+ * @copyright  2015 The Open University
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qbehaviour_manualgraded_type_test extends basic_testcase {
+
+    /** @var qbehaviour_manualgraded_type */
+    protected $behaviourtype;
+
+    public function setUp() {
+        parent::setUp();
+        $this->behaviourtype = question_engine::get_behaviour_type('manualgraded');
+    }
+
+    public function test_is_archetypal() {
+        $this->assertTrue($this->behaviourtype->is_archetypal());
+    }
+
+    public function test_get_unused_display_options() {
+        $this->assertEquals(array('correctness', 'marks', 'specificfeedback', 'generalfeedback', 'rightanswer'),
+                $this->behaviourtype->get_unused_display_options());
+    }
+
+    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));
+    }
+}
diff --git a/question/behaviour/missing/tests/behaviourtype_test.php b/question/behaviour/missing/tests/behaviourtype_test.php
new file mode 100644 (file)
index 0000000..fe18cae
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains tests for the missing behaviour type stand-in class.
+ *
+ * @package   qbehaviour_missing
+ * @category  test
+ * @copyright 2015 The Open University
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once(dirname(__FILE__) . '/../../../engine/lib.php');
+require_once(dirname(__FILE__) . '/../../../engine/tests/helpers.php');
+
+
+/**
+ * Unit tests for the missing behaviour type stand-in  class.
+ *
+ * @copyright  2015 The Open University
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qbehaviour_missing_type_test extends basic_testcase {
+
+    /** @var qbehaviour_missing_type */
+    protected $behaviourtype;
+
+    public function setUp() {
+        parent::setUp();
+        $this->behaviourtype = question_engine::get_behaviour_type('missing');
+    }
+
+    public function test_is_archetypal() {
+        $this->assertFalse($this->behaviourtype->is_archetypal());
+    }
+
+    public function test_get_unused_display_options() {
+        $this->assertEquals(array(),
+                $this->behaviourtype->get_unused_display_options());
+    }
+
+    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));
+    }
+}