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


PHP test_question_maker::make_an_essay_question方法代码示例

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


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

示例1: test_is_complete_response

 public function test_is_complete_response()
 {
     $essay = test_question_maker::make_an_essay_question();
     $essay->start_attempt(new question_attempt_step(), 1);
     // The empty string should be considered an empty response, as should a lack of a response.
     $this->assertFalse($essay->is_complete_response(array('answer' => '')));
     $this->assertFalse($essay->is_complete_response(array()));
     // Any nonempty string should be considered a complete response.
     $this->assertTrue($essay->is_complete_response(array('answer' => 'A student response.')));
     $this->assertTrue($essay->is_complete_response(array('answer' => '0 times.')));
     $this->assertTrue($essay->is_complete_response(array('answer' => '0')));
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:12,代码来源:question_test.php

示例2: test_manual_graded_out_of_range_throws_exception

 public function test_manual_graded_out_of_range_throws_exception()
 {
     global $PAGE;
     // The current text editor depends on the users profile setting - so it needs a valid user.
     $this->setAdminUser();
     // Required to init a text editor.
     $PAGE->set_url('/');
     // Create an essay question.
     $essay = test_question_maker::make_an_essay_question();
     $this->start_attempt_at_question($essay, 'deferredfeedback', 10);
     // Check the right model is being used.
     $this->assertEquals('manualgraded', $this->quba->get_question_attempt($this->slot)->get_behaviour_name());
     // 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($essay), $this->get_does_not_contain_feedback_expectation());
     // Simulate some data submitted by the student.
     $this->process_submission(array('answer' => 'This is my wonderful essay!', 'answerformat' => FORMAT_HTML));
     // Verify.
     $this->check_current_state(question_state::$complete);
     $this->check_current_mark(null);
     $this->check_current_output(new question_contains_tag_with_attribute('textarea', 'name', $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')), $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->assertEquals('This is my wonderful essay!', $this->quba->get_response_summary($this->slot));
     // Try to process a an invalid grade.
     $this->expectException('coding_exception');
     $this->manual_grade('Comment', '10.1', FORMAT_HTML);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:32,代码来源:walkthrough_test.php

示例3: test_is_same_response_with_template

    public function test_is_same_response_with_template() {
        $essay = test_question_maker::make_an_essay_question();

        $essay->responsetemplate = 'Once upon a time';

        $essay->start_attempt(new question_attempt_step(), 1);

        $this->assertTrue($essay->is_same_response(
                array(),
                array('answer' => 'Once upon a time')));

        $this->assertTrue($essay->is_same_response(
                array('answer' => ''),
                array('answer' => 'Once upon a time')));

        $this->assertTrue($essay->is_same_response(
                array('answer' => 'Once upon a time'),
                array('answer' => '')));

        $this->assertTrue($essay->is_same_response(
                array('answer' => ''),
                array()));

        $this->assertTrue($essay->is_same_response(
                array('answer' => 'Once upon a time'),
                array()));

        $this->assertFalse($essay->is_same_response(
                array('answer' => 0),
                array('answer' => '')));

        $this->assertFalse($essay->is_same_response(
                array('answer' => ''),
                array('answer' => 0)));

        $this->assertFalse($essay->is_same_response(
                array('answer' => '0'),
                array('answer' => '')));

        $this->assertFalse($essay->is_same_response(
                array('answer' => ''),
                array('answer' => '0')));
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:43,代码来源:question_test.php

示例4: test_summarise_response

 public function test_summarise_response() {
     $longstring = str_repeat('0123456789', 50);
     $essay = test_question_maker::make_an_essay_question();
     $this->assertEquals($longstring,
             $essay->summarise_response(array('answer' => $longstring)));
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:6,代码来源:question_test.php

示例5: test_is_complete_response

 public function test_is_complete_response()
 {
     $this->resetAfterTest(true);
     // Create a new logged-in user, so we can test responses with attachments.
     $user = $this->getDataGenerator()->create_user();
     $this->setUser($user);
     // Create sample attachments to use in testing.
     $helper = test_question_maker::get_test_helper('essay');
     $attachments = array();
     for ($i = 0; $i < 4; ++$i) {
         $attachments[$i] = $helper->make_attachments_saver($i);
     }
     // Create the essay question under test.
     $essay = test_question_maker::make_an_essay_question();
     $essay->start_attempt(new question_attempt_step(), 1);
     // Test the "traditional" case, where we must recieve a response from the user.
     $essay->responserequired = 1;
     $essay->attachmentsrequired = 0;
     $essay->responseformat = 'editor';
     // The empty string should be considered an incomplete response, as should a lack of a response.
     $this->assertFalse($essay->is_complete_response(array('answer' => '')));
     $this->assertFalse($essay->is_complete_response(array()));
     // Any nonempty string should be considered a complete response.
     $this->assertTrue($essay->is_complete_response(array('answer' => 'A student response.')));
     $this->assertTrue($essay->is_complete_response(array('answer' => '0 times.')));
     $this->assertTrue($essay->is_complete_response(array('answer' => '0')));
     // Test the case where two files are required.
     $essay->attachmentsrequired = 2;
     // Attaching less than two files should result in an incomplete response.
     $this->assertFalse($essay->is_complete_response(array('answer' => 'A')));
     $this->assertFalse($essay->is_complete_response(array('answer' => 'A', 'attachments' => $attachments[0])));
     $this->assertFalse($essay->is_complete_response(array('answer' => 'A', 'attachments' => $attachments[1])));
     // Anything without response text should result in an incomplete response.
     $this->assertFalse($essay->is_complete_response(array('answer' => '', 'attachments' => $attachments[2])));
     // Attaching two or more files should result in a complete response.
     $this->assertTrue($essay->is_complete_response(array('answer' => 'A', 'attachments' => $attachments[2])));
     $this->assertTrue($essay->is_complete_response(array('answer' => 'A', 'attachments' => $attachments[3])));
     // Test the case in which two files are required, but the inline
     // response is optional.
     $essay->responserequired = 0;
     $this->assertFalse($essay->is_complete_response(array('answer' => '', 'attachments' => $attachments[1])));
     $this->assertTrue($essay->is_complete_response(array('answer' => '', 'attachments' => $attachments[2])));
     // Test the case in which both the response and inline text are optional.
     $essay->attachmentsrequired = 0;
     // Providing no answer and no attachment should result in an incomplete
     // response.
     $this->assertFalse($essay->is_complete_response(array('answer' => '')));
     $this->assertFalse($essay->is_complete_response(array('answer' => '', 'attachments' => $attachments[0])));
     // Providing an answer _or_ an attachment should result in a complete
     // response.
     $this->assertTrue($essay->is_complete_response(array('answer' => '', 'attachments' => $attachments[1])));
     $this->assertTrue($essay->is_complete_response(array('answer' => 'Answer text.', 'attachments' => $attachments[0])));
     // Test the case in which we're in "no inline response" mode,
     // in which the response is not required (as it's not provided).
     $essay->reponserequired = 0;
     $essay->responseformat = 'noinline';
     $essay->attachmensrequired = 1;
     $this->assertFalse($essay->is_complete_response(array()));
     $this->assertFalse($essay->is_complete_response(array('attachments' => $attachments[0])));
     // Providing an attachment should result in a complete response.
     $this->assertTrue($essay->is_complete_response(array('attachments' => $attachments[1])));
     // Ensure that responserequired is ignored when we're in inline response mode.
     $essay->reponserequired = 1;
     $this->assertTrue($essay->is_complete_response(array('attachments' => $attachments[1])));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:65,代码来源:question_test.php

示例6: test_manual_graded_essay_can_grade_0

    public function test_manual_graded_essay_can_grade_0() {

        // Create an essay question.
        $essay = test_question_maker::make_an_essay_question();
        $this->start_attempt_at_question($essay, 'deferredfeedback', 10);

        // Check the right model is being used.
        $this->assertEquals('manualgraded', $this->quba->get_question_attempt(
                $this->slot)->get_behaviour_name());

        // 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($essay),
                $this->get_does_not_contain_feedback_expectation());

        // Simulate some data submitted by the student.
        $this->process_submission(array('answer' => 'This is my wonderful essay!'));

        // Verify.
        $this->check_current_state(question_state::$complete);
        $this->check_current_mark(null);
        $this->check_current_output(
                new question_contains_tag_with_attribute('textarea', 'name',
                $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')),
                $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->assertEquals('This is my wonderful essay!',
                $this->quba->get_response_summary($this->slot));

        // Process a blank comment and a grade of 0.
        $this->manual_grade('', 0);

        // Verify.
        $this->check_current_state(question_state::$mangrwrong);
        $this->check_current_mark(0);
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:43,代码来源:walkthrough_test.php

示例7: test_manual_graded_respects_display_options

 public function test_manual_graded_respects_display_options()
 {
     // This test is for MDL-43874. Manual comments were not respecting the
     // Display options for feedback.
     // The current text editor depends on the users profile setting - so it needs a valid user.
     $this->setAdminUser();
     // Create an essay question.
     $essay = test_question_maker::make_an_essay_question();
     $this->start_attempt_at_question($essay, 'deferredfeedback', 10);
     // Check the right model is being used.
     $this->assertEquals('manualgraded', $this->quba->get_question_attempt($this->slot)->get_behaviour_name());
     // 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($essay), $this->get_does_not_contain_feedback_expectation());
     // Simulate some data submitted by the student.
     $this->process_submission(array('answer' => 'This is my wonderful essay!', 'answerformat' => FORMAT_HTML));
     // Verify.
     $this->check_current_state(question_state::$complete);
     $this->check_current_mark(null);
     $this->check_current_output(new question_contains_tag_with_attribute('textarea', 'name', $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')), $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->assertEquals('This is my wonderful essay!', $this->quba->get_response_summary($this->slot));
     // Process a comment and a grade.
     $this->manual_grade('This should only appear if the displya options allow it', 5, FORMAT_HTML);
     // Verify.
     $this->check_current_state(question_state::$mangrpartial);
     $this->check_current_mark(5);
     $this->displayoptions->manualcomment = question_display_options::HIDDEN;
     $this->check_output_does_not_contain('This should only appear if the displya options allow it');
     $this->displayoptions->manualcomment = question_display_options::VISIBLE;
     $this->check_output_contains('This should only appear if the displya options allow it');
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:37,代码来源:walkthrough_test.php


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