本文整理汇总了PHP中test_question_maker::make_question方法的典型用法代码示例。如果您正苦于以下问题:PHP test_question_maker::make_question方法的具体用法?PHP test_question_maker::make_question怎么用?PHP test_question_maker::make_question使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test_question_maker
的用法示例。
在下文中一共展示了test_question_maker::make_question方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_false_right_does_not_show_feedback_when_not_answered
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');
$this->start_attempt_at_question($tf, 'deferredfeedback', 1);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output(
$this->get_contains_question_text_expectation($tf),
$this->get_does_not_contain_feedback_expectation(),
new question_contains_tag_with_contents('h3',
get_string('questiontext', 'question')));
$this->assertEquals(get_string('false', 'qtype_truefalse'),
$this->quba->get_right_answer_summary($this->slot));
$this->assertRegExp('/' . preg_quote($tf->questiontext, '/') . '/',
$this->quba->get_question_summary($this->slot));
$this->assertNull($this->quba->get_response_summary($this->slot));
// Finish the attempt without answering.
$this->quba->finish_all_questions();
// Verify.
$this->check_current_state(question_state::$gaveup);
$this->check_current_mark(null);
$this->check_current_output(
$this->get_contains_tf_true_radio_expectation(false, false),
$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, '/') . '/'));
}
示例2: test_interactive
public function test_interactive()
{
// Create a gapselect question.
$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));
$this->start_attempt_at_question($q, 'interactive', 3, 1);
$values = $q->vs->get_values();
$this->assertEquals($values, $q->datasetloader->load_values(1));
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_does_not_contain_validation_error_expectation(), $this->get_does_not_contain_try_again_button_expectation(), $this->get_no_hint_visible_expectation());
// Submit blank.
$this->process_submission(array('-submit' => 1, 'answer' => ''));
// Verify.
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_contains_validation_error_expectation(), $this->get_does_not_contain_try_again_button_expectation(), $this->get_no_hint_visible_expectation());
// Sumit something that does not look like a number.
$this->process_submission(array('-submit' => 1, 'answer' => 'newt'));
// Verify.
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_contains_validation_error_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());
// Now get it right.
$this->process_submission(array('-submit' => 1, 'answer' => $values['a'] + $values['b']));
// Verify.
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(3);
$this->check_current_output($this->get_contains_mark_summary(3), $this->get_does_not_contain_submit_button_expectation(), $this->get_contains_correct_expectation(), $this->get_does_not_contain_validation_error_expectation(), $this->get_no_hint_visible_expectation());
}
示例3: test_render_missing
public function test_render_missing()
{
$records = new question_test_recordset(array(array('questionattemptid', 'contextid', 'questionusageid', 'slot', 'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'maxfraction', 'flagged', 'questionsummary', 'rightanswer', 'responsesummary', 'timemodified', 'attemptstepid', 'sequencenumber', 'state', 'fraction', 'timecreated', 'userid', 'name', 'value'), array(1, 123, 1, 1, 'strangeunknown', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 1, 0, 'todo', null, 1256233700, 1, '_order', '1,2,3'), array(1, 123, 1, 1, 'strangeunknown', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 2, 1, 'complete', 0.5, 1256233705, 1, '-submit', '1'), array(1, 123, 1, 1, 'strangeunknown', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 2, 1, 'complete', 0.5, 1256233705, 1, 'choice0', '1')));
$question = test_question_maker::make_question('truefalse', 'true');
$question->id = -1;
question_bank::start_unit_test();
question_bank::load_test_question_data($question);
$qa = question_attempt::load_from_records($records, 1, new question_usage_null_observer(), 'deferredfeedback');
question_bank::end_unit_test();
$this->assertEquals(2, $qa->get_num_steps());
$step = $qa->get_step(0);
$this->assertEquals(question_state::$todo, $step->get_state());
$this->assertNull($step->get_fraction());
$this->assertEquals(1256233700, $step->get_timecreated());
$this->assertEquals(1, $step->get_user_id());
$this->assertEquals(array('_order' => '1,2,3'), $step->get_all_data());
$step = $qa->get_step(1);
$this->assertEquals(question_state::$complete, $step->get_state());
$this->assertEquals(0.5, $step->get_fraction());
$this->assertEquals(1256233705, $step->get_timecreated());
$this->assertEquals(1, $step->get_user_id());
$this->assertEquals(array('-submit' => '1', 'choice0' => '1'), $step->get_all_data());
$output = $qa->render(new question_display_options(), '1');
$this->assertRegExp('/' . preg_quote($qa->get_question()->questiontext, '/') . '/', $output);
$this->assertRegExp('/' . preg_quote(get_string('questionusedunknownmodel', 'qbehaviour_missing'), '/') . '/', $output);
$this->assertTag(array('tag' => 'div', 'attributes' => array('class' => 'warning')), $output);
}
示例4: test_manual_graded_truefalse
public function test_manual_graded_truefalse()
{
// Create a true-false question with correct answer true.
$tf = test_question_maker::make_question('truefalse', 'true');
$this->start_attempt_at_question($tf, 'manualgraded', 2);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_question_text_expectation($tf), $this->get_does_not_contain_feedback_expectation());
// Process a true answer and check the expected result.
$this->process_submission(array('answer' => 1));
$this->check_current_state(question_state::$complete);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_tf_true_radio_expectation(true, true), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation());
// Finish the attempt.
$this->quba->finish_all_questions();
// Verify.
$this->check_current_state(question_state::$needsgrading);
$this->check_current_mark(null);
$this->check_current_output($this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_specific_feedback_expectation());
// Process a manual comment.
$this->manual_grade('Not good enough!', 1);
$this->check_current_state(question_state::$mangrpartial);
$this->check_current_mark(1);
$this->check_current_output($this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_specific_feedback_expectation(), new PatternExpectation('/' . preg_quote('Not good enough!') . '/'));
}
示例5: test_summarise_response
public function test_summarise_response()
{
$question = test_question_maker::make_question('multianswer');
$question->start_attempt(new question_attempt_step(), 1);
$rightchoice = $question->subquestions[2]->get_correct_response();
$this->assertEqual(get_string('subqresponse', 'qtype_multianswer', array('i' => 1, 'response' => 'Owl')) . '; ' . get_string('subqresponse', 'qtype_multianswer', array('i' => 2, 'response' => 'Pussy-cat')), $question->summarise_response(array('sub1_answer' => 'Owl', 'sub2_answer' => reset($rightchoice))));
}
示例6: setUp
protected function setUp()
{
$this->question = test_question_maker::make_question('description');
$this->question->defaultmark = 3;
$this->usageid = 13;
$this->qa = new question_attempt($this->question, $this->usageid);
}
示例7: test_informationitem_feedback_description
public function test_informationitem_feedback_description()
{
// Create a true-false question with correct answer true.
$description = test_question_maker::make_question('description');
$this->start_attempt_at_question($description, 'deferredfeedback');
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_question_text_expectation($description), new question_contains_tag_with_attributes('input', array('type' => 'hidden', 'name' => $this->quba->get_field_prefix($this->slot) . '-seen', 'value' => 1)), $this->get_does_not_contain_feedback_expectation());
// Process a submission indicating this question has been seen.
$this->process_submission(array('-seen' => 1));
$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('/type=\\"hidden\\"[^>]*name=\\"[^"]*seen\\"|name=\\"[^"]*seen\\"[^>]*type=\\"hidden\\"/'), $this->get_does_not_contain_feedback_expectation());
// Finish the attempt.
$this->quba->finish_all_questions();
// Verify.
$this->check_current_state(question_state::$finished);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_question_text_expectation($description), $this->get_contains_general_feedback_expectation($description));
// Process a manual comment.
$this->manual_grade('Not good enough!', null, FORMAT_HTML);
$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!', '/') . '/'));
// Check that trying to process a manual comment with a grade causes an exception.
$this->setExpectedException('moodle_exception');
$this->manual_grade('Not good enough!', 1, FORMAT_HTML);
}
示例8: test_classify_response
public function test_classify_response()
{
$tf = test_question_maker::make_question('truefalse', 'true');
$tf->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array($tf->id => new question_classified_response(0, get_string('false', 'qtype_truefalse'), 0.0)), $tf->classify_response(array('answer' => '0')));
$this->assertEquals(array($tf->id => new question_classified_response(1, get_string('true', 'qtype_truefalse'), 1.0)), $tf->classify_response(array('answer' => '1')));
$this->assertEquals(array($tf->id => question_classified_response::no_response()), $tf->classify_response(array()));
}
示例9: setUp
protected function setUp() {
$this->question = test_question_maker::make_question('description');
$this->qa = new testable_question_attempt($this->question, 0, null, 2);
for ($i = 0; $i < 3; $i++) {
$step = new question_attempt_step(array('i' => $i));
$this->qa->add_step($step);
}
}
示例10: test_initialise_question_instance
public function test_initialise_question_instance()
{
$qdata = test_question_maker::get_question_data('stack', 'test3');
$q = $this->qtype->make_question($qdata);
$expectedq = test_question_maker::make_question('stack', 'test3');
$expectedq->stamp = $q->stamp;
$expectedq->version = $q->version;
$this->assertEquals($expectedq, $q);
}
示例11: test_classify_response
public function test_classify_response()
{
$question = test_question_maker::make_question('calculatedsimple');
$question->start_attempt(new question_attempt_step(), 1);
$values = $question->vs->get_values();
$this->assertEquals(array(new question_classified_response(13, $values['a'] + $values['b'], 1.0)), $question->classify_response(array('answer' => $values['a'] + $values['b'])));
$this->assertEquals(array(new question_classified_response(14, $values['a'] - $values['b'], 0.0)), $question->classify_response(array('answer' => $values['a'] - $values['b'])));
$this->assertEquals(array(new question_classified_response(17, 7 * $values['a'], 0.0)), $question->classify_response(array('answer' => 7 * $values['a'])));
$this->assertEquals(array(question_classified_response::no_response()), $question->classify_response(array('answer' => '')));
}
示例12: make_question
public function make_question($question)
{
try {
$q = test_question_maker::make_question('coderunner', $question);
} catch (qtype_coderunner_missing_question_type $ex) {
$this->markTestSkipped("{$question} question unavailable: test skipped");
}
$q->contextid = $this->category->contextid;
return $q;
}
示例13: setUp
protected function setUp()
{
$this->quba = question_engine::make_questions_usage_by_activity('unit_test', context_system::instance());
$this->quba->set_preferred_behaviour('deferredfeedback');
$slot = $this->quba->add_question(test_question_maker::make_question('description'));
$this->qas[$slot] = $this->quba->get_question_attempt($slot);
$slot = $this->quba->add_question(test_question_maker::make_question('description'));
$this->qas[$slot] = $this->quba->get_question_attempt($slot);
$this->iterator = $this->quba->get_attempt_iterator();
}
示例14: setUp
protected function setUp()
{
$question = test_question_maker::make_question('description');
$this->qa = new testable_question_attempt($question, 0);
for ($i = 0; $i < 3; $i++) {
$step = new question_attempt_step(array('i' => $i));
$this->qa->add_step($step);
}
$this->iterator = $this->qa->get_step_iterator();
}
示例15: test_synchronised_question_should_use_the_same_dataset
public function test_synchronised_question_should_use_the_same_dataset()
{
// Actually, we cheat here. We use the same question twice, not two different synchronised questions.
$question = test_question_maker::make_question('calculated');
$quba = question_engine::make_questions_usage_by_activity('test', context_system::instance());
$quba->set_preferred_behaviour('deferredfeedback');
$slot1 = $quba->add_question($question);
$slot2 = $quba->add_question($question);
$quba->start_all_questions(new core_question\engine\variants\least_used_strategy($quba, new qubaid_list(array())));
$this->assertEquals($quba->get_variant($slot1), $quba->get_variant($slot2));
}