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


PHP Question::getErrors方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $question = new Question();
     $question->question = Input::get('question');
     $question->right_answer = Input::get('right_answer');
     $question->wrong_answer1 = Input::get('wrong_answer1');
     $question->wrong_answer2 = Input::get('wrong_answer2');
     $question->wrong_answer3 = Input::get('wrong_answer3');
     $question->category = Input::get('category');
     if (!$question->save()) {
         $errors = $question->getErrors();
     } else {
         return Redirect::action('QuestionsController@show', $question->id)->with(array('question', $question));
     }
 }
开发者ID:air-talk,项目名称:Air-Talk,代码行数:20,代码来源:QuestionsController.php

示例2: actionCreatequestion

 public function actionCreatequestion()
 {
     $questionModel = new Question();
     if (isset($_POST["Question"])) {
         $questionModel->attributes = $_POST["Question"];
         $questionModel->content = htmlspecialchars($_POST["Question"]["content"]);
         $questionModel->title = htmlspecialchars($_POST["Question"]["title"]);
         $questionModel->create_time = time();
         $questionModel->update_time = time();
         $questionModel->create_user = Yii::app()->user->id;
         if ($questionModel->save()) {
             Question::model()->inserNotify($questionModel->id);
             $topic_ids = "";
             $topicArray = explode(",", trim($questionModel->topic_ids, ","));
             $topic_ids .= ",";
             for ($i = 0; $i < count($topicArray); $i++) {
                 $model = Topic::model()->find("name='" . $topicArray[$i] . "'");
                 if ($model == NULL) {
                     $newModel = new Topic();
                     $newModel->name = $topicArray[$i];
                     $newModel->create_user = Yii::app()->user->id;
                     $newModel->create_time = time();
                     if ($newModel->save()) {
                         $topic_ids .= $newModel->id . ",";
                     }
                 } else {
                     $topic_ids .= $model->id . ",";
                 }
             }
             Question::model()->updateByPk($questionModel->id, array("topic_ids" => $topic_ids));
         }
         echo CJSON::encode($questionModel->getErrors());
     }
 }
开发者ID:ruzuojun,项目名称:shiqu,代码行数:34,代码来源:DefaultController.php

示例3: index


