public function editAction()
 {
     if (!$this->hasACL('edit_evaluations')) {
         $this->doNoAccessError();
     }
     $request = $this->getRequest();
     $qid = $this->getSanParam('qid');
     $qtext = $this->getSanParam('qtext');
     $qtype = $this->getSanParam('qtype');
     $title = $this->getSanParam('title');
     if ($request->isPost()) {
         //validate
         $status = ValidationContainer::instance();
         $status->checkRequired($this, 'title', t('Title'));
         foreach ($qtext as $i => $t) {
             if ($t and !$qtype[$i]) {
                 $status->addError('qtype', t('You must choose a question type for each question.'));
                 break;
             }
             if (!$t and $qtype[$i]) {
                 $status->addError('qtype', t('You must enter question text for each question.'));
                 break;
             }
         }
         $custom_answers = array();
         $useCustomAnswers = $this->getSanParam('qrelabel');
         foreach ($qtext as $i => $val) {
             $custom_answers[] = $useCustomAnswers[$i] ? $this->getSanParam('answers' . ($i + 1)) : array();
         }
         if ($status->hasError()) {
             $status->setStatusMessage(t('The evaluation could not be saved.'));
         } else {
             $ev = new Evaluation();
             $ev_row = $ev->find($this->getSanParam('id'))->current();
             $ev_row->title = $title;
             if ($id = $ev_row->save()) {
                 $ev->updateQuestions($id, $qtext, $qtype, $qid, $custom_answers) or $status->setStatusMessage(t('Error saving questions.'));
                 $status->setStatusMessage(t('The evaluation was saved.'));
                 $this->_redirect('evaluation/browse');
             } else {
                 $status->setStatusMessage(t('The evaluation could not be saved.'));
             }
         }
     } else {
         if ($id = $this->getSanParam('id')) {
             list($title, $qtext, $qtype, $qid) = $this->_fetchQuestions();
             $answers = Evaluation::fetchCustomAnswers($id);
             if (count($answers)) {
                 $answers = $answers->toArray();
             }
             $this->view->assign('answers', $answers);
         }
     }
     $this->view->assign('title', $title);
     $this->view->assign('qid', $qid);
     $this->view->assign('qtext', $qtext);
     $this->view->assign('qtype', $qtype);
 }