/** * @param Question $question * @return array */ private function prepareQuestion(Question $question) { $questionData = array(); $questionData['id'] = $question->getId(); $questionData['title'] = $question->getTitle(); $questionData['content'] = $question->getContent(); $questionData['type'] = $question->getType(); $questionData['nextQuestionId'] = $question->getNextQuestionId(); $questionData['tickLength'] = $question->getTickLength(); /** * @var PotentialAnswer $potentialAnswer */ foreach ($question->getPotentialAnswers() as $potentialAnswer) { $questionData['potentialAnswers'][] = array('id' => $potentialAnswer->getId(), 'answer' => $potentialAnswer->getAnswer(), 'questionId' => $question->getId(), 'nextQuestionId' => $potentialAnswer->getNextQuestionId(), 'realAnswer' => $potentialAnswer->getRealAnswer()); } /** * @var QuestionAttachment $attachment */ foreach ($question->getAttachments() as $attachment) { $questionData['attachments'][] = array('id' => $attachment->getId(), 'title' => $attachment->getTitle(), 'path' => $attachment->getPath(), 'description' => $attachment->getDescription(), 'questionId' => $question->getId()); } return $questionData; }
private function parseGroupFixAnswer(Question $question, User $user) { $answers = array(); $repository = $this->getDoctrine()->getRepository('AppBundle:MultiAnswer'); /** * @var MultiAnswer $multiAnswers */ $multiAnswers = $repository->findBy(array('question_id' => $question->getId(), 'created_by' => $user->getId())); /** * @var MultiAnswer $multiAnswer */ foreach ($multiAnswers as $multiAnswer) { $answers[$multiAnswer->getAnswerKey()] = $multiAnswer->getAnswer(); } return $answers; }