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


PHP Survey::addQuestion方法代码示例

本文整理汇总了PHP中Survey::addQuestion方法的典型用法代码示例。如果您正苦于以下问题:PHP Survey::addQuestion方法的具体用法?PHP Survey::addQuestion怎么用?PHP Survey::addQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Survey的用法示例。


在下文中一共展示了Survey::addQuestion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post

 public function post()
 {
     if (!isset($this->get['survey_id'], $this->post['question'])) {
         $this->message = "Missing one or more required parameters";
         $this->status = 400;
         return;
     }
     $survey = new Survey($this->get['survey_id']);
     if (!$survey->exists()) {
         $this->message = "Survey does not exist";
         $this->status = 404;
         return;
     }
     if (($questionID = $survey->addQuestion($this->post['question'])) === false) {
         $this->message = 'Internal Server Error';
         $this->status = 500;
         return;
     }
     $surveyData = $survey->apiData();
     $this->response[$this->slug][] = $surveyData['questions'][$questionID];
     return;
 }
开发者ID:nickyleach,项目名称:OSTSurvey,代码行数:22,代码来源:QuestionsAPIController.php

示例2: testSurveyName

 public function testSurveyName()
 {
     $survey = new Survey();
     $survey->setSurveyName("yesno");
     $survey->setDescription('stuff');
     $q = new SurveyQuestion();
     $q->setType(QuestionType::YesNo());
     $q->setQuestion("A question");
     $survey->addQuestion($q);
     //add another question
     $q2 = new SurveyQuestion();
     $q2->setType(QuestionType::StarRating());
     $secondQuestion = "Second question";
     $q2->setQuestion($secondQuestion);
     $survey->addQuestion($q2);
     $this->surveyManager->createSurvey($survey);
     SurveyEntityManager::testClear();
     $service = $this->newSurveyService();
     $this->request['Body'] = "yesno";
     $this->request['From'] = "1234";
     $serviced = $service->service();
     $this->assertTrue($serviced);
     $this->request['Body'] = "no";
     $this->request['From'] = "1234";
     $serviced = $service->service();
     $this->assertTrue($serviced);
     $this->assertContains($secondQuestion, $service->getResponse()->getContent());
 }
开发者ID:sarhanm,项目名称:sms-survey,代码行数:28,代码来源:SurveyServiceTest.php

示例3: testDeleteQuestionFromSurvey

 public function testDeleteQuestionFromSurvey()
 {
     $survey = new Survey();
     $survey->setSurveyName("hi");
     $survey->setDescription('stuff');
     $qtypes = QuestionType::toArray();
     $max = rand(4, 5);
     for ($i = 0; $i < $max; ++$i) {
         $q = new SurveyQuestion();
         $q->setType(new QuestionType(rand(1, count($qtypes))));
         $q->setQuestion("q" . $i);
         $survey->addQuestion($q);
     }
     $this->manager->createSurvey($survey);
     $toDelete = $survey->getQuestions()[rand(0, $max - 1)];
     $idToDelete = $toDelete->getId();
     $survey->deleteQuestion($idToDelete);
     $this->manager->updateSurvey($survey);
     $this->assertEquals($max - 1, count($survey->getQuestions()));
 }
开发者ID:sarhanm,项目名称:sms-survey,代码行数:20,代码来源:SurveyManagerTest.php

示例4: testTagCloud

 public function testTagCloud()
 {
     $survey = new Survey();
     $survey->setSurveyName("hi");
     $survey->setDescription('stuff');
     $q = new SurveyQuestion();
     $q->setType(QuestionType::Text());
     $q->setQuestion("Your Suggestions");
     $survey->addQuestion($q);
     $this->manager->createSurvey($survey);
     $max = rand(1, 20);
     for ($i = 0; $i < $max; ++$i) {
         $val = $this->getRandomString();
         $ans = new SurveyAnswer();
         $ans->setAnswer($val);
         $ans->setAnsweredBy("+12064122496");
         $this->manager->addAnswer($q->getId(), $ans);
     }
     $answers = $this->manager->getAnswers($survey->getId());
     $strArr = ReportChartFormatter::getChartData($answers->getAnswers($q->getId()), ChartFormats::TagCloud());
     $this->assertNotNull($strArr);
     //TODO: how the heck do i test this? I guess that it just works?
 }
开发者ID:sarhanm,项目名称:sms-survey,代码行数:23,代码来源:AnswerChartFormatterTest.php


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