public function getAnswerByQuestion(SxCms_Survey_Question $question) { $db = Zend_Registry::get('db'); $select = $db->select()->from(array('sqa' => 'SurveyQuestionAnswer'), array('*'))->where('sqa.survey_question_id = ?', $question->getId()); $results = $db->fetchAll($select); foreach ($results as $result) { $answer = new SxCms_Survey_Question_Answer(); $answer->setId($result['answer_id'])->setSurveyQuestionId($result['survey_question_id'])->setAnswer($result['answer']); $question->addAnswer($answer, $result['answer_id']); } return; }
public function getQuestionBySurvey(SxCms_Survey $survey) { $db = Zend_Registry::get('db'); $select = $db->select()->from(array('sq' => 'SurveyQuestion'), array('*'))->where('sq.survey_id = ?', $survey->getId())->where('sq.language = ?', $survey->getLanguage()); $results = $db->fetchAll($select); foreach ($results as $result) { $question = new SxCms_Survey_Question(); $question->setId($result['question_id'])->setSurveyId($result['survey_id'])->setLanguage($result['language'])->setQuestion($result['question'])->setType($result['type'])->setComment($result['comment']); $survey->addQuestion($question, $result['question_id']); $proxy = new SxCms_Survey_Question_Answer_Proxy(); $proxy->getAnswerByQuestion($question); } return; }
public function addQuestionAction() { $key = $this->_getParam('key', null); if ($key != '') { $question = $this->_survey->getQuestion($key); } else { $question = new SxCms_Survey_Question(); } if ($this->getRequest()->isPost()) { $question->setQuestion($this->_getParam('question'))->setType($this->_getParam('type'))->setComment($this->_getParam('comment')); $this->_survey->addQuestion($question, $key); } $this->view->survey = $this->_survey; $this->view->question = $question; $this->_helper->layout()->disableLayout(); $this->render('questiontable'); }