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


PHP question_bank::start_unit_test方法代码示例

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


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

示例1: 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

示例2: setUp

 protected function setUp()
 {
     // Create a usage in an initial state, with one shortanswer question added,
     // and attempted in interactive mode submitted responses 'toad' then 'frog'.
     // Then set it to use a new unit of work for any subsequent changes.
     // Create a short answer question.
     $question = test_question_maker::make_question('shortanswer');
     $question->hints = array(new question_hint(0, 'This is the first hint.', FORMAT_HTML), new question_hint(0, 'This is the second hint.', FORMAT_HTML));
     $question->id = -1;
     question_bank::start_unit_test();
     question_bank::load_test_question_data($question);
     $this->setup_initial_test_state($this->get_test_data());
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:13,代码来源:unitofwork_test.php

示例3: test_load_data_no_qas

    public function test_load_data_no_qas() {
        // The code had a bug where if a question_usage had no question_attempts,
        // load_from_records got stuck in an infinite loop. This test is to
        // verify that no longer happens.
        $scid = context_system::instance()->id;
        $records = new question_test_recordset(array(
        array('qubaid', 'contextid', 'component', 'preferredbehaviour',
                                                   'questionattemptid', 'questionusageid', 'slot',
                                                                        'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'flagged',
                                                                                                               'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
                                                                                                                                         'attemptstepid', 'sequencenumber', 'state', 'fraction',
                                                                                                                                                                   'timecreated', 'userid', 'name', 'value'),
        array(1, $scid, 'unit_test', 'interactive', null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null),
        ));

        question_bank::start_unit_test();
        $quba = question_usage_by_activity::load_from_records($records, 1);
        question_bank::end_unit_test();

        $this->assertEquals('unit_test', $quba->get_owning_component());
        $this->assertEquals(1, $quba->get_id());
        $this->assertInstanceOf('question_engine_unit_of_work', $quba->get_observer());
        $this->assertEquals('interactive', $quba->get_preferred_behaviour());

        $this->assertEquals(array(), $quba->get_slots());
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:26,代码来源:questionusagebyactivity_test.php

示例4: test_load_with_unnecessary_autosaved_data

 public function test_load_with_unnecessary_autosaved_data()
 {
     // The point here is that the somehow (probably due to two things
     // happening concurrently, we have autosaved data in the database that
     // has already been superceded by real data, so it should be ignored.
     // There is also a second lot of redundant data to delete.
     $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, 'deferredfeedback', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 5, -2, 'complete', null, 1256233715, 1, 'answer', '0'), array(1, 123, 1, 1, 'deferredfeedback', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 4, -1, 'complete', null, 1256233715, 1, 'answer', '0'), array(1, 123, 1, 1, 'deferredfeedback', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 1, 0, 'todo', null, 1256233700, 1, null, null), array(1, 123, 1, 1, 'deferredfeedback', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 2, 1, 'complete', null, 1256233705, 1, 'answer', '1'), array(1, 123, 1, 1, 'deferredfeedback', -1, 1, 2.0, 0.0, 1.0, 1, '', '', '', 1256233790, 3, 2, 'complete', null, 1256233710, 1, 'answer', '0')));
     $question = test_question_maker::make_question('truefalse', 'true');
     $question->id = -1;
     question_bank::start_unit_test();
     question_bank::load_test_question_data($question);
     $observer = new testable_question_engine_unit_of_work(question_engine::make_questions_usage_by_activity('unit_test', context_system::instance()));
     $qa = question_attempt::load_from_records($records, 1, $observer, 'deferredfeedback');
     question_bank::end_unit_test();
     $this->assertEquals($question->questiontext, $qa->get_question()->questiontext);
     $this->assertEquals(3, $qa->get_num_steps());
     $this->assertFalse($qa->has_autosaved_step());
     $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(), $step->get_all_data());
     $step = $qa->get_step(1);
     $this->assertEquals(question_state::$complete, $step->get_state());
     $this->assertNull($step->get_fraction());
     $this->assertEquals(1256233705, $step->get_timecreated());
     $this->assertEquals(1, $step->get_user_id());
     $this->assertEquals(array('answer' => '1'), $step->get_all_data());
     $step = $qa->get_step(2);
     $this->assertEquals(question_state::$complete, $step->get_state());
     $this->assertNull($step->get_fraction());
     $this->assertEquals(1256233710, $step->get_timecreated());
     $this->assertEquals(1, $step->get_user_id());
     $this->assertEquals(array('answer' => '0'), $step->get_all_data());
     $this->assertEquals(2, count($observer->get_steps_deleted()));
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:37,代码来源:questionattempt_db_test.php

