本文整理汇总了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;
}
示例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());
}
示例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()));
}
示例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?
}