Línea 33... |
Línea 33... |
33 |
* @copyright 2015 The Open University
|
33 |
* @copyright 2015 The Open University
|
34 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
34 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
35 |
*/
|
35 |
*/
|
36 |
class least_used_variant_strategy_test extends \advanced_testcase {
|
36 |
class least_used_variant_strategy_test extends \advanced_testcase {
|
Línea 37... |
Línea 37... |
37 |
|
37 |
|
38 |
public function test_question_with_one_variant_always_picks_that() {
|
38 |
public function test_question_with_one_variant_always_picks_that(): void {
|
39 |
$question = \test_question_maker::make_question('shortanswer');
|
39 |
$question = \test_question_maker::make_question('shortanswer');
|
40 |
$quba = question_engine::make_questions_usage_by_activity('test', \context_system::instance());
|
40 |
$quba = question_engine::make_questions_usage_by_activity('test', \context_system::instance());
|
41 |
$quba->set_preferred_behaviour('deferredfeedback');
|
41 |
$quba->set_preferred_behaviour('deferredfeedback');
|
42 |
$slot = $quba->add_question($question);
|
42 |
$slot = $quba->add_question($question);
|
43 |
$quba->start_all_questions(new least_used_strategy(
|
43 |
$quba->start_all_questions(new least_used_strategy(
|
44 |
$quba, new qubaid_list([])));
|
44 |
$quba, new qubaid_list([])));
|
45 |
$this->assertEquals(1, $quba->get_variant($slot));
|
45 |
$this->assertEquals(1, $quba->get_variant($slot));
|
Línea 46... |
Línea 46... |
46 |
}
|
46 |
}
|
47 |
|
47 |
|
48 |
public function test_synchronised_question_should_use_the_same_dataset() {
|
48 |
public function test_synchronised_question_should_use_the_same_dataset(): void {
|
49 |
// Actually, we cheat here. We use the same question twice, not two different synchronised questions.
|
49 |
// Actually, we cheat here. We use the same question twice, not two different synchronised questions.
|
50 |
$question = \test_question_maker::make_question('calculated');
|
50 |
$question = \test_question_maker::make_question('calculated');
|
51 |
$quba = question_engine::make_questions_usage_by_activity('test', \context_system::instance());
|
51 |
$quba = question_engine::make_questions_usage_by_activity('test', \context_system::instance());
|
Línea 55... |
Línea 55... |
55 |
$quba->start_all_questions(new least_used_strategy(
|
55 |
$quba->start_all_questions(new least_used_strategy(
|
56 |
$quba, new qubaid_list([])));
|
56 |
$quba, new qubaid_list([])));
|
57 |
$this->assertEquals($quba->get_variant($slot1), $quba->get_variant($slot2));
|
57 |
$this->assertEquals($quba->get_variant($slot1), $quba->get_variant($slot2));
|
58 |
}
|
58 |
}
|
Línea 59... |
Línea 59... |
59 |
|
59 |
|
60 |
public function test_second_attempt_uses_other_dataset() {
|
60 |
public function test_second_attempt_uses_other_dataset(): void {
|
61 |
global $DB;
|
61 |
global $DB;
|
62 |
$this->resetAfterTest();
|
62 |
$this->resetAfterTest();
|
Línea 63... |
Línea 63... |
63 |
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
63 |
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|