芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/public_html/cepali/mod/lesson/tests/pagetypes_test.php
. /** * Unit tests for page types classes * * @package mod_lesson * @category test * @copyright 2015 Jean-Michel Vedrine * @license http://www.gnu.org/copyleft/gpl.html GNU Public License */ defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/mod/lesson/locallib.php'); require_once($CFG->dirroot . '/mod/lesson/pagetypes/essay.php'); /** * This class contains the test cases for some of the functions in the lesson essay page type class. * * @copyright 2015 Jean-Michel Vedrine * @license http://www.gnu.org/copyleft/gpl.html GNU Public License */ class mod_lesson_essay_page_type_test extends advanced_testcase { public function test_lesson_essay_extract_useranswer() { // Test that reponseformat is added when not present. $answer = 'O:8:"stdClass":6:{s:4:"sent";i:1;s:6:"graded";i:1;s:5:"score";s:1:"1";' . 's:6:"answer";s:64:"
This is my answer
with bold
and
italics
";' . 's:12:"answerformat";s:1:"1";s:8:"response";s:10:"Well done!";}'; $userresponse = new stdClass; $userresponse->sent = 1; $userresponse->graded = 1; $userresponse->score = 1; $userresponse->answer = "
This is my answer
with bold
and
italics
"; $userresponse->answerformat = FORMAT_HTML; $userresponse->response = "Well done!"; $userresponse->responseformat = FORMAT_HTML; $this->assertEquals($userresponse, lesson_page_type_essay::extract_useranswer($answer)); // Test that reponseformat is not modified when present. $answer = 'O:8:"stdClass":7:{s:4:"sent";i:0;s:6:"graded";i:1;s:5:"score";s:1:"0";' . 's:6:"answer";s:64:"
This is my answer
with bold
and
italics
";' . 's:12:"answerformat";s:1:"1";s:8:"response";s:10:"Well done!";s:14:"responseformat";s:1:"2";}'; $userresponse = new stdClass; $userresponse->sent = 0; $userresponse->graded = 1; $userresponse->score = 0; $userresponse->answer = "
This is my answer
with bold
and
italics
"; $userresponse->answerformat = FORMAT_HTML; $userresponse->response = "Well done!"; $userresponse->responseformat = FORMAT_PLAIN; $this->assertEquals($userresponse, lesson_page_type_essay::extract_useranswer($answer)); } }