當前位置: 首頁>>代碼示例>>PHP>>正文


PHP test_question_maker::get_test_helper方法代碼示例

本文整理匯總了PHP中test_question_maker::get_test_helper方法的典型用法代碼示例。如果您正苦於以下問題:PHP test_question_maker::get_test_helper方法的具體用法?PHP test_question_maker::get_test_helper怎麽用?PHP test_question_maker::get_test_helper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在test_question_maker的用法示例。


在下文中一共展示了test_question_maker::get_test_helper方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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


注:本文中的test_question_maker::get_test_helper方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。