本文整理汇总了PHP中test_question_maker::make_a_matching_question方法的典型用法代码示例。如果您正苦于以下问题:PHP test_question_maker::make_a_matching_question方法的具体用法?PHP test_question_maker::make_a_matching_question怎么用?PHP test_question_maker::make_a_matching_question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test_question_maker
的用法示例。
在下文中一共展示了test_question_maker::make_a_matching_question方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_interactive_feedback_match_reset
public function test_interactive_feedback_match_reset()
{
// Create a matching question.
$m = test_question_maker::make_a_matching_question();
$m->shufflestems = false;
$m->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));
$this->start_attempt_at_question($m, 'interactive', 12);
$choiceorder = $m->get_choice_order();
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
$choices = array(0 => get_string('choose') . '...');
foreach ($choiceorder as $key => $choice) {
$choices[$key] = $m->choices[$choice];
}
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->assertEquals('interactivecountback', $this->quba->get_question_attempt($this->slot)->get_behaviour_name());
$this->check_current_output($this->get_contains_select_expectation('sub0', $choices, null, true), $this->get_contains_select_expectation('sub1', $choices, null, true), $this->get_contains_select_expectation('sub2', $choices, null, true), $this->get_contains_select_expectation('sub3', $choices, null, true), $this->get_contains_question_text_expectation($m), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(3), $this->get_does_not_contain_num_parts_correct(), $this->get_no_hint_visible_expectation());
// Submit an answer with two right, and two wrong.
$this->process_submission(array('sub0' => $orderforchoice[1], 'sub1' => $orderforchoice[1], 'sub2' => $orderforchoice[1], 'sub3' => $orderforchoice[1], '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false), $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[1], false), $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[1], false), $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false), $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), new question_pattern_expectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_interactive'), '/') . '/'), $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(), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub0', $orderforchoice[1]), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub1', '0'), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub2', '0'), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[1]));
// Check that extract responses will return the reset data.
$prefix = $this->quba->get_field_prefix($this->slot);
$this->assertEquals(array('sub0' => 1), $this->quba->extract_responses($this->slot, array($prefix . 'sub0' => 1)));
// Do try again.
$this->process_submission(array('sub0' => $orderforchoice[1], 'sub3' => $orderforchoice[1], '-tryagain' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], true), $this->get_contains_select_expectation('sub1', $choices, null, true), $this->get_contains_select_expectation('sub2', $choices, null, true), $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], true), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(2), $this->get_no_hint_visible_expectation());
// Submit the right answer.
$this->process_submission(array('sub0' => $orderforchoice[1], 'sub1' => $orderforchoice[2], 'sub2' => $orderforchoice[2], 'sub3' => $orderforchoice[1], '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(10);
$this->check_current_output($this->get_contains_select_expectation('sub0', $choices, $orderforchoice[1], false), $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false), $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false), $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false), $this->get_contains_submit_button_expectation(false), $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"/'));
}
示例2: test_match_clear_wrong
public function test_match_clear_wrong()
{
// Create a matching question.
$m = test_question_maker::make_a_matching_question();
$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));
$m->shufflestems = false;
$this->start_attempt_at_question($m, 'interactive', 4);
$choiceorder = $m->get_choice_order();
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
$choices = array(0 => get_string('choose') . '...');
foreach ($choiceorder as $key => $choice) {
$choices[$key] = $m->choices[$choice];
}
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_select_expectation('sub0', $choices, null, true), $this->get_contains_select_expectation('sub1', $choices, null, true), $this->get_contains_select_expectation('sub2', $choices, null, true), $this->get_contains_select_expectation('sub3', $choices, null, true), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(3), $this->get_no_hint_visible_expectation());
// Submit a completely wrong response.
$this->process_submission(array('sub0' => $orderforchoice[3], 'sub1' => $orderforchoice[3], 'sub2' => $orderforchoice[3], 'sub3' => $orderforchoice[3], '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_select_expectation('sub0', $choices, 3, false), $this->get_contains_select_expectation('sub1', $choices, 3, false), $this->get_contains_select_expectation('sub2', $choices, 3, false), $this->get_contains_select_expectation('sub3', $choices, 3, false), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub0', '0'), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub1', '0'), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub2', '0'), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub3', '0'), $this->get_contains_submit_button_expectation(false), $this->get_contains_hint_expectation('This is the first hint.'));
// Try again.
$this->process_submission(array('sub0' => 0, 'sub1' => 0, 'sub2' => 0, 'sub3' => 0, '-tryagain' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_select_expectation('sub0', $choices, null, true), $this->get_contains_select_expectation('sub1', $choices, null, true), $this->get_contains_select_expectation('sub2', $choices, null, true), $this->get_contains_select_expectation('sub3', $choices, null, true), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(2), $this->get_no_hint_visible_expectation());
// Submit a partially wrong response.
$this->process_submission(array('sub0' => $orderforchoice[3], 'sub1' => $orderforchoice[3], 'sub2' => $orderforchoice[2], 'sub3' => $orderforchoice[1], '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_select_expectation('sub0', $choices, 3, false), $this->get_contains_select_expectation('sub1', $choices, 3, false), $this->get_contains_select_expectation('sub2', $choices, 2, false), $this->get_contains_select_expectation('sub3', $choices, 1, false), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub0', '0'), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub1', '0'), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub2', $orderforchoice[2]), $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[1]), $this->get_contains_submit_button_expectation(false), $this->get_contains_hint_expectation('This is the second hint.'));
// Try again.
$this->process_submission(array('sub0' => 0, 'sub1' => 0, 'sub2' => $orderforchoice[2], 'sub3' => $orderforchoice[1], '-tryagain' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_select_expectation('sub0', $choices, null, true), $this->get_contains_select_expectation('sub1', $choices, null, true), $this->get_contains_select_expectation('sub2', $choices, 2, true), $this->get_contains_select_expectation('sub3', $choices, 1, true), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(1), $this->get_no_hint_visible_expectation());
}
示例3: test_prepare_simulated_post_data
public function test_prepare_simulated_post_data()
{
$m = test_question_maker::make_a_matching_question();
$m->start_attempt(new question_attempt_step(), 1);
$postdata = $m->prepare_simulated_post_data(array('Dog' => 'Mammal', 'Frog' => 'Amphibian', 'Toad' => 'Amphibian', 'Cat' => 'Mammal'));
$this->assertEquals(array(4, 4), $m->get_num_parts_right($postdata));
}
示例4: test_classify_response
public function test_classify_response() {
$match = test_question_maker::make_a_matching_question();
$match->shufflestems = false;
$match->start_attempt(new question_attempt_step(), 1);
$choiceorder = $match->get_choice_order();
$orderforchoice = array_combine(array_values($choiceorder), array_keys($choiceorder));
$choices = array(0 => get_string('choose') . '...');
foreach ($choiceorder as $key => $choice) {
$choices[$key] = $match->choices[$choice];
}
$this->assertEquals(array(
1 => new question_classified_response(2, 'Amphibian', 0),
2 => new question_classified_response(3, 'Insect', 0),
3 => question_classified_response::no_response(),
4 => question_classified_response::no_response(),
), $match->classify_response(array('sub0' => $orderforchoice[2],
'sub1' => $orderforchoice[3], 'sub2' => 0, 'sub3' => 0)));
$this->assertEquals(array(
1 => new question_classified_response(1, 'Mammal', 0.25),
2 => new question_classified_response(2, 'Amphibian', 0.25),
3 => new question_classified_response(2, 'Amphibian', 0.25),
4 => new question_classified_response(1, 'Mammal', 0.25),
), $match->classify_response(array('sub0' => $orderforchoice[1],
'sub1' => $orderforchoice[2], 'sub2' => $orderforchoice[2],
'sub3' => $orderforchoice[1])));
}