diff --git a/question/behaviour/adaptive/tests/behaviourtype_test.php b/question/behaviour/adaptive/tests/behaviour_type_test.php similarity index 86% rename from question/behaviour/adaptive/tests/behaviourtype_test.php rename to question/behaviour/adaptive/tests/behaviour_type_test.php index 82951113920..ffc5badf4bc 100644 --- a/question/behaviour/adaptive/tests/behaviourtype_test.php +++ b/question/behaviour/adaptive/tests/behaviour_type_test.php @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * 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 - */ +namespace qbehaviour_adaptive; +use question_engine; defined('MOODLE_INTERNAL') || die(); @@ -34,10 +28,12 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit 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 */ -class qbehaviour_adaptive_type_test extends basic_testcase { +class behaviour_type_test extends \basic_testcase { /** @var qbehaviour_adaptive_type */ protected $behaviourtype; diff --git a/question/behaviour/adaptive/tests/walkthrough_test.php b/question/behaviour/adaptive/tests/walkthrough_test.php index 56772b3f092..f91e26d6fd5 100644 --- a/question/behaviour/adaptive/tests/walkthrough_test.php +++ b/question/behaviour/adaptive/tests/walkthrough_test.php @@ -14,17 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace qbehaviour_adaptive; -/** - * This file contains tests that walks a question through the adaptive - * behaviour. - * - * @package qbehaviour - * @subpackage adaptive - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -36,48 +28,49 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the adaptive behaviour. * + * @package qbehaviour_adaptive * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { protected function get_contains_penalty_info_expectation($penalty) { $penaltyinfo = get_string('gradingdetailspenalty', 'qbehaviour_adaptive', format_float($penalty, $this->displayoptions->markdp)); - return new question_pattern_expectation('/'.preg_quote($penaltyinfo, '/').'/'); + return new \question_pattern_expectation('/'.preg_quote($penaltyinfo, '/').'/'); } protected function get_does_not_contain_penalty_info_expectation() { $penaltyinfo = get_string('gradingdetailspenalty', 'qbehaviour_adaptive', 'XXXXX'); $penaltypattern = '/'.str_replace('XXXXX', '\\w*', preg_quote($penaltyinfo, '/')).'/'; - return new question_no_pattern_expectation($penaltypattern); + return new \question_no_pattern_expectation($penaltypattern); } protected function get_contains_total_penalty_expectation($penalty) { $penaltyinfo = get_string('gradingdetailspenaltytotal', 'qbehaviour_adaptive', format_float($penalty, $this->displayoptions->markdp)); - return new question_pattern_expectation('/'.preg_quote($penaltyinfo, '/').'/'); + return new \question_pattern_expectation('/'.preg_quote($penaltyinfo, '/').'/'); } protected function get_does_not_contain_total_penalty_expectation() { $penaltyinfo = get_string('gradingdetailspenaltytotal', 'qbehaviour_adaptive', 'XXXXX'); $penaltypattern = '/'.str_replace('XXXXX', '\\w*', preg_quote($penaltyinfo, '/')).'/'; - return new question_no_pattern_expectation($penaltypattern); + return new \question_no_pattern_expectation($penaltypattern); } protected function get_contains_disregarded_info_expectation() { $penaltyinfo = get_string('disregardedwithoutpenalty', 'qbehaviour_adaptive'); - return new question_pattern_expectation('/'.preg_quote($penaltyinfo, '/').'/'); + return new \question_pattern_expectation('/'.preg_quote($penaltyinfo, '/').'/'); } protected function get_does_not_contain_disregarded_info_expectation() { $penaltyinfo = get_string('disregardedwithoutpenalty', 'qbehaviour_adaptive'); - return new question_no_pattern_expectation('/'.preg_quote($penaltyinfo, '/').'/'); + return new \question_no_pattern_expectation('/'.preg_quote($penaltyinfo, '/').'/'); } public function test_adaptive_multichoice() { // Create a multiple choice, single response question. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $mc->penalty = 0.3333333; $this->start_attempt_at_question($mc, 'adaptive', 3); @@ -165,7 +158,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b $this->check_current_mark(1); $this->check_current_output( $this->get_contains_mark_summary(1), - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Now change the correct answer to the question, and regrade. $mc->answers[13]->fraction = -0.33333333; @@ -187,7 +180,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b public function test_adaptive_multichoice2() { // Create a multiple choice, multiple response question. - $mc = test_question_maker::make_a_multichoice_multi_question(); + $mc = \test_question_maker::make_a_multichoice_multi_question(); $mc->penalty = 0.3333333; $mc->shuffleanswers = 0; $this->start_attempt_at_question($mc, 'adaptive', 2); @@ -239,7 +232,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b public function test_adaptive_shortanswer_partially_right() { // Create a short answer question. - $sa = test_question_maker::make_question('shortanswer'); + $sa = \test_question_maker::make_question('shortanswer'); $this->start_attempt_at_question($sa, 'adaptive'); // Check the initial state. @@ -318,7 +311,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b public function test_adaptive_shortanswer_wrong_right_wrong() { // Create a short answer question. - $sa = test_question_maker::make_question('shortanswer'); + $sa = \test_question_maker::make_question('shortanswer'); $this->start_attempt_at_question($sa, 'adaptive', 6); // Check the initial state. @@ -401,7 +394,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b public function test_adaptive_shortanswer_invalid_after_complete() { // Create a short answer question. - $sa = test_question_maker::make_question('shortanswer'); + $sa = \test_question_maker::make_question('shortanswer'); $this->start_attempt_at_question($sa, 'adaptive'); // Check the initial state. @@ -483,7 +476,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b public function test_adaptive_shortanswer_zero_penalty() { // Create a short answer question. - $sa = test_question_maker::make_question('shortanswer'); + $sa = \test_question_maker::make_question('shortanswer'); // Disable penalties for this question. $sa->penalty = 0; $this->start_attempt_at_question($sa, 'adaptive'); @@ -540,7 +533,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b public function test_adaptive_shortanswer_try_to_submit_blank() { // Create a short answer question with correct answer true. - $sa = test_question_maker::make_question('shortanswer'); + $sa = \test_question_maker::make_question('shortanswer'); $this->start_attempt_at_question($sa, 'adaptive'); // Check the initial state. @@ -599,7 +592,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b public function test_adaptive_numerical() { // Create a numerical question. - $sa = test_question_maker::make_question('numerical', 'pi'); + $sa = \test_question_maker::make_question('numerical', 'pi'); $this->start_attempt_at_question($sa, 'adaptive'); // Check the initial state. @@ -654,7 +647,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b public function test_adaptive_numerical_invalid() { // Create a numerical question. - $numq = test_question_maker::make_question('numerical', 'pi'); + $numq = \test_question_maker::make_question('numerical', 'pi'); $numq->penalty = 0.1; $this->start_attempt_at_question($numq, 'adaptive'); @@ -758,7 +751,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b public function test_adaptive_multianswer() { // Create a multianswer question. - $q = test_question_maker::make_question('multianswer', 'twosubq'); + $q = \test_question_maker::make_question('multianswer', 'twosubq'); // To simplify testing, multichoice subquestion's answers are not shuffled. $q->subquestions[2]->shuffleanswers = 0; $choices = array('0' => 'Bow-wow', '1' => 'Wiggly worm', '2' => 'Pussy-cat'); diff --git a/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php b/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php index 34d77762a14..24a9687670b 100644 --- a/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php +++ b/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php @@ -14,16 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the adaptive (no penalties)k - * behaviour. - * - * @package qbehaviour - * @subpackage adaptivenopenalty - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_adaptivenopenalty; +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -35,31 +28,32 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the adaptive (no penalties) behaviour. * + * @package qbehaviour_adaptivenopenalty * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { protected function get_does_not_contain_gradingdetails_expectation() { - return new question_no_pattern_expectation('/class="gradingdetails"/'); + return new \question_no_pattern_expectation('/class="gradingdetails"/'); } protected function get_does_not_contain_penalty_info_expectation() { $penaltyinfo = get_string('gradingdetailspenalty', 'qbehaviour_adaptive', 'XXXXX'); $penaltypattern = '/'.str_replace('XXXXX', '\\w*', preg_quote($penaltyinfo, '/')).'/'; - return new question_no_pattern_expectation($penaltypattern); + return new \question_no_pattern_expectation($penaltypattern); } protected function get_does_not_contain_total_penalty_expectation() { $penaltyinfo = get_string('gradingdetailspenaltytotal', 'qbehaviour_adaptive', 'XXXXX'); $penaltypattern = '/'.str_replace('XXXXX', '\\w*', preg_quote($penaltyinfo, '/')).'/'; - return new question_no_pattern_expectation($penaltypattern); + return new \question_no_pattern_expectation($penaltypattern); } public function test_multichoice() { // Create a multiple choice, single response question. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $mc->penalty = 0.3333333; $this->start_attempt_at_question($mc, 'adaptivenopenalty', 3); @@ -147,7 +141,7 @@ class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrou $this->check_current_mark(1); $this->check_current_output( $this->get_contains_mark_summary(1), - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Now change the correct answer to the question, and regrade. $mc->answers[13]->fraction = -0.33333333; @@ -169,7 +163,7 @@ class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrou public function test_multichoice2() { // Create a multiple choice, multiple response question. - $mc = test_question_maker::make_a_multichoice_multi_question(); + $mc = \test_question_maker::make_a_multichoice_multi_question(); $mc->penalty = 0.3333333; $mc->shuffleanswers = 0; $this->start_attempt_at_question($mc, 'adaptivenopenalty', 2); @@ -220,7 +214,7 @@ class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrou public function test_numerical_invalid() { // Create a numerical question - $numq = test_question_maker::make_question('numerical', 'pi'); + $numq = \test_question_maker::make_question('numerical', 'pi'); $numq->penalty = 0.1; $this->start_attempt_at_question($numq, 'adaptivenopenalty'); diff --git a/question/behaviour/deferredcbm/tests/behaviourtype_test.php b/question/behaviour/deferredcbm/tests/behaviour_type_test.php similarity index 85% rename from question/behaviour/deferredcbm/tests/behaviourtype_test.php rename to question/behaviour/deferredcbm/tests/behaviour_type_test.php index 8e5654af84e..0d1ab506ad8 100644 --- a/question/behaviour/deferredcbm/tests/behaviourtype_test.php +++ b/question/behaviour/deferredcbm/tests/behaviour_type_test.php @@ -14,16 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the deferred feedback - * with certainty base marking behaviour. - * - * @package qbehaviour - * @subpackage deferredcbm - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_deferredcbm; +use question_display_options; +use question_engine; defined('MOODLE_INTERNAL') || die(); @@ -35,10 +29,11 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the deferred feedback with certainty base marking behaviour. * + * @package qbehaviour_deferredcbm * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_deferredcbm_type_test extends qbehaviour_walkthrough_test_base { +class behaviour_type_test extends \qbehaviour_walkthrough_test_base { /** @var qbehaviour_deferredcbm_type */ protected $behaviourtype; @@ -70,9 +65,9 @@ class qbehaviour_deferredcbm_type_test extends qbehaviour_walkthrough_test_base // Create a usage comprising 3 true-false questions. $this->quba->set_preferred_behaviour('deferredcbm'); - $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 3); - $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 3); - $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 3); + $this->quba->add_question(\test_question_maker::make_question('truefalse', 'true'), 3); + $this->quba->add_question(\test_question_maker::make_question('truefalse', 'true'), 3); + $this->quba->add_question(\test_question_maker::make_question('truefalse', 'true'), 3); $this->quba->start_all_questions(); // Process responses right, high certainty; right, med certainty; wrong, med certainty. @@ -106,9 +101,9 @@ class qbehaviour_deferredcbm_type_test extends qbehaviour_walkthrough_test_base // Create a usage comprising 3 true-false questions. $this->quba->set_preferred_behaviour('deferredcbm'); - $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 1); - $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 1); - $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 1); + $this->quba->add_question(\test_question_maker::make_question('truefalse', 'true'), 1); + $this->quba->add_question(\test_question_maker::make_question('truefalse', 'true'), 1); + $this->quba->add_question(\test_question_maker::make_question('truefalse', 'true'), 1); $this->quba->start_all_questions(); // Process responses right, high certainty; right, med certainty; wrong, med certainty. diff --git a/question/behaviour/deferredcbm/tests/walkthrough_test.php b/question/behaviour/deferredcbm/tests/walkthrough_test.php index 97b5fa9cc23..c5a3bad1b9b 100644 --- a/question/behaviour/deferredcbm/tests/walkthrough_test.php +++ b/question/behaviour/deferredcbm/tests/walkthrough_test.php @@ -14,16 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the deferred feedback - * with certainty base marking behaviour. - * - * @package qbehaviour - * @subpackage deferredcbm - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_deferredcbm; +use question_cbm; +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -35,14 +29,15 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the deferred feedback with certainty base marking behaviour. * + * @package qbehaviour_deferredcbm * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { public function test_deferred_cbm_truefalse_high_certainty() { // Create a true-false question with correct answer true. - $tf = test_question_maker::make_question('truefalse', 'true'); + $tf = \test_question_maker::make_question('truefalse', 'true'); $this->start_attempt_at_question($tf, 'deferredcbm', 2); // Verify. @@ -102,7 +97,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes // Verify. $this->check_current_state(question_state::$mangrright); $this->check_current_mark(5); - $this->check_current_output(new question_pattern_expectation('/' . + $this->check_current_output(new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Now change the correct answer to the question, and regrade. @@ -119,7 +114,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes public function test_deferred_cbm_truefalse_low_certainty() { // Create a true-false question with correct answer true. - $tf = test_question_maker::make_question('truefalse', 'true'); + $tf = \test_question_maker::make_question('truefalse', 'true'); $this->start_attempt_at_question($tf, 'deferredcbm', 2); // Verify. @@ -158,7 +153,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes public function test_deferred_cbm_truefalse_default_certainty() { // Create a true-false question with correct answer true. - $tf = test_question_maker::make_question('truefalse', 'true'); + $tf = \test_question_maker::make_question('truefalse', 'true'); $this->start_attempt_at_question($tf, 'deferredcbm', 2); // Verify. @@ -180,7 +175,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes $this->check_current_mark(2); $this->check_current_output($this->get_contains_correct_expectation(), $this->get_contains_cbm_radio_expectation(1, false, false), - new question_pattern_expectation('/' . preg_quote( + new \question_pattern_expectation('/' . preg_quote( get_string('assumingcertainty', 'qbehaviour_deferredcbm', question_cbm::get_string( $qa->get_last_behaviour_var('_assumedcertainty'))), '/') . '/')); @@ -191,7 +186,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes public function test_deferredcbm_resume_multichoice_single() { // Create a multiple-choice question. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); // Attempt it getting it wrong. $this->start_attempt_at_question($mc, 'deferredcbm', 1); @@ -258,7 +253,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes public function test_deferred_cbm_truefalse_no_certainty_feedback_when_not_answered() { // Create a true-false question with correct answer true. - $tf = test_question_maker::make_question('truefalse', 'true'); + $tf = \test_question_maker::make_question('truefalse', 'true'); $this->start_attempt_at_question($tf, 'deferredcbm', 2); // Verify. @@ -277,6 +272,6 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes $this->check_current_state(question_state::$gaveup); $this->check_current_mark(null); $this->check_current_output( - new question_no_pattern_expectation('/class=\"im-feedback/')); + new \question_no_pattern_expectation('/class=\"im-feedback/')); } } diff --git a/question/behaviour/deferredfeedback/tests/behaviourtype_test.php b/question/behaviour/deferredfeedback/tests/behaviour_type_test.php similarity index 85% rename from question/behaviour/deferredfeedback/tests/behaviourtype_test.php rename to question/behaviour/deferredfeedback/tests/behaviour_type_test.php index 9bb1eff7927..858a3908946 100644 --- a/question/behaviour/deferredfeedback/tests/behaviourtype_test.php +++ b/question/behaviour/deferredfeedback/tests/behaviour_type_test.php @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * 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 - */ +namespace qbehaviour_deferredfeedback; +use question_engine; defined('MOODLE_INTERNAL') || die(); @@ -34,10 +28,12 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit 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 */ -class qbehaviour_deferredfeedback_type_test extends qbehaviour_walkthrough_test_base { +class behaviour_type_test extends \qbehaviour_walkthrough_test_base { /** @var qbehaviour_deferredfeedback_type */ protected $behaviourtype; diff --git a/question/behaviour/deferredfeedback/tests/walkthrough_test.php b/question/behaviour/deferredfeedback/tests/walkthrough_test.php index e8112af50bf..8441574e3e1 100644 --- a/question/behaviour/deferredfeedback/tests/walkthrough_test.php +++ b/question/behaviour/deferredfeedback/tests/walkthrough_test.php @@ -14,16 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the deferred feedback - * behaviour. - * - * @package qbehaviour - * @subpackage deferredfeedback - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_deferredfeedback; +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -35,14 +28,15 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the deferred feedback behaviour. * + * @package qbehaviour_deferredfeedback * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_deferredfeedback_walkthrough_test extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { public function test_deferredfeedback_feedback_truefalse() { // Create a true-false question with correct answer true. - $tf = test_question_maker::make_question('truefalse', 'true'); + $tf = \test_question_maker::make_question('truefalse', 'true'); $this->start_attempt_at_question($tf, 'deferredfeedback', 2); // Check the initial state. @@ -89,7 +83,7 @@ class qbehaviour_deferredfeedback_walkthrough_test extends qbehaviour_walkthroug $this->check_current_mark(2); $this->check_current_output($this->get_contains_correct_expectation(), $this->get_contains_tf_true_radio_expectation(false, true), - new question_pattern_expectation('/class="r0 correct"/')); + new \question_pattern_expectation('/class="r0 correct"/')); $this->assertEquals(get_string('true', 'qtype_truefalse'), $this->quba->get_response_summary($this->slot)); @@ -99,7 +93,7 @@ class qbehaviour_deferredfeedback_walkthrough_test extends qbehaviour_walkthroug $this->check_current_state(question_state::$mangrpartial); $this->check_current_mark(1); $this->check_current_output( - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Now change the correct answer to the question, and regrade. $tf->rightanswer = false; @@ -116,7 +110,7 @@ class qbehaviour_deferredfeedback_walkthrough_test extends qbehaviour_walkthroug public function test_deferredfeedback_feedback_multichoice_single() { // Create a true-false question with correct answer true. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $this->start_attempt_at_question($mc, 'deferredfeedback', 3); // Start a deferred feedback attempt and add the question to it. @@ -171,7 +165,7 @@ class qbehaviour_deferredfeedback_walkthrough_test extends qbehaviour_walkthroug public function test_deferredfeedback_resume_multichoice_single() { // Create a multiple-choice question. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); // Attempt it getting it wrong. $this->start_attempt_at_question($mc, 'deferredfeedback', 3); @@ -224,7 +218,7 @@ class qbehaviour_deferredfeedback_walkthrough_test extends qbehaviour_walkthroug public function test_deferredfeedback_resume_multichoice_single_emptyanswer_first() { // Create a multiple-choice question. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); // Attempt it and submit empty. $this->start_attempt_at_question($mc, 'deferredfeedback', 3); diff --git a/question/behaviour/immediatecbm/tests/behaviourtype_test.php b/question/behaviour/immediatecbm/tests/behaviour_type_test.php similarity index 85% rename from question/behaviour/immediatecbm/tests/behaviourtype_test.php rename to question/behaviour/immediatecbm/tests/behaviour_type_test.php index 6c4ca9ee2bd..237a91471dd 100644 --- a/question/behaviour/immediatecbm/tests/behaviourtype_test.php +++ b/question/behaviour/immediatecbm/tests/behaviour_type_test.php @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * 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 - */ +namespace qbehaviour_immediatecbm; +use question_engine; defined('MOODLE_INTERNAL') || die(); @@ -34,10 +28,12 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit 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 */ -class qbehaviour_immediatecbm_type_test extends qbehaviour_walkthrough_test_base { +class behaviour_type_test extends \qbehaviour_walkthrough_test_base { /** @var qbehaviour_immediatecbm_type */ protected $behaviourtype; diff --git a/question/behaviour/immediatecbm/tests/walkthrough_test.php b/question/behaviour/immediatecbm/tests/walkthrough_test.php index c61759fbb01..790b5583d5b 100644 --- a/question/behaviour/immediatecbm/tests/walkthrough_test.php +++ b/question/behaviour/immediatecbm/tests/walkthrough_test.php @@ -14,16 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the immediate cbm - * behaviour. - * - * @package qbehaviour - * @subpackage immediatecbm - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_immediatecbm; +use question_cbm; +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -35,14 +29,15 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the immediate cbm behaviour. * + * @package qbehaviour_immediatecbm * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { public function test_immediatecbm_feedback_multichoice_right() { // Create a true-false question with correct answer true. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $this->start_attempt_at_question($mc, 'immediatecbm'); $rightindex = $this->get_mc_right_answer_index($mc); @@ -116,7 +111,7 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te $this->check_current_mark(0.5); $this->check_current_output( $this->get_contains_partcorrect_expectation(), - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Now change the correct answer to the question, and regrade. $mc->answers[13]->fraction = -0.33333333; @@ -136,7 +131,7 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te public function test_immediatecbm_feedback_multichoice_try_to_submit_blank() { // Create a true-false question with correct answer true. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $this->start_attempt_at_question($mc, 'immediatecbm'); // Check the initial state. @@ -183,13 +178,13 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te $this->check_current_mark(0.5); $this->check_current_output( $this->get_contains_partcorrect_expectation(), - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); } public function test_immediatecbm_feedback_shortanswer_try_to_submit_no_certainty() { // Create a short answer question with correct answer true. - $sa = test_question_maker::make_question('shortanswer'); + $sa = \test_question_maker::make_question('shortanswer'); $this->start_attempt_at_question($sa, 'immediatecbm'); // Check the initial state. @@ -223,7 +218,7 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te public function test_immediatecbm_feedback_multichoice_wrong_on_finish() { // Create a true-false question with correct answer true. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $this->start_attempt_at_question($mc, 'immediatecbm'); // Check the initial state. @@ -269,7 +264,7 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te public function test_immediatecbm_cbm_truefalse_no_certainty_feedback_when_not_answered() { // Create a true-false question with correct answer true. - $tf = test_question_maker::make_question('truefalse', 'true'); + $tf = \test_question_maker::make_question('truefalse', 'true'); $this->start_attempt_at_question($tf, 'immediatecbm', 2); // Verify. @@ -287,6 +282,6 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te $this->check_current_state(question_state::$gaveup); $this->check_current_mark(null); $this->check_current_output( - new question_no_pattern_expectation('/class=\"im-feedback/')); + new \question_no_pattern_expectation('/class=\"im-feedback/')); } } diff --git a/question/behaviour/immediatefeedback/tests/behaviourtype_test.php b/question/behaviour/immediatefeedback/tests/behaviour_type_test.php similarity index 85% rename from question/behaviour/immediatefeedback/tests/behaviourtype_test.php rename to question/behaviour/immediatefeedback/tests/behaviour_type_test.php index 354dccd4b44..8f4e8b807d2 100644 --- a/question/behaviour/immediatefeedback/tests/behaviourtype_test.php +++ b/question/behaviour/immediatefeedback/tests/behaviour_type_test.php @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * 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 - */ +namespace qbehaviour_immediatefeedback; +use question_engine; defined('MOODLE_INTERNAL') || die(); @@ -34,10 +28,12 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit 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 */ -class qbehaviour_immediatefeedback_type_test extends basic_testcase { +class behaviour_type_test extends \basic_testcase { /** @var qbehaviour_immediatefeedback_type */ protected $behaviourtype; diff --git a/question/behaviour/immediatefeedback/tests/walkthrough_test.php b/question/behaviour/immediatefeedback/tests/walkthrough_test.php index 00e1a851b6d..b48047cb4c0 100644 --- a/question/behaviour/immediatefeedback/tests/walkthrough_test.php +++ b/question/behaviour/immediatefeedback/tests/walkthrough_test.php @@ -14,16 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the immediate feedback - * behaviour. - * - * @package qbehaviour - * @subpackage immediatefeedback - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_immediatefeedback; +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -35,14 +28,15 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the immediate feedback behaviour. * + * @package qbehaviour_immediatefeedback * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_immediatefeedback_walkthrough_test extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { public function test_immediatefeedback_feedback_multichoice_right() { // Create a true-false question with correct answer true. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $this->start_attempt_at_question($mc, 'immediatefeedback'); $rightindex = $this->get_mc_right_answer_index($mc); @@ -123,7 +117,7 @@ class qbehaviour_immediatefeedback_walkthrough_test extends qbehaviour_walkthrou $this->check_current_mark(0.5); $this->check_current_output( $this->get_contains_partcorrect_expectation(), - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Now change the correct answer to the question, and regrade. $mc->answers[13]->fraction = -0.33333333; @@ -143,7 +137,7 @@ class qbehaviour_immediatefeedback_walkthrough_test extends qbehaviour_walkthrou public function test_immediatefeedback_feedback_multichoice_try_to_submit_blank() { // Create a true-false question with correct answer true. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $this->start_attempt_at_question($mc, 'immediatefeedback'); // Check the initial state. @@ -192,13 +186,13 @@ class qbehaviour_immediatefeedback_walkthrough_test extends qbehaviour_walkthrou $this->check_current_mark(0.5); $this->check_current_output( $this->get_contains_partcorrect_expectation(), - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); } public function test_immediatefeedback_feedback_multichoice_wrong_on_finish() { // Create a true-false question with correct answer true. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $this->start_attempt_at_question($mc, 'immediatefeedback'); // Check the initial state. diff --git a/question/behaviour/informationitem/tests/behaviourtype_test.php b/question/behaviour/informationitem/tests/behaviour_type_test.php similarity index 85% rename from question/behaviour/informationitem/tests/behaviourtype_test.php rename to question/behaviour/informationitem/tests/behaviour_type_test.php index 35c9e7d1fa5..ddcca899e9e 100644 --- a/question/behaviour/informationitem/tests/behaviourtype_test.php +++ b/question/behaviour/informationitem/tests/behaviour_type_test.php @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * 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 - */ +namespace qbehaviour_informationitem; +use question_engine; defined('MOODLE_INTERNAL') || die(); @@ -34,10 +28,12 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit 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 */ -class qbehaviour_informationitem_type_testcase extends basic_testcase { +class behaviour_type_test extends \basic_testcase { /** @var qbehaviour_informationitem_type */ protected $behaviourtype; diff --git a/question/behaviour/informationitem/tests/walkthrough_test.php b/question/behaviour/informationitem/tests/walkthrough_test.php index 27896e27d5a..553eebabc2b 100644 --- a/question/behaviour/informationitem/tests/walkthrough_test.php +++ b/question/behaviour/informationitem/tests/walkthrough_test.php @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the information item - * behaviour. - * - * @package qbehaviour_informationitem - * @category test - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_informationitem; + +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -34,14 +28,16 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the information item behaviour. * + * @package qbehaviour_informationitem + * @category test * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_informationitem_walkthrough_testcase extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { public function test_informationitem_feedback_description() { // Create a true-false question with correct answer true. - $description = test_question_maker::make_question('description'); + $description = \test_question_maker::make_question('description'); $this->start_attempt_at_question($description, 'deferredfeedback'); // Check the initial state. @@ -65,7 +61,7 @@ class qbehaviour_informationitem_walkthrough_testcase extends qbehaviour_walkthr $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output($this->get_does_not_contain_correctness_expectation(), - new question_no_pattern_expectation( + new \question_no_pattern_expectation( '/type=\"hidden\"[^>]*name=\"[^"]*seen\"|name=\"[^"]*seen\"[^>]*type=\"hidden\"/'), $this->get_does_not_contain_feedback_expectation()); @@ -85,7 +81,7 @@ class qbehaviour_informationitem_walkthrough_testcase extends qbehaviour_walkthr $this->check_current_state(question_state::$manfinished); $this->check_current_mark(null); $this->check_current_output( - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Check that trying to process a manual comment with a grade causes an exception. $this->expectException('moodle_exception'); diff --git a/question/behaviour/interactive/tests/behaviourtype_test.php b/question/behaviour/interactive/tests/behaviour_type_test.php similarity index 85% rename from question/behaviour/interactive/tests/behaviourtype_test.php rename to question/behaviour/interactive/tests/behaviour_type_test.php index 7f4eab7a957..2298059e8e4 100644 --- a/question/behaviour/interactive/tests/behaviourtype_test.php +++ b/question/behaviour/interactive/tests/behaviour_type_test.php @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * 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 - */ +namespace qbehaviour_interactive; +use question_engine; defined('MOODLE_INTERNAL') || die(); @@ -34,10 +28,12 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit 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 */ -class qbehaviour_interactive_type_test extends basic_testcase { +class behaviour_type_test extends \basic_testcase { /** @var qbehaviour_interactive_type */ protected $behaviourtype; diff --git a/question/behaviour/interactive/tests/walkthrough_test.php b/question/behaviour/interactive/tests/walkthrough_test.php index ec21240f1c0..5cb0145540b 100644 --- a/question/behaviour/interactive/tests/walkthrough_test.php +++ b/question/behaviour/interactive/tests/walkthrough_test.php @@ -14,15 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the interactive - * behaviour. - * - * @package qbehaviour_interactive - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_interactive; +use question_display_options; +use question_hint; +use question_hint_with_parts; +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -34,15 +31,16 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the interactive behaviour. * + * @package qbehaviour_interactive * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { public function test_interactive_feedback_multichoice_right() { // Create a multichoice single question. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $mc->hints = array( new question_hint_with_parts(0, 'This is the first hint.', FORMAT_HTML, false, false), new question_hint_with_parts(0, 'This is the second hint.', FORMAT_HTML, true, true), @@ -97,7 +95,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_does_not_contain_submit_button_expectation(), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new question_pattern_expectation('/Tries remaining: 2/'), + new \question_pattern_expectation('/Tries remaining: 2/'), $this->get_contains_hint_expectation('This is the first hint')); // Check that, if we review in this state, the try again button is disabled. @@ -163,7 +161,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->check_current_output( $this->get_contains_mark_summary(0.5), $this->get_contains_partcorrect_expectation(), - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Check regrading does not mess anything up. $this->quba->regrade_all_questions(); @@ -182,7 +180,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes public function test_interactive_finish_when_try_again_showing() { // Create a multichoice single question. - $mc = test_question_maker::make_a_multichoice_single_question(); + $mc = \test_question_maker::make_a_multichoice_single_question(); $mc->showstandardinstruction = true; $mc->hints = array( new question_hint_with_parts(0, 'This is the first hint.', FORMAT_HTML, false, false), @@ -205,7 +203,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(2), $this->get_no_hint_visible_expectation(), - new question_pattern_expectation('/' . + new \question_pattern_expectation('/' . preg_quote(get_string('selectone', 'qtype_multichoice'), '/') . '/')); // Submit the wrong answer. @@ -222,7 +220,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_does_not_contain_submit_button_expectation(), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new question_pattern_expectation('/Tries remaining: 1/'), + new \question_pattern_expectation('/Tries remaining: 1/'), $this->get_contains_hint_expectation('This is the first hint')); // Finish the attempt. @@ -243,7 +241,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes public function test_interactive_shortanswer_try_to_submit_blank() { // Create a short answer question. - $sa = test_question_maker::make_question('shortanswer'); + $sa = \test_question_maker::make_question('shortanswer'); $sa->hints = array( new question_hint(0, 'This is the first hint.', FORMAT_HTML), new question_hint(0, 'This is the second hint.', FORMAT_HTML), @@ -286,7 +284,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_does_not_contain_submit_button_expectation(), $this->get_does_not_contain_validation_error_expectation(), $this->get_contains_try_again_button_expectation(true), - new question_pattern_expectation('/Tries remaining: 2/'), + new \question_pattern_expectation('/Tries remaining: 2/'), $this->get_contains_hint_expectation('This is the first hint')); $this->assertEquals('newt', $this->quba->get_response_summary($this->slot)); @@ -338,7 +336,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes public function test_interactive_feedback_multichoice_multiple_reset() { // Create a multichoice multiple question. - $mc = test_question_maker::make_a_multichoice_multi_question(); + $mc = \test_question_maker::make_a_multichoice_multi_question(); $mc->showstandardinstruction = true; $mc->hints = array( new question_hint_with_parts(0, 'This is the first hint.', FORMAT_HTML, true, true), @@ -366,7 +364,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_does_not_contain_num_parts_correct(), $this->get_tries_remaining_expectation(3), $this->get_no_hint_visible_expectation(), - new question_pattern_expectation('/' . + new \question_pattern_expectation('/' . preg_quote(get_string('selectmulti', 'qtype_multichoice'), '/') . '/')); // Submit an answer with one right, and one wrong. @@ -384,7 +382,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_does_not_contain_submit_button_expectation(), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new question_pattern_expectation('/Tries remaining: 2/'), + new \question_pattern_expectation('/Tries remaining: 2/'), $this->get_contains_hint_expectation('This is the first hint'), $this->get_contains_num_parts_correct(1), $this->get_contains_standard_incorrect_combined_feedback_expectation(), @@ -418,7 +416,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes public function test_interactive_regrade_changing_num_tries_leaving_open() { // Create a multichoice multiple question. - $q = test_question_maker::make_question('shortanswer'); + $q = \test_question_maker::make_question('shortanswer'); $q->hints = array( new question_hint_with_parts(0, 'This is the first hint.', FORMAT_HTML, true, true), new question_hint_with_parts(0, 'This is the second hint.', FORMAT_HTML, true, true), @@ -451,7 +449,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes public function test_interactive_regrade_changing_num_tries_finished() { // Create a multichoice multiple question. - $q = test_question_maker::make_question('shortanswer'); + $q = \test_question_maker::make_question('shortanswer'); $q->hints = array( new question_hint_with_parts(0, 'This is the first hint.', FORMAT_HTML, true, true), new question_hint_with_parts(0, 'This is the second hint.', FORMAT_HTML, true, true), @@ -487,7 +485,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes public function test_review_of_interactive_questions_before_finished() { // Create a multichoice multiple question. - $q = test_question_maker::make_question('shortanswer'); + $q = \test_question_maker::make_question('shortanswer'); $q->hints = array( new question_hint_with_parts(0, 'This is the first hint.', FORMAT_HTML, true, true), new question_hint_with_parts(0, 'This is the second hint.', FORMAT_HTML, true, true), diff --git a/question/behaviour/interactivecountback/tests/behaviourtype_test.php b/question/behaviour/interactivecountback/tests/behaviour_type_test.php similarity index 84% rename from question/behaviour/interactivecountback/tests/behaviourtype_test.php rename to question/behaviour/interactivecountback/tests/behaviour_type_test.php index ed5f20e1f32..83aea488e0e 100644 --- a/question/behaviour/interactivecountback/tests/behaviourtype_test.php +++ b/question/behaviour/interactivecountback/tests/behaviour_type_test.php @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * 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 - */ +namespace qbehaviour_interactivecountback; +use question_engine; defined('MOODLE_INTERNAL') || die(); @@ -34,10 +28,12 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit 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 */ -class qbehaviour_interactivecountback_type_test extends basic_testcase { +class behaviour_type_test extends \basic_testcase { /** @var qbehaviour_interactivecountback_type */ protected $behaviourtype; diff --git a/question/behaviour/interactivecountback/tests/walkthrough_test.php b/question/behaviour/interactivecountback/tests/walkthrough_test.php index 255cbe71eff..291567c3acc 100644 --- a/question/behaviour/interactivecountback/tests/walkthrough_test.php +++ b/question/behaviour/interactivecountback/tests/walkthrough_test.php @@ -14,16 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the interactive with - * countback behaviour. - * - * @package qbehaviour - * @subpackage interactivecountback - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_interactivecountback; +use question_hint_with_parts; +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -35,14 +29,15 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the interactive with countback behaviour. * + * @package qbehaviour_interactivecountback * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { public function test_interactive_feedback_match_reset() { // Create a matching question. - $m = test_question_maker::make_question('match'); + $m = \test_question_maker::make_question('match'); $m->shufflestems = false; $m->hints = array( new question_hint_with_parts(0, 'This is the first hint.', FORMAT_HTML, true, true), @@ -87,7 +82,7 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth $this->get_does_not_contain_submit_button_expectation(), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new question_pattern_expectation('/Tries remaining: 2/'), + new \question_pattern_expectation('/Tries remaining: 2/'), $this->get_contains_hint_expectation('This is the first hint'), $this->get_contains_num_parts_correct(2), $this->get_contains_standard_partiallycorrect_combined_feedback_expectation(), @@ -142,7 +137,7 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth $this->get_does_not_contain_try_again_button_expectation(), $this->get_contains_correct_expectation(), $this->get_contains_standard_correct_combined_feedback_expectation(), - new question_no_pattern_expectation('/class="control\b[^"]*\bpartiallycorrect"/')); + new \question_no_pattern_expectation('/class="control\b[^"]*\bpartiallycorrect"/')); $this->check_output_contains_selectoptions( $this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false), $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false), diff --git a/question/behaviour/manualgraded/tests/behaviourtype_test.php b/question/behaviour/manualgraded/tests/behaviour_type_test.php similarity index 86% rename from question/behaviour/manualgraded/tests/behaviourtype_test.php rename to question/behaviour/manualgraded/tests/behaviour_type_test.php index 0ba9aff5946..f7a26b0b5db 100644 --- a/question/behaviour/manualgraded/tests/behaviourtype_test.php +++ b/question/behaviour/manualgraded/tests/behaviour_type_test.php @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * 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 - */ +namespace qbehaviour_manualgraded; +use question_engine; defined('MOODLE_INTERNAL') || die(); @@ -34,10 +28,12 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit 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 */ -class qbehaviour_manualgraded_type_test extends basic_testcase { +class behaviour_type_test extends \basic_testcase { /** @var qbehaviour_manualgraded_type */ protected $behaviourtype; diff --git a/question/behaviour/manualgraded/tests/walkthrough_test.php b/question/behaviour/manualgraded/tests/walkthrough_test.php index 7b10b900edf..f829c3ce689 100644 --- a/question/behaviour/manualgraded/tests/walkthrough_test.php +++ b/question/behaviour/manualgraded/tests/walkthrough_test.php @@ -14,15 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * This file contains tests that walks a question through the manual graded - * behaviour. - * - * @package qbehaviour_manualgraded - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ +namespace qbehaviour_manualgraded; +use question_display_options; +use question_state; defined('MOODLE_INTERNAL') || die(); @@ -34,10 +29,11 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the manual graded behaviour. * + * @package qbehaviour_manualgraded * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthrough_test_base { +class walkthrough_test extends \qbehaviour_walkthrough_test_base { public function test_manual_graded_essay() { global $PAGE; @@ -47,7 +43,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $PAGE->set_url('/'); // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. @@ -67,7 +63,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( - new question_contains_tag_with_attribute('textarea', 'name', + new \question_contains_tag_with_attribute('textarea', 'name', $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')), $this->get_does_not_contain_feedback_expectation()); @@ -101,7 +97,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$mangrright); $this->check_current_mark(10); $this->check_current_output( - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Now change the max mark for the question and regrade. $this->quba->regrade_question($this->slot, true, 1); @@ -120,7 +116,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $PAGE->set_url('/'); // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. @@ -149,7 +145,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$mangrpartial); $this->check_current_mark(1); $this->check_current_output( - new question_pattern_expectation('/' . preg_quote('Not good enough!') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!') . '/')); // Now change the max mark for the question and regrade. $this->quba->regrade_question($this->slot, true, 1); @@ -162,7 +158,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug public function test_manual_graded_truefalse() { // Create a true-false question with correct answer true. - $tf = test_question_maker::make_question('truefalse', 'true'); + $tf = \test_question_maker::make_question('truefalse', 'true'); $this->start_attempt_at_question($tf, 'manualgraded', 2); // Check the initial state. @@ -200,7 +196,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_output( $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_specific_feedback_expectation(), - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); } public function test_manual_grade_ungraded_question() { @@ -212,7 +208,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $PAGE->set_url('/'); // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 0); // Check the right model is being used. @@ -232,7 +228,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( - new question_contains_tag_with_attribute('textarea', 'name', + new \question_contains_tag_with_attribute('textarea', 'name', $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')), $this->get_does_not_contain_feedback_expectation()); @@ -257,12 +253,12 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$needsgrading); $this->check_current_mark(null); $this->check_current_output( - new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); } public function test_manual_graded_ignore_repeat_sumbission() { // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. @@ -303,7 +299,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$needsgrading); $this->check_current_mark(null); $this->check_current_output( - new question_pattern_expectation('/' . + new \question_pattern_expectation('/' . preg_quote('I am not sure what grade to award.', '/') . '/')); // Now grade it. @@ -312,7 +308,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$mangrpartial); $this->check_current_mark(9); $this->check_current_output( - new question_pattern_expectation('/' . preg_quote('Pretty good!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Pretty good!', '/') . '/')); // Process the same data again, and make sure it does not add a step. $this->manual_grade('Pretty good!', '9.00000', FORMAT_HTML); @@ -326,7 +322,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$needsgrading); $this->check_current_mark(null); $this->check_current_output( - new question_pattern_expectation('/' . + new \question_pattern_expectation('/' . preg_quote('Actually, I am not sure any more.', '/') . '/')); $qa = $this->quba->get_question_attempt($this->slot); @@ -336,7 +332,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug public function test_manual_graded_ignore_repeat_sumbission_commas() { // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. @@ -373,7 +369,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->assertEquals('Manually graded 9 with comment: Pretty good!', $qa->summarise_action($qa->get_last_step())); $this->check_current_output( - new question_pattern_expectation('/' . preg_quote('Pretty good!', '/') . '/')); + new \question_pattern_expectation('/' . preg_quote('Pretty good!', '/') . '/')); // Process the same mark with a dot. Verify it does not add a new step. $this->manual_grade('Pretty good!', '9.00000', FORMAT_HTML); @@ -391,7 +387,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $PAGE->set_url('/'); // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. @@ -411,7 +407,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( - new question_contains_tag_with_attribute('textarea', 'name', + new \question_contains_tag_with_attribute('textarea', 'name', $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')), $this->get_does_not_contain_feedback_expectation()); @@ -441,7 +437,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $PAGE->set_url('/'); // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Simulate some data submitted by the student. @@ -472,7 +468,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $PAGE->set_url('/'); // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. @@ -492,7 +488,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( - new question_contains_tag_with_attribute('textarea', 'name', + new \question_contains_tag_with_attribute('textarea', 'name', $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')), $this->get_does_not_contain_feedback_expectation()); @@ -527,7 +523,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $PAGE->set_url('/'); // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. @@ -547,7 +543,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( - new question_contains_tag_with_attribute('textarea', 'name', + new \question_contains_tag_with_attribute('textarea', 'name', $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')), $this->get_does_not_contain_feedback_expectation()); @@ -574,7 +570,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $PAGE->set_url('/'); // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. @@ -594,7 +590,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output( - new question_contains_tag_with_attribute('textarea', 'name', + new \question_contains_tag_with_attribute('textarea', 'name', $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')), $this->get_does_not_contain_feedback_expectation()); @@ -622,7 +618,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $PAGE->set_url('/'); // Create an essay question. - $essay = test_question_maker::make_an_essay_question(); + $essay = \test_question_maker::make_an_essay_question(); $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. @@ -647,7 +643,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $preg = '/