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


PHP Evaluation::fetchRelatedCustomAnswers方法代码示例

本文整理汇总了PHP中Evaluation::fetchRelatedCustomAnswers方法的典型用法代码示例。如果您正苦于以下问题:PHP Evaluation::fetchRelatedCustomAnswers方法的具体用法?PHP Evaluation::fetchRelatedCustomAnswers怎么用?PHP Evaluation::fetchRelatedCustomAnswers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Evaluation的用法示例。


在下文中一共展示了Evaluation::fetchRelatedCustomAnswers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dataAction

    public function dataAction()
    {
        $request = $this->getRequest();
        $id = $this->getSanParam('id');
        //get training and evaluation ids
        list($evaluation_id, $training_id) = Evaluation::fetchAssignment($id);
        if (!$evaluation_id) {
            $status->setStatusMessage(t('The evaluation could not be loaded.'));
            return;
        }
        //load training
        $trainingTable = new Training();
        $course_name = $trainingTable->getCourseName($training_id);
        $this->view->assign('course_name', $course_name);
        list($title, $qtext, $qtype, $qid) = $this->_fetchQuestions($evaluation_id);
        $answerArray = Evaluation::fetchRelatedCustomAnswers($evaluation_id);
        if ($request->isPost()) {
            //validate
            $status = ValidationContainer::instance();
            if ($status->hasError()) {
                $status->setStatusMessage(t('The evaluation could not be saved.'));
            } else {
                //make sure we have at least one response
                $found = false;
                foreach ($qid as $qidi) {
                    if ($this->getSanParam('value_' . $qidi) !== null && $this->getSanParam('value_' . $qidi) !== '') {
                        $found = true;
                    }
                }
                if ($found) {
                    //save response row
                    $qr_table = new ITechTable(array('name' => 'evaluation_response'));
                    $qr_row = $qr_table->createRow();
                    $qr_row->evaluation_to_training_id = $id;
                    if (isset($qr_row->trainer_person_id)) {
                        $qr_row->trainer_person_id = $this->getSanParam('trainer_id') ? $this->getSanParam('trainer_id') : null;
                    }
                    if (isset($qr_row->person_id)) {
                        $qr_row->person_id = $this->getSanParam('person_id') ? $this->getSanParam('person_id') : null;
                    }
                    $qr_id = $qr_row->save();
                    //save question rows
                    $erq_table = new ITechTable(array('name' => 'evaluation_question_response'));
                    foreach ($qid as $qk => $qidi) {
                        //  $q_table = new ITechTable(array('name'=>'evaluation_question'));
                        $qrow = $erq_table->createRow();
                        $qrow->evaluation_response_id = $qr_id;
                        $qrow->evaluation_question_id = $qidi;
                        $response_value = $this->getSanParam('value_' . $qidi);
                        if ($qtype[$qk] == 'Text' || !empty($answerArray[$qidi])) {
                            // is text or relabeled (will store as text)
                            $qrow->value_text = $response_value;
                        } else {
                            $qrow->value_int = $response_value;
                        }
                        if ($response_value) {
                            $qrow->save();
                        }
                    }
                }
                if ($this->getSanParam('go')) {
                    $this->_redirect('training/edit/id/' . $training_id);
                }
            }
        }
        $this->view->assign('title', $title);
        $this->view->assign('qtext', $qtext);
        $this->view->assign('qtype', $qtype);
        $this->view->assign('qid', $qid);
        $this->view->assign('answers', $answerArray);
        // list of trainers
        require_once 'models/table/TrainingToTrainer.php';
        require_once 'models/table/PersonToTraining.php';
        $this->view->assign('trainers', TrainingToTrainer::getTrainers($training_id)->toArray());
        $this->view->assign('participants', PersonToTraining::getParticipants($training_id)->toArray());
        // all evaluations attached to this training
        if ($training_id) {
            $otherEvalDropDown = '';
            $db = $this->dbfunc();
            $otherEvals = $db->fetchAll('SELECT ett.id, evaluation_id, title
									FROM evaluation_to_training as ett
									LEFT JOIN evaluation e ON e.id = ett.evaluation_id
									WHERE e.is_deleted = 0 AND ett.training_id = ?', $training_id);
            if ($otherEvals && count($otherEvals) > 1) {
                $selectOptions = array();
                foreach ($otherEvals as $v) {
                    if ($v['id'] && $v['title']) {
                        $selectOptions[] = "<option value=\"{$v['id']}\"" . ($id == $v['id'] ? ' selected' : '') . ">{$v['title']}</option>";
                    }
                }
                $otherEvalDropDown = '<select id="other_evals" name="other_evals">' . implode('', $selectOptions) . '</select>';
            }
            $this->view->assign('otherEvalDropDown', $otherEvalDropDown);
        }
    }
开发者ID:falafflepotatoe,项目名称:trainsmart-code,代码行数:95,代码来源:EvaluationController.php


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