本文整理汇总了PHP中Question::setTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::setTitle方法的具体用法?PHP Question::setTitle怎么用?PHP Question::setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::setTitle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeAdd
public function executeAdd()
{
if ($this->getRequest()->getMethod() == sfRequest::POST) {
// create question
$user = $this->getUser()->getSubscriber();
$question = new Question();
$question->setTitle($this->getRequestParameter('title'));
$question->setBody($this->getRequestParameter('body'));
$question->setUser($user);
$question->save();
$user->isInterestedIn($question);
$question->addTagsForUser($this->getRequestParameter('tag'), $user->getId());
return $this->redirect('@question?stripped_title=' . $question->getStrippedTitle());
}
}
示例2: testTimeLeftZero
/**
* @expectedException mdagostino\MultipleChoiceExams\ExpiredTimeException
* @expectedExceptionMessage There is no left time to complete the exam.
*/
public function testTimeLeftZero()
{
// This test checks if the questions are not available to be answered
// when the time to complete the exam is exactly the duration of the exam.
$exam = new Exam();
$exam->setDuration(30);
$examTimer = \Mockery::mock('ExamTimer');
// The time is in seconds, 30 minutes are 1800 seconds.
$examTimer->shouldReceive('getTime')->andReturn(0, 1000, 1800);
$exam->setTimer($examTimer);
for ($i = 0; $i < 10; $i++) {
$available_answers = array('one', 'two', 'three');
$right_answers = array('one', 'three');
$question = new Question();
$question->setTitle('Question ' . $i)->setDescription('Description for question ' . $i)->setAvailableAnswers($available_answers)->setRightAnswers($right_answers);
$questions[] = $question;
}
$exam->setQuestions($questions);
$exam->start();
$exam->answerQuestion(0, array('one'));
$exam->answerQuestion(1, array('one', 'two'));
$exam->answerQuestion(2, array('one', 'three'));
$exam->finalize();
$this->assertFalse($exam->isApproved());
}
示例3: duplicate
/**
* duplicate question from DB
*
* @author Sebastien Piraux <pir@cerdecam.be>
* @return object duplicated question
*/
public function duplicate()
{
// question
$duplicated = new Question();
$duplicated->setTitle($this->title);
$duplicated->setDescription($this->description);
$duplicated->setType($this->type);
$duplicated->setGrade($this->grade);
$duplicated->setCategoryId($this->categoryId);
$duplicatedId = $duplicated->save();
// attachment need to be copied in the correct repository but for that we need the id
if (!empty($this->attachment) && file_exists($this->questionDirSys . $this->attachment)) {
$duplicated->copyAttachment($this->questionDirSys . $this->attachment);
}
// else $duplicated->attachment keeps its default value
// and its answers
$duplicated->answer = $this->answer->duplicate($duplicatedId);
return $duplicated;
}