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


PHP Answer::getErrors方法代码示例

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


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

示例1: saveQuestionnaireAnswers

 /**
  * save answers by this questionnaire.
  * for each question group then question save answer
  * //copy the questionnaire into answer
  * //then fill it with answers
  * @param questionnaire
  */
 public function saveQuestionnaireAnswers($model)
 {
     if (isset($_SESSION['datapatient'])) {
         $patients = $_SESSION['datapatient'];
     }
     $answer = new Answer();
     $answer->creator = ucfirst(Yii::app()->user->getPrenom()) . " " . strtoupper(Yii::app()->user->getNom());
     $answer->last_updated = DateTime::createFromFormat('d/m/Y', date('d/m/Y'));
     $answer->copy($model);
     $answer->type = $model->type;
     $answer->login = Yii::app()->user->id;
     $answer->id_patient = (string) $patients->id;
     $flagNoInputToSave = true;
     foreach ($answer->answers_group as $answer_group) {
         foreach ($answer_group->answers as $answerQuestion) {
             $input = $answer_group->id . "_" . $answerQuestion->id;
             if (isset($_POST['Questionnaire'][$input])) {
                 $flagNoInputToSave = false;
                 if ($answerQuestion->type != "number" && $answerQuestion->type != "expression" && $answerQuestion->type != "date") {
                     $answerQuestion->setAnswer($_POST['Questionnaire'][$input]);
                 } elseif ($answerQuestion->type == "date") {
                     $answerQuestion->setAnswerDate($_POST['Questionnaire'][$input]);
                 } else {
                     $answerQuestion->setAnswerNumerique($_POST['Questionnaire'][$input]);
                 }
             }
             //if array, specific save action
             if ($answerQuestion->type == "array") {
                 //construct each id input an dget the result to store it
                 $rows = $answerQuestion->rows;
                 $arrows = split(",", $rows);
                 $cols = $answerQuestion->columns;
                 $arcols = split(",", $cols);
                 $answerArray = "";
                 foreach ($arrows as $row) {
                     foreach ($arcols as $col) {
                         $idunique = $idquestiongroup . "_" . $question->id . "_" . $row . "_" . $col;
                         if (isset($_POST['Questionnaire'][$idunique])) {
                             $answerArray .= $_POST['Questionnaire'][$idunique] . ",";
                         }
                     }
                 }
                 $answerQuestion->setAnswer($answerArray);
             }
         }
     }
     if ($flagNoInputToSave == false) {
         if ($answer->save()) {
             Yii::app()->user->setFlash('success', Yii::t('common', 'patientFormSaved'));
         } else {
             Yii::app()->user->setFlash('error', Yii::t('common', 'patientFormNotSaved'));
             Yii::log("pb save answer" . print_r($answer->getErrors()), CLogger::LEVEL_ERROR);
         }
     } else {
         Yii::app()->user->setFlash('error', Yii::t('common', 'patientFormNotSaved'));
         //null result
         $answer = null;
     }
     return $answer;
 }
开发者ID:Biobanques,项目名称:cbsd_platform,代码行数:67,代码来源:QuestionnaireController.php

示例2: index


//.........这里部分代码省略.........
         if ($sQuestionType == "R" && Survey::model()->findByPk($iSurveyID)->active == "Y") {
             QuestionAttribute::model()->find("qid = :qid AND attribute = 'max_subquestions'", array(':qid' => $iQuestionID));
             $answerCount = Answer::model()->countByAttributes(array('qid' => $iQuestionID, 'language' => Survey::model()->findByPk($iSurveyID)->language));
             $oQuestionAttribute = new QuestionAttribute();
             $oQuestionAttribute->qid = $iQuestionID;
             $oQuestionAttribute->attribute = 'max_subquestions';
             $oQuestionAttribute->value = $answerCount;
             $oQuestionAttribute->save();
         }
         //First delete all answers
         Answer::model()->deleteAllByAttributes(array('qid' => $iQuestionID));
         LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
         for ($iScaleID = 0; $iScaleID < $iScaleCount; $iScaleID++) {
             $iMaxCount = (int) Yii::app()->request->getPost('answercount_' . $iScaleID);
             for ($iSortOrderID = 1; $iSortOrderID < $iMaxCount; $iSortOrderID++) {
                 $sCode = sanitize_paranoid_string(Yii::app()->request->getPost('code_' . $iSortOrderID . '_' . $iScaleID));
                 //var_dump($sCode);
                 $iAssessmentValue = (int) Yii::app()->request->getPost('assessment_' . $iSortOrderID . '_' . $iScaleID);
                 foreach ($aSurveyLanguages as $sLanguage) {
                     $sAnswerText = Yii::app()->request->getPost('answer_' . $sLanguage . '_' . $iSortOrderID . '_' . $iScaleID);
                     // Fix bug with FCKEditor saving strange BR types
                     $sAnswerText = $oFixCKeditor->fixCKeditor($sAnswerText);
                     // Now we insert the answers
                     $oAnswer = new Answer();
                     $oAnswer->code = $sCode;
                     $oAnswer->answer = $sAnswerText;
                     $oAnswer->qid = $iQuestionID;
                     $oAnswer->sortorder = $iSortOrderID;
                     $oAnswer->language = $sLanguage;
                     $oAnswer->assessment_value = $iAssessmentValue;
                     $oAnswer->scale_id = $iScaleID;
                     if (!$oAnswer->save()) {
                         $sErrors = '<br/>';
                         foreach ($oAnswer->getErrors() as $sError) {
                             $sErrors .= $sError[0] . '<br/>';
                         }
                         // Let's give a new to code to the answer to save it, so user entries are not lost
                         $bAnswerSave = false;
                         while (!$bAnswerSave) {
                             $oAnswer->code = rand(11111, 99999);
                             // If the random code already exist (very low probablilty), answer will not be save and a new code will be generated
                             if ($oAnswer->save()) {
                                 $sError = '<strong>' . sprintf(gT('A code has been updated to %s.'), $oAnswer->code) . '</strong><br/>';
                                 $bAnswerSave = true;
                             }
                         }
                         Yii::app()->setFlashMessage(gT("Failed to update answer: ") . $sCode . $sErrors, 'error');
                     }
                 }
                 // Updating code (oldcode!==null) => update condition with the new code
                 $sOldCode = Yii::app()->request->getPost('oldcode_' . $iSortOrderID . '_' . $iScaleID);
                 if (isset($sOldCode) && $sCode !== $sOldCode) {
                     Condition::model()->updateAll(array('value' => $sCode), 'cqid=:cqid AND value=:value', array(':cqid' => $iQuestionID, ':value' => $sOldCode));
                 }
             }
             // for ($sortorderid=0;$sortorderid<$maxcount;$sortorderid++)
         }
         //  for ($scale_id=0;
         LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
         if (!Yii::app()->request->getPost('bFullPOST')) {
             Yii::app()->setFlashMessage(gT("Not all answer options 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("Answer options were successfully saved.");
         }
         LimeExpressionManager::SetDirtyFlag();
         if ($sDBOutput != '') {
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:67,代码来源:database.php


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