//.........这里部分代码省略.........
                             $oSubQuestion->relevance = isset($aRelevance[$iScaleID][$iPosition]) ? $aRelevance[$iScaleID][$iPosition] : "";
                         } else {
                             $oSubQuestion = Question::model()->find("qid=:qid AND language=:language", array(":qid" => $aInsertQID[$iScaleID][$iPosition], ':language' => $sLanguage));
                             if (!$oSubQuestion) {
                                 $oSubQuestion = new Question();
                             }
                             $oSubQuestion->sid = $iSurveyID;
                             $oSubQuestion->qid = $aInsertQID[$iScaleID][$iPosition];
                             $oSubQuestion->gid = $iQuestionGroupID;
                             $oSubQuestion->question_order = $iPosition + 1;
                             $oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
                             $oSubQuestion->question = $subquestionvalue;
                             $oSubQuestion->parent_qid = $iQuestionID;
                             $oSubQuestion->language = $sLanguage;
                             $oSubQuestion->scale_id = $iScaleID;
                             $oSubQuestion->relevance = isset($aRelevance[$iScaleID][$iPosition]) ? $aRelevance[$iScaleID][$iPosition] : "";
                         }
                     }
                     if ($oSubQuestion->qid) {
                         switchMSSQLIdentityInsert('questions', true);
                         $bSubQuestionResult = $oSubQuestion->save();
                         switchMSSQLIdentityInsert('questions', false);
                     } else {
                         $bSubQuestionResult = $oSubQuestion->save();
                     }
                     if ($bSubQuestionResult) {
                         if (substr($subquestionkey, 0, 3) != 'new' && isset($aOldCodes[$iScaleID][$iPosition]) && $aCodes[$iScaleID][$iPosition] !== $aOldCodes[$iScaleID][$iPosition]) {
                             Condition::model()->updateAll(array('cfieldname' => '+' . $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID . $aCodes[$iScaleID][$iPosition], 'value' => $aCodes[$iScaleID][$iPosition]), 'cqid=:cqid AND cfieldname=:cfieldname AND value=:value', array(':cqid' => $iQuestionID, ':cfieldname' => $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID, ':value' => $aOldCodes[$iScaleID][$iPosition]));
                         }
                         if (!isset($aInsertQID[$iScaleID][$iPosition])) {
                             $aInsertQID[$iScaleID][$iPosition] = $oSubQuestion->qid;
                         }
                     } else {
                         $aErrors = $oSubQuestion->getErrors();
                         if (count($aErrors)) {
                             //$sErrorMessage=gT("Question could not be updated with this errors:");
                             foreach ($aErrors as $sAttribute => $aStringErrors) {
                                 foreach ($aStringErrors as $sStringErrors) {
                                     Yii::app()->setFlashMessage(sprintf(gT("Error on %s for subquestion %s: %s"), $sAttribute, $aCodes[$iScaleID][$iPosition], $sStringErrors), 'error');
                                 }
                             }
                         } else {
                             Yii::app()->setFlashMessage(sprintf(gT("Subquestions %s could not be updated."), $aCodes[$iScaleID][$iPosition]), 'error');
                         }
                     }
                     $iPosition++;
                 }
             }
         }
         LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
         // Do it only if there are no error ?
         if (!isset($aErrors) || !count($aErrors)) {
             if (!Yii::app()->request->getPost('bFullPOST')) {
                 Yii::app()->session['flashmessage'] = gT("Not all subquestions were saved. This usually happens due to server limitations ( PHP setting max_input_vars) - please contact your system administrator.");
             } else {
                 Yii::app()->session['flashmessage'] = gT("Subquestions were successfully saved.");
             }
         }
         //$action='editsubquestions';
         LimeExpressionManager::SetDirtyFlag();
         if ($sDBOutput != '') {
             echo 'Problem in database controller: ' . $sDBOutput;
         } else {
             if (Yii::app()->request->getPost('close-after-save') === 'true') {
                 $this->getController()->redirect(array('/admin/questions/sa/view/surveyid/' . $iSurveyID . '/gid/' . $iQuestionGroupID . '/qid/' . $iQuestionID));
             }
开发者ID:joaocc,项目名称:LimeSurvey--LimeSurvey,代码行数:67,代码来源:database.php

示例4: index


//.........这里部分代码省略.........
                             $oSubQuestion->relevance = $aRelevance[0][$iPosition];
                         } else {
                             $oSubQuestion = Question::model()->find("qid=:qid AND language=:language", array(":qid" => $aInsertQID[$iScaleID][$iPosition], ':language' => $sLanguage));
                             if (!$oSubQuestion) {
                                 $oSubQuestion = new Question();
                             }
                             $oSubQuestion->sid = $iSurveyID;
                             $oSubQuestion->qid = $aInsertQID[$iScaleID][$iPosition];
                             $oSubQuestion->gid = $iQuestionGroupID;
                             $oSubQuestion->question_order = $iPosition + 1;
                             $oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
                             $oSubQuestion->question = $subquestionvalue;
                             $oSubQuestion->parent_qid = $iQuestionID;
                             $oSubQuestion->language = $sLanguage;
                             $oSubQuestion->scale_id = $iScaleID;
                             $oSubQuestion->relevance = $aRelevance[$iScaleID][$iPosition];
                         }
                     }
                     if ($oSubQuestion->qid) {
                         switchMSSQLIdentityInsert('questions', true);
                         $bSubQuestionResult = $oSubQuestion->save();
                         switchMSSQLIdentityInsert('questions', false);
                     } else {
                         $bSubQuestionResult = $oSubQuestion->save();
                     }
                     if ($bSubQuestionResult) {
                         if (substr($subquestionkey, 0, 3) != 'new' && isset($aOldCodes[$iScaleID][$iPosition]) && $aCodes[$iScaleID][$iPosition] !== $aOldCodes[$iScaleID][$iPosition]) {
                             Condition::model()->updateAll(array('cfieldname' => '+' . $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID . $aCodes[$iScaleID][$iPosition], 'value' => $aCodes[$iScaleID][$iPosition]), 'cqid=:cqid AND cfieldname=:cfieldname AND value=:value', array(':cqid' => $iQuestionID, ':cfieldname' => $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID, ':value' => $aOldCodes[$iScaleID][$iPosition]));
                         }
                         if (!isset($aInsertQID[$iScaleID][$iPosition])) {
                             $aInsertQID[$iScaleID][$iPosition] = $oSubQuestion->qid;
                         }
                     } else {
                         $aErrors = $oSubQuestion->getErrors();
                         if (count($aErrors)) {
                             //$sErrorMessage=gT("Question could not be updated with this errors:");
                             foreach ($aErrors as $sAttribute => $aStringErrors) {
                                 foreach ($aStringErrors as $sStringErrors) {
                                     Yii::app()->setFlashMessage(sprintf(gT("Error on %s for subquestion %s: %s"), $sAttribute, $aCodes[$iScaleID][$iPosition], $sStringErrors), 'error');
                                 }
                             }
                         } else {
                             Yii::app()->setFlashMessage(sprintf(gT("Subquestions %s could not be updated."), $aCodes[$iScaleID][$iPosition]), 'error');
                         }
                     }
                     $iPosition++;
                 }
             }
         }
         LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
         // Do it only if there are no error ?
         if (!isset($aErrors) || !count($aErrors)) {
             if (!Yii::app()->request->getPost('bFullPOST')) {
                 Yii::app()->session['flashmessage'] = gT("Not all subquestions were saved. This usually happens due to server limitations ( PHP setting max_input_vars) - please contact your system administrator.");
             } else {
                 Yii::app()->session['flashmessage'] = gT("Subquestions were successfully saved.");
             }
         }
         //$action='editsubquestions';
         LimeExpressionManager::SetDirtyFlag();
         if ($sDBOutput != '') {
             echo $sDBOutput;
         } else {
             $this->getController()->redirect(array('/admin/questions/sa/subquestions/surveyid/' . $iSurveyID . '/gid/' . $iQuestionGroupID . '/qid/' . $iQuestionID));
         }
     }
