Пример #1
0
 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;
 }
Пример #2
0
 public function addAnswerAction()
 {
     $questionId = $this->_getParam('questionId');
     $key = $this->_getParam('key');
     if ($key != "") {
         $question = $this->_questions[$questionId];
         $answer = $question->getAnswer($key);
     } else {
         $answer = new SxCms_Survey_Question_Answer();
     }
     if ($this->getRequest()->isPost()) {
         $answer->setSurveyQuestionId($questionId)->setAnswer($this->_getParam('answer'));
         if ($key != "") {
             $question = $this->_questions[$questionId];
             $question->removeAnswer($key);
         }
         $question = $this->_questions[$answer->getSurveyQuestionId()];
         $question->addAnswer($answer, $key);
     }
     $this->view->survey = $this->_survey;
     $this->_helper->layout()->disableLayout();
     $this->render('answertable');
 }