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


PHP Question::setTitle方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:emacsattic,项目名称:symfony,代码行数:15,代码来源:actions.class.php

示例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());
 }
开发者ID:micaelamenara,项目名称:MultipleChoiceExams,代码行数:29,代码来源:IntegrationExamTest.php

示例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;
 }
开发者ID:rhertzog,项目名称:lcs,代码行数:25,代码来源:question.class.php


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