/**
  * @param ISurveyQuestionTemplate $question
  * @return bool
  */
 public function belongsTo(ISurveyQuestionTemplate $question)
 {
     foreach ($this->getQuestions() as $q) {
         if ($q->getIdentifier() === $question->getIdentifier()) {
             return true;
         }
     }
     return false;
 }
Beispiel #2
0
 /**
  * @param ISurveyQuestionTemplate $question
  * @return ISurveyAnswer
  */
 public function findAnswerByQuestion(ISurveyQuestionTemplate $question)
 {
     foreach ($this->getSteps() as $step) {
         if ($step instanceof SurveyRegularStep) {
             $answer = $step->getAnswerByTemplateId($question->getIdentifier());
             if (!is_null($answer)) {
                 return $answer;
             }
         }
     }
     return null;
 }
 /**
  * @param ISurveyQuestionTemplate $question
  * @param mixed $answer_value
  * @return ISurveyAnswer
  */
 public function buildAnswer(ISurveyQuestionTemplate $question, $answer_value)
 {
     $answer = new SurveyAnswer();
     if (is_array($answer_value)) {
         $answer_value = str_replace('{comma}', ',', $answer_value);
         $answer->Value = implode(',', $answer_value);
     } else {
         $answer->Value = $answer_value;
     }
     $answer->QuestionID = $question->getIdentifier();
     return $answer;
 }