本文整理汇总了PHP中Evaluation::insertQuestions方法的典型用法代码示例。如果您正苦于以下问题:PHP Evaluation::insertQuestions方法的具体用法?PHP Evaluation::insertQuestions怎么用?PHP Evaluation::insertQuestions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Evaluation
的用法示例。
在下文中一共展示了Evaluation::insertQuestions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCopyAction
public function addCopyAction()
{
if (!$this->hasACL('edit_evaluations')) {
$this->doNoAccessError();
}
$request = $this->getRequest();
$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->createRow(array('title' => $title));
if ($id = $ev_row->save()) {
$ev->insertQuestions($id, $qtext, $qtype, $custom_answers);
$status->setStatusMessage(t('The new evaluation was created.'));
$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();
}
}
$this->view->assign('title', $title);
$this->view->assign('qtext', $qtext);
$this->view->assign('qtype', $qtype);
}