/** * Executes index action * * @param sfRequest $request A request object */ public function execute($request) { sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); $this->dayNumber = $this->getRequest()->getParameter('nr'); $this->questions = Doctrine_Query::create()->select('q.*, qo.*')->from('Questions q')->leftJoin('q.QuestionsOrder qo')->where('qo.day_number =? ', $this->dayNumber)->execute(); if ($this->questions) { $this->questionsCollectionForm = new questionsCollectionForm(null, array('questions' => $this->questions)); if ($this->getRequest()->hasParameter('questionsCollection')) { $this->questionsCollectionForm->bind($this->getRequest()->getParameter('questionsCollection')); if ($this->questionsCollectionForm->isValid()) { $i = 0; foreach ($this->questionsCollectionForm->getValues() as $question) { if ($this->questions[$i]->id == $question['id']) { $this->questions[$i]->fromArray($question); $this->questions[$i]->save(); $i++; } else { $invalidAnswer = QuestionsTable::getInstance()->findOneById($question['id']); $invalidAnswer->fromArray($question); $invalidAnswer->save(); } } } } } }
/** * Executes index action * * @param sfRequest $request A request object */ public function execute($request) { sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); $this->answers = QuestionsAnswersTable::getInstance()->findByQuestionId($this->getRequest()->getParameter('id')); $this->question = QuestionsTable::getInstance()->findOneById($this->getRequest()->getParameter('id')); $this->dayNumber = QuestionsOrderTable::getInstance()->findOneByQuestionId($this->getRequest()->getParameter('id')); $this->dayNumber = $this->dayNumber['day_number']; if ($this->answers) { $this->answersCollectionForm = new answersCollectionForm(null, array('answers' => $this->answers)); if ($this->getRequest()->hasParameter('answersCollection')) { $this->answersCollectionForm->bind($this->getRequest()->getParameter('answersCollection')); if ($this->answersCollectionForm->isValid()) { $i = 0; foreach ($this->answersCollectionForm->getValues() as $answer) { if ($this->answers[$i]->id == $answer['id']) { $this->answers[$i]->fromArray($answer); $this->answers[$i]->save(); $i++; } else { $invalidAnswer = QuestionsAnswersTable::getInstance()->findOneById($answer['id']); $invalidAnswer->fromArray($answer); $invalidAnswer->save(); } } } } } }
/** * Executes index action * * @param sfRequest $request A request object */ public function execute($request) { sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); $questionId = $this->getRequest()->getParameter('questionId'); $question = QuestionsTable::getInstance()->findOneById($questionId); if ($question) { $question['answer_id'] = null; $question->save(); } $this->redirect(url_for2('default', array('module' => 'questions', 'action' => 'answers'), true) . '?id=' . $questionId); }
/** * Executes index action * * @param sfRequest $request A request object */ public function execute($request) { sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); $this->question = QuestionsTable::getInstance()->findOneById($this->getRequest()->getParameter('id')); if ($this->question) { $this->deleteQuestionForm = new deleteQuestionForm(); $this->deleteQuestionForm->setDefaults($this->question->toArray()); if ($this->getRequest()->hasParameter('deleteQuestion')) { $this->deleteQuestionForm->bind($this->getRequest()->getParameter('deleteQuestion')); if ($this->deleteQuestionForm->isValid()) { $this->question->delete(); $this->redirect(url_for2('default_index', array('module' => 'questions'), true) . '?id=' . $this->question->id); } } } }
/** * Executes index action * * @param sfRequest $request A request object */ public function execute($request) { sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); $this->question = QuestionsTable::getInstance()->findOneById($this->getRequest()->getParameter('questionId')); if ($this->question) { $this->addAnswerForm = new addAnswerForm(); $this->addAnswerForm->setDefault('question_id', $this->question['id']); if ($this->getRequest()->hasParameter('addAnswer')) { $this->addAnswerForm->bind($this->getRequest()->getParameter('addAnswer')); if ($this->addAnswerForm->isValid()) { $this->questionAnswer = new QuestionsAnswers(); $this->questionAnswer->fromArray($this->addAnswerForm->getValues()); $this->questionAnswer->save(); $this->redirect(url_for2('default', array('module' => 'questions', 'action' => 'answers'), true) . '?id=' . $this->question->id); } } } }
/** * Executes index action * * @param sfRequest $request A request object */ public function execute($request) { sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); $this->editForm = new questionForm(); $this->question = QuestionsTable::getInstance()->findOneById($this->getRequest()->getParameter('id')); if ($this->question) { $this->editForm->setDefaults($this->question->toArray()); } if ($this->getRequest()->hasParameter('editQuestion')) { $this->editForm->bind($this->getRequest()->getParameter('editQuestion')); if ($this->editForm->isValid()) { $this->question->fromArray($this->editForm->getValues()); $this->question->save(); $this->getUser()->setFlash('editSuccess', true); $this->redirect(url_for2('default', array('module' => 'questions', 'action' => 'index'))); } } }
public static function getSurveyQuestions() { $q = QuestionsTable::getInstance()->createQuery('q'); return $q->execute(); }