当前位置: 首页>>代码示例>>PHP>>正文


PHP Evaluation::insertQuestions方法代码示例

本文整理汇总了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);
 }
开发者ID:falafflepotatoe,项目名称:trainsmart-code,代码行数:50,代码来源:EvaluationController.php


注:本文中的Evaluation::insertQuestions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。