当前位置: 首页>>代码示例>>PHP>>正文


PHP test_question_maker类代码示例

本文整理汇总了PHP中test_question_maker的典型用法代码示例。如果您正苦于以下问题:PHP test_question_maker类的具体用法?PHP test_question_maker怎么用?PHP test_question_maker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了test_question_maker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_test_question_data

 protected function get_test_question_data()
 {
     global $USER;
     $q = new stdClass();
     $q->id = 0;
     $q->name = 'Gapfill Question';
     $q->category = 0;
     $q->contextid = 0;
     $q->parent = 0;
     $q->questiontext = 'The [cat] sat on the [mat]';
     $q->questiontextformat = FORMAT_HTML;
     $q->generalfeedback = 'General feedback.';
     $q->generalfeedbackformat = FORMAT_HTML;
     $q->defaultmark = 1;
     $q->penalty = 0.3333333;
     $q->length = 1;
     $q->stamp = make_unique_id_code();
     $q->version = make_unique_id_code();
     $q->hidden = 0;
     $q->timecreated = time();
     $q->timemodified = time();
     $q->createdby = $USER->id;
     $q->modifiedby = $USER->id;
     $q->options = new stdClass();
     test_question_maker::set_standard_combined_feedback_fields($q->options);
     $q->options->displayanswers = 0;
     $q->options->delimitchars = "[]";
     return $q;
 }
开发者ID:dthies,项目名称:moodle-qtype_gapfill,代码行数:29,代码来源:questiontype_test.php

示例2: make_calculated_question_sum

    /**
     * Makes a calculated question about summing two numbers.
     * @return qtype_calculated_question
     */
    public function make_calculated_question_sum() {
        question_bank::load_question_definition_classes('calculated');
        $q = new qtype_calculated_question();
        test_question_maker::initialise_a_question($q);
        $q->name = 'Simple sum';
        $q->questiontext = 'What is {a} + {b}?';
        $q->generalfeedback = 'Generalfeedback: {={a} + {b}} is the right answer.';

        $q->answers = array(
            13 => new qtype_numerical_answer(13, '{a} + {b}', 1.0, 'Very good.', FORMAT_HTML, 0),
            14 => new qtype_numerical_answer(14, '{a} - {b}', 0.0, 'Add. not subtract!.',
                    FORMAT_HTML, 0),
            17 => new qtype_numerical_answer(17, '*', 0.0, 'Completely wrong.', FORMAT_HTML, 0),
        );
        foreach ($q->answers as $answer) {
            $answer->correctanswerlength = 2;
            $answer->correctanswerformat = 1;
        }

        $q->qtype = question_bank::get_qtype('calculated');
        $q->unitdisplay = qtype_numerical::UNITNONE;
        $q->unitgradingtype = 0;
        $q->unitpenalty = 0;
        $q->ap = new qtype_numerical_answer_processor(array());
        $q->synchronised = false;

        $q->datasetloader = new qtype_calculated_test_dataset_loader(0, array(
            array('a' => 1, 'b' => 5),
            array('a' => 3, 'b' => 4),
        ));

        return $q;
    }
开发者ID:nigeldaley,项目名称:moodle,代码行数:37,代码来源:helper.php

示例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);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:missingbehaviour_test.php

示例4: 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);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:29,代码来源:walkthrough_test.php

示例5: 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, '/') . '/'));

    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:34,代码来源:walkthrough_test.php

示例6: 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());
 }
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:walkthrough_test.php

示例7: 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))));
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:7,代码来源:testquestion.php

示例8: 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);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:7,代码来源:questionattempt_test.php

