function testTextProblem() { $content = '<problem><text>Problem question.</text><answer>The answer.</answer></problem>'; $p = ProblemFactory::create('text', $content); $txt = $p->getText(); echo "text={$txt}\nans={$p->answer}\n"; $this->assertEqual($p->getText(), 'Problem question.'); $this->assertEqual($p->answer, 'The answer.'); }
/** * Initializes the inputs with existing post data. * This method is invoked by the framework when the page is being initialized. * @param mixed event parameter */ public function onInit($param) { parent::onInit($param); // Retrieves the existing user data. This is equivalent to: // $postRecord=$this->getPost(); $problemRecord = $this->Problem; // Authorization check: only the author or the administrator can edit the post //if($postRecord->author_id!==$this->User->Name && !$this->User->IsAdmin) // throw new THttpException(500,'You are not allowed to edit this post.'); if (!$this->IsPostBack) { // Populates the input controls with the existing post data $p = ProblemFactory::create($problemRecord->problem_type, $problemRecord->content); $this->TextEdit->Text = $p->getText(); $this->AnswerEdit->Text = $p->answer; } }
public function getText() { $p = ProblemFactory::create($this->Data->problem_type, $this->Data->content); return $p->getText(); }