MDL-49315 questions: unit tests for each behaviour type class

This commit is contained in:
Tim Hunt 2015-02-26 17:08:57 +00:00
parent b90f98dade
commit 097efe9de3
9 changed files with 567 additions and 0 deletions

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}