开发者ID:nicbon,项目名称:LimeSurvey,代码行数:67,代码来源:database.php

示例5: set_question_sub_questions

 public function set_question_sub_questions($sSessionKey, $iSurveyID, $iQuestionID, $data)
 {
     $data_array = unserialize($data);
     Yii::app()->loadHelper('database');
     $aSurveyLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
     $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
     array_unshift($aSurveyLanguages, $sBaseLanguage);
     $arQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
     $sQuestionType = $arQuestion['type'];
     // Checked
     $aQuestionTypeList = getQuestionTypeList('', 'array');
     $iScaleCount = $aQuestionTypeList[$sQuestionType]['subquestions'];
     //$clang = $this->getController()->lang;
     // First delete any deleted ids
     //$aDeletedQIDs = explode(' ', trim($data));
     $aDeletedQIDs = explode('+', $data_array['deletedqids']);
     $iQuestionGroupID = $data_array['gid'];
     LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
     $aDeletedQIDs = array_unique($aDeletedQIDs, SORT_NUMERIC);
     foreach ($aDeletedQIDs as $iDeletedQID) {
         $iDeletedQID = (int) $iDeletedQID;
         if ($iDeletedQID > 0) {
             // don't remove undefined
             $iInsertCount = Question::model()->deleteAllByAttributes(array('qid' => $iDeletedQID));
             if (!$iInsertCount) {
                 return "Failed to delete answer";
             }
         }
     }
     //Determine ids by evaluating the hidden field
     $aRows = array();
     $aCodes = array();
     $aOldCodes = array();
     foreach ($data_array as $key => $value) {
         $key = explode('_', $key);
         if ($key[0] == 'answer') {
             $aRows[$key[3]][$key[1]][$key[2]] = $value;
         }
         if ($key[0] == 'code') {
             $aCodes[$key[2]][] = $value;
         }
         if ($key[0] == 'oldcode') {
             $aOldCodes[$key[2]][] = $value;
         }
     }
     $aInsertQID = array();
     for ($iScaleID = 0; $iScaleID < $iScaleCount; $iScaleID++) {
         foreach ($aSurveyLanguages as $sLanguage) {
             $iPosition = 0;
             $test = '';
             foreach ($aRows[$iScaleID][$sLanguage] as $subquestionkey => $subquestionvalue) {
                 $test .= $subquestionvalue . ', ';
                 // create a new sub question
                 if (substr($subquestionkey, 0, 3) != 'new') {
                     $oSubQuestion = Question::model()->find("qid=:qid AND language=:language", array(":qid" => $subquestionkey, ':language' => $sLanguage));
                     $oSubQuestion->question_order = $iPosition + 1;
                     $oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
                     $oSubQuestion->question = $subquestionvalue;
                     $oSubQuestion->scale_id = $iScaleID;
                     // update the old sub questions
                 } else {
                     if (!isset($aInsertQID[$iScaleID][$iPosition])) {
                         $oSubQuestion = new Question();
                         $oSubQuestion->sid = $iSurveyID;
                         $oSubQuestion->gid = $iQuestionGroupID;
                         $oSubQuestion->question_order = $iPosition + 1;
                         $oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
                         $oSubQuestion->question = $subquestionvalue;
                         $oSubQuestion->parent_qid = $iQuestionID;
                         $oSubQuestion->language = $sLanguage;
                         $oSubQuestion->scale_id = $iScaleID;
                         // update old sub questions
                     } else {
                         $oSubQuestion = Question::model()->find("qid=:qid AND language=:language", array(":qid" => $aInsertQID[$iScaleID][$iPosition], ':language' => $sLanguage));
                         if (!$oSubQuestion) {
                             $oSubQuestion = new Question();
                         }
                         $oSubQuestion->sid = $iSurveyID;
                         $oSubQuestion->gid = $iQuestionGroupID;
                         $oSubQuestion->question_order = $iPosition + 1;
                         $oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
                         $oSubQuestion->question = $subquestionvalue;
                         $oSubQuestion->parent_qid = $iQuestionID;
                         $oSubQuestion->language = $sLanguage;
                         $oSubQuestion->scale_id = $iScaleID;
                     }
                 }
                 $bSubQuestionResult = $oSubQuestion->save();
                 if ($bSubQuestionResult) {
                     if (substr($subquestionkey, 0, 3) != 'new' && isset($aOldCodes[$iScaleID][$iPosition]) && $aCodes[$iScaleID][$iPosition] !== $aOldCodes[$iScaleID][$iPosition]) {
                         Condition::model()->updateAll(array('cfieldname' => '+' . $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID . $aCodes[$iScaleID][$iPosition], 'value' => $aCodes[$iScaleID][$iPosition]), 'cqid=:cqid AND cfieldname=:cfieldname AND value=:value', array(':cqid' => $iQuestionID, ':cfieldname' => $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID, ':value' => $aOldCodes[$iScaleID][$iPosition]));
                     }
                     if (!isset($aInsertQID[$iScaleID][$iPosition])) {
                         $aInsertQID[$iScaleID][$iPosition] = $oSubQuestion->qid;
                     }
                 } else {
                     $aErrors = $oSubQuestion->getErrors();
                     if (count($aErrors)) {
                         foreach ($aErrors as $sAttribute => $aStringErrors) {
                             foreach ($aStringErrors as $sStringErrors) {
//.........这里部分代码省略.........
开发者ID:sevenearths,项目名称:limesurvey-api-test,代码行数:101,代码来源:remotecontrol_handle.php

示例6: index


//.........这里部分代码省略.........
                             $oSubQuestion->sid = $iSurveyID;
                             $oSubQuestion->gid = $iQuestionGroupID;
                             $oSubQuestion->question_order = $iPosition + 1;
                             $oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
                             $oSubQuestion->question = $subquestionvalue;
                             $oSubQuestion->parent_qid = $iQuestionID;
                             $oSubQuestion->language = $sLanguage;
                             $oSubQuestion->scale_id = $iScaleID;
                         } else {
                             $oSubQuestion = Question::model()->find("qid=:qid AND language=:language", array(":qid" => $aInsertQID[$iScaleID][$iPosition], ':language' => $sLanguage));
                             if (!$oSubQuestion) {
                                 $oSubQuestion = new Question();
                             }
                             $oSubQuestion->sid = $iSurveyID;
                             $oSubQuestion->qid = $aInsertQID[$iScaleID][$iPosition];
                             $oSubQuestion->gid = $iQuestionGroupID;
                             $oSubQuestion->question_order = $iPosition + 1;
                             $oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
                             $oSubQuestion->question = $subquestionvalue;
                             $oSubQuestion->parent_qid = $iQuestionID;
                             $oSubQuestion->language = $sLanguage;
                             $oSubQuestion->scale_id = $iScaleID;
                         }
                     }
                     $bSubQuestionResult = $oSubQuestion->save();
                     if ($bSubQuestionResult) {
                         if (substr($subquestionkey, 0, 3) != 'new' && isset($aOldCodes[$iScaleID][$iPosition]) && $aCodes[$iScaleID][$iPosition] !== $aOldCodes[$iScaleID][$iPosition]) {
                             Condition::model()->updateAll(array('cfieldname' => '+' . $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID . $aCodes[$iScaleID][$iPosition], 'value' => $aCodes[$iScaleID][$iPosition]), 'cqid=:cqid AND cfieldname=:cfieldname AND value=:value', array(':cqid' => $iQuestionID, ':cfieldname' => $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID, ':value' => $aOldCodes[$iScaleID][$iPosition]));
                         }
                         if (!isset($aInsertQID[$iScaleID][$iPosition])) {
                             $aInsertQID[$iScaleID][$iPosition] = $oSubQuestion->qid;
                         }
                     } else {
                         $aErrors = $oSubQuestion->getErrors();
                         if (count($aErrors)) {
                             //$sErrorMessage=$clang->gT("Question could not be updated with this errors:");
                             foreach ($aErrors as $sAttribute => $aStringErrors) {
                                 foreach ($aStringErrors as $sStringErrors) {
                                     Yii::app()->setFlashMessage(sprintf($clang->gT("Error on %s for subquestion %s: %s"), $sAttribute, $aCodes[$iScaleID][$iPosition], $sStringErrors), 'error');
                                 }
                             }
                         } else {
                             Yii::app()->setFlashMessage(sprintf($clang->gT("Subquestions %s could not be updated."), $aCodes[$iScaleID][$iPosition]), 'error');
                         }
                     }
                     $iPosition++;
                 }
             }
         }
         LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
         // Do it only if there are no error ?
         if (!isset($aErrors) || !count($aErrors)) {
             if (!Yii::app()->request->getPost('bFullPOST')) {
                 Yii::app()->session['flashmessage'] = $clang->gT("Not all subquestions were saved. This usually happens due to server limitations ( PHP setting max_input_vars) - please contact your system administrator.");
             } else {
                 Yii::app()->session['flashmessage'] = $clang->gT("Subquestions were successfully saved.");
             }
         }
         //$action='editsubquestions';
         LimeExpressionManager::SetDirtyFlag();
         if ($sDBOutput != '') {
             echo $sDBOutput;
         } else {
             $this->getController()->redirect(array('/admin/questions/sa/subquestions/surveyid/' . $iSurveyID . '/gid/' . $iQuestionGroupID . '/qid/' . $iQuestionID));
         }
     }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:67,代码来源:database.php

示例7: createQuestion

 private function createQuestion($sCode, $sType, $iGid, $iOrder)
 {
     //Need to renumber all questions on or after this
     $iOrder;
     $sQuery = "UPDATE {{questions}} SET question_order=question_order+1 WHERE sid=:sid AND gid=:gid AND question_order >= :order";
     Yii::app()->db->createCommand($sQuery)->bindValues(array(':sid' => $this->iSurveyId, ':gid' => $iGid, ':order' => $iOrder))->query();
     if ($sType == "h") {
         $sNewQuestionType = "X";
     } else {
         $sNewQuestionType = $this->aDelphiCodes[$sType]['questiontype'];
     }
     switch ($sType) {
         case 'hist':
             $newQuestionText = "<p class='kce-default'>" . $this->get("historytext_{$this->sLanguage}", 'Survey', $this->iSurveyId, $this->get('historytext', null, null, $this->settings['historytext']['default'])) . "</p>";
             break;
         case 'comm':
             $newQuestionText = $this->get("commenttext_{$this->sLanguage}", 'Survey', $this->iSurveyId, $this->get('commenttext', null, null, $this->settings['commenttext']['default']));
             break;
         case 'comh':
             $oQuestionComment = Question::model()->find("sid=:sid and title=:title and language=:language", array(":sid" => $this->iSurveyId, ":title" => $sCode . "comm", ":language" => $this->sLanguage));
             $newQuestionText = "<p class='kce-default'>" . $this->get("commenthist_{$this->sLanguage}", 'Survey', $this->iSurveyId, $this->get('commenthist', null, null, $this->settings['commenthist']['default'])) . "</p>";
             if (isset($oQuestionComment) && $oQuestionComment->question) {
                 $newQuestionText .= "<div class='kce-historycomment'>" . $oQuestionComment->question . "</div>";
             }
             break;
         case "h":
             $oQuestionComment = Question::model()->find("sid=:sid and title=:title and language=:language", array(":sid" => $this->iSurveyId, ":title" => $sCode, ":language" => $this->sLanguage));
             $newQuestionText = "<p class='kce-default'>" . $this->get("commenthist_{$this->sLanguage}", 'Survey', $this->iSurveyId, $this->get('commenthist', null, null, $this->settings['commenthist']['default'])) . "</p>";
             //~ if(isset($oQuestionComment) && $oQuestionComment->question)
             //~ $newQuestionText .= "<div class='kce-historycomment'>".$oQuestionComment->question."</div>";
             break;
         default:
             $newQuestionText = "";
             break;
     }
     $oQuestion = new Question();
     $oQuestion->sid = $this->iSurveyId;
     $oQuestion->gid = $iGid;
     $oQuestion->title = $sCode . $sType;
     $oQuestion->question = $newQuestionText;
     $oQuestion->help = '';
     $oQuestion->preg = '';
     $oQuestion->other = 'N';
     $oQuestion->mandatory = 'N';
     $oQuestion->type = $sNewQuestionType;
     $oQuestion->question_order = $iOrder;
     $oSurvey = Survey::model()->findByPk($this->iSurveyId);
     $oQuestion->language = $oSurvey->language;
     if ($oQuestion->save()) {
         $iQuestionId = $oQuestion->qid;
         $aLang = $oSurvey->additionalLanguages;
         foreach ($aLang as $sLang) {
             switch ($sType) {
                 case 'hist':
                     $newQuestionText = "<p class='kce-default'>" . $this->get("historytext_{$sLang}", 'Survey', $this->iSurveyId, $this->get('historytext', null, null, $this->settings['historytext']['default'])) . "</p>";
                     break;
                 case 'comm':
                     $newQuestionText = $this->get("commenttext_{$sLang}", 'Survey', $this->iSurveyId, $this->get('commenttext', null, null, $this->settings['commenttext']['default']));
                     break;
                 case 'commh':
                     $oQuestionComment = Question::model()->find("sid=:sid and title=:title and language=:language", array(":sid" => $this->iSurveyId, ":title" => $sCode . "comm", ":language" => $sLang));
                     $newQuestionText = "<p class='kce-default'>" . $this->get("commenthist_{$sLang}", 'Survey', $this->iSurveyId, $this->get('commenthist', null, null, $this->settings['commenthist']['default'])) . "</p>";
                     if (isset($oQuestionComment) && $oQuestionComment->question) {
                         $newQuestionText .= "<div class='kce-historycomment'>" . $oQuestionComment->question . "</div>";
                     }
                     break;
                 case 'h':
                     $oQuestionComment = Question::model()->find("sid=:sid and title=:title and language=:language", array(":sid" => $this->iSurveyId, ":title" => $sCode, ":language" => $sLang));
                     $newQuestionText = "<p class='kce-default'>" . $this->get("commenthist_{$sLang}", 'Survey', $this->iSurveyId, $this->get('commenthist', null, null, $this->settings['commenthist']['default'])) . "</p>";
                     if (isset($oQuestionComment) && $oQuestionComment->question) {
                         $newQuestionText .= "<div class='kce-historycomment'>" . $oQuestionComment->question . "</div>";
                     }
                     break;
                 default:
                     $newQuestionText = "";
                     break;
             }
             $oLangQuestion = new Question();
             $oLangQuestion->sid = $this->iSurveyId;
             $oLangQuestion->gid = $iGid;
             $oLangQuestion->qid = $iQuestionId;
             $oLangQuestion->title = $sCode . $sType;
             $oLangQuestion->question = $newQuestionText;
             $oLangQuestion->help = $newQuestionText;
             $oLangQuestion->type = $oQuestion->type;
             $oLangQuestion->question_order = $iOrder;
             $oLangQuestion->language = $sLang;
             if (!$oLangQuestion->save()) {
                 tracevar($oLangQuestion->getErrors());
             }
         }
         $this->addResult("Created question {$sCode}{$sType}.", 'success');
         return $iQuestionId;
     }
     $this->addResult("Unable to create question {$sCode}{$sType}, please contact the software developer.", 'error', $oQuestion->getErrors());
 }
开发者ID:SondagesPro,项目名称:LS-AutoComment_IterativeQuestionnaire,代码行数:96,代码来源:autoCommentIterativeQuestionnaire.php


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