Merge branch 'MDL-73799' of https://github.com/stronk7/moodle
This commit is contained in:
+5
-9
@@ -14,15 +14,9 @@
|
||||
// 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
|
||||
*/
|
||||
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;
|
||||
@@ -14,17 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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');
|
||||
|
||||
@@ -14,16 +14,9 @@
|
||||
// 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 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');
|
||||
|
||||
|
||||
+11
-16
@@ -14,16 +14,10 @@
|
||||
// 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 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.
|
||||
@@ -14,16 +14,10 @@
|
||||
// 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 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/'));
|
||||
}
|
||||
}
|
||||
|
||||
+5
-9
@@ -14,15 +14,9 @@
|
||||
// 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
|
||||
*/
|
||||
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;
|
||||
@@ -14,16 +14,9 @@
|
||||
// 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 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);
|
||||
|
||||
+5
-9
@@ -14,15 +14,9 @@
|
||||
// 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
|
||||
*/
|
||||
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;
|
||||
@@ -14,16 +14,10 @@
|
||||
// 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 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/'));
|
||||
}
|
||||
}
|
||||
|
||||
+5
-9
@@ -14,15 +14,9 @@
|
||||
// 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
|
||||
*/
|
||||
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;
|
||||
@@ -14,16 +14,9 @@
|
||||
// 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 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.
|
||||
|
||||
+5
-9
@@ -14,15 +14,9 @@
|
||||
// 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
|
||||
*/
|
||||
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;
|
||||
@@ -14,15 +14,9 @@
|
||||
// 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 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');
|
||||
|
||||
+5
-9
@@ -14,15 +14,9 @@
|
||||
// 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
|
||||
*/
|
||||
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;
|
||||
@@ -14,15 +14,12 @@
|
||||
// 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 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),
|
||||
|
||||
+5
-9
@@ -14,15 +14,9 @@
|
||||
// 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
|
||||
*/
|
||||
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;
|
||||
@@ -14,16 +14,10 @@
|
||||
// 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 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),
|
||||
|
||||
+5
-9
@@ -14,15 +14,9 @@
|
||||
// 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
|
||||
*/
|
||||
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;
|
||||
@@ -14,15 +14,10 @@
|
||||
// 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 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 = '/<textarea [^>]+name="[^"]+-comment"[^>]+>\*one\n\*two\n\*three\n/';
|
||||
$this->displayoptions->manualcomment = question_display_options::EDITABLE;
|
||||
$this->check_current_output(
|
||||
new question_pattern_expectation($preg)
|
||||
new \question_pattern_expectation($preg)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -660,7 +656,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug
|
||||
$PAGE->set_url('/');
|
||||
|
||||
// Create an essay question graded out of 15 and attempt it.
|
||||
$essay = test_question_maker::make_an_essay_question();
|
||||
$essay = \test_question_maker::make_an_essay_question();
|
||||
$this->start_attempt_at_question($essay, 'deferredfeedback', 15);
|
||||
$this->process_submission(array('answer' => 'This is my wonderful essay!', 'answerformat' => FORMAT_HTML));
|
||||
$this->quba->finish_all_questions();
|
||||
@@ -696,7 +692,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug
|
||||
$PAGE->set_url('/');
|
||||
|
||||
// Create an essay question graded out of 15 and attempt it.
|
||||
$essay = test_question_maker::make_an_essay_question();
|
||||
$essay = \test_question_maker::make_an_essay_question();
|
||||
$this->start_attempt_at_question($essay, 'deferredfeedback', 10);
|
||||
$this->process_submission(array('answer' => 'This is my wonderful essay!', 'answerformat' => FORMAT_HTML));
|
||||
$this->quba->finish_all_questions();
|
||||
|
||||
+5
-9
@@ -14,15 +14,9 @@
|
||||
// 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
|
||||
*/
|
||||
namespace qbehaviour_missing;
|
||||
|
||||
use question_engine;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +28,12 @@ require_once(__DIR__ . '/../../../engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit 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
|
||||
*/
|
||||
class qbehaviour_missing_type_test extends basic_testcase {
|
||||
class behaviour_type_test extends \basic_testcase {
|
||||
|
||||
/** @var qbehaviour_missing_type */
|
||||
protected $behaviourtype;
|
||||
@@ -14,14 +14,10 @@
|
||||
// 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 that walks a question through a whole attempt.
|
||||
*
|
||||
* @package core_question
|
||||
* @copyright 2017 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core_question;
|
||||
|
||||
use question_bank;
|
||||
use question_display_options;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,15 +29,16 @@ require_once(__DIR__ . '/helpers.php');
|
||||
/**
|
||||
* End-to-end tests of attempting a question.
|
||||
*
|
||||
* @package core_question
|
||||
* @copyright 2017 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_question_walkthrough_testcase extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
public function test_regrade_does_not_lose_flag() {
|
||||
|
||||
// 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);
|
||||
|
||||
// Process a true answer.
|
||||
|
||||
@@ -14,15 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace qtype_calculated;
|
||||
|
||||
/**
|
||||
* Unit tests for the calculated question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage calculated
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_display_options;
|
||||
use question_state;
|
||||
use qtype_numerical;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,12 +31,13 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for qtype_calculated_definition.
|
||||
*
|
||||
* @package qtype_calculated
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_calculated_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
public function test_is_complete_response() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
|
||||
$this->assertFalse($question->is_complete_response(array()));
|
||||
$this->assertTrue($question->is_complete_response(array('answer' => '0')));
|
||||
@@ -47,7 +46,7 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
|
||||
$this->assertFalse($question->is_gradable_response(array()));
|
||||
$this->assertTrue($question->is_gradable_response(array('answer' => '0')));
|
||||
@@ -56,7 +55,7 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -68,7 +67,7 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
|
||||
public function test_get_correct_response() {
|
||||
// Testing with 3.0 + 0.1416.
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 3);
|
||||
$values = $question->vs->get_values();
|
||||
$this->assertSame(array('answer' => '3.01' ), $question->get_correct_response());
|
||||
@@ -79,7 +78,7 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
$this->assertSame(array('answer' => '3.0' ), $question->get_correct_response());
|
||||
|
||||
// Testing with 1.0 + 5.0.
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
$this->assertSame(array('answer' => '6.00' ), $question->get_correct_response());
|
||||
@@ -91,7 +90,7 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
$this->assertSame(array('answer' => '6.0' ),
|
||||
$question->get_correct_response());
|
||||
// Testing with 31.0 + 0.01416 .
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 4);
|
||||
$values = $question->vs->get_values();
|
||||
$this->assertSame(array('answer' => '31.01' ), $question->get_correct_response());
|
||||
@@ -105,7 +104,7 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -114,7 +113,7 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -122,7 +121,7 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -141,7 +140,7 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response_no_star() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
unset($question->answers[17]);
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
@@ -161,18 +160,18 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_variants_selection_seed_q_not_synchronised() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$this->assertEquals($question->stamp, $question->get_variants_selection_seed());
|
||||
}
|
||||
|
||||
public function test_get_variants_selection_seed_q_synchronised_datasets_not() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->synchronised = true;
|
||||
$this->assertEquals($question->stamp, $question->get_variants_selection_seed());
|
||||
}
|
||||
|
||||
public function test_get_variants_selection_seed_q_synchronised() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->synchronised = true;
|
||||
$question->datasetloader->set_are_synchronised($question->category, true);
|
||||
$this->assertEquals('category' . $question->category,
|
||||
@@ -185,9 +184,9 @@ class qtype_calculated_question_test extends advanced_testcase {
|
||||
public function test_get_question_definition_for_external_rendering() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$qa = test_question_maker::get_a_qa($question);
|
||||
$qa = \test_question_maker::get_a_qa($question);
|
||||
$displayoptions = new question_display_options();
|
||||
|
||||
$options = $question->get_question_definition_for_external_rendering($qa, $displayoptions);
|
||||
|
||||
+16
-17
@@ -14,14 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for (some of) question/type/calculated/questiontype.php.
|
||||
*
|
||||
* @package qtype_calculated
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_calculated;
|
||||
|
||||
use qtype_calculated;
|
||||
use qtype_numerical;
|
||||
use question_bank;
|
||||
use question_possible_response;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,13 +31,14 @@ require_once($CFG->dirroot . '/question/type/calculated/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for question/type/calculated/questiontype.php.
|
||||
*
|
||||
* @package qtype_calculated
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
* @covers \question_type
|
||||
* @covers \qtype_calculated
|
||||
*/
|
||||
class qtype_calculated_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
protected $tolerance = 0.00000001;
|
||||
protected $qtype;
|
||||
|
||||
@@ -60,7 +59,7 @@ class qtype_calculated_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score() {
|
||||
$q = test_question_maker::get_question_data('calculated');
|
||||
$q = \test_question_maker::get_question_data('calculated');
|
||||
$q->options->answers[17]->fraction = 0.1;
|
||||
$this->assertEquals(0.1, $this->qtype->get_random_guess_score($q));
|
||||
}
|
||||
@@ -68,15 +67,15 @@ class qtype_calculated_test extends advanced_testcase {
|
||||
public function test_load_question() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
/** @var core_question_generator $generator */
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$category = $generator->create_question_category(['contextid' => $syscontext->id]);
|
||||
|
||||
$fromform = test_question_maker::get_question_form_data('calculated');
|
||||
$fromform = \test_question_maker::get_question_form_data('calculated');
|
||||
$fromform->category = $category->id . ',' . $syscontext->id;
|
||||
|
||||
$question = new stdClass();
|
||||
$question = new \stdClass();
|
||||
$question->category = $category->id;
|
||||
$question->qtype = 'calculated';
|
||||
$question->createdby = 0;
|
||||
@@ -144,7 +143,7 @@ class qtype_calculated_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
protected function get_possible_response($ans, $tolerance, $type) {
|
||||
$a = new stdClass();
|
||||
$a = new \stdClass();
|
||||
$a->answer = $ans;
|
||||
$a->tolerance = $tolerance;
|
||||
$a->tolerancetype = get_string($type, 'qtype_numerical');
|
||||
@@ -152,7 +151,7 @@ class qtype_calculated_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_possible_responses() {
|
||||
$q = test_question_maker::get_question_data('calculated');
|
||||
$q = \test_question_maker::get_question_data('calculated');
|
||||
|
||||
$this->assertEquals(array(
|
||||
$q->id => array(
|
||||
@@ -167,7 +166,7 @@ class qtype_calculated_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_possible_responses_no_star() {
|
||||
$q = test_question_maker::get_question_data('calculated');
|
||||
$q = \test_question_maker::get_question_data('calculated');
|
||||
unset($q->options->answers[17]);
|
||||
|
||||
$this->assertEquals(array(
|
||||
@@ -189,10 +188,10 @@ class qtype_calculated_test extends advanced_testcase {
|
||||
// Enable multilang filter to on content and heading.
|
||||
filter_set_global_state('multilang', TEXTFILTER_ON);
|
||||
filter_set_applies_to_strings('multilang', 1);
|
||||
$filtermanager = filter_manager::instance();
|
||||
$filtermanager = \filter_manager::instance();
|
||||
$filtermanager->reset_caches();
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = \context_system::instance();
|
||||
|
||||
$longmultilangquestionname = "<span lang=\"en\" class=\"multilang\">Lorem ipsum dolor sit amet, consetetur sadipscing elitr</span><span lang=\"fr\" class=\"multilang\">Lorem ipsum dolor sit amet, consetetur sadipscing elitr</span>";
|
||||
$shortmultilangquestionname = "<span lang=\"en\" class=\"multilang\">Lorem ipsum</span><span lang=\"fr\" class=\"multilang\">Lorem ipsum</span>";
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* calculated questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage calculated
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_calculated;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of calculated question attempts.
|
||||
*
|
||||
* @package qtype_calculated
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_calculated_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
public function test_calculated_adaptive_qsession97() {
|
||||
$quiz = (object) array(
|
||||
'id' => '4',
|
||||
@@ -14,15 +14,10 @@
|
||||
// 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 overall tests of calculated questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage calculated
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_calculated;
|
||||
|
||||
use question_hint;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,14 +28,15 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the calculated question type.
|
||||
*
|
||||
* @package qtype_calculated
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_calculated_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive() {
|
||||
|
||||
// Create a gapselect question.
|
||||
$q = test_question_maker::make_question('calculated');
|
||||
$q = \test_question_maker::make_question('calculated');
|
||||
$q->hints = array(
|
||||
new question_hint(1, 'This is the first hint.', FORMAT_HTML),
|
||||
new question_hint(2, 'This is the second hint.', FORMAT_HTML),
|
||||
@@ -85,7 +81,7 @@ class qtype_calculated_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_contains_validation_error_expectation(),
|
||||
new question_pattern_expectation('/' .
|
||||
new \question_pattern_expectation('/' .
|
||||
preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
|
||||
@@ -14,16 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace qtype_calculatedmulti;
|
||||
|
||||
/**
|
||||
* Unit tests for the calculated multiple-choice question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage calculatedmulti
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,12 +29,13 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for qtype_calculatedmulti_definition.
|
||||
*
|
||||
* @package qtype_calculatedmulti
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_calculatedmulti_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
public function test_is_complete_response() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
|
||||
$this->assertFalse($question->is_complete_response(array()));
|
||||
$this->assertTrue($question->is_complete_response(array('answer' => '0')));
|
||||
@@ -48,7 +44,7 @@ class qtype_calculatedmulti_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
|
||||
$this->assertFalse($question->is_gradable_response(array()));
|
||||
$this->assertTrue($question->is_gradable_response(array('answer' => '0')));
|
||||
@@ -57,7 +53,7 @@ class qtype_calculatedmulti_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -68,7 +64,7 @@ class qtype_calculatedmulti_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -77,7 +73,7 @@ class qtype_calculatedmulti_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -86,7 +82,7 @@ class qtype_calculatedmulti_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -94,7 +90,7 @@ class qtype_calculatedmulti_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$question = test_question_maker::make_question('calculated');
|
||||
$question = \test_question_maker::make_question('calculated');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -111,4 +107,4 @@ class qtype_calculatedmulti_question_test extends advanced_testcase {
|
||||
question_classified_response::no_response()),
|
||||
$question->classify_response(array('answer' => '')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* calculated multiple-choice questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage calculatedmulti
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_calculatedmulti;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of calculated multiple-choice question attempts.
|
||||
*
|
||||
* @package qtype_calculatedmulti
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_calculatedmulti_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
public function test_calculatedmulti_adaptive_qsession96() {
|
||||
$quiz = (object) array(
|
||||
'id' => '4',
|
||||
@@ -14,15 +14,10 @@
|
||||
// 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 overall tests of calculated multiple-choice questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage calculatedmulti
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_calculatedmulti;
|
||||
|
||||
use question_hint_with_parts;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,15 +28,16 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the calculated multiple-choice question type.
|
||||
*
|
||||
* @package qtype_calculatedmulti
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_calculatedmulti_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
public function test_interactive_single_response() {
|
||||
|
||||
// Create a gapselect question.
|
||||
$q = test_question_maker::make_question('calculatedmulti', 'singleresponse');
|
||||
$q = \test_question_maker::make_question('calculatedmulti', 'singleresponse');
|
||||
$q->shuffleanswers = false;
|
||||
$q->hints = array(
|
||||
new question_hint_with_parts(1, 'This is the first hint.', FORMAT_HTML, true, false),
|
||||
@@ -105,7 +101,7 @@ class qtype_calculatedmulti_walkthrough_test extends qbehaviour_walkthrough_test
|
||||
public function test_interactive_multi_response() {
|
||||
|
||||
// Create a gapselect question.
|
||||
$q = test_question_maker::make_question('calculatedmulti', 'multiresponse');
|
||||
$q = \test_question_maker::make_question('calculatedmulti', 'multiresponse');
|
||||
$q->shuffleanswers = false;
|
||||
$q->hints = array(
|
||||
new question_hint_with_parts(1, 'This is the first hint.', FORMAT_HTML, true, false),
|
||||
|
||||
@@ -14,16 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace qtype_calculatedsimple;
|
||||
|
||||
/**
|
||||
* Unit tests for the simple calculated question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage calculatedsimple
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,12 +29,13 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for qtype_calculatedsimple_definition.
|
||||
*
|
||||
* @package qtype_calculatedsimple
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_calculatedsimple_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
public function test_is_complete_response() {
|
||||
$question = test_question_maker::make_question('calculatedsimple');
|
||||
$question = \test_question_maker::make_question('calculatedsimple');
|
||||
|
||||
$this->assertFalse($question->is_complete_response(array()));
|
||||
$this->assertTrue($question->is_complete_response(array('answer' => '0')));
|
||||
@@ -48,7 +44,7 @@ class qtype_calculatedsimple_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$question = test_question_maker::make_question('calculatedsimple');
|
||||
$question = \test_question_maker::make_question('calculatedsimple');
|
||||
|
||||
$this->assertFalse($question->is_gradable_response(array()));
|
||||
$this->assertTrue($question->is_gradable_response(array('answer' => '0')));
|
||||
@@ -57,7 +53,7 @@ class qtype_calculatedsimple_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$question = test_question_maker::make_question('calculatedsimple');
|
||||
$question = \test_question_maker::make_question('calculatedsimple');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -68,7 +64,7 @@ class qtype_calculatedsimple_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$question = test_question_maker::make_question('calculatedsimple');
|
||||
$question = \test_question_maker::make_question('calculatedsimple');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -77,7 +73,7 @@ class qtype_calculatedsimple_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$question = test_question_maker::make_question('calculatedsimple');
|
||||
$question = \test_question_maker::make_question('calculatedsimple');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -86,7 +82,7 @@ class qtype_calculatedsimple_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$question = test_question_maker::make_question('calculatedsimple');
|
||||
$question = \test_question_maker::make_question('calculatedsimple');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -94,7 +90,7 @@ class qtype_calculatedsimple_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$question = test_question_maker::make_question('calculatedsimple');
|
||||
$question = \test_question_maker::make_question('calculatedsimple');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$values = $question->vs->get_values();
|
||||
|
||||
@@ -111,4 +107,4 @@ class qtype_calculatedsimple_question_test extends advanced_testcase {
|
||||
question_classified_response::no_response()),
|
||||
$question->classify_response(array('answer' => '')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-11
@@ -14,14 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the calculatedsimple question type class.
|
||||
*
|
||||
* @package qtype_calculatedsimple
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_calculatedsimple;
|
||||
|
||||
use qtype_calculated_dataset_loader;
|
||||
use qtype_calculatedsimple;
|
||||
use qtype_calculatedsimple_edit_form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,6 +32,7 @@ require_once($CFG->dirroot . '/question/type/calculatedsimple/edit_calculatedsim
|
||||
/**
|
||||
* Unit tests for the calculatedsimple question type class.
|
||||
*
|
||||
* @package qtype_calculatedsimple
|
||||
* @copyright 2007 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
@@ -46,7 +44,7 @@ require_once($CFG->dirroot . '/question/type/calculatedsimple/edit_calculatedsim
|
||||
* @covers \qtype_calculatedsimple_edit_form
|
||||
*
|
||||
*/
|
||||
class qtype_calculatedsimple_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp(): void {
|
||||
@@ -70,8 +68,8 @@ class qtype_calculatedsimple_test extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
|
||||
$questiondata = test_question_maker::get_question_data('calculatedsimple', 'sumwithvariants');
|
||||
$formdata = test_question_maker::get_question_form_data('calculatedsimple', 'sumwithvariants');
|
||||
$questiondata = \test_question_maker::get_question_data('calculatedsimple', 'sumwithvariants');
|
||||
$formdata = \test_question_maker::get_question_form_data('calculatedsimple', 'sumwithvariants');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -79,7 +77,7 @@ class qtype_calculatedsimple_test extends advanced_testcase {
|
||||
$formdata->category = "{$cat->id},{$cat->contextid}";
|
||||
qtype_calculatedsimple_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_calculatedsimple_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_calculatedsimple_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* simple calculated questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage calculatedsimple
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_calculatedsimple;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of simple calculated question attempts.
|
||||
*
|
||||
* @package qtype_calculatedsimple
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_calculatedsimple_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
public function test_calculatedsimple_adaptive_qsession95() {
|
||||
$quiz = (object) array(
|
||||
'id' => '4',
|
||||
@@ -14,15 +14,10 @@
|
||||
// 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 overall tests of simple calculated questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage calculatedsimple
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_calculatedsimple;
|
||||
|
||||
use question_hint;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,14 +28,15 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the simple calculated question type.
|
||||
*
|
||||
* @package qtype_calculatedsimple
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_calculatedsimple_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive() {
|
||||
|
||||
// Create a gapselect question.
|
||||
$q = test_question_maker::make_question('calculatedsimple');
|
||||
$q = \test_question_maker::make_question('calculatedsimple');
|
||||
$q->hints = array(
|
||||
new question_hint(1, 'This is the first hint.', FORMAT_HTML),
|
||||
new question_hint(2, 'This is the second hint.', FORMAT_HTML),
|
||||
@@ -84,7 +80,7 @@ class qtype_calculatedsimple_walkthrough_test extends qbehaviour_walkthrough_tes
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_contains_validation_error_expectation(),
|
||||
new question_pattern_expectation('/' .
|
||||
new \question_pattern_expectation('/' .
|
||||
preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
|
||||
+11
-14
@@ -14,13 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop onto image edit form.
|
||||
*
|
||||
* @package qtype_ddimageortext
|
||||
* @copyright 2019 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddimageortext\form;
|
||||
|
||||
use qtype_ddimageortext_edit_form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -32,10 +28,11 @@ require_once($CFG->dirroot . '/question/type/ddimageortext/edit_ddimageortext_fo
|
||||
/**
|
||||
* Unit tests for the drag-and-drop onto image edit form.
|
||||
*
|
||||
* @package qtype_ddimageortext
|
||||
* @copyright 2019 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddimageortext_edit_form_test extends advanced_testcase {
|
||||
class edit_form_test extends \advanced_testcase {
|
||||
/**
|
||||
* Helper method.
|
||||
*
|
||||
@@ -47,23 +44,23 @@ class qtype_ddimageortext_edit_form_test extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
$category = question_make_default_categories(array($syscontext));
|
||||
$fakequestion = new stdClass();
|
||||
$fakequestion = new \stdClass();
|
||||
$fakequestion->qtype = 'ddimageortext';
|
||||
$fakequestion->contextid = $syscontext->id;
|
||||
$fakequestion->createdby = 2;
|
||||
$fakequestion->category = $category->id;
|
||||
$fakequestion->questiontext = 'Test question';
|
||||
$fakequestion->options = new stdClass();
|
||||
$fakequestion->options = new \stdClass();
|
||||
$fakequestion->options->answers = array();
|
||||
$fakequestion->formoptions = new stdClass();
|
||||
$fakequestion->formoptions = new \stdClass();
|
||||
$fakequestion->formoptions->movecontext = null;
|
||||
$fakequestion->formoptions->repeatelements = true;
|
||||
$fakequestion->inputs = null;
|
||||
|
||||
$form = new qtype_ddimageortext_edit_form(new moodle_url('/'), $fakequestion, $category,
|
||||
new core_question\local\bank\question_edit_contexts($syscontext));
|
||||
$form = new qtype_ddimageortext_edit_form(new \moodle_url('/'), $fakequestion, $category,
|
||||
new \core_question\local\bank\question_edit_contexts($syscontext));
|
||||
|
||||
return [$form, $category];
|
||||
}
|
||||
@@ -14,14 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop onto image question definition class.
|
||||
*
|
||||
* @package qtype_ddimageortext
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddimageortext;
|
||||
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,13 +30,14 @@ require_once($CFG->dirroot . '/question/type/ddimageortext/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the matching question definition class.
|
||||
*
|
||||
* @package qtype_ddimageortext
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
class question_test extends \basic_testcase {
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$this->assertEquals('The quick brown fox jumped over the lazy dog.; '.
|
||||
'[[Drop zone 1]] -> {1. quick / 2. fox}; '.
|
||||
'[[Drop zone 2]] -> {1. quick / 2. fox}; '.
|
||||
@@ -49,7 +47,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_question_summary_maths() {
|
||||
$dd = test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$this->assertEquals('Fill in the operators to make this equation work: '.
|
||||
'7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3; '.
|
||||
'[[Drop zone 1]] -> {1. + / 2. -}; '.
|
||||
@@ -60,7 +58,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -72,7 +70,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response_maths() {
|
||||
$dd = test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -84,17 +82,17 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$this->assertEquals(0.5, $dd->get_random_guess_score());
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score_maths() {
|
||||
$dd = test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$this->assertEquals(0.5, $dd->get_random_guess_score());
|
||||
}
|
||||
|
||||
public function test_get_right_choice_for() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -103,7 +101,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_right_choice_for_maths() {
|
||||
$dd = test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -114,7 +112,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_clear_wrong_from_response() {
|
||||
$dd = test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -124,7 +122,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_num_parts_right() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -135,7 +133,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_num_parts_right_maths() {
|
||||
$dd = test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -145,7 +143,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_expected_data() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(
|
||||
@@ -155,7 +153,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -164,7 +162,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response_maths() {
|
||||
$dd = test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -173,7 +171,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_is_same_response() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertTrue($dd->is_same_response(
|
||||
@@ -197,7 +195,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
array('p1' => '1', 'p2' => '2', 'p3' => '2', 'p4' => '4')));
|
||||
}
|
||||
public function test_is_complete_response() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($dd->is_complete_response(array()));
|
||||
@@ -209,7 +207,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($dd->is_gradable_response(array()));
|
||||
@@ -223,7 +221,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -236,7 +234,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_grading_maths() {
|
||||
$dd = test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddimageortext', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -249,7 +247,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -269,7 +267,7 @@ class qtype_ddimageortext_question_test extends basic_testcase {
|
||||
|
||||
public function test_summarise_response_choice_deleted() {
|
||||
/** @var qtype_ddtoimage_question_base $dd */
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
// Simulation of an instructor deleting 1 choice after an attempt has been made.
|
||||
|
||||
+4
-8
@@ -14,14 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop onto image question definition class.
|
||||
*
|
||||
* @package qtype_ddimageortext
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddimageortext;
|
||||
|
||||
use question_bank;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,10 +28,11 @@ require_once($CFG->dirroot . '/question/type/ddimageortext/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the drag-and-drop onto image question definition class.
|
||||
*
|
||||
* @package qtype_ddimageortext
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddimageortext_test extends basic_testcase {
|
||||
class question_type_test extends \basic_testcase {
|
||||
/** @var qtype_ddimageortext instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
@@ -14,14 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop onto image question type.
|
||||
*
|
||||
* @package qtype_ddimageortext
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddimageortext;
|
||||
|
||||
use question_display_options;
|
||||
use question_hint_with_parts;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,17 +30,18 @@ require_once($CFG->dirroot . '/question/type/ddimageortext/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the drag-and-drop onto image question type.
|
||||
*
|
||||
* @package qtype_ddimageortext
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
/**
|
||||
* Get an expectation that the output contains an item ready to drag.
|
||||
* @param int $dragitemno the item number.
|
||||
* @param int $choice which choice this is.
|
||||
* @param int $group which drag group it belongs to.
|
||||
* @return question_contains_tag_with_attributes the required expectation.
|
||||
* @return \question_contains_tag_with_attributes the required expectation.
|
||||
*/
|
||||
protected function get_contains_drag_image_home_expectation($dragitemno, $choice, $group) {
|
||||
$class = 'group' . $group . ' draghome choice' . $choice;
|
||||
@@ -51,13 +49,13 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$expectedattrs = array();
|
||||
$expectedattrs['class'] = $class;
|
||||
|
||||
return new question_contains_tag_with_attributes('div', $expectedattrs);
|
||||
return new \question_contains_tag_with_attributes('div', $expectedattrs);
|
||||
}
|
||||
|
||||
public function test_interactive_behaviour() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -194,7 +192,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_deferred_feedback() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 12);
|
||||
|
||||
@@ -297,7 +295,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_deferred_feedback_unanswered() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 12);
|
||||
|
||||
@@ -360,7 +358,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_deferred_feedback_partial_answer() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
|
||||
|
||||
@@ -422,7 +420,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_interactive_grading() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(1, 'This is the first hint.',
|
||||
FORMAT_MOODLE, true, true),
|
||||
@@ -602,7 +600,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_interactive_correct_no_submit() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(23, 'This is the first hint.',
|
||||
FORMAT_MOODLE, false, false),
|
||||
@@ -662,7 +660,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_interactive_partial_no_submit() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(23, 'This is the first hint.',
|
||||
FORMAT_MOODLE, false, false),
|
||||
@@ -724,7 +722,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_interactive_no_right_clears() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, true),
|
||||
new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
|
||||
@@ -801,7 +799,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_display_of_right_answer_when_shuffled() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext');
|
||||
$dd = \test_question_maker::make_question('ddimageortext');
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
|
||||
|
||||
// Check the initial state.
|
||||
@@ -858,7 +856,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_mixed_lang_rendering() {
|
||||
|
||||
// Create a mixe drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddimageortext', 'mixedlang');
|
||||
$dd = \test_question_maker::make_question('ddimageortext', 'mixedlang');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'interactive', 1);
|
||||
|
||||
@@ -866,8 +864,8 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->check_current_state(question_state::$todo);
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
new question_pattern_expectation('~<div class="group1 draghome choice1"><span lang="fr">la</span></div>~'),
|
||||
new question_pattern_expectation('~<div class="group1 draghome choice2"><span lang="fr">ma</span></div>~')
|
||||
new \question_pattern_expectation('~<div class="group1 draghome choice1"><span lang="fr">la</span></div>~'),
|
||||
new \question_pattern_expectation('~<div class="group1 draghome choice2"><span lang="fr">ma</span></div>~')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-14
@@ -14,13 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop markers edit form.
|
||||
*
|
||||
* @package qtype_ddmarker
|
||||
* @copyright 2019 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddmarker\form;
|
||||
|
||||
use qtype_ddmarker_edit_form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -32,10 +28,11 @@ require_once($CFG->dirroot . '/question/type/ddmarker/edit_ddmarker_form.php');
|
||||
/**
|
||||
* Unit tests for the drag-and-drop markers edit form.
|
||||
*
|
||||
* @package qtype_ddmarker
|
||||
* @copyright 2019 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddmarker_edit_form_test extends advanced_testcase {
|
||||
class edit_form_test extends \advanced_testcase {
|
||||
/**
|
||||
* Helper method.
|
||||
*
|
||||
@@ -47,23 +44,23 @@ class qtype_ddmarker_edit_form_test extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
$category = question_make_default_categories(array($syscontext));
|
||||
$fakequestion = new stdClass();
|
||||
$fakequestion = new \stdClass();
|
||||
$fakequestion->qtype = 'ddmarker';
|
||||
$fakequestion->contextid = $syscontext->id;
|
||||
$fakequestion->createdby = 2;
|
||||
$fakequestion->category = $category->id;
|
||||
$fakequestion->questiontext = 'Test question';
|
||||
$fakequestion->options = new stdClass();
|
||||
$fakequestion->options = new \stdClass();
|
||||
$fakequestion->options->answers = array();
|
||||
$fakequestion->formoptions = new stdClass();
|
||||
$fakequestion->formoptions = new \stdClass();
|
||||
$fakequestion->formoptions->movecontext = null;
|
||||
$fakequestion->formoptions->repeatelements = true;
|
||||
$fakequestion->inputs = null;
|
||||
|
||||
$form = new qtype_ddmarker_edit_form(new moodle_url('/'), $fakequestion, $category,
|
||||
new core_question\local\bank\question_edit_contexts($syscontext));
|
||||
$form = new qtype_ddmarker_edit_form(new \moodle_url('/'), $fakequestion, $category,
|
||||
new \core_question\local\bank\question_edit_contexts($syscontext));
|
||||
|
||||
return [$form, $category];
|
||||
}
|
||||
@@ -14,15 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop markers question definition class.
|
||||
*
|
||||
* @package qtype_ddmarker
|
||||
* @copyright 2012 The Open University
|
||||
* @author Jamie Pratt <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddmarker;
|
||||
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -34,13 +30,14 @@ require_once($CFG->dirroot . '/question/type/ddmarker/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the drag-and-drop markers question definition class.
|
||||
*
|
||||
* @package qtype_ddmarker
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddmarker_question_test extends basic_testcase {
|
||||
class question_test extends \basic_testcase {
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$this->assertEquals('The quick brown fox jumped over the lazy dog.; '.
|
||||
'[[Drop zone 1]] -> {quick / fox / lazy}; '.
|
||||
'[[Drop zone 2]] -> {quick / fox / lazy}; '.
|
||||
@@ -49,7 +46,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_question_summary_maths() {
|
||||
$dd = test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddmarker', 'maths');
|
||||
$this->assertEquals('Fill in the operators to make this equation work:; '.
|
||||
'[[Drop zone 1]] -> {+ / - / * / /}; '.
|
||||
'[[Drop zone 2]] -> {+ / - / * / /}; '.
|
||||
@@ -58,7 +55,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -71,7 +68,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response_maths() {
|
||||
$dd = test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -84,17 +81,17 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$this->assertEquals(null, $dd->get_random_guess_score());
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score_maths() {
|
||||
$dd = test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddmarker', 'maths');
|
||||
$this->assertEquals(null, $dd->get_random_guess_score());
|
||||
}
|
||||
|
||||
public function test_get_right_choice_for() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -104,7 +101,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_right_choice_for_maths() {
|
||||
$dd = test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -114,7 +111,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_clear_wrong_from_response() {
|
||||
$dd = test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -124,7 +121,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_num_parts_right() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -143,7 +140,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_num_parts_right_maths() {
|
||||
$dd = test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -153,7 +150,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_expected_data() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(
|
||||
@@ -163,7 +160,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -172,7 +169,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response_maths() {
|
||||
$dd = test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -180,7 +177,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_is_same_response() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertTrue($dd->is_same_response(
|
||||
@@ -228,7 +225,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
'c3' => '300,300;100,100', 'c4' => '400,400')));
|
||||
}
|
||||
public function test_is_complete_response() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($dd->is_complete_response(array()));
|
||||
@@ -240,7 +237,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($dd->is_gradable_response(array()));
|
||||
@@ -254,7 +251,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -267,7 +264,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_grading_maths() {
|
||||
$dd = test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddmarker', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -285,7 +282,7 @@ class qtype_ddmarker_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
|
||||
+4
-9
@@ -14,15 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop markers question definition class.
|
||||
*
|
||||
* @package qtype_ddmarker
|
||||
* @copyright 2012 The Open University
|
||||
* @author Jamie Pratt <me@jamiep.org>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddmarker;
|
||||
|
||||
use question_bank;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -34,10 +28,11 @@ require_once($CFG->dirroot . '/question/type/ddmarker/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the drag-and-drop markers question definition class.
|
||||
*
|
||||
* @package qtype_ddmarker
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddmarker_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
/** @var qtype_ddmarker instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
@@ -14,15 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop markers question type.
|
||||
*
|
||||
* @package qtype_ddmarker
|
||||
* @copyright 2012 The Open University
|
||||
* @author Jamie Pratt <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddmarker;
|
||||
|
||||
use question_display_options;
|
||||
use question_hint_ddmarker;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -34,16 +30,17 @@ require_once($CFG->dirroot . '/question/type/ddmarker/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the drag-and-drop markers question type.
|
||||
*
|
||||
* @package qtype_ddmarker
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
/**
|
||||
* Get an expectation that the output contains a marker.
|
||||
* @param unknown $choice which choice.
|
||||
* @param unknown $infinite whether there are infinitely many of that choice.
|
||||
* @return question_contains_tag_with_attributes the expectation.
|
||||
* @return \question_contains_tag_with_attributes the expectation.
|
||||
*/
|
||||
protected function get_contains_draggable_marker_home_expectation($choice, $infinite) {
|
||||
$class = 'marker choice'.$choice;
|
||||
@@ -54,7 +51,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$expectedattrs = array();
|
||||
$expectedattrs['class'] = $class;
|
||||
|
||||
return new question_contains_tag_with_attributes('span', $expectedattrs);
|
||||
return new \question_contains_tag_with_attributes('span', $expectedattrs);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,13 +65,13 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
if (!is_null($value)) {
|
||||
$expectedattributes['value'] = s($value);
|
||||
}
|
||||
return new question_contains_tag_with_attributes('input', $expectedattributes);
|
||||
return new \question_contains_tag_with_attributes('input', $expectedattributes);
|
||||
}
|
||||
|
||||
public function test_interactive_behaviour() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->hints = array(
|
||||
new question_hint_ddmarker(13, 'This is the first hint.',
|
||||
FORMAT_HTML, false, false, false),
|
||||
@@ -183,7 +180,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_deferred_feedback() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 12);
|
||||
|
||||
@@ -262,7 +259,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_deferred_feedback_unanswered() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 12);
|
||||
|
||||
@@ -312,7 +309,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_deferred_feedback_partial_answer() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
|
||||
|
||||
@@ -360,7 +357,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_grading() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->hints = array(
|
||||
new question_hint_ddmarker(1, 'This is the first hint.',
|
||||
FORMAT_MOODLE, true, true, false),
|
||||
@@ -504,7 +501,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_correct_no_submit() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->hints = array(
|
||||
new question_hint_ddmarker(23, 'This is the first hint.',
|
||||
FORMAT_MOODLE, false, false, false),
|
||||
@@ -557,7 +554,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_partial_no_submit() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->hints = array(
|
||||
new question_hint_ddmarker(23, 'This is the first hint.',
|
||||
FORMAT_MOODLE, false, false, false),
|
||||
@@ -612,7 +609,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_no_right_clears() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$dd->hints = array(
|
||||
new question_hint_ddmarker(23, 'This is the first hint.',
|
||||
FORMAT_MOODLE, false, true, false),
|
||||
@@ -678,7 +675,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_display_of_right_answer_when_shuffled() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddmarker');
|
||||
$dd = \test_question_maker::make_question('ddmarker');
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
|
||||
|
||||
// Check the initial state.
|
||||
|
||||
+10
-15
@@ -14,13 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop words into sentences edit form.
|
||||
*
|
||||
* @package qtype_ddwtos
|
||||
* @copyright 2018 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddwtos\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -32,10 +26,11 @@ require_once($CFG->dirroot . '/question/type/ddwtos/edit_ddwtos_form.php');
|
||||
/**
|
||||
* Unit tests for the drag-and-drop words into sentences edit form.
|
||||
*
|
||||
* @package qtype_ddwtos
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddwtos_edit_form_test extends advanced_testcase {
|
||||
class edit_form_test extends \advanced_testcase {
|
||||
/**
|
||||
* Helper method.
|
||||
*
|
||||
@@ -49,23 +44,23 @@ class qtype_ddwtos_edit_form_test extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
$category = question_make_default_categories(array($syscontext));
|
||||
$fakequestion = new stdClass();
|
||||
$fakequestion = new \stdClass();
|
||||
$fakequestion->qtype = 'ddwtos'; // Does not actually matter if this is wrong.
|
||||
$fakequestion->contextid = $syscontext->id;
|
||||
$fakequestion->createdby = 2;
|
||||
$fakequestion->category = $category->id;
|
||||
$fakequestion->questiontext = 'Test [[1]] question [[2]]';
|
||||
$fakequestion->options = new stdClass();
|
||||
$fakequestion->options = new \stdClass();
|
||||
$fakequestion->options->answers = array();
|
||||
$fakequestion->formoptions = new stdClass();
|
||||
$fakequestion->formoptions = new \stdClass();
|
||||
$fakequestion->formoptions->movecontext = null;
|
||||
$fakequestion->formoptions->repeatelements = true;
|
||||
$fakequestion->inputs = null;
|
||||
|
||||
$form = new $classname(new moodle_url('/'), $fakequestion, $category,
|
||||
new core_question\local\bank\question_edit_contexts($syscontext));
|
||||
$form = new $classname(new \moodle_url('/'), $fakequestion, $category,
|
||||
new \core_question\local\bank\question_edit_contexts($syscontext));
|
||||
|
||||
return [$form, $category];
|
||||
}
|
||||
@@ -76,7 +71,7 @@ class qtype_ddwtos_edit_form_test extends advanced_testcase {
|
||||
public function test_number_of_choice_groups() {
|
||||
list($form) = $this->get_form('qtype_ddwtos_edit_form');
|
||||
// Use reflection to get the protected property we need.
|
||||
$property = new ReflectionProperty('qtype_ddwtos_edit_form', '_form');
|
||||
$property = new \ReflectionProperty('qtype_ddwtos_edit_form', '_form');
|
||||
$property->setAccessible(true);
|
||||
$mform = $property->getValue($form);
|
||||
$choices = $mform->getElement('choices[0]');
|
||||
@@ -14,14 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop words into sentences question definition class.
|
||||
*
|
||||
* @package qtype_ddwtos
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddwtos;
|
||||
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -33,27 +30,28 @@ require_once($CFG->dirroot . '/question/type/ddwtos/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the matching question definition class.
|
||||
*
|
||||
* @package qtype_ddwtos
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddwtos_question_test extends basic_testcase {
|
||||
class question_test extends \basic_testcase {
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$this->assertEquals('The [[1]] brown [[2]] jumped over the [[3]] dog.; ' .
|
||||
'[[1]] -> {quick / slow}; [[2]] -> {fox / dog}; [[3]] -> {lazy / assiduous}',
|
||||
$dd->get_question_summary());
|
||||
}
|
||||
|
||||
public function test_get_question_summary_maths() {
|
||||
$dd = test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddwtos', 'maths');
|
||||
$this->assertEquals('Fill in the operators to make this equation work: ' .
|
||||
'7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3; [[1]] -> {+ / - / * / /}',
|
||||
$dd->get_question_summary());
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -62,7 +60,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response_maths() {
|
||||
$dd = test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -71,17 +69,17 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$this->assertEquals(0.5, $dd->get_random_guess_score());
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score_maths() {
|
||||
$dd = test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddwtos', 'maths');
|
||||
$this->assertEquals(0.25, $dd->get_random_guess_score());
|
||||
}
|
||||
|
||||
public function test_get_right_choice_for() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -90,7 +88,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_right_choice_for_maths() {
|
||||
$dd = test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -99,7 +97,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_clear_wrong_from_response() {
|
||||
$dd = test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -109,7 +107,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_num_parts_right() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -120,7 +118,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_num_parts_right_maths() {
|
||||
$dd = test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -130,7 +128,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_expected_data() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array('p1' => PARAM_INT, 'p2' => PARAM_INT, 'p3' => PARAM_INT),
|
||||
@@ -138,7 +136,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -147,7 +145,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response_maths() {
|
||||
$dd = test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -156,7 +154,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_is_same_response() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertTrue($dd->is_same_response(
|
||||
@@ -180,7 +178,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
array('p1' => '1', 'p2' => '2', 'p3' => '2')));
|
||||
}
|
||||
public function test_is_complete_response() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($dd->is_complete_response(array()));
|
||||
@@ -192,7 +190,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($dd->is_gradable_response(array()));
|
||||
@@ -206,7 +204,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -219,7 +217,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_grading_maths() {
|
||||
$dd = test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd = \test_question_maker::make_question('ddwtos', 'maths');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -232,7 +230,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->shufflechoices = false;
|
||||
$dd->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
|
||||
+20
-21
@@ -14,14 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop words into sentences question definition class.
|
||||
*
|
||||
* @package qtype_ddwtos
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddwtos;
|
||||
|
||||
use question_answer;
|
||||
use question_bank;
|
||||
use question_hint_with_parts;
|
||||
use question_possible_response;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -33,10 +31,11 @@ require_once($CFG->dirroot . '/question/type/ddwtos/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the drag-and-drop words into sentences question definition class.
|
||||
*
|
||||
* @package qtype_ddwtos
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddwtos_test extends question_testcase {
|
||||
class question_type_test extends \question_testcase {
|
||||
/** @var qtype_ddwtos instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
@@ -62,7 +61,7 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
protected function get_test_question_data() {
|
||||
global $USER;
|
||||
|
||||
$dd = new stdClass();
|
||||
$dd = new \stdClass();
|
||||
$dd->id = 0;
|
||||
$dd->category = 0;
|
||||
$dd->contextid = 0;
|
||||
@@ -88,10 +87,10 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
$dd->generalfeedback = 'This sentence uses each letter of the alphabet.';
|
||||
$dd->qtype = 'ddwtos';
|
||||
|
||||
$dd->options = new stdClass();
|
||||
$dd->options = new \stdClass();
|
||||
$dd->options->shuffleanswers = true;
|
||||
|
||||
test_question_maker::set_standard_combined_feedback_fields($dd->options);
|
||||
\test_question_maker::set_standard_combined_feedback_fields($dd->options);
|
||||
|
||||
$dd->options->answers = array(
|
||||
(object) array('answer' => 'quick', 'feedback' =>
|
||||
@@ -122,15 +121,15 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
public function test_save_question() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
/** @var core_question_generator $generator */
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$category = $generator->create_question_category(['contextid' => $syscontext->id]);
|
||||
|
||||
$fromform = test_question_maker::get_question_form_data('ddwtos', 'missingchoiceno');
|
||||
$fromform = \test_question_maker::get_question_form_data('ddwtos', 'missingchoiceno');
|
||||
$fromform->category = $category->id . ',' . $syscontext->id;
|
||||
|
||||
$question = new stdClass();
|
||||
$question = new \stdClass();
|
||||
$question->category = $category->id;
|
||||
$question->qtype = 'ddwtos';
|
||||
$question->createdby = 0;
|
||||
@@ -147,7 +146,7 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
public function test_initialise_question_instance() {
|
||||
$qdata = $this->get_test_question_data();
|
||||
|
||||
$expected = test_question_maker::make_question('ddwtos');
|
||||
$expected = \test_question_maker::make_question('ddwtos');
|
||||
$expected->stamp = $qdata->stamp;
|
||||
$expected->idnumber = null;
|
||||
|
||||
@@ -230,11 +229,11 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
</question>';
|
||||
$xmldata = xmlize($xml);
|
||||
|
||||
$importer = new qformat_xml();
|
||||
$importer = new \qformat_xml();
|
||||
$q = $importer->try_importing_using_qtypes(
|
||||
$xmldata['question'], null, null, 'ddwtos');
|
||||
|
||||
$expectedq = new stdClass();
|
||||
$expectedq = new \stdClass();
|
||||
$expectedq->qtype = 'ddwtos';
|
||||
$expectedq->name = 'A drag-and-drop question';
|
||||
$expectedq->questiontext = 'Put these in order: [[1]], [[2]], [[3]].';
|
||||
@@ -267,12 +266,12 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
$expectedq->hintshownumcorrect = array(true, true);
|
||||
$expectedq->hintclearwrong = array(false, true);
|
||||
|
||||
$this->assert(new question_check_specified_fields_expectation($expectedq), $q);
|
||||
$this->assert(new \question_check_specified_fields_expectation($expectedq), $q);
|
||||
$this->assertEquals($expectedq->hint, $q->hint);
|
||||
}
|
||||
|
||||
public function test_xml_export() {
|
||||
$qdata = new stdClass();
|
||||
$qdata = new \stdClass();
|
||||
$qdata->id = 123;
|
||||
$qdata->contextid = \context_system::instance()->id;
|
||||
$qdata->idnumber = null;
|
||||
@@ -287,7 +286,7 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
$qdata->options = new \stdClass();
|
||||
$qdata->options->shuffleanswers = 1;
|
||||
$qdata->options->correctfeedback = '<p>Your answer is correct.</p>';
|
||||
$qdata->options->correctfeedbackformat = FORMAT_MOODLE;
|
||||
@@ -316,7 +315,7 @@ class qtype_ddwtos_test extends question_testcase {
|
||||
FORMAT_MOODLE, true, true),
|
||||
);
|
||||
|
||||
$exporter = new qformat_xml();
|
||||
$exporter = new \qformat_xml();
|
||||
$xml = $exporter->writequestion($qdata);
|
||||
|
||||
$expectedxml = '<!-- question: 123 -->
|
||||
@@ -14,14 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the drag-and-drop words into sentences question type.
|
||||
*
|
||||
* @package qtype_ddwtos
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_ddwtos;
|
||||
|
||||
use question_display_options;
|
||||
use question_hint_with_parts;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -33,10 +30,11 @@ require_once($CFG->dirroot . '/question/type/ddwtos/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the drag-and-drop words into sentences question type.
|
||||
*
|
||||
* @package qtype_ddwtos
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
protected function get_contains_drop_box_expectation($place, $group, $readonly,
|
||||
$stateclass = '0') {
|
||||
@@ -50,13 +48,13 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
}
|
||||
$expectedattrs['class'] = $class;
|
||||
|
||||
return new question_contains_tag_with_attributes('span', $expectedattrs);
|
||||
return new \question_contains_tag_with_attributes('span', $expectedattrs);
|
||||
}
|
||||
|
||||
public function test_interactive_behaviour() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -166,7 +164,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_deferred_feedback() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
|
||||
|
||||
@@ -249,7 +247,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_deferred_feedback_unanswered() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
|
||||
|
||||
@@ -305,7 +303,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_deferred_feedback_partial_answer() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->shufflechoices = false;
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
|
||||
|
||||
@@ -360,7 +358,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_grading() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(1, 'This is the first hint.',
|
||||
FORMAT_MOODLE, true, true),
|
||||
@@ -516,7 +514,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_correct_no_submit() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(23, 'This is the first hint.',
|
||||
FORMAT_MOODLE, false, false),
|
||||
@@ -572,7 +570,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_partial_no_submit() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(23, 'This is the first hint.',
|
||||
FORMAT_MOODLE, false, false),
|
||||
@@ -628,7 +626,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_no_right_clears() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$dd->hints = array(
|
||||
new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, true),
|
||||
new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
|
||||
@@ -695,7 +693,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_display_of_right_answer_when_shuffled() {
|
||||
|
||||
// Create a drag-and-drop question.
|
||||
$dd = test_question_maker::make_question('ddwtos');
|
||||
$dd = \test_question_maker::make_question('ddwtos');
|
||||
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
|
||||
|
||||
// Check the initial state.
|
||||
@@ -748,7 +746,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
$this->get_contains_drop_box_expectation('2', 2, true, 'correct'),
|
||||
$this->get_contains_drop_box_expectation('3', 3, true, 'correct'),
|
||||
$this->get_contains_correct_expectation(),
|
||||
new question_pattern_expectation('/' .
|
||||
new \question_pattern_expectation('/' .
|
||||
preg_quote('The [quick] brown [fox] jumped over the [lazy] dog.', '/') . '/'));
|
||||
}
|
||||
}
|
||||
|
||||
+8
-11
@@ -14,14 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the description question type class.
|
||||
*
|
||||
* @package qtype_description
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_description;
|
||||
|
||||
use qtype_description;
|
||||
use qtype_description_edit_form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,10 +31,11 @@ require_once($CFG->dirroot . '/question/type/description/edit_description_form.p
|
||||
/**
|
||||
* Unit tests for the description question type class.
|
||||
*
|
||||
* @package qtype_description
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_description_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp(): void {
|
||||
@@ -74,8 +71,8 @@ class qtype_description_test extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
|
||||
$questiondata = test_question_maker::get_question_data('description');
|
||||
$formdata = test_question_maker::get_question_form_data('description');
|
||||
$questiondata = \test_question_maker::get_question_data('description');
|
||||
$formdata = \test_question_maker::get_question_form_data('description');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -83,7 +80,7 @@ class qtype_description_test extends advanced_testcase {
|
||||
$formdata->category = "{$cat->id},{$cat->contextid}";
|
||||
qtype_description_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_description_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_description_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* description questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage description
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_description;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of description question attempts.
|
||||
*
|
||||
* @package qtype_description
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_description_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
|
||||
public function test_description_deferredfeedback_history80() {
|
||||
$quiz = (object) array(
|
||||
@@ -14,15 +14,7 @@
|
||||
// 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 that walks a description question through its interaction model.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage description
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_description;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -30,13 +22,19 @@ global $CFG;
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
|
||||
|
||||
class qtype_description_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
/**
|
||||
* This file contains tests that walks a description question through its interaction model.
|
||||
*
|
||||
* @package qtype_description
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
public function test_informationitem_feedback_description() {
|
||||
|
||||
// Create a description question.
|
||||
$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.
|
||||
@@ -44,7 +42,7 @@ class qtype_description_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->quba->get_question_attempt($this->slot)->get_behaviour_name());
|
||||
|
||||
$this->check_current_output(
|
||||
new question_contains_tag_with_contents('h4', get_string('informationtext', 'qtype_description'))
|
||||
new \question_contains_tag_with_contents('h4', get_string('informationtext', 'qtype_description'))
|
||||
);
|
||||
|
||||
// Further tests of the description qtype are in
|
||||
|
||||
+7
-12
@@ -14,13 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the essay edit form.
|
||||
*
|
||||
* @package qtype_essay
|
||||
* @copyright 2021 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_essay\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -32,10 +26,11 @@ require_once($CFG->dirroot . '/question/type/essay/edit_essay_form.php');
|
||||
/**
|
||||
* Unit tests for the essay edit form.
|
||||
*
|
||||
* @package qtype_essay
|
||||
* @copyright 2021 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_essay_edit_form_test extends advanced_testcase {
|
||||
class edit_form_test extends \advanced_testcase {
|
||||
/**
|
||||
* Helper method.
|
||||
*
|
||||
@@ -50,9 +45,9 @@ class qtype_essay_edit_form_test extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
$category = question_make_default_categories(array($syscontext));
|
||||
$fakequestion = new stdClass();
|
||||
$fakequestion = new \stdClass();
|
||||
$fakequestion->qtype = 'essay';
|
||||
$fakequestion->contextid = $syscontext->id;
|
||||
$fakequestion->createdby = $USER->id;
|
||||
@@ -66,10 +61,10 @@ class qtype_essay_edit_form_test extends advanced_testcase {
|
||||
$fakequestion->filetypeslist = '';
|
||||
|
||||
$form = new $classname(
|
||||
new moodle_url('/'),
|
||||
new \moodle_url('/'),
|
||||
$fakequestion,
|
||||
$category,
|
||||
new core_question\local\bank\question_edit_contexts($syscontext)
|
||||
new \core_question\local\bank\question_edit_contexts($syscontext)
|
||||
);
|
||||
|
||||
return [$form, $category];
|
||||
@@ -14,15 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the essay question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage essay
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_essay;
|
||||
|
||||
use question_attempt_step;
|
||||
use question_display_options;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,12 +28,13 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the matching question definition class.
|
||||
*
|
||||
* @package qtype_essay
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_essay_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
public function test_get_question_summary() {
|
||||
$essay = test_question_maker::make_an_essay_question();
|
||||
$essay = \test_question_maker::make_an_essay_question();
|
||||
$essay->questiontext = 'Hello <img src="http://example.com/globe.png" alt="world" />';
|
||||
$this->assertEquals('Hello [world]', $essay->get_question_summary());
|
||||
}
|
||||
@@ -65,7 +61,7 @@ class qtype_essay_question_test extends advanced_testcase {
|
||||
$attachments = $this->create_user_and_sample_attachments($numberofattachments);
|
||||
|
||||
// Create the essay question under test.
|
||||
$essay = test_question_maker::make_an_essay_question();
|
||||
$essay = \test_question_maker::make_an_essay_question();
|
||||
$essay->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$essay->responseformat = 'editor';
|
||||
@@ -105,7 +101,7 @@ class qtype_essay_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_same_response() {
|
||||
$essay = test_question_maker::make_an_essay_question();
|
||||
$essay = \test_question_maker::make_an_essay_question();
|
||||
|
||||
$essay->responsetemplate = '';
|
||||
|
||||
@@ -149,7 +145,7 @@ class qtype_essay_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_same_response_with_template() {
|
||||
$essay = test_question_maker::make_an_essay_question();
|
||||
$essay = \test_question_maker::make_an_essay_question();
|
||||
|
||||
$essay->responsetemplate = 'Once upon a time';
|
||||
|
||||
@@ -199,7 +195,7 @@ class qtype_essay_question_test extends advanced_testcase {
|
||||
$attachments = $this->create_user_and_sample_attachments();
|
||||
|
||||
// Create the essay question under test.
|
||||
$essay = test_question_maker::make_an_essay_question();
|
||||
$essay = \test_question_maker::make_an_essay_question();
|
||||
$essay->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
// Test the "traditional" case, where we must receive a response from the user.
|
||||
@@ -309,10 +305,10 @@ class qtype_essay_question_test extends advanced_testcase {
|
||||
public function test_get_question_definition_for_external_rendering() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$essay = test_question_maker::make_an_essay_question();
|
||||
$essay = \test_question_maker::make_an_essay_question();
|
||||
$essay->minwordlimit = 15;
|
||||
$essay->start_attempt(new question_attempt_step(), 1);
|
||||
$qa = test_question_maker::get_a_qa($essay);
|
||||
$qa = \test_question_maker::get_a_qa($essay);
|
||||
$displayoptions = new question_display_options();
|
||||
|
||||
$options = $essay->get_question_definition_for_external_rendering($qa, $displayoptions);
|
||||
@@ -343,7 +339,7 @@ class qtype_essay_question_test extends advanced_testcase {
|
||||
*/
|
||||
public function test_get_validation_error(int $responserequired,
|
||||
int $minwordlimit, int $maxwordlimit, string $expected): void {
|
||||
$question = test_question_maker::make_an_essay_question();
|
||||
$question = \test_question_maker::make_an_essay_question();
|
||||
$response = ['answer' => 'One two three four five six seven eight nine ten eleven twelve thirteen fourteen.'];
|
||||
$question->responserequired = $responserequired;
|
||||
$question->minwordlimit = $minwordlimit;
|
||||
@@ -380,7 +376,7 @@ class qtype_essay_question_test extends advanced_testcase {
|
||||
* @param string $expected error message | null
|
||||
*/
|
||||
public function test_get_word_count_message_for_review(?int $minwordlimit, ?int $maxwordlimit, string $expected): void {
|
||||
$question = test_question_maker::make_an_essay_question();
|
||||
$question = \test_question_maker::make_an_essay_question();
|
||||
$question->minwordlimit = $minwordlimit;
|
||||
$question->maxwordlimit = $maxwordlimit;
|
||||
|
||||
@@ -425,7 +421,7 @@ class qtype_essay_question_test extends advanced_testcase {
|
||||
$this->setUser($user);
|
||||
|
||||
// Create sample attachments to use in testing.
|
||||
$helper = test_question_maker::get_test_helper('essay');
|
||||
$helper = \test_question_maker::get_test_helper('essay');
|
||||
$attachments = [];
|
||||
for ($i = 0; $i < ($numberofattachments + 1); ++$i) {
|
||||
$attachments[$i] = $helper->make_attachments_saver($i);
|
||||
|
||||
+5
-10
@@ -14,15 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the essay question type class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage essay
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_essay;
|
||||
|
||||
use qtype_essay;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,10 +27,11 @@ require_once($CFG->dirroot . '/question/type/essay/questiontype.php');
|
||||
/**
|
||||
* Unit tests for the essay question type class.
|
||||
*
|
||||
* @package qtype_essay
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_essay_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp(): void {
|
||||
@@ -48,7 +43,7 @@ class qtype_essay_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
protected function get_test_question_data() {
|
||||
$q = new stdClass();
|
||||
$q = new \stdClass();
|
||||
$q->id = 1;
|
||||
|
||||
return $q;
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* essay questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage essay
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_essay;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of essay question attempts.
|
||||
*
|
||||
* @package qtype_essay
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_essay_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
|
||||
public function test_essay_deferredfeedback_history98220() {
|
||||
$quiz = (object) array(
|
||||
@@ -14,28 +14,25 @@
|
||||
// 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 that walks essay questions through some attempts.
|
||||
*
|
||||
* @package qtype_essay
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_essay;
|
||||
|
||||
use question_bank;
|
||||
use question_engine;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
|
||||
|
||||
/**
|
||||
* Unit tests for the essay question type.
|
||||
*
|
||||
* @package qtype_essay
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
protected function check_contains_textarea($name, $content = '', $height = 10) {
|
||||
$fieldname = $this->quba->get_field_prefix($this->slot) . $name;
|
||||
@@ -62,7 +59,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
protected function save_file_to_draft_area($usercontextid, $draftitemid, $filename, $contents) {
|
||||
$fs = get_file_storage();
|
||||
|
||||
$filerecord = new stdClass();
|
||||
$filerecord = new \stdClass();
|
||||
$filerecord->contextid = $usercontextid;
|
||||
$filerecord->component = 'user';
|
||||
$filerecord->filearea = 'draft';
|
||||
@@ -81,7 +78,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$PAGE->set_url('/');
|
||||
|
||||
// Create an essay question.
|
||||
$q = test_question_maker::make_question('essay', 'editor');
|
||||
$q = \test_question_maker::make_question('essay', 'editor');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
|
||||
|
||||
$prefix = $this->quba->get_field_prefix($this->slot);
|
||||
@@ -133,7 +130,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
public function test_deferred_feedback_plain_text() {
|
||||
|
||||
// Create an essay question.
|
||||
$q = test_question_maker::make_question('essay', 'plain');
|
||||
$q = \test_question_maker::make_question('essay', 'plain');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
|
||||
|
||||
$prefix = $this->quba->get_field_prefix($this->slot);
|
||||
@@ -191,7 +188,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$PAGE->set_url('/');
|
||||
|
||||
// Create an essay question.
|
||||
$q = test_question_maker::make_question('essay', 'responsetemplate');
|
||||
$q = \test_question_maker::make_question('essay', 'responsetemplate');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
|
||||
|
||||
$prefix = $this->quba->get_field_prefix($this->slot);
|
||||
@@ -247,7 +244,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->setAdminUser();
|
||||
// Required to init a text editor.
|
||||
$PAGE->set_url('/');
|
||||
$usercontextid = context_user::instance($USER->id)->id;
|
||||
$usercontextid = \context_user::instance($USER->id)->id;
|
||||
$fs = get_file_storage();
|
||||
|
||||
// Create an essay question in the DB.
|
||||
@@ -267,11 +264,11 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
// First we need to get the draft item ids.
|
||||
$this->render();
|
||||
if (!preg_match('/env=editor&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('Editor draft item id not found.');
|
||||
throw new \coding_exception('Editor draft item id not found.');
|
||||
}
|
||||
$editordraftid = $matches[1];
|
||||
if (!preg_match('/env=filemanager&action=browse&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('File manager draft item id not found.');
|
||||
throw new \coding_exception('File manager draft item id not found.');
|
||||
}
|
||||
$attachementsdraftid = $matches[1];
|
||||
|
||||
@@ -295,11 +292,11 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
|
||||
$this->render();
|
||||
if (!preg_match('/env=editor&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('Editor draft item id not found.');
|
||||
throw new \coding_exception('Editor draft item id not found.');
|
||||
}
|
||||
$editordraftid = $matches[1];
|
||||
if (!preg_match('/env=filemanager&action=browse&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('File manager draft item id not found.');
|
||||
throw new \coding_exception('File manager draft item id not found.');
|
||||
}
|
||||
$attachementsdraftid = $matches[1];
|
||||
|
||||
@@ -328,7 +325,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
|
||||
$q = question_bank::load_question($question->id);
|
||||
$this->quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
$this->quba->set_preferred_behaviour('deferredfeedback');
|
||||
$this->slot = $this->quba->add_question($q, 1);
|
||||
$this->quba->start_question_based_on($this->slot, $oldqa);
|
||||
@@ -343,11 +340,11 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
|
||||
$this->render();
|
||||
if (!preg_match('/env=editor&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('Editor draft item id not found.');
|
||||
throw new \coding_exception('Editor draft item id not found.');
|
||||
}
|
||||
$editordraftid = $matches[1];
|
||||
if (!preg_match('/env=filemanager&action=browse&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('File manager draft item id not found.');
|
||||
throw new \coding_exception('File manager draft item id not found.');
|
||||
}
|
||||
$attachementsdraftid = $matches[1];
|
||||
|
||||
@@ -371,7 +368,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->setAdminUser();
|
||||
// Required to init a text editor.
|
||||
$PAGE->set_url('/');
|
||||
$usercontextid = context_user::instance($USER->id)->id;
|
||||
$usercontextid = \context_user::instance($USER->id)->id;
|
||||
$fs = get_file_storage();
|
||||
|
||||
// Create an essay question in the DB.
|
||||
@@ -391,11 +388,11 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
// First we need to get the draft item ids.
|
||||
$this->render();
|
||||
if (!preg_match('/env=editor&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('Editor draft item id not found.');
|
||||
throw new \coding_exception('Editor draft item id not found.');
|
||||
}
|
||||
$editordraftid = $matches[1];
|
||||
if (!preg_match('/env=filemanager&action=browse&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('File manager draft item id not found.');
|
||||
throw new \coding_exception('File manager draft item id not found.');
|
||||
}
|
||||
$attachementsdraftid = $matches[1];
|
||||
|
||||
@@ -423,7 +420,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
|
||||
$q = question_bank::load_question($question->id);
|
||||
$this->quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
$this->quba->set_preferred_behaviour('deferredfeedback');
|
||||
$this->slot = $this->quba->add_question($q, 1);
|
||||
$this->quba->start_question_based_on($this->slot, $oldqa);
|
||||
@@ -444,7 +441,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
$usercontextid = context_user::instance($USER->id)->id;
|
||||
$usercontextid = \context_user::instance($USER->id)->id;
|
||||
|
||||
// Create an essay question in the DB.
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
@@ -484,7 +481,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
|
||||
$q = question_bank::load_question($question->id);
|
||||
$this->quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
$this->quba->set_preferred_behaviour('deferredfeedback');
|
||||
$this->slot = $this->quba->add_question($q, 1);
|
||||
$this->quba->start_question_based_on($this->slot, $oldqa);
|
||||
@@ -511,7 +508,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->setAdminUser();
|
||||
// Required to init a text editor.
|
||||
$PAGE->set_url('/');
|
||||
$usercontextid = context_user::instance($USER->id)->id;
|
||||
$usercontextid = \context_user::instance($USER->id)->id;
|
||||
$fs = get_file_storage();
|
||||
|
||||
// Create an essay question in the DB.
|
||||
@@ -532,11 +529,11 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
// First we need to get the draft item ids.
|
||||
$this->render();
|
||||
if (!preg_match('/env=editor&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('Editor draft item id not found.');
|
||||
throw new \coding_exception('Editor draft item id not found.');
|
||||
}
|
||||
$editordraftid = $matches[1];
|
||||
if (!preg_match('/env=filemanager&action=browse&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('File manager draft item id not found.');
|
||||
throw new \coding_exception('File manager draft item id not found.');
|
||||
}
|
||||
$attachementsdraftid = $matches[1];
|
||||
|
||||
@@ -570,7 +567,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->setAdminUser();
|
||||
// Required to init a text editor.
|
||||
$PAGE->set_url('/');
|
||||
$usercontextid = context_user::instance($USER->id)->id;
|
||||
$usercontextid = \context_user::instance($USER->id)->id;
|
||||
$fs = get_file_storage();
|
||||
|
||||
// Create an essay question in the DB.
|
||||
@@ -591,11 +588,11 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
// First we need to get the draft item ids.
|
||||
$this->render();
|
||||
if (!preg_match('/env=editor&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('Editor draft item id not found.');
|
||||
throw new \coding_exception('Editor draft item id not found.');
|
||||
}
|
||||
$editordraftid = $matches[1];
|
||||
if (!preg_match('/env=filemanager&action=browse&.*?itemid=(\d+)&/', $this->currentoutput, $matches)) {
|
||||
throw new coding_exception('File manager draft item id not found.');
|
||||
throw new \coding_exception('File manager draft item id not found.');
|
||||
}
|
||||
$attachementsdraftid = $matches[1];
|
||||
|
||||
@@ -632,7 +629,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
|
||||
// Create an essay question.
|
||||
/** @var qtype_essay_question $q */
|
||||
$q = test_question_maker::make_question('essay', 'editor');
|
||||
$q = \test_question_maker::make_question('essay', 'editor');
|
||||
$q->minwordlimit = 3;
|
||||
$q->maxwordlimit = 7;
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
|
||||
|
||||
+13
-11
@@ -22,6 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_gapselect\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -37,7 +38,7 @@ require_once($CFG->dirroot . '/question/type/gapselect/edit_gapselect_form.php')
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_gapselect_edit_form_base_testable extends qtype_gapselect_edit_form_base {
|
||||
class qtype_gapselect_edit_form_base_testable extends \qtype_gapselect_edit_form_base {
|
||||
public function get_illegal_tag_error($text) {
|
||||
return parent::get_illegal_tag_error($text);
|
||||
}
|
||||
@@ -59,10 +60,11 @@ class qtype_gapselect_edit_form_base_testable extends qtype_gapselect_edit_form_
|
||||
/**
|
||||
* Unit tests for select missing words question edit form.
|
||||
*
|
||||
* @package qtype_gapselect
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_gapselect_edit_form_test extends advanced_testcase {
|
||||
class edit_form_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Helper method.
|
||||
@@ -78,34 +80,34 @@ class qtype_gapselect_edit_form_test extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
$category = question_make_default_categories(array($syscontext));
|
||||
$fakequestion = new stdClass();
|
||||
$fakequestion = new \stdClass();
|
||||
$fakequestion->qtype = 'gapselect'; // Does not actually matter if this is wrong.
|
||||
$fakequestion->contextid = $syscontext->id;
|
||||
$fakequestion->createdby = 2;
|
||||
$fakequestion->category = $category->id;
|
||||
$fakequestion->questiontext = 'Test [[1]] question [[2]]';
|
||||
$fakequestion->options = new stdClass();
|
||||
$fakequestion->options = new \stdClass();
|
||||
$fakequestion->options->answers = array();
|
||||
$fakequestion->formoptions = new stdClass();
|
||||
$fakequestion->formoptions = new \stdClass();
|
||||
$fakequestion->formoptions->movecontext = null;
|
||||
$fakequestion->formoptions->repeatelements = true;
|
||||
$fakequestion->inputs = null;
|
||||
|
||||
$form = new $classname(new moodle_url('/'), $fakequestion, $category,
|
||||
new core_question\local\bank\question_edit_contexts($syscontext));
|
||||
$form = new $classname(new \moodle_url('/'), $fakequestion, $category,
|
||||
new \core_question\local\bank\question_edit_contexts($syscontext));
|
||||
|
||||
return [$form, $category];
|
||||
}
|
||||
|
||||
public function test_get_illegal_tag_error() {
|
||||
list($form) = $this->get_form('qtype_gapselect_edit_form_base_testable');
|
||||
list($form) = $this->get_form('\qtype_gapselect\form\qtype_gapselect_edit_form_base_testable');
|
||||
|
||||
$this->assertEquals('', $form->get_illegal_tag_error('frog'));
|
||||
$this->assertEquals('', $form->get_illegal_tag_error('<i>toad</i>'));
|
||||
|
||||
$a = new stdClass();
|
||||
$a = new \stdClass();
|
||||
$a->tag = '<ijk>';
|
||||
$a->allowed = '<sub>, <sup>, <b>, <i>, <em>, <strong>, <span>';
|
||||
$this->assertEquals(get_string('tagsnotallowed', 'qtype_gapselect', $a), $form->get_illegal_tag_error('<ijk>'));
|
||||
@@ -143,7 +145,7 @@ class qtype_gapselect_edit_form_test extends advanced_testcase {
|
||||
public function test_number_of_choice_groups() {
|
||||
list($form) = $this->get_form('qtype_gapselect_edit_form');
|
||||
// Use reflection to get the protected property we need.
|
||||
$property = new ReflectionProperty('qtype_gapselect_edit_form', '_form');
|
||||
$property = new \ReflectionProperty('qtype_gapselect_edit_form', '_form');
|
||||
$property->setAccessible(true);
|
||||
$mform = $property->getValue($form);
|
||||
$choices = $mform->getElement('choices[0]');
|
||||
@@ -14,14 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the select missing words question definition class.
|
||||
*
|
||||
* @package qtype_gapselect
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_gapselect;
|
||||
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_display_options;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -33,27 +31,28 @@ require_once($CFG->dirroot . '/question/type/gapselect/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the select missing words question definition class.
|
||||
*
|
||||
* @package qtype_gapselect
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_gapselect_question_test extends basic_testcase {
|
||||
class question_test extends \basic_testcase {
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$this->assertEquals('The [[1]] brown [[2]] jumped over the [[3]] dog.; ' .
|
||||
'[[1]] -> {quick / slow}; [[2]] -> {fox / dog}; [[3]] -> {lazy / assiduous}',
|
||||
$gapselect->get_question_summary());
|
||||
}
|
||||
|
||||
public function test_get_question_summary_maths() {
|
||||
$gapselect = test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect = \test_question_maker::make_question('gapselect', 'maths');
|
||||
$this->assertEquals('Fill in the operators to make this equation work: ' .
|
||||
'7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3; [[1]] -> {+ / - / * / /}',
|
||||
$gapselect->get_question_summary());
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -62,7 +61,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response_maths() {
|
||||
$gapselect = test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect = \test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -71,17 +70,17 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$this->assertEquals(0.5, $gapselect->get_random_guess_score());
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score_maths() {
|
||||
$gapselect = test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect = \test_question_maker::make_question('gapselect', 'maths');
|
||||
$this->assertEquals(0.25, $gapselect->get_random_guess_score());
|
||||
}
|
||||
|
||||
public function test_get_right_choice_for() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -90,7 +89,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_right_choice_for_maths() {
|
||||
$gapselect = test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect = \test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -99,7 +98,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_clear_wrong_from_response() {
|
||||
$gapselect = test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect = \test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -109,7 +108,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_num_parts_right() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -120,7 +119,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_num_parts_right_maths() {
|
||||
$gapselect = test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect = \test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -129,7 +128,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_expected_data() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array('p1' => PARAM_INT, 'p2' => PARAM_INT, 'p3' => PARAM_INT),
|
||||
@@ -137,7 +136,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -146,7 +145,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response_maths() {
|
||||
$gapselect = test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect = \test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -155,7 +154,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_is_same_response() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertTrue($gapselect->is_same_response(
|
||||
@@ -179,7 +178,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
array('p1' => '1', 'p2' => '2', 'p3' => '2')));
|
||||
}
|
||||
public function test_is_complete_response() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($gapselect->is_complete_response(array()));
|
||||
@@ -191,7 +190,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($gapselect->is_gradable_response(array()));
|
||||
@@ -205,7 +204,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -218,7 +217,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_grading_maths() {
|
||||
$gapselect = test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect = \test_question_maker::make_question('gapselect', 'maths');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -231,7 +230,7 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$gapselect = test_question_maker::make_question('gapselect');
|
||||
$gapselect = \test_question_maker::make_question('gapselect');
|
||||
$gapselect->shufflechoices = false;
|
||||
$gapselect->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -251,9 +250,9 @@ class qtype_gapselect_question_test extends basic_testcase {
|
||||
* test_get_question_definition_for_external_rendering
|
||||
*/
|
||||
public function test_get_question_definition_for_external_rendering() {
|
||||
$question = test_question_maker::make_question('gapselect', 'maths');
|
||||
$question = \test_question_maker::make_question('gapselect', 'maths');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$qa = test_question_maker::get_a_qa($question);
|
||||
$qa = \test_question_maker::get_a_qa($question);
|
||||
$displayoptions = new question_display_options();
|
||||
|
||||
$options = $question->get_question_definition_for_external_rendering($qa, $displayoptions);
|
||||
|
||||
+19
-20
@@ -14,14 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the select missing words question question definition class.
|
||||
*
|
||||
* @package qtype_gapselect
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_gapselect;
|
||||
|
||||
use question_answer;
|
||||
use question_bank;
|
||||
use question_hint_with_parts;
|
||||
use question_possible_response;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -32,10 +30,11 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the select missing words question definition class.
|
||||
*
|
||||
* @package qtype_gapselect
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_gapselect_test extends question_testcase {
|
||||
class question_type_test extends \question_testcase {
|
||||
/** @var qtype_gapselect instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
@@ -61,15 +60,15 @@ class qtype_gapselect_test extends question_testcase {
|
||||
public function test_save_question() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
/** @var core_question_generator $generator */
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$category = $generator->create_question_category(['contextid' => $syscontext->id]);
|
||||
|
||||
$fromform = test_question_maker::get_question_form_data('gapselect', 'missingchoiceno');
|
||||
$fromform = \test_question_maker::get_question_form_data('gapselect', 'missingchoiceno');
|
||||
$fromform->category = $category->id . ',' . $syscontext->id;
|
||||
|
||||
$question = new stdClass();
|
||||
$question = new \stdClass();
|
||||
$question->category = $category->id;
|
||||
$question->qtype = 'gapselect';
|
||||
$question->createdby = 0;
|
||||
@@ -86,10 +85,10 @@ class qtype_gapselect_test extends question_testcase {
|
||||
/**
|
||||
* Get some test question data.
|
||||
* @return object the data to construct a question like
|
||||
* {@link test_question_maker::make_question('gapselect')}.
|
||||
* {@see \test_question_maker::make_question('gapselect')}.
|
||||
*/
|
||||
protected function get_test_question_data() {
|
||||
return test_question_maker::get_question_data('gapselect');
|
||||
return \test_question_maker::get_question_data('gapselect');
|
||||
}
|
||||
|
||||
public function test_name() {
|
||||
@@ -103,7 +102,7 @@ class qtype_gapselect_test extends question_testcase {
|
||||
public function test_initialise_question_instance() {
|
||||
$qdata = $this->get_test_question_data();
|
||||
|
||||
$expected = test_question_maker::make_question('gapselect');
|
||||
$expected = \test_question_maker::make_question('gapselect');
|
||||
$expected->stamp = $qdata->stamp;
|
||||
|
||||
$q = $this->qtype->make_question($qdata);
|
||||
@@ -184,11 +183,11 @@ class qtype_gapselect_test extends question_testcase {
|
||||
</question>';
|
||||
$xmldata = xmlize($xml);
|
||||
|
||||
$importer = new qformat_xml();
|
||||
$importer = new \qformat_xml();
|
||||
$q = $importer->try_importing_using_qtypes(
|
||||
$xmldata['question'], null, null, 'gapselect');
|
||||
|
||||
$expectedq = new stdClass();
|
||||
$expectedq = new \stdClass();
|
||||
$expectedq->qtype = 'gapselect';
|
||||
$expectedq->name = 'A select missing words question';
|
||||
$expectedq->questiontext = 'Put these in order: [[1]], [[2]], [[3]].';
|
||||
@@ -220,12 +219,12 @@ class qtype_gapselect_test extends question_testcase {
|
||||
'format' => FORMAT_MOODLE));
|
||||
$expectedq->hintshownumcorrect = array(true, true);
|
||||
$expectedq->hintclearwrong = array(false, true);
|
||||
$this->assert(new question_check_specified_fields_expectation($expectedq), $q);
|
||||
$this->assert(new \question_check_specified_fields_expectation($expectedq), $q);
|
||||
$this->assertEquals($expectedq->hint, $q->hint);
|
||||
}
|
||||
|
||||
public function test_xml_export() {
|
||||
$qdata = new stdClass();
|
||||
$qdata = new \stdClass();
|
||||
$qdata->id = 123;
|
||||
$qdata->contextid = \context_system::instance()->id;
|
||||
$qdata->idnumber = null;
|
||||
@@ -240,7 +239,7 @@ class qtype_gapselect_test extends question_testcase {
|
||||
$qdata->penalty = 0.3333333;
|
||||
$qdata->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
|
||||
|
||||
$qdata->options = new stdClass();
|
||||
$qdata->options = new \stdClass();
|
||||
$qdata->options->shuffleanswers = 1;
|
||||
$qdata->options->correctfeedback = '<p>Your answer is correct.</p>';
|
||||
$qdata->options->correctfeedbackformat = FORMAT_MOODLE;
|
||||
@@ -263,7 +262,7 @@ class qtype_gapselect_test extends question_testcase {
|
||||
FORMAT_MOODLE, true, true),
|
||||
);
|
||||
|
||||
$exporter = new qformat_xml();
|
||||
$exporter = new \qformat_xml();
|
||||
$xml = $exporter->writequestion($qdata);
|
||||
|
||||
$expectedxml = '<!-- question: 123 -->
|
||||
@@ -14,14 +14,10 @@
|
||||
// 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 that simulate a user attempt a gapselect question.
|
||||
*
|
||||
* @package qtype_gapselect
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_gapselect;
|
||||
|
||||
use question_hint_with_parts;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -33,14 +29,15 @@ require_once($CFG->dirroot . '/question/type/gapselect/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the gap-select question type.
|
||||
*
|
||||
* @package qtype_gapselect
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_behaviour() {
|
||||
|
||||
// Create a gapselect question.
|
||||
$q = test_question_maker::make_question('gapselect');
|
||||
$q = \test_question_maker::make_question('gapselect');
|
||||
$q->hints = array(
|
||||
new question_hint_with_parts(1, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(2, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -156,11 +153,11 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
// Enable multilang filter to on content and heading.
|
||||
filter_set_global_state('multilang', TEXTFILTER_ON);
|
||||
filter_set_applies_to_strings('multilang', 1);
|
||||
$filtermanager = filter_manager::instance();
|
||||
$filtermanager = \filter_manager::instance();
|
||||
$filtermanager->reset_caches();
|
||||
|
||||
// Create a multilang gapselect question.
|
||||
$q = test_question_maker::make_question('gapselect', 'multilang');
|
||||
$q = \test_question_maker::make_question('gapselect', 'multilang');
|
||||
$q->shufflechoices = false;
|
||||
$this->start_attempt_at_question($q, 'interactive', 3);
|
||||
|
||||
@@ -177,7 +174,7 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
public function test_choices_containing_dollars() {
|
||||
|
||||
// Choices with a currency like entry (e.g. $3) should display.
|
||||
$q = test_question_maker::make_question('gapselect', 'currency');
|
||||
$q = \test_question_maker::make_question('gapselect', 'currency');
|
||||
$q->shufflechoices = false;
|
||||
$this->start_attempt_at_question($q, 'interactive', 1);
|
||||
|
||||
|
||||
@@ -14,14 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the matching question definition classes.
|
||||
*
|
||||
* @package qtype_match
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_match;
|
||||
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_display_options;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -32,13 +30,14 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the matching question definition class.
|
||||
*
|
||||
* @package qtype_match
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_match_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
|
||||
public function test_get_expected_data() {
|
||||
$question = test_question_maker::make_question('match');
|
||||
$question = \test_question_maker::make_question('match');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array('sub0' => PARAM_INT, 'sub1' => PARAM_INT,
|
||||
@@ -46,7 +45,7 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_complete_response() {
|
||||
$question = test_question_maker::make_question('match');
|
||||
$question = \test_question_maker::make_question('match');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($question->is_complete_response(array()));
|
||||
@@ -58,7 +57,7 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$question = test_question_maker::make_question('match');
|
||||
$question = \test_question_maker::make_question('match');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($question->is_gradable_response(array()));
|
||||
@@ -72,7 +71,7 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_same_response() {
|
||||
$question = test_question_maker::make_question('match');
|
||||
$question = \test_question_maker::make_question('match');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertTrue($question->is_same_response(
|
||||
@@ -97,7 +96,7 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$question = test_question_maker::make_question('match');
|
||||
$question = \test_question_maker::make_question('match');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$correctresponse = $question->prepare_simulated_post_data(
|
||||
@@ -126,7 +125,7 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$question = test_question_maker::make_question('match');
|
||||
$question = \test_question_maker::make_question('match');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$correct = $question->prepare_simulated_post_data(array('Dog' => 'Mammal',
|
||||
@@ -137,7 +136,7 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$match = test_question_maker::make_question('match');
|
||||
$match = \test_question_maker::make_question('match');
|
||||
$match->start_attempt(new question_attempt_step(), 1);
|
||||
$qsummary = $match->get_question_summary();
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($match->questiontext, '/') . '/', $qsummary);
|
||||
@@ -150,7 +149,7 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$match = test_question_maker::make_question('match');
|
||||
$match = \test_question_maker::make_question('match');
|
||||
$match->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$summary = $match->summarise_response($match->prepare_simulated_post_data(array('Dog' => 'Amphibian', 'Frog' => 'Mammal')));
|
||||
@@ -160,7 +159,7 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$match = test_question_maker::make_question('match');
|
||||
$match = \test_question_maker::make_question('match');
|
||||
$match->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$response = $match->prepare_simulated_post_data(array('Dog' => 'Amphibian', 'Frog' => 'Insect', 'Toad' => '', 'Cat' => ''));
|
||||
@@ -182,14 +181,14 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response_choice_deleted_after_attempt() {
|
||||
$match = test_question_maker::make_question('match');
|
||||
$match = \test_question_maker::make_question('match');
|
||||
$firststep = new question_attempt_step();
|
||||
|
||||
$match->start_attempt($firststep, 1);
|
||||
$response = $match->prepare_simulated_post_data(array(
|
||||
'Dog' => 'Amphibian', 'Frog' => 'Insect', 'Toad' => '', 'Cat' => 'Mammal'));
|
||||
|
||||
$match = test_question_maker::make_question('match');
|
||||
$match = \test_question_maker::make_question('match');
|
||||
unset($match->stems[4]);
|
||||
unset($match->stemsformat[4]);
|
||||
unset($match->right[4]);
|
||||
@@ -203,14 +202,14 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response_choice_added_after_attempt() {
|
||||
$match = test_question_maker::make_question('match');
|
||||
$match = \test_question_maker::make_question('match');
|
||||
$firststep = new question_attempt_step();
|
||||
|
||||
$match->start_attempt($firststep, 1);
|
||||
$response = $match->prepare_simulated_post_data(array(
|
||||
'Dog' => 'Amphibian', 'Frog' => 'Insect', 'Toad' => '', 'Cat' => 'Mammal'));
|
||||
|
||||
$match = test_question_maker::make_question('match');
|
||||
$match = \test_question_maker::make_question('match');
|
||||
$match->stems[5] = "Snake";
|
||||
$match->stemsformat[5] = FORMAT_HTML;
|
||||
$match->choices[5] = "Reptile";
|
||||
@@ -226,7 +225,7 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_prepare_simulated_post_data() {
|
||||
$m = test_question_maker::make_question('match');
|
||||
$m = \test_question_maker::make_question('match');
|
||||
$m->start_attempt(new question_attempt_step(), 1);
|
||||
$postdata = $m->prepare_simulated_post_data(array('Dog' => 'Mammal', 'Frog' => 'Amphibian',
|
||||
'Toad' => 'Amphibian', 'Cat' => 'Mammal'));
|
||||
@@ -237,9 +236,9 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
* test_get_question_definition_for_external_rendering
|
||||
*/
|
||||
public function test_get_question_definition_for_external_rendering() {
|
||||
$question = test_question_maker::make_question('match');
|
||||
$question = \test_question_maker::make_question('match');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$qa = test_question_maker::get_a_qa($question);
|
||||
$qa = \test_question_maker::get_a_qa($question);
|
||||
$displayoptions = new question_display_options();
|
||||
|
||||
$options = $question->get_question_definition_for_external_rendering($qa, $displayoptions);
|
||||
|
||||
+14
-15
@@ -14,14 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the matching question definition class.
|
||||
*
|
||||
* @package qtype_match
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_match;
|
||||
|
||||
use qtype_match;
|
||||
use qtype_match_edit_form;
|
||||
use question_bank;
|
||||
use question_possible_response;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,10 +33,11 @@ require_once($CFG->dirroot . '/question/type/match/edit_match_form.php');
|
||||
/**
|
||||
* Unit tests for the matching question definition class.
|
||||
*
|
||||
* @package qtype_match
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_match_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
/** @var qtype_match instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
@@ -52,7 +51,7 @@ class qtype_match_test extends advanced_testcase {
|
||||
|
||||
protected function get_test_question_data() {
|
||||
global $USER;
|
||||
$q = new stdClass();
|
||||
$q = new \stdClass();
|
||||
$q->id = 0;
|
||||
$q->name = 'Matching question';
|
||||
$q->category = 0;
|
||||
@@ -76,9 +75,9 @@ class qtype_match_test extends advanced_testcase {
|
||||
$q->createdby = $USER->id;
|
||||
$q->modifiedby = $USER->id;
|
||||
|
||||
$q->options = new stdClass();
|
||||
$q->options = new \stdClass();
|
||||
$q->options->shuffleanswers = false;
|
||||
test_question_maker::set_standard_combined_feedback_fields($q->options);
|
||||
\test_question_maker::set_standard_combined_feedback_fields($q->options);
|
||||
|
||||
$q->options->subquestions = array(
|
||||
14 => (object) array(
|
||||
@@ -115,7 +114,7 @@ class qtype_match_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_make_question_instance() {
|
||||
$questiondata = test_question_maker::get_question_data('match', 'trickynums');
|
||||
$questiondata = \test_question_maker::get_question_data('match', 'trickynums');
|
||||
$question = question_bank::make_question($questiondata);
|
||||
$this->assertEquals($questiondata->name, $question->name);
|
||||
$this->assertEquals($questiondata->questiontext, $question->questiontext);
|
||||
@@ -166,8 +165,8 @@ class qtype_match_test extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
|
||||
$questiondata = test_question_maker::get_question_data('match');
|
||||
$formdata = test_question_maker::get_question_form_data('match');
|
||||
$questiondata = \test_question_maker::get_question_data('match');
|
||||
$formdata = \test_question_maker::get_question_form_data('match');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -176,7 +175,7 @@ class qtype_match_test extends advanced_testcase {
|
||||
|
||||
qtype_match_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_match_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_match_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
$fromform = $form->get_data();
|
||||
+3
-10
@@ -14,15 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* match questions.
|
||||
*
|
||||
* @package qtype_match
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_match;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of match question attempts.
|
||||
*
|
||||
* @package qtype_match
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_match_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
|
||||
public function test_match_deferredfeedback_history6220() {
|
||||
$quiz = (object) array(
|
||||
@@ -14,15 +14,10 @@
|
||||
// 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 that walks a question through the interactive
|
||||
* behaviour.
|
||||
*
|
||||
* @package qtype_match
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_match;
|
||||
|
||||
use question_hint_with_parts;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,15 +28,16 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the matching question type.
|
||||
*
|
||||
* @package qtype_match
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
public function test_deferred_feedback_unanswered() {
|
||||
|
||||
// Create a matching question.
|
||||
$m = test_question_maker::make_question('match');
|
||||
$m = \test_question_maker::make_question('match');
|
||||
$m->shufflestems = false;
|
||||
$this->start_attempt_at_question($m, 'deferredfeedback', 4);
|
||||
|
||||
@@ -98,7 +94,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_deferred_feedback_partial_answer() {
|
||||
|
||||
// Create a matching question.
|
||||
$m = test_question_maker::make_question('match');
|
||||
$m = \test_question_maker::make_question('match');
|
||||
$m->shufflestems = false;
|
||||
$this->start_attempt_at_question($m, 'deferredfeedback', 4);
|
||||
|
||||
@@ -155,7 +151,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_correct_no_submit() {
|
||||
|
||||
// Create a matching question.
|
||||
$m = test_question_maker::make_question('match');
|
||||
$m = \test_question_maker::make_question('match');
|
||||
$m->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -209,7 +205,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_partial_no_submit() {
|
||||
|
||||
// Create a matching question.
|
||||
$m = test_question_maker::make_question('match');
|
||||
$m = \test_question_maker::make_question('match');
|
||||
$m->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -263,7 +259,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_with_invalid() {
|
||||
|
||||
// Create a matching question.
|
||||
$m = test_question_maker::make_question('match');
|
||||
$m = \test_question_maker::make_question('match');
|
||||
$m->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -333,7 +329,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
public function test_match_with_tricky_html_choices() {
|
||||
|
||||
// Create a matching question.
|
||||
$m = test_question_maker::make_question('match');
|
||||
$m = \test_question_maker::make_question('match');
|
||||
$m->stems = array(
|
||||
1 => '(1, 2]',
|
||||
2 => '[1, 2]',
|
||||
@@ -380,14 +376,14 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
|
||||
$this->displayoptions->history = 1;
|
||||
$this->check_current_output(
|
||||
new question_pattern_expectation('/' .
|
||||
new \question_pattern_expectation('/' .
|
||||
preg_quote(htmlspecialchars($rightresponsesummary), '/') . '/'));
|
||||
}
|
||||
|
||||
public function test_match_clear_wrong() {
|
||||
|
||||
// Create a matching question.
|
||||
$m = test_question_maker::make_question('match');
|
||||
$m = \test_question_maker::make_question('match');
|
||||
$m->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, true),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
|
||||
@@ -14,15 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace qtype_multianswer;
|
||||
|
||||
/**
|
||||
* Unit tests for the multianswer question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage multianswer
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
use question_attempt_step;
|
||||
use question_display_options;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
@@ -31,18 +29,19 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for qtype_multianswer_question.
|
||||
*
|
||||
* @package qtype_multianswer
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_multianswer_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
public function test_get_expected_data() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
$this->assertEquals(array('sub1_answer' => PARAM_RAW_TRIMMED,
|
||||
'sub2_answer' => PARAM_RAW), $question->get_expected_data());
|
||||
}
|
||||
|
||||
public function test_is_complete_response() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
|
||||
$this->assertFalse($question->is_complete_response(array()));
|
||||
$this->assertTrue($question->is_complete_response(array('sub1_answer' => 'Owl',
|
||||
@@ -53,7 +52,7 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
|
||||
$this->assertFalse($question->is_gradable_response(array()));
|
||||
$this->assertTrue($question->is_gradable_response(array('sub1_answer' => 'Owl',
|
||||
@@ -64,7 +63,7 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$rightchoice = $question->subquestions[2]->get_correct_response();
|
||||
@@ -80,7 +79,7 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$rightchoice = $question->subquestions[2]->get_correct_response();
|
||||
@@ -90,7 +89,7 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
|
||||
// Bit of a hack to make testing easier.
|
||||
$question->subquestions[2]->shuffleanswers = false;
|
||||
@@ -103,7 +102,7 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$rightchoice = $question->subquestions[2]->get_correct_response();
|
||||
@@ -116,7 +115,7 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_num_parts_right() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$rightchoice = $question->subquestions[2]->get_correct_response();
|
||||
@@ -145,7 +144,7 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
|
||||
public function test_get_num_parts_right_fourmc() {
|
||||
// Create a multianswer question with four mcq.
|
||||
$question = test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$question = \test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$response = array('sub1_answer' => '1', 'sub2_answer' => '1',
|
||||
@@ -155,7 +154,7 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_clear_wrong_from_response() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$rightchoice = $question->subquestions[2]->get_correct_response();
|
||||
@@ -179,7 +178,7 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_compute_final_grade() {
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
// Set penalty to 0.2 to ease calculations.
|
||||
$question->penalty = 0.2;
|
||||
// Set subquestion 2 defaultmark to 2, to make it a better test,
|
||||
@@ -245,9 +244,9 @@ class qtype_multianswer_question_test extends advanced_testcase {
|
||||
public function test_get_question_definition_for_external_rendering() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$question = test_question_maker::make_question('multianswer');
|
||||
$question = \test_question_maker::make_question('multianswer');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$qa = test_question_maker::get_a_qa($question);
|
||||
$qa = \test_question_maker::get_a_qa($question);
|
||||
$displayoptions = new question_display_options();
|
||||
|
||||
$options = $question->get_question_definition_for_external_rendering($qa, $displayoptions);
|
||||
|
||||
+17
-19
@@ -14,15 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the multianswer question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage multianswer
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_multianswer;
|
||||
|
||||
use qtype_multianswer;
|
||||
use qtype_multianswer_edit_form;
|
||||
use qtype_multichoice_base;
|
||||
use question_bank;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -36,10 +33,11 @@ require_once($CFG->dirroot . '/question/type/multianswer/edit_multianswer_form.p
|
||||
/**
|
||||
* Unit tests for the multianswer question definition class.
|
||||
*
|
||||
* @package qtype_multianswer
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_multianswer_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
/** @var qtype_multianswer instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
@@ -53,7 +51,7 @@ class qtype_multianswer_test extends advanced_testcase {
|
||||
|
||||
protected function get_test_question_data() {
|
||||
global $USER;
|
||||
$q = new stdClass();
|
||||
$q = new \stdClass();
|
||||
$q->id = 0;
|
||||
$q->name = 'Simple multianswer';
|
||||
$q->category = 0;
|
||||
@@ -78,7 +76,7 @@ class qtype_multianswer_test extends advanced_testcase {
|
||||
$q->createdby = $USER->id;
|
||||
$q->modifiedby = $USER->id;
|
||||
|
||||
$sadata = new stdClass();
|
||||
$sadata = new \stdClass();
|
||||
$sadata->id = 1;
|
||||
$sadata->qtype = 'shortanswer';
|
||||
$sadata->defaultmark = 1;
|
||||
@@ -87,7 +85,7 @@ class qtype_multianswer_test extends advanced_testcase {
|
||||
$sadata->options->answers[2] = (object) array('answer' => 'Wiggly worm', 'fraction' => 0);
|
||||
$sadata->options->answers[3] = (object) array('answer' => 'Pussy-cat', 'fraction' => 1);
|
||||
|
||||
$mcdata = new stdClass();
|
||||
$mcdata = new \stdClass();
|
||||
$mcdata->id = 1;
|
||||
$mcdata->qtype = 'multichoice';
|
||||
$mcdata->defaultmark = 1;
|
||||
@@ -113,22 +111,22 @@ class qtype_multianswer_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score() {
|
||||
$q = test_question_maker::get_question_data('multianswer', 'twosubq');
|
||||
$q = \test_question_maker::get_question_data('multianswer', 'twosubq');
|
||||
$this->assertEqualsWithDelta(0.1666667, $this->qtype->get_random_guess_score($q), 0.0000001);
|
||||
}
|
||||
|
||||
public function test_load_question() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
/** @var core_question_generator $generator */
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$category = $generator->create_question_category(['contextid' => $syscontext->id]);
|
||||
|
||||
$fromform = test_question_maker::get_question_form_data('multianswer');
|
||||
$fromform = \test_question_maker::get_question_form_data('multianswer');
|
||||
$fromform->category = $category->id . ',' . $syscontext->id;
|
||||
|
||||
$question = new stdClass();
|
||||
$question = new \stdClass();
|
||||
$question->category = $category->id;
|
||||
$question->qtype = 'multianswer';
|
||||
$question->createdby = 0;
|
||||
@@ -239,9 +237,9 @@ class qtype_multianswer_test extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
|
||||
$questiondata = test_question_maker::get_question_data('multianswer');
|
||||
$questiondata = \test_question_maker::get_question_data('multianswer');
|
||||
|
||||
$formdata = test_question_maker::get_question_form_data('multianswer');
|
||||
$formdata = \test_question_maker::get_question_form_data('multianswer');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -249,7 +247,7 @@ class qtype_multianswer_test extends advanced_testcase {
|
||||
$formdata->category = "{$cat->id},{$cat->contextid}";
|
||||
qtype_multianswer_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_multianswer_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_multianswer_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* multianswer questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage multianswer
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_multianswer;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of multianswer question attempts.
|
||||
*
|
||||
* @package qtype_multianswer
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_multianswer_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
public function test_multianswer_adaptivenopenalty_qsession104() {
|
||||
$quiz = (object) array(
|
||||
'id' => '5',
|
||||
@@ -14,15 +14,11 @@
|
||||
// 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 overall tests of multianswer questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage multianswer
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_multianswer;
|
||||
|
||||
use question_display_options;
|
||||
use question_hint_with_parts;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,20 +29,21 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the multianswer question type.
|
||||
*
|
||||
* @package qtype_multianswer
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
protected function get_contains_subq_status(question_state $state) {
|
||||
return new question_pattern_expectation('~' .
|
||||
return new \question_pattern_expectation('~' .
|
||||
preg_quote($state->default_string(true), '~') . '<br />~');
|
||||
}
|
||||
|
||||
public function test_deferred_feedback() {
|
||||
|
||||
// Create a multianswer question.
|
||||
$q = test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$q = \test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 4);
|
||||
|
||||
// Check the initial state.
|
||||
@@ -97,7 +94,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
// Tests the situation found in MDL-35370.
|
||||
|
||||
// Create a multianswer question with one numerical subquestion, right answer zero.
|
||||
$q = test_question_maker::make_question('multianswer', 'numericalzero');
|
||||
$q = \test_question_maker::make_question('multianswer', 'numericalzero');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
|
||||
|
||||
// Check the initial state.
|
||||
@@ -116,7 +113,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_mark(null);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
new question_pattern_expectation('~<input[^>]* class="[^"]*incorrect[^"]*" [^>]*/>~'),
|
||||
new \question_pattern_expectation('~<input[^>]* class="[^"]*incorrect[^"]*" [^>]*/>~'),
|
||||
$this->get_contains_subq_status(question_state::$gaveup),
|
||||
$this->get_does_not_contain_validation_error_expectation());
|
||||
}
|
||||
@@ -125,7 +122,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
// Tests the situation found in MDL-35370.
|
||||
|
||||
// Create a multianswer question with one numerical subquestion, right answer zero.
|
||||
$q = test_question_maker::make_question('multianswer', 'numericalzero');
|
||||
$q = \test_question_maker::make_question('multianswer', 'numericalzero');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
|
||||
|
||||
// Check the initial state.
|
||||
@@ -164,7 +161,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
// Tests the situation found in MDL-35370.
|
||||
|
||||
// Create a multianswer question with one numerical subquestion, right answer zero.
|
||||
$q = test_question_maker::make_question('multianswer', 'numericalzero');
|
||||
$q = \test_question_maker::make_question('multianswer', 'numericalzero');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
|
||||
|
||||
// Check the initial state.
|
||||
@@ -202,7 +199,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
public function test_interactive_feedback() {
|
||||
|
||||
// Create a multianswer question.
|
||||
$q = test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$q = \test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$q->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, true),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -330,7 +327,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
public function test_interactive_partial_response_does_not_reveal_answer() {
|
||||
|
||||
// Create a multianswer question.
|
||||
$q = test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$q = \test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$q->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, true),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -388,7 +385,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
public function test_interactivecountback_feedback() {
|
||||
|
||||
// Create a multianswer question.
|
||||
$q = test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$q = \test_question_maker::make_question('multianswer', 'fourmc');
|
||||
$q->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, true, true),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -426,7 +423,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$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->check_output_contains_selectoptions(
|
||||
$this->get_contains_select_expectation('sub1_answer', $choices, 1, false),
|
||||
@@ -469,7 +466,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->get_does_not_contain_submit_button_expectation(),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_contains_correct_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('sub1_answer', $choices, '0', false),
|
||||
$this->get_contains_select_expectation('sub2_answer', $choices, '1', false),
|
||||
@@ -480,7 +477,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
public function test_deferred_feedback_multiple() {
|
||||
|
||||
// Create a multianswer question.
|
||||
$q = test_question_maker::make_question('multianswer', 'multiple');
|
||||
$q = \test_question_maker::make_question('multianswer', 'multiple');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 2);
|
||||
|
||||
// Check the initial state.
|
||||
|
||||
+17
-19
@@ -14,14 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the mulitple choice question definition class.
|
||||
*
|
||||
* @package qtype_multichoice
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_multichoice;
|
||||
|
||||
use qtype_multichoice;
|
||||
use qtype_multichoice_edit_form;
|
||||
use question_possible_response;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +31,11 @@ require_once($CFG->dirroot . '/question/type/multichoice/edit_multichoice_form.p
|
||||
/**
|
||||
* Unit tests for the multiple choice question definition class.
|
||||
*
|
||||
* @package qtype_multichoice
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_multichoice_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp(): void {
|
||||
@@ -53,9 +51,9 @@ class qtype_multichoice_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
protected function get_test_question_data() {
|
||||
$q = new stdClass();
|
||||
$q = new \stdClass();
|
||||
$q->id = 1;
|
||||
$q->options = new stdClass();
|
||||
$q->options = new \stdClass();
|
||||
$q->options->single = true;
|
||||
$q->options->answers[1] = (object) array('answer' => 'frog',
|
||||
'answerformat' => FORMAT_HTML, 'fraction' => 1);
|
||||
@@ -113,8 +111,8 @@ class qtype_multichoice_test extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
|
||||
$questiondata = test_question_maker::get_question_data('multichoice', $which);
|
||||
$formdata = test_question_maker::get_question_form_data('multichoice', $which);
|
||||
$questiondata = \test_question_maker::get_question_data('multichoice', $which);
|
||||
$formdata = \test_question_maker::get_question_form_data('multichoice', $which);
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -122,7 +120,7 @@ class qtype_multichoice_test extends advanced_testcase {
|
||||
$formdata->category = "{$cat->id},{$cat->contextid}";
|
||||
qtype_multichoice_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_multichoice_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_multichoice_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
@@ -175,8 +173,8 @@ class qtype_multichoice_test extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a complete, in DB question to use.
|
||||
$questiondata = test_question_maker::get_question_data('multichoice', 'two_of_four');
|
||||
$formdata = test_question_maker::get_question_form_data('multichoice', 'two_of_four');
|
||||
$questiondata = \test_question_maker::get_question_data('multichoice', 'two_of_four');
|
||||
$formdata = \test_question_maker::get_question_form_data('multichoice', 'two_of_four');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -184,7 +182,7 @@ class qtype_multichoice_test extends advanced_testcase {
|
||||
$formdata->category = "{$cat->id},{$cat->contextid}";
|
||||
qtype_multichoice_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_multichoice_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_multichoice_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
@@ -198,7 +196,7 @@ class qtype_multichoice_test extends advanced_testcase {
|
||||
// Load it.
|
||||
$this->qtype->get_question_options($question);
|
||||
$this->assertDebuggingNotCalled();
|
||||
$this->assertInstanceOf(stdClass::class, $question->options);
|
||||
$this->assertInstanceOf(\stdClass::class, $question->options);
|
||||
|
||||
$options = $question->options;
|
||||
$this->assertEquals($question->id, $options->questionid);
|
||||
@@ -214,7 +212,7 @@ class qtype_multichoice_test extends advanced_testcase {
|
||||
$this->qtype->get_question_options($question);
|
||||
|
||||
$this->assertDebuggingCalled('Question ID '.$question->id.' was missing an options record. Using default.');
|
||||
$this->assertInstanceOf(stdClass::class, $question->options);
|
||||
$this->assertInstanceOf(\stdClass::class, $question->options);
|
||||
$options = $question->options;
|
||||
$this->assertEquals($question->id, $options->questionid);
|
||||
$this->assertCount(4, $options->answers);
|
||||
@@ -232,7 +230,7 @@ class qtype_multichoice_test extends advanced_testcase {
|
||||
$this->qtype->get_question_options($question);
|
||||
|
||||
$this->assertDebuggingCalled('Question ID '.$question->id.' was missing an options record. Using default.');
|
||||
$this->assertInstanceOf(stdClass::class, $question->options);
|
||||
$this->assertInstanceOf(\stdClass::class, $question->options);
|
||||
$options = $question->options;
|
||||
$this->assertEquals($question->id, $options->questionid);
|
||||
$this->assertCount(0, $options->answers);
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* multichoice questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage multichoice
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_multichoice;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of multichoice question attempts.
|
||||
*
|
||||
* @package qtype_multichoice
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_multichoice_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
|
||||
public function test_multichoice_deferredfeedback_history960() {
|
||||
$quiz = (object) array(
|
||||
@@ -14,19 +14,9 @@
|
||||
// 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 that walk mutichoice questions through various behaviours.
|
||||
*
|
||||
* Note, there are already lots of tests of the multichoice type in the behaviour
|
||||
* tests. (Search for test_question_maker::make_a_multichoice.) This file only
|
||||
* contains a few additional tests for problems that were found during testing.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage multichoice
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_multichoice;
|
||||
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -38,14 +28,19 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the mutiple choice question type.
|
||||
*
|
||||
* Note, there are already lots of tests of the multichoice type in the behaviour
|
||||
* tests. (Search for \test_question_maker::make_a_multichoice.) This file only
|
||||
* contains a few additional tests for problems that were found during testing.
|
||||
*
|
||||
* @package qtype_multichoice
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
public function test_deferredfeedback_feedback_multichoice_single() {
|
||||
|
||||
// Create a multichoice, single question.
|
||||
$mc = test_question_maker::make_a_multichoice_single_question();
|
||||
$mc = \test_question_maker::make_a_multichoice_single_question();
|
||||
$mc->shuffleanswers = false;
|
||||
$mc->answers[14]->fraction = 0.1; // Make one of the choices partially right.
|
||||
$rightindex = 0;
|
||||
@@ -72,14 +67,14 @@ class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_output(
|
||||
$this->get_contains_mc_radio_expectation($rightindex, false, true),
|
||||
$this->get_contains_correct_expectation(),
|
||||
new question_pattern_expectation('/class="r0 correct"/'),
|
||||
new question_pattern_expectation('/class="r1"/'));
|
||||
new \question_pattern_expectation('/class="r0 correct"/'),
|
||||
new \question_pattern_expectation('/class="r1"/'));
|
||||
}
|
||||
|
||||
public function test_deferredfeedback_feedback_multichoice_single_showstandardunstruction_yes() {
|
||||
|
||||
// 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;
|
||||
|
||||
$this->start_attempt_at_question($mc, 'deferredfeedback', 3);
|
||||
@@ -93,7 +88,7 @@ class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
public function test_deferredfeedback_feedback_multichoice_single_showstandardunstruction_no() {
|
||||
|
||||
// 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 = false;
|
||||
|
||||
$this->start_attempt_at_question($mc, 'deferredfeedback', 3);
|
||||
@@ -106,7 +101,7 @@ class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
|
||||
public function test_deferredfeedback_feedback_multichoice_multi() {
|
||||
// Create a multichoice, multi question.
|
||||
$mc = test_question_maker::make_a_multichoice_multi_question();
|
||||
$mc = \test_question_maker::make_a_multichoice_multi_question();
|
||||
$mc->shuffleanswers = false;
|
||||
|
||||
$this->start_attempt_at_question($mc, 'deferredfeedback', 2);
|
||||
@@ -122,8 +117,8 @@ class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->get_contains_mc_checkbox_expectation('choice2', false, true),
|
||||
$this->get_contains_mc_checkbox_expectation('choice3', false, false),
|
||||
$this->get_contains_correct_expectation(),
|
||||
new question_pattern_expectation('/class="r0 correct"/'),
|
||||
new question_pattern_expectation('/class="r1"/'));
|
||||
new \question_pattern_expectation('/class="r0 correct"/'),
|
||||
new \question_pattern_expectation('/class="r1"/'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +127,7 @@ class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
public function test_deferredfeedback_feedback_multichoice_clearchoice() {
|
||||
|
||||
// Create a multichoice, single question.
|
||||
$mc = test_question_maker::make_a_multichoice_single_question();
|
||||
$mc = \test_question_maker::make_a_multichoice_single_question();
|
||||
$mc->shuffleanswers = false;
|
||||
|
||||
$clearchoice = -1;
|
||||
@@ -191,14 +186,14 @@ class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->check_current_output(
|
||||
$this->get_contains_mc_radio_expectation($rightchoice, false, true),
|
||||
$this->get_contains_correct_expectation(),
|
||||
new question_pattern_expectation('/class="r0 correct"/'),
|
||||
new question_pattern_expectation('/class="r1"/'));
|
||||
new \question_pattern_expectation('/class="r0 correct"/'),
|
||||
new \question_pattern_expectation('/class="r1"/'));
|
||||
}
|
||||
|
||||
public function test_deferredfeedback_feedback_multichoice_multi_showstandardunstruction_yes() {
|
||||
|
||||
// Create a multichoice, multi question.
|
||||
$mc = test_question_maker::make_a_multichoice_multi_question();
|
||||
$mc = \test_question_maker::make_a_multichoice_multi_question();
|
||||
$mc->showstandardinstruction = true;
|
||||
|
||||
$this->start_attempt_at_question($mc, 'deferredfeedback', 3);
|
||||
@@ -212,7 +207,7 @@ class qtype_multichoice_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
public function test_deferredfeedback_feedback_multichoice_multi_showstandardunstruction_no() {
|
||||
|
||||
// Create a multichoice, multi question.
|
||||
$mc = test_question_maker::make_a_multichoice_multi_question();
|
||||
$mc = \test_question_maker::make_a_multichoice_multi_question();
|
||||
$mc->showstandardinstruction = false;
|
||||
|
||||
$this->start_attempt_at_question($mc, 'deferredfeedback', 3);
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace qtype_numerical;
|
||||
|
||||
/**
|
||||
* Unit tests for the numerical question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage numerical
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
use qtype_numerical;
|
||||
use qtype_numerical_answer_processor;
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_display_options;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
@@ -32,12 +32,13 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the numerical question definition class.
|
||||
*
|
||||
* @package qtype_numerical
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_numerical_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
public function test_is_complete_response() {
|
||||
$question = test_question_maker::make_question('numerical');
|
||||
$question = \test_question_maker::make_question('numerical');
|
||||
|
||||
$this->assertFalse($question->is_complete_response(array()));
|
||||
$this->assertTrue($question->is_complete_response(array('answer' => '0')));
|
||||
@@ -46,7 +47,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$question = test_question_maker::make_question('numerical');
|
||||
$question = \test_question_maker::make_question('numerical');
|
||||
|
||||
$this->assertFalse($question->is_gradable_response(array()));
|
||||
$this->assertTrue($question->is_gradable_response(array('answer' => '0')));
|
||||
@@ -55,7 +56,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$question = test_question_maker::make_question('numerical');
|
||||
$question = \test_question_maker::make_question('numerical');
|
||||
|
||||
$this->assertEquals(array(0, question_state::$gradedwrong),
|
||||
$question->grade_response(array('answer' => '1.0')));
|
||||
@@ -64,7 +65,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading_with_units() {
|
||||
$question = test_question_maker::make_question('numerical');
|
||||
$question = \test_question_maker::make_question('numerical');
|
||||
$question->unitgradingtype = qtype_numerical::UNITOPTIONAL;
|
||||
$question->ap = new qtype_numerical_answer_processor(
|
||||
array('m' => 1, 'cm' => 100), false, '.', ',');
|
||||
@@ -82,7 +83,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading_with_units_graded() {
|
||||
$question = test_question_maker::make_question('numerical');
|
||||
$question = \test_question_maker::make_question('numerical');
|
||||
$question->unitgradingtype = qtype_numerical::UNITGRADED;
|
||||
$question->ap = new qtype_numerical_answer_processor(
|
||||
array('m' => 1, 'cm' => 100), false, '.', ',');
|
||||
@@ -104,7 +105,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading_unit() {
|
||||
$question = test_question_maker::make_question('numerical', 'unit');
|
||||
$question = \test_question_maker::make_question('numerical', 'unit');
|
||||
|
||||
$this->assertEquals(array(0, question_state::$gradedwrong),
|
||||
$question->grade_response(array('answer' => '2', 'unit' => 'm')));
|
||||
@@ -129,7 +130,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading_currency() {
|
||||
$question = test_question_maker::make_question('numerical', 'currency');
|
||||
$question = \test_question_maker::make_question('numerical', 'currency');
|
||||
|
||||
$this->assertEquals(array(1, question_state::$gradedright),
|
||||
$question->grade_response(array('answer' => '$1332')));
|
||||
@@ -150,51 +151,51 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$question = test_question_maker::make_question('numerical');
|
||||
$question = \test_question_maker::make_question('numerical');
|
||||
|
||||
$this->assertEquals(array('answer' => '3.14'),
|
||||
$question->get_correct_response());
|
||||
}
|
||||
|
||||
public function test_get_correct_response_units() {
|
||||
$question = test_question_maker::make_question('numerical', 'unit');
|
||||
$question = \test_question_maker::make_question('numerical', 'unit');
|
||||
|
||||
$this->assertEquals(array('answer' => '1.25', 'unit' => 'm'),
|
||||
$question->get_correct_response());
|
||||
}
|
||||
|
||||
public function test_get_correct_response_currency() {
|
||||
$question = test_question_maker::make_question('numerical', 'currency');
|
||||
$question = \test_question_maker::make_question('numerical', 'currency');
|
||||
|
||||
$this->assertEquals(array('answer' => '$ 1332'),
|
||||
$question->get_correct_response());
|
||||
}
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$num = test_question_maker::make_question('numerical');
|
||||
$num = \test_question_maker::make_question('numerical');
|
||||
$qsummary = $num->get_question_summary();
|
||||
$this->assertEquals('What is pi to two d.p.?', $qsummary);
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$num = test_question_maker::make_question('numerical');
|
||||
$num = \test_question_maker::make_question('numerical');
|
||||
$this->assertEquals('3.1', $num->summarise_response(array('answer' => '3.1')));
|
||||
}
|
||||
|
||||
public function test_summarise_response_zero() {
|
||||
$num = test_question_maker::make_question('numerical');
|
||||
$num = \test_question_maker::make_question('numerical');
|
||||
$this->assertEquals('0', $num->summarise_response(array('answer' => '0')));
|
||||
}
|
||||
|
||||
public function test_summarise_response_unit() {
|
||||
$num = test_question_maker::make_question('numerical', 'unit');
|
||||
$num = \test_question_maker::make_question('numerical', 'unit');
|
||||
$this->assertEquals('3.1', $num->summarise_response(array('answer' => '3.1')));
|
||||
$this->assertEquals('3.1m', $num->summarise_response(array('answer' => '3.1m')));
|
||||
$this->assertEquals('3.1 cm', $num->summarise_response(array('answer' => '3.1 cm')));
|
||||
}
|
||||
|
||||
public function test_summarise_response_currency() {
|
||||
$num = test_question_maker::make_question('numerical', 'currency');
|
||||
$num = \test_question_maker::make_question('numerical', 'currency');
|
||||
$this->assertEquals('100', $num->summarise_response(array('answer' => '100')));
|
||||
$this->assertEquals('$100', $num->summarise_response(array('answer' => '$100')));
|
||||
$this->assertEquals('$ 100', $num->summarise_response(array('answer' => '$ 100')));
|
||||
@@ -202,7 +203,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$num = test_question_maker::make_question('numerical');
|
||||
$num = \test_question_maker::make_question('numerical');
|
||||
$num->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array(
|
||||
@@ -221,7 +222,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response_no_star() {
|
||||
$num = test_question_maker::make_question('numerical');
|
||||
$num = \test_question_maker::make_question('numerical');
|
||||
unset($num->answers[17]);
|
||||
$num->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -238,7 +239,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response_unit() {
|
||||
$num = test_question_maker::make_question('numerical', 'unit');
|
||||
$num = \test_question_maker::make_question('numerical', 'unit');
|
||||
$num->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array(
|
||||
@@ -269,7 +270,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response_unit_no_star() {
|
||||
$num = test_question_maker::make_question('numerical', 'unit');
|
||||
$num = \test_question_maker::make_question('numerical', 'unit');
|
||||
unset($num->answers[17]);
|
||||
$num->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
@@ -292,7 +293,7 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response_currency() {
|
||||
$num = test_question_maker::make_question('numerical', 'currency');
|
||||
$num = \test_question_maker::make_question('numerical', 'currency');
|
||||
$num->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array(
|
||||
@@ -313,9 +314,9 @@ class qtype_numerical_question_test extends advanced_testcase {
|
||||
public function test_get_question_definition_for_external_rendering() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$question = test_question_maker::make_question('numerical', 'unit');
|
||||
$question = \test_question_maker::make_question('numerical', 'unit');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$qa = test_question_maker::get_a_qa($question);
|
||||
$qa = \test_question_maker::get_a_qa($question);
|
||||
$displayoptions = new question_display_options();
|
||||
|
||||
$options = $question->get_question_definition_for_external_rendering($qa, $displayoptions);
|
||||
|
||||
+11
-14
@@ -14,15 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for (some of) question/type/numerical/questiontype.php.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage numerical
|
||||
* @copyright 2006 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_numerical;
|
||||
|
||||
use qtype_numerical;
|
||||
use qtype_numerical_edit_form;
|
||||
use question_possible_response;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,13 +31,14 @@ require_once($CFG->dirroot . '/question/type/numerical/edit_numerical_form.php')
|
||||
/**
|
||||
* Unit tests for question/type/numerical/questiontype.php.
|
||||
*
|
||||
* @package qtype_numerical
|
||||
* @copyright 2006 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
* @covers \question_type
|
||||
* @covers \qtype_numerical
|
||||
*/
|
||||
class qtype_numerical_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
protected $tolerance = 0.00000001;
|
||||
protected $qtype;
|
||||
|
||||
@@ -54,9 +51,9 @@ class qtype_numerical_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
protected function get_test_question_data() {
|
||||
$q = new stdClass;
|
||||
$q = new \stdClass;
|
||||
$q->id = 1;
|
||||
$q->options = new stdClass();
|
||||
$q->options = new \stdClass();
|
||||
$q->options->unitpenalty = 0;
|
||||
$q->options->answers[13] = (object) array(
|
||||
'id' => 13,
|
||||
@@ -126,8 +123,8 @@ class qtype_numerical_test extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
|
||||
$questiondata = test_question_maker::get_question_data('numerical');
|
||||
$formdata = test_question_maker::get_question_form_data('numerical');
|
||||
$questiondata = \test_question_maker::get_question_data('numerical');
|
||||
$formdata = \test_question_maker::get_question_form_data('numerical');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -135,7 +132,7 @@ class qtype_numerical_test extends advanced_testcase {
|
||||
$formdata->category = "{$cat->id},{$cat->contextid}";
|
||||
qtype_numerical_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_numerical_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_numerical_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* numerical questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage numerical
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_numerical;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of numerical question attempts.
|
||||
*
|
||||
* @package qtype_numerical
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_numerical_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
|
||||
public function test_numerical_deferredfeedback_history620() {
|
||||
$quiz = (object) array(
|
||||
@@ -14,15 +14,10 @@
|
||||
// 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 overall tests of numerical questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage numerical
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_numerical;
|
||||
|
||||
use question_hint;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,14 +29,15 @@ require_once($CFG->dirroot . '/question/type/numerical/tests/helper.php');
|
||||
/**
|
||||
* Unit tests for the numerical question type.
|
||||
*
|
||||
* @package qtype_numerical
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
public function test_interactive_currency() {
|
||||
|
||||
// Create a gapselect question.
|
||||
$q = test_question_maker::make_question('numerical', 'currency');
|
||||
$q = \test_question_maker::make_question('numerical', 'currency');
|
||||
$q->hints = array(
|
||||
new question_hint(1, 'This is the first hint.', FORMAT_HTML),
|
||||
new question_hint(2, 'This is the second hint.', FORMAT_HTML),
|
||||
@@ -84,7 +80,7 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_submit_button_expectation(true),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_contains_validation_error_expectation(),
|
||||
new question_pattern_expectation('/' .
|
||||
new \question_pattern_expectation('/' .
|
||||
preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
@@ -108,7 +104,7 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
public function test_deferredfeedback_currency() {
|
||||
|
||||
// Create a gapselect question.
|
||||
$q = test_question_maker::make_question('numerical', 'currency');
|
||||
$q = \test_question_maker::make_question('numerical', 'currency');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 3);
|
||||
|
||||
// Check the initial state.
|
||||
@@ -144,7 +140,7 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_contains_validation_error_expectation(),
|
||||
new question_pattern_expectation('/' .
|
||||
new \question_pattern_expectation('/' .
|
||||
preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
@@ -182,7 +178,7 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
public function test_deferredfeedback_unit() {
|
||||
|
||||
// Create a gapselect question.
|
||||
$q = test_question_maker::make_question('numerical', 'unit');
|
||||
$q = \test_question_maker::make_question('numerical', 'unit');
|
||||
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
|
||||
|
||||
$unitchoices = array(
|
||||
@@ -227,7 +223,7 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_contains_validation_error_expectation(),
|
||||
new question_pattern_expectation('/' .
|
||||
new \question_pattern_expectation('/' .
|
||||
preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
@@ -243,7 +239,7 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_marked_out_of_summary(),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
$this->get_contains_validation_error_expectation(),
|
||||
new question_pattern_expectation('/' .
|
||||
new \question_pattern_expectation('/' .
|
||||
preg_quote(get_string('unitnotselected', 'qtype_numerical'), '/') . '/'),
|
||||
$this->get_does_not_contain_try_again_button_expectation(),
|
||||
$this->get_no_hint_visible_expectation());
|
||||
|
||||
+8
-12
@@ -14,15 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the random question type class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage random
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_random;
|
||||
|
||||
use qtype_random;
|
||||
use question_bank;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +29,11 @@ require_once($CFG->dirroot . '/question/type/random/questiontype.php');
|
||||
/**
|
||||
* Unit tests for the random question type class.
|
||||
*
|
||||
* @package qtype_random
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_random_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp(): void {
|
||||
@@ -63,15 +59,15 @@ class qtype_random_test extends advanced_testcase {
|
||||
public function test_load_question() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
/** @var core_question_generator $generator */
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$category = $generator->create_question_category(['contextid' => $syscontext->id]);
|
||||
|
||||
$fromform = test_question_maker::get_question_form_data('random');
|
||||
$fromform = \test_question_maker::get_question_form_data('random');
|
||||
$fromform->category = $category->id . ',' . $syscontext->id;
|
||||
|
||||
$question = new stdClass();
|
||||
$question = new \stdClass();
|
||||
$question->category = $category->id;
|
||||
$question->qtype = 'random';
|
||||
$question->createdby = 0;
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* random questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage random
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_random;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of random question attempts.
|
||||
*
|
||||
* @package qtype_random
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_random_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
|
||||
public function test_random_deferredfeedback_history620() {
|
||||
$quiz = (object) array(
|
||||
@@ -14,14 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the radom shortanswer matching question definition classes.
|
||||
*
|
||||
* @package qtype_randomsamatch
|
||||
* @copyright 2013 Jean-Michel Vedrine
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_randomsamatch;
|
||||
|
||||
use question_attempt_step;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -32,13 +28,14 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the random shortanswer matching question definition class.
|
||||
*
|
||||
* @package qtype_randomsamatch
|
||||
* @copyright 2013 Jean-Michel Vedrine
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
|
||||
public function test_get_expected_data() {
|
||||
$question = test_question_maker::make_question('randomsamatch');
|
||||
$question = \test_question_maker::make_question('randomsamatch');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array('sub0' => PARAM_INT, 'sub1' => PARAM_INT,
|
||||
@@ -46,7 +43,7 @@ class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_complete_response() {
|
||||
$question = test_question_maker::make_question('randomsamatch');
|
||||
$question = \test_question_maker::make_question('randomsamatch');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($question->is_complete_response(array()));
|
||||
@@ -58,7 +55,7 @@ class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$question = test_question_maker::make_question('randomsamatch');
|
||||
$question = \test_question_maker::make_question('randomsamatch');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertFalse($question->is_gradable_response(array()));
|
||||
@@ -72,7 +69,7 @@ class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_same_response() {
|
||||
$question = test_question_maker::make_question('randomsamatch');
|
||||
$question = \test_question_maker::make_question('randomsamatch');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertTrue($question->is_same_response(
|
||||
@@ -97,7 +94,7 @@ class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$question = test_question_maker::make_question('randomsamatch');
|
||||
$question = \test_question_maker::make_question('randomsamatch');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$choiceorder = $question->get_choice_order();
|
||||
@@ -115,7 +112,7 @@ class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$question = test_question_maker::make_question('randomsamatch');
|
||||
$question = \test_question_maker::make_question('randomsamatch');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$choiceorder = $question->get_choice_order();
|
||||
@@ -127,7 +124,7 @@ class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$question = test_question_maker::make_question('randomsamatch');
|
||||
$question = \test_question_maker::make_question('randomsamatch');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$qsummary = $question->get_question_summary();
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($question->questiontext, '/') . '/', $qsummary);
|
||||
@@ -140,7 +137,7 @@ class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$question = test_question_maker::make_question('randomsamatch');
|
||||
$question = \test_question_maker::make_question('randomsamatch');
|
||||
$question->shufflestems = false;
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
|
||||
+4
-11
@@ -14,15 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* randomsamatch questions.
|
||||
*
|
||||
* @package qtype_randomsamatch
|
||||
* @copyright 2013 Jean-Michel Vedrine
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_randomsamatch;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of randomsamatch question attempts.
|
||||
*
|
||||
* @package qtype_randomsamatch
|
||||
* @copyright 2013 Jean-Michel Vedrine
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_randomsamatch_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
public function test_randomsamatch_deferredfeedback_qsession1() {
|
||||
$quiz = (object) array(
|
||||
'id' => '1',
|
||||
@@ -403,4 +396,4 @@ class qtype_randomsamatch_attempt_upgrader_test extends question_attempt_upgrade
|
||||
|
||||
$this->compare_qas($expectedqa, $qa);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,15 +14,10 @@
|
||||
// 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 that walks a question through the interactive
|
||||
* behaviour.
|
||||
*
|
||||
* @package qtype_randomsamatch
|
||||
* @copyright 2013 Jean-Michel Vedrine
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_randomsamatch;
|
||||
|
||||
use question_hint_with_parts;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,15 +28,16 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the randomsamatch question type.
|
||||
*
|
||||
* @package qtype_randomsamatch
|
||||
* @copyright 2013 Jean-Michel Vedrine
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
|
||||
public function test_deferred_feedback_unanswered() {
|
||||
|
||||
// Create a randomsamatch question.
|
||||
$m = test_question_maker::make_question('randomsamatch');
|
||||
$m = \test_question_maker::make_question('randomsamatch');
|
||||
$this->start_attempt_at_question($m, 'deferredfeedback', 4);
|
||||
|
||||
$choiceorder = $m->get_choice_order();
|
||||
@@ -97,7 +93,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_deferred_feedback_partial_answer() {
|
||||
|
||||
// Create a randomsamatching question.
|
||||
$m = test_question_maker::make_question('randomsamatch');
|
||||
$m = \test_question_maker::make_question('randomsamatch');
|
||||
$m->shufflestems = false;
|
||||
$this->start_attempt_at_question($m, 'deferredfeedback', 4);
|
||||
|
||||
@@ -154,7 +150,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_interactive_correct_no_submit() {
|
||||
|
||||
// Create a randomsamatching question.
|
||||
$m = test_question_maker::make_question('randomsamatch');
|
||||
$m = \test_question_maker::make_question('randomsamatch');
|
||||
$m->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -208,7 +204,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_interactive_partial_no_submit() {
|
||||
|
||||
// Create a randomsamatching question.
|
||||
$m = test_question_maker::make_question('randomsamatch');
|
||||
$m = \test_question_maker::make_question('randomsamatch');
|
||||
$m->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -262,7 +258,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_interactive_with_invalid() {
|
||||
|
||||
// Create a randomsamatching question.
|
||||
$m = test_question_maker::make_question('randomsamatch');
|
||||
$m = \test_question_maker::make_question('randomsamatch');
|
||||
$m->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, false),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
@@ -332,7 +328,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
public function test_randomsamatch_clear_wrong() {
|
||||
|
||||
// Create a randomsamatching question.
|
||||
$m = test_question_maker::make_question('randomsamatch');
|
||||
$m = \test_question_maker::make_question('randomsamatch');
|
||||
$m->hints = array(
|
||||
new question_hint_with_parts(11, 'This is the first hint.', FORMAT_HTML, false, true),
|
||||
new question_hint_with_parts(12, 'This is the second hint.', FORMAT_HTML, true, true),
|
||||
|
||||
@@ -14,15 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the short answer question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage shortanswer
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_shortanswer;
|
||||
|
||||
use qtype_shortanswer_question;
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_display_options;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +32,11 @@ require_once($CFG->dirroot . '/question/type/shortanswer/question.php');
|
||||
/**
|
||||
* Unit tests for the short answer question definition class.
|
||||
*
|
||||
* @package qtype_shortanswer
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_shortanswer_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
public function test_compare_string_with_wildcard() {
|
||||
// Test case sensitive literal matches.
|
||||
$this->assertTrue((bool)qtype_shortanswer_question::compare_string_with_wildcard(
|
||||
@@ -139,7 +138,7 @@ class qtype_shortanswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_complete_response() {
|
||||
$question = test_question_maker::make_question('shortanswer');
|
||||
$question = \test_question_maker::make_question('shortanswer');
|
||||
|
||||
$this->assertFalse($question->is_complete_response(array()));
|
||||
$this->assertFalse($question->is_complete_response(array('answer' => '')));
|
||||
@@ -149,7 +148,7 @@ class qtype_shortanswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$question = test_question_maker::make_question('shortanswer');
|
||||
$question = \test_question_maker::make_question('shortanswer');
|
||||
|
||||
$this->assertFalse($question->is_gradable_response(array()));
|
||||
$this->assertFalse($question->is_gradable_response(array('answer' => '')));
|
||||
@@ -159,7 +158,7 @@ class qtype_shortanswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$question = test_question_maker::make_question('shortanswer');
|
||||
$question = \test_question_maker::make_question('shortanswer');
|
||||
|
||||
$this->assertEquals(array(0, question_state::$gradedwrong),
|
||||
$question->grade_response(array('answer' => 'x')));
|
||||
@@ -170,32 +169,32 @@ class qtype_shortanswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$question = test_question_maker::make_question('shortanswer');
|
||||
$question = \test_question_maker::make_question('shortanswer');
|
||||
|
||||
$this->assertEquals(array('answer' => 'frog'),
|
||||
$question->get_correct_response());
|
||||
}
|
||||
|
||||
public function test_get_correct_response_escapedwildcards() {
|
||||
$question = test_question_maker::make_question('shortanswer', 'escapedwildcards');
|
||||
$question = \test_question_maker::make_question('shortanswer', 'escapedwildcards');
|
||||
|
||||
$this->assertEquals(array('answer' => 'x*y'), $question->get_correct_response());
|
||||
}
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$sa = test_question_maker::make_question('shortanswer');
|
||||
$sa = \test_question_maker::make_question('shortanswer');
|
||||
$qsummary = $sa->get_question_summary();
|
||||
$this->assertEquals('Name an amphibian: __________', $qsummary);
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$sa = test_question_maker::make_question('shortanswer');
|
||||
$sa = \test_question_maker::make_question('shortanswer');
|
||||
$summary = $sa->summarise_response(array('answer' => 'dog'));
|
||||
$this->assertEquals('dog', $summary);
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$sa = test_question_maker::make_question('shortanswer');
|
||||
$sa = \test_question_maker::make_question('shortanswer');
|
||||
$sa->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array(
|
||||
@@ -213,7 +212,7 @@ class qtype_shortanswer_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response_no_star() {
|
||||
$sa = test_question_maker::make_question('shortanswer', 'frogonly');
|
||||
$sa = \test_question_maker::make_question('shortanswer', 'frogonly');
|
||||
$sa->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array(
|
||||
@@ -233,9 +232,9 @@ class qtype_shortanswer_question_test extends advanced_testcase {
|
||||
public function test_get_question_definition_for_external_rendering() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$question = test_question_maker::make_question('shortanswer');
|
||||
$question = \test_question_maker::make_question('shortanswer');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$qa = test_question_maker::get_a_qa($question);
|
||||
$qa = \test_question_maker::get_a_qa($question);
|
||||
$displayoptions = new question_display_options();
|
||||
|
||||
$options = $question->get_question_definition_for_external_rendering($qa, $displayoptions);
|
||||
|
||||
+16
-18
@@ -14,14 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the shortanswer question type class.
|
||||
*
|
||||
* @package qtype_shortanswer
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_shortanswer;
|
||||
|
||||
use qtype_shortanswer;
|
||||
use qtype_shortanswer_edit_form;
|
||||
use question_possible_response;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,13 +31,14 @@ require_once($CFG->dirroot . '/question/type/shortanswer/edit_shortanswer_form.p
|
||||
/**
|
||||
* Unit tests for the shortanswer question type class.
|
||||
*
|
||||
* @package qtype_shortanswer
|
||||
* @copyright 2007 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
* @covers \question_type
|
||||
* @covers \qtype_shortanswer
|
||||
*/
|
||||
class qtype_shortanswer_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp(): void {
|
||||
@@ -52,7 +50,7 @@ class qtype_shortanswer_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
protected function get_test_question_data() {
|
||||
return test_question_maker::get_question_data('shortanswer');
|
||||
return \test_question_maker::get_question_data('shortanswer');
|
||||
}
|
||||
|
||||
public function test_name() {
|
||||
@@ -64,13 +62,13 @@ class qtype_shortanswer_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_random_guess_score() {
|
||||
$q = test_question_maker::get_question_data('shortanswer');
|
||||
$q = \test_question_maker::get_question_data('shortanswer');
|
||||
$q->options->answers[15]->fraction = 0.1;
|
||||
$this->assertEquals(0.1, $this->qtype->get_random_guess_score($q));
|
||||
}
|
||||
|
||||
public function test_get_possible_responses() {
|
||||
$q = test_question_maker::get_question_data('shortanswer');
|
||||
$q = \test_question_maker::get_question_data('shortanswer');
|
||||
|
||||
$this->assertEquals(array(
|
||||
$q->id => array(
|
||||
@@ -83,7 +81,7 @@ class qtype_shortanswer_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_possible_responses_no_star() {
|
||||
$q = test_question_maker::get_question_data('shortanswer', 'frogonly');
|
||||
$q = \test_question_maker::get_question_data('shortanswer', 'frogonly');
|
||||
|
||||
$this->assertEquals(array(
|
||||
$q->id => array(
|
||||
@@ -98,8 +96,8 @@ class qtype_shortanswer_test extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
|
||||
$questiondata = test_question_maker::get_question_data('shortanswer');
|
||||
$formdata = test_question_maker::get_question_form_data('shortanswer');
|
||||
$questiondata = \test_question_maker::get_question_data('shortanswer');
|
||||
$formdata = \test_question_maker::get_question_form_data('shortanswer');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -107,7 +105,7 @@ class qtype_shortanswer_test extends advanced_testcase {
|
||||
$formdata->category = "{$cat->id},{$cat->contextid}";
|
||||
qtype_shortanswer_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_shortanswer_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_shortanswer_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
@@ -146,8 +144,8 @@ class qtype_shortanswer_test extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
|
||||
$questiondata = test_question_maker::get_question_data('shortanswer');
|
||||
$formdata = test_question_maker::get_question_form_data('shortanswer');
|
||||
$questiondata = \test_question_maker::get_question_data('shortanswer');
|
||||
$formdata = \test_question_maker::get_question_form_data('shortanswer');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -156,7 +154,7 @@ class qtype_shortanswer_test extends advanced_testcase {
|
||||
$formdata->answer[0] = ' frog ';
|
||||
qtype_shortanswer_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_shortanswer_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_shortanswer_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* truefalse questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage shortanswer
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_shortanswer;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of shortanswer question attempts.
|
||||
*
|
||||
* @package qtype_shortanswer
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_shortanswer_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
|
||||
public function test_shortanswer_deferredfeedback_history620() {
|
||||
$quiz = (object) array(
|
||||
+4
-9
@@ -14,15 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the question type base class.
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage questiontypes
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core_question;
|
||||
|
||||
use question_bank;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,12 +27,13 @@ require_once($CFG->dirroot . '/question/type/questiontypebase.php');
|
||||
/**
|
||||
* Tests for some of ../questionbase.php
|
||||
*
|
||||
* @package core_question
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
* @covers \question_type
|
||||
*/
|
||||
class question_type_testcase extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
public function test_save_question_name() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
@@ -14,15 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the true-false question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage truefalse
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_truefalse;
|
||||
|
||||
use question_attempt_step;
|
||||
use question_classified_response;
|
||||
use question_display_options;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,12 +30,13 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Unit tests for the true-false question definition class.
|
||||
*
|
||||
* @package qtype_truefalse
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_truefalse_question_test extends advanced_testcase {
|
||||
class question_test extends \advanced_testcase {
|
||||
public function test_is_complete_response() {
|
||||
$question = test_question_maker::make_question('truefalse', 'true');
|
||||
$question = \test_question_maker::make_question('truefalse', 'true');
|
||||
|
||||
$this->assertFalse($question->is_complete_response(array()));
|
||||
$this->assertTrue($question->is_complete_response(array('answer' => 0)));
|
||||
@@ -46,7 +44,7 @@ class qtype_truefalse_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_is_gradable_response() {
|
||||
$question = test_question_maker::make_question('truefalse', 'true');
|
||||
$question = \test_question_maker::make_question('truefalse', 'true');
|
||||
|
||||
$this->assertFalse($question->is_gradable_response(array()));
|
||||
$this->assertTrue($question->is_gradable_response(array('answer' => 0)));
|
||||
@@ -54,7 +52,7 @@ class qtype_truefalse_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_grading() {
|
||||
$question = test_question_maker::make_question('truefalse', 'true');
|
||||
$question = \test_question_maker::make_question('truefalse', 'true');
|
||||
|
||||
$this->assertEquals(array(0, question_state::$gradedwrong),
|
||||
$question->grade_response(array('answer' => 0)));
|
||||
@@ -63,7 +61,7 @@ class qtype_truefalse_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_correct_response() {
|
||||
$question = test_question_maker::make_question('truefalse', 'true');
|
||||
$question = \test_question_maker::make_question('truefalse', 'true');
|
||||
|
||||
// True.
|
||||
$this->assertSame(array('answer' => 1),
|
||||
@@ -76,13 +74,13 @@ class qtype_truefalse_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_question_summary() {
|
||||
$tf = test_question_maker::make_question('truefalse', 'true');
|
||||
$tf = \test_question_maker::make_question('truefalse', 'true');
|
||||
$qsummary = $tf->get_question_summary();
|
||||
$this->assertEquals('The answer is true.', $qsummary);
|
||||
}
|
||||
|
||||
public function test_summarise_response() {
|
||||
$tf = test_question_maker::make_question('truefalse', 'true');
|
||||
$tf = \test_question_maker::make_question('truefalse', 'true');
|
||||
|
||||
$this->assertEquals(get_string('false', 'qtype_truefalse'),
|
||||
$tf->summarise_response(array('answer' => '0')));
|
||||
@@ -92,7 +90,7 @@ class qtype_truefalse_question_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
$tf = test_question_maker::make_question('truefalse', 'true');
|
||||
$tf = \test_question_maker::make_question('truefalse', 'true');
|
||||
$tf->start_attempt(new question_attempt_step(), 1);
|
||||
|
||||
$this->assertEquals(array(
|
||||
@@ -114,9 +112,9 @@ class qtype_truefalse_question_test extends advanced_testcase {
|
||||
public function test_get_question_definition_for_external_rendering() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$question = test_question_maker::make_question('truefalse', 'true');
|
||||
$question = \test_question_maker::make_question('truefalse', 'true');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$qa = test_question_maker::get_a_qa($question);
|
||||
$qa = \test_question_maker::get_a_qa($question);
|
||||
$displayoptions = new question_display_options();
|
||||
|
||||
$options = $question->get_question_definition_for_external_rendering($qa, $displayoptions);
|
||||
|
||||
+15
-17
@@ -14,15 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for the true-false question definition class.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage truefalse
|
||||
* @copyright 2007 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_truefalse;
|
||||
|
||||
use qtype_truefalse;
|
||||
use qtype_truefalse_edit_form;
|
||||
use question_bank;
|
||||
use question_possible_response;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,10 +32,11 @@ require_once($CFG->dirroot . '/question/type/truefalse/edit_truefalse_form.php')
|
||||
/**
|
||||
* Unit tests for the true-false question definition class.
|
||||
*
|
||||
* @package qtype_truefalse
|
||||
* @copyright 2007 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_truefalse_test extends advanced_testcase {
|
||||
class question_type_test extends \advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp(): void {
|
||||
@@ -64,15 +62,15 @@ class qtype_truefalse_test extends advanced_testcase {
|
||||
public function test_load_question() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = \context_system::instance();
|
||||
/** @var core_question_generator $generator */
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$category = $generator->create_question_category(['contextid' => $syscontext->id]);
|
||||
|
||||
$fromform = test_question_maker::get_question_form_data('truefalse');
|
||||
$fromform = \test_question_maker::get_question_form_data('truefalse');
|
||||
$fromform->category = $category->id . ',' . $syscontext->id;
|
||||
|
||||
$question = new stdClass();
|
||||
$question = new \stdClass();
|
||||
$question->category = $category->id;
|
||||
$question->qtype = 'truefalse';
|
||||
$question->createdby = 0;
|
||||
@@ -120,9 +118,9 @@ class qtype_truefalse_test extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_get_possible_responses() {
|
||||
$q = new stdClass();
|
||||
$q = new \stdClass();
|
||||
$q->id = 1;
|
||||
$q->options = new stdClass();
|
||||
$q->options = new \stdClass();
|
||||
$q->options->trueanswer = 1;
|
||||
$q->options->falseanswer = 2;
|
||||
$q->options->answers[1] = (object) array('fraction' => 1);
|
||||
@@ -140,8 +138,8 @@ class qtype_truefalse_test extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$this->setAdminUser();
|
||||
|
||||
$questiondata = test_question_maker::get_question_data('truefalse');
|
||||
$formdata = test_question_maker::get_question_form_data('truefalse');
|
||||
$questiondata = \test_question_maker::get_question_data('truefalse');
|
||||
$formdata = \test_question_maker::get_question_form_data('truefalse');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $generator->create_question_category(array());
|
||||
@@ -149,7 +147,7 @@ class qtype_truefalse_test extends advanced_testcase {
|
||||
$formdata->category = "{$cat->id},{$cat->contextid}";
|
||||
qtype_truefalse_edit_form::mock_submit((array)$formdata);
|
||||
|
||||
$form = qtype_truefalse_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
$form = \qtype_truefalse_test_helper::get_question_editing_form($cat, $questiondata);
|
||||
|
||||
$this->assertTrue($form->is_validated());
|
||||
|
||||
+3
-11
@@ -14,16 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests of the upgrade to the new Moodle question engine for attempts at
|
||||
* truefalse questions.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage truefalse
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace qtype_truefalse;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,10 +25,11 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
|
||||
/**
|
||||
* Testing the upgrade of truefalse question attempts.
|
||||
*
|
||||
* @package qtype_truefalse
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_truefalse_attempt_upgrader_test extends question_attempt_upgrader_test_base {
|
||||
class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
|
||||
|
||||
public function test_truefalse_deferredfeedback_history620() {
|
||||
$quiz = (object) array(
|
||||
@@ -14,16 +14,9 @@
|
||||
// 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 that walks a truefalse question through various
|
||||
* behaviours.
|
||||
*
|
||||
* @package qtype
|
||||
* @subpackage truefalse
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qtype_truefalse;
|
||||
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,14 +27,15 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
/**
|
||||
* Walkthrough tests for the truefalse question type.
|
||||
*
|
||||
* @package qtype_truefalse
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qtype_truefalse_walkthrough_test extends qbehaviour_walkthrough_test_base {
|
||||
class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
public function test_false_right_does_not_show_feedback_when_not_answered() {
|
||||
|
||||
// Create a true-false question with correct answer false.
|
||||
$tf = test_question_maker::make_question('truefalse', 'false');
|
||||
$tf = \test_question_maker::make_question('truefalse', 'false');
|
||||
$this->start_attempt_at_question($tf, 'deferredfeedback', 1);
|
||||
|
||||
// Check the initial state.
|
||||
@@ -50,7 +44,7 @@ class qtype_truefalse_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($tf),
|
||||
$this->get_does_not_contain_feedback_expectation(),
|
||||
new question_contains_tag_with_contents('h4',
|
||||
new \question_contains_tag_with_contents('h4',
|
||||
get_string('questiontext', 'question')));
|
||||
$this->assertEquals(get_string('false', 'qtype_truefalse'),
|
||||
$this->quba->get_right_answer_summary($this->slot));
|
||||
@@ -69,7 +63,7 @@ class qtype_truefalse_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
$this->get_contains_tf_false_radio_expectation(false, false),
|
||||
|
||||
// In particular, check that the false feedback is not displayed.
|
||||
new question_no_pattern_expectation('/' . preg_quote($tf->falsefeedback, '/') . '/'));
|
||||
new \question_no_pattern_expectation('/' . preg_quote($tf->falsefeedback, '/') . '/'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user