示例5: test_load_missing_question

 public function test_load_missing_question()
 {
     $records = new test_recordset(array(array('questionattemptid', 'contextid', 'questionusageid', 'slot', 'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'flagged', 'questionsummary', 'rightanswer', 'responsesummary', 'timemodified', 'attemptstepid', 'sequencenumber', 'state', 'fraction', 'timecreated', 'userid', 'name', 'value'), array(1, 123, 1, 1, 'deferredfeedback', -1, 1, 2.0, 0.0, 0, '', '', '', 1256233790, 1, 0, 'todo', null, 1256233700, 1, null, null)));
     question_bank::start_unit_test();
     $qa = question_attempt::load_from_records($records, 1, new question_usage_null_observer(), 'deferredfeedback');
     question_bank::end_unit_test();
     $missingq = question_bank::get_qtype('missingtype')->make_deleted_instance(-1, 2);
     $this->assertEqual($missingq, $qa->get_question());
     $this->assertEqual(1, $qa->get_num_steps());
     $step = $qa->get_step(0);
     $this->assertEqual(question_state::$todo, $step->get_state());
     $this->assertNull($step->get_fraction());
     $this->assertEqual(1256233700, $step->get_timecreated());
     $this->assertEqual(1, $step->get_user_id());
     $this->assertEqual(array(), $step->get_all_data());
 }
开发者ID:hatone,项目名称:moodle,代码行数:16,代码来源:testquestionattempt.php

示例6: test_load

    public function test_load() {
        $records = new question_test_recordset(array(
        array('qubaid', 'contextid', 'component', 'preferredbehaviour',
                                               'questionattemptid', 'contextid', 'questionusageid', 'slot',
                                                              'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'flagged',
                                                                                                             'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
                                                                                                                                     'attemptstepid', 'sequencenumber', 'state', 'fraction',
                                                                                                                                                                     'timecreated', 'userid', 'name', 'value'),
        array(1, 1, 'unit_test', 'interactive', 1, 123, 1, 1, 'interactive', -1, 1, 2.0000000, 0.0000000, 0, '', '', '', 1256233790, 1, 0, 'todo',             null, 1256233700, 1,       null, null),
        array(1, 1, 'unit_test', 'interactive', 1, 123, 1, 1, 'interactive', -1, 1, 2.0000000, 0.0000000, 0, '', '', '', 1256233790, 2, 1, 'todo',             null, 1256233705, 1,   'answer',  '1'),
        array(1, 1, 'unit_test', 'interactive', 1, 123, 1, 1, 'interactive', -1, 1, 2.0000000, 0.0000000, 0, '', '', '', 1256233790, 5, 2, 'gradedright', 1.0000000, 1256233720, 1,  '-finish',  '1'),
        ));

        $question = test_question_maker::make_question('truefalse', 'true');
        $question->id = -1;

        question_bank::start_unit_test();
        question_bank::load_test_question_data($question);
        $quba = question_usage_by_activity::load_from_records($records, 1);
        question_bank::end_unit_test();

        $this->assertEquals('unit_test', $quba->get_owning_component());
        $this->assertEquals(1, $quba->get_id());
        $this->assertInstanceOf('question_engine_unit_of_work', $quba->get_observer());
        $this->assertEquals('interactive', $quba->get_preferred_behaviour());

        $qa = $quba->get_question_attempt(1);

        $this->assertEquals($question->questiontext, $qa->get_question()->questiontext);

        $this->assertEquals(3, $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(), $step->get_all_data());

        $step = $qa->get_step(1);
        $this->assertEquals(question_state::$todo, $step->get_state());
        $this->assertNull($step->get_fraction());
        $this->assertEquals(1256233705, $step->get_timecreated());
        $this->assertEquals(1, $step->get_user_id());
        $this->assertEquals(array('answer' => '1'), $step->get_all_data());

        $step = $qa->get_step(2);
        $this->assertEquals(question_state::$gradedright, $step->get_state());
        $this->assertEquals(1, $step->get_fraction());
        $this->assertEquals(1256233720, $step->get_timecreated());
        $this->assertEquals(1, $step->get_user_id());
        $this->assertEquals(array('-finish' => '1'), $step->get_all_data());
    }
开发者ID:numbas,项目名称:moodle,代码行数:53,代码来源:questionusagebyactivity_test.php


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