本文整理汇总了PHP中Evaluation::fetchCustomAnswers方法的典型用法代码示例。如果您正苦于以下问题:PHP Evaluation::fetchCustomAnswers方法的具体用法?PHP Evaluation::fetchCustomAnswers怎么用?PHP Evaluation::fetchCustomAnswers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Evaluation
的用法示例。
在下文中一共展示了Evaluation::fetchCustomAnswers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
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);
}