示例9: get_test_question_data

 /**
  * @return object the data to construct a question like
  * {@link qtype_gapselect_test_helper::make_a_gapselect_question()}.
  */
 protected function get_test_question_data()
 {
     global $USER;
     $gapselect = new stdClass();
     $gapselect->id = 0;
     $gapselect->category = 0;
     $gapselect->contextid = 0;
     $gapselect->parent = 0;
     $gapselect->questiontextformat = FORMAT_HTML;
     $gapselect->generalfeedbackformat = FORMAT_HTML;
     $gapselect->defaultmark = 1;
     $gapselect->penalty = 0.3333333;
     $gapselect->length = 1;
     $gapselect->stamp = make_unique_id_code();
     $gapselect->version = make_unique_id_code();
     $gapselect->hidden = 0;
     $gapselect->timecreated = time();
     $gapselect->timemodified = time();
     $gapselect->createdby = $USER->id;
     $gapselect->modifiedby = $USER->id;
     $gapselect->name = 'Selection from drop down list question';
     $gapselect->questiontext = 'The [[1]] brown [[2]] jumped over the [[3]] dog.';
     $gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.';
     $gapselect->qtype = 'gapselect';
     $gapselect->options = new stdClass();
     $gapselect->options->shuffleanswers = true;
     test_question_maker::set_standard_combined_feedback_fields($gapselect->options);
     $gapselect->options->answers = array((object) array('answer' => 'quick', 'feedback' => '1'), (object) array('answer' => 'fox', 'feedback' => '2'), (object) array('answer' => 'lazy', 'feedback' => '3'), (object) array('answer' => 'assiduous', 'feedback' => '3'), (object) array('answer' => 'dog', 'feedback' => '2'), (object) array('answer' => 'slow', 'feedback' => '1'));
     return $gapselect;
 }
开发者ID:ndunand,项目名称:moodle-qtype_gapselect,代码行数:34,代码来源:questiontype_test.php

示例10: get_test_question_data

 protected function get_test_question_data()
 {
     global $USER;
     $q = new stdClass();
     $q->id = 0;
     $q->name = 'Drag and drop matching question';
     $q->category = 0;
     $q->contextid = 0;
     $q->parent = 0;
     $q->questiontext = 'Classify the animals.';
     $q->questiontextformat = FORMAT_HTML;
     $q->generalfeedback = 'General feedback.';
     $q->generalfeedbackformat = FORMAT_HTML;
     $q->defaultmark = 1;
     $q->penalty = 0.3333333;
     $q->length = 1;
     $q->stamp = make_unique_id_code();
     $q->version = make_unique_id_code();
     $q->hidden = 0;
     $q->timecreated = time();
     $q->timemodified = time();
     $q->createdby = $USER->id;
     $q->modifiedby = $USER->id;
     $q->options = new stdClass();
     $q->options->shuffleanswers = false;
     test_question_maker::set_standard_combined_feedback_fields($q->options);
     $q->options->subquestions = array(14 => (object) array('id' => 14, 'questiontext' => 'frog', 'questiontextformat' => FORMAT_HTML, 'answertext' => 'amphibian', 'answertextformat' => FORMAT_HTML), 15 => (object) array('id' => 15, 'questiontext' => 'cat', 'questiontextformat' => FORMAT_HTML, 'answertext' => 'mammal', 'answertextformat' => FORMAT_HTML), 16 => (object) array('id' => 16, 'questiontext' => 'newt', 'questiontextformat' => FORMAT_HTML, 'answertext' => 'amphibian', 'answertextformat' => FORMAT_HTML), 17 => (object) array('id' => 17, 'questiontext' => '', 'questiontextformat' => FORMAT_HTML, 'answertext' => 'insect', 'answertextformat' => FORMAT_HTML));
     return $q;
 }
开发者ID:VERSION2-Inc,项目名称:moodle-qtype_ddmatch,代码行数:29,代码来源:questiontype_test.php

示例11: 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()));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:question_test.php

示例12: 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);
     }
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:8,代码来源:questionattempt_with_steps_test.php

示例13: 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;
 }
开发者ID:pac,项目名称:CodeRunner,代码行数:10,代码来源:coderunnertestcase.php

示例14: 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' => '')));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:10,代码来源:question_test.php

示例15: 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();
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:10,代码来源:questionattemptiterator_test.php


注:本文中的test_question_maker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。