• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP QuestionAttribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: index


//.........这里部分代码省略.........
                  *
                  */
                 if ($sAction == 'copyquestion') {
                     if (returnGlobal('copysubquestions') == "Y") {
                         $aSQIDMappings = array();
                         $r1 = Question::model()->getSubQuestions(returnGlobal('oldqid'));
                         $aSubQuestions = $r1->readAll();
                         foreach ($aSubQuestions as $qr1) {
                             $qr1['parent_qid'] = $iQuestionID;
                             if (isset($aSQIDMappings[$qr1['qid']])) {
                                 $qr1['qid'] = $aSQIDMappings[$qr1['qid']];
                             } else {
                                 $oldqid = $qr1['qid'];
                                 unset($qr1['qid']);
                             }
                             $qr1['gid'] = $iQuestionGroupID;
                             $iInsertID = Question::model()->insertRecords($qr1);
                             if (!isset($qr1['qid'])) {
                                 $aSQIDMappings[$oldqid] = $iInsertID;
                             }
                         }
                     }
                     if (returnGlobal('copyanswers') == "Y") {
                         $r1 = Answer::model()->getAnswers(returnGlobal('oldqid'));
                         $aAnswerOptions = $r1->readAll();
                         foreach ($aAnswerOptions as $qr1) {
                             Answer::model()->insertRecords(array('qid' => $iQuestionID, 'code' => $qr1['code'], 'answer' => $qr1['answer'], 'assessment_value' => $qr1['assessment_value'], 'sortorder' => $qr1['sortorder'], 'language' => $qr1['language'], 'scale_id' => $qr1['scale_id']));
                         }
                     }
                     /**
                      * Copy attribute
                      */
                     if (returnGlobal('copyattributes') == "Y") {
                         $oOldAttributes = QuestionAttribute::model()->findAll("qid=:qid", array("qid" => returnGlobal('oldqid')));
                         foreach ($oOldAttributes as $oOldAttribute) {
                             $attribute = new QuestionAttribute();
                             $attribute->qid = $iQuestionID;
                             $attribute->value = $oOldAttribute->value;
                             $attribute->attribute = $oOldAttribute->attribute;
                             $attribute->language = $oOldAttribute->language;
                             $attribute->save();
                         }
                     }
                     // Since 2.5, user can edit attribute while copying
                     $qattributes = questionAttributes();
                     $validAttributes = $qattributes[Yii::app()->request->getPost('type')];
                     $aLanguages = array_merge(array(Survey::model()->findByPk($iSurveyID)->language), Survey::model()->findByPk($iSurveyID)->additionalLanguages);
                     foreach ($validAttributes as $validAttribute) {
                         if ($validAttribute['i18n']) {
                             foreach ($aLanguages as $sLanguage) {
                                 $value = Yii::app()->request->getPost($validAttribute['name'] . '_' . $sLanguage);
                                 $iInsertCount = QuestionAttribute::model()->findAllByAttributes(array('attribute' => $validAttribute['name'], 'qid' => $iQuestionID, 'language' => $sLanguage));
                                 if (count($iInsertCount) > 0) {
                                     if ($value != '') {
                                         QuestionAttribute::model()->updateAll(array('value' => $value), 'attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
                                     } else {
                                         QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
                                     }
                                 } elseif ($value != '') {
                                     $attribute = new QuestionAttribute();
                                     $attribute->qid = $iQuestionID;
                                     $attribute->value = $value;
                                     $attribute->attribute = $validAttribute['name'];
                                     $attribute->language = $sLanguage;
                                     $attribute->save();
                                 }
开发者ID:joaocc,项目名称:LimeSurvey--LimeSurvey,代码行数:67,代码来源:database.php


示例2: do_array_dual

function do_array_dual($ia)
{
    global $thissurvey;
    $aLastMoveResult = LimeExpressionManager::GetLastMoveResult();
    $aMandatoryViolationSubQ = $aLastMoveResult['mandViolation'] && $ia[6] == 'Y' ? explode("|", $aLastMoveResult['unansweredSQs']) : array();
    $repeatheadings = Yii::app()->getConfig("repeatheadings");
    $minrepeatheadings = Yii::app()->getConfig("minrepeatheadings");
    $extraclass = "";
    $answertypeclass = "";
    // Maybe not
    $caption = "";
    // Just leave empty, are replaced after
    $inputnames = array();
    $labelans1 = array();
    $labelans = array();
    /*
     * Get Question Attributes
     */
    $aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]);
    // Get questions and answers by defined order
    if ($aQuestionAttributes['random_order'] == 1) {
        $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY " . dbRandom();
    } else {
        $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY question_order";
    }
    $ansresult = dbExecuteAssoc($ansquery);
    //Checked
    $aSubQuestions = $ansresult->readAll();
    $anscount = count($aSubQuestions);
    $lquery = "SELECT * FROM {{answers}} WHERE scale_id=0 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
    $lresult = dbExecuteAssoc($lquery);
    //Checked
    $aAnswersScale0 = $lresult->readAll();
    $lquery1 = "SELECT * FROM {{answers}} WHERE scale_id=1 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
    $lresult1 = dbExecuteAssoc($lquery1);
    //Checked
    $aAnswersScale1 = $lresult1->readAll();
    // Set attributes
    if ($aQuestionAttributes['use_dropdown'] == 1) {
        $useDropdownLayout = true;
        $extraclass .= " dropdown-list";
        $answertypeclass .= " dropdown";
        $doDualScaleFunction = "doDualScaleDropDown";
        // javascript funtion to lauch at end of answers
        $caption = gT("A table with a subquestion on each row, with two answers to provide on each line.  Please select the answers.");
    } else {
        $useDropdownLayout = false;
        $extraclass .= " radio-list";
        $answertypeclass .= " radio";
        $doDualScaleFunction = "doDualScaleRadio";
        $caption = gT("A table with one subquestion on each row and two answers to provide on each row. The related answer options are in the top table header row.");
    }
    if (ctype_digit(trim($aQuestionAttributes['repeat_headings'])) && trim($aQuestionAttributes['repeat_headings'] != "")) {
        $repeatheadings = intval($aQuestionAttributes['repeat_headings']);
        $minrepeatheadings = 0;
    }
    $leftheader = trim($aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '' ? $leftheader = $aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']] : '';
    $rightheader = trim($aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '' ? $aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']] : '';
    $answerwidth = trim($aQuestionAttributes['answer_width']) != '' ? $aQuestionAttributes['answer_width'] : 20;
    // Find if we have rigth and center text
    $sQuery = "SELECT count(question) FROM {{questions}} WHERE parent_qid=" . $ia[0] . " and scale_id=0 AND question like '%|%'";
    $rigthCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
    $rightexists = $rigthCount > 0;
    // $right_exists: flag to find out if there are any right hand answer parts. leaving right column but don't force with
    $sQuery = "SELECT count(question) FROM {{questions}} WHERE parent_qid=" . $ia[0] . " and scale_id=0 AND question like '%|%|%'";
    $centerCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
    $centerexists = $centerCount > 0;
    // $center_exists: flag to find out if there are any center hand answer parts. leaving center column but don't force with
    // Label and code for input
    foreach ($aAnswersScale0 as $lrow) {
        $labels0[] = array('code' => $lrow['code'], 'title' => $lrow['answer']);
    }
    foreach ($aAnswersScale1 as $lrow) {
        $labels1[] = array('code' => $lrow['code'], 'title' => $lrow['answer']);
    }
    if (count($aAnswersScale0) > 0 && $anscount) {
        $answer = "";
        $fn = 1;
        // Used by repeat_heading
        // No drop-down
        if ($useDropdownLayout === false) {
            $aData = array();
            $aData['answertypeclass'] = $answertypeclass;
            $columnswidth = 100 - $answerwidth;
            $labelans0 = array();
            $labelans1 = array();
            $labelcode0 = array();
            $labelcode1 = array();
            foreach ($aAnswersScale0 as $lrow) {
                $labelans0[] = $lrow['answer'];
                $labelcode0[] = $lrow['code'];
            }
            foreach ($aAnswersScale1 as $lrow) {
                $labelans1[] = $lrow['answer'];
                $labelcode1[] = $lrow['code'];
            }
            $numrows = count($labelans0) + count($labelans1);
            // Add needed row and fill some boolean: shownoanswer, rightexists, centerexists
            $shownoanswer = $ia[6] != "Y" && SHOW_NO_ANSWER == 1;
            if ($shownoanswer) {
//.........这里部分代码省略.........
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:101,代码来源:qanda_helper.php


示例3: index


//.........这里部分代码省略.........
                         #                            }
                     }
                 }
             }
             if (!$iQuestionID) {
                 Yii::app()->setFlashMessage($clang->gT("Question could not be created."), 'error');
             } else {
                 if ($sAction == 'copyquestion') {
                     if (returnGlobal('copysubquestions') == "Y") {
                         $aSQIDMappings = array();
                         $r1 = Question::model()->getSubQuestions(returnGlobal('oldqid'));
                         while ($qr1 = $r1->read()) {
                             $qr1['parent_qid'] = $iQuestionID;
                             if (isset($aSQIDMappings[$qr1['qid']])) {
                                 $qr1['qid'] = $aSQIDMappings[$qr1['qid']];
                             } else {
                                 $oldqid = $qr1['qid'];
                                 unset($qr1['qid']);
                             }
                             $qr1['gid'] = $iQuestionGroupID;
                             $iInsertID = Question::model()->insertRecords($qr1);
                             if (!isset($qr1['qid'])) {
                                 $aSQIDMappings[$oldqid] = $iInsertID;
                             }
                         }
                     }
                     if (returnGlobal('copyanswers') == "Y") {
                         $r1 = Answer::model()->getAnswers(returnGlobal('oldqid'));
                         while ($qr1 = $r1->read()) {
                             Answer::model()->insertRecords(array('qid' => $iQuestionID, 'code' => $qr1['code'], 'answer' => $qr1['answer'], 'assessment_value' => $qr1['assessment_value'], 'sortorder' => $qr1['sortorder'], 'language' => $qr1['language'], 'scale_id' => $qr1['scale_id']));
                         }
                     }
                     if (returnGlobal('copyattributes') == "Y") {
                         $oOldAttributes = QuestionAttribute::model()->findAll("qid=:qid", array("qid" => returnGlobal('oldqid')));
                         foreach ($oOldAttributes as $oOldAttribute) {
                             $attribute = new QuestionAttribute();
                             $attribute->qid = $iQuestionID;
                             $attribute->value = $oOldAttribute->value;
                             $attribute->attribute = $oOldAttribute->attribute;
                             $attribute->language = $oOldAttribute->language;
                             $attribute->save();
                         }
                     }
                 } else {
                     $qattributes = questionAttributes();
                     $validAttributes = $qattributes[Yii::app()->request->getPost('type')];
                     $aLanguages = array_merge(array(Survey::model()->findByPk($iSurveyID)->language), Survey::model()->findByPk($iSurveyID)->additionalLanguages);
                     foreach ($validAttributes as $validAttribute) {
                         if ($validAttribute['i18n']) {
                             foreach ($aLanguages as $sLanguage) {
                                 $value = Yii::app()->request->getPost($validAttribute['name'] . '_' . $sLanguage);
                                 $iInsertCount = QuestionAttribute::model()->findAllByAttributes(array('attribute' => $validAttribute['name'], 'qid' => $iQuestionID, 'language' => $sLanguage));
                                 if (count($iInsertCount) > 0) {
                                     if ($value != '') {
                                         QuestionAttribute::model()->updateAll(array('value' => $value), 'attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
                                     } else {
                                         QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
                                     }
                                 } elseif ($value != '') {
                                     $attribute = new QuestionAttribute();
                                     $attribute->qid = $iQuestionID;
                                     $attribute->value = $value;
                                     $attribute->attribute = $validAttribute['name'];
                                     $attribute->language = $sLanguage;
                                     $attribute->save();
                                 }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:67,代码来源:database.php


示例4: index


//.........这里部分代码省略.........
                 }
             }
             if (!$iQuestionID) {
                 Yii::app()->setFlashMessage(gT("Question could not be created."), 'error');
             } else {
                 if ($sAction == 'copyquestion') {
                     if (returnGlobal('copysubquestions') == "Y") {
                         $aSQIDMappings = array();
                         $r1 = Question::model()->getSubQuestions(returnGlobal('oldqid'));
                         $aSubQuestions = $r1->readAll();
                         foreach ($aSubQuestions as $qr1) {
                             $qr1['parent_qid'] = $iQuestionID;
                             if (isset($aSQIDMappings[$qr1['qid']])) {
                                 $qr1['qid'] = $aSQIDMappings[$qr1['qid']];
                             } else {
                                 $oldqid = $qr1['qid'];
                                 unset($qr1['qid']);
                             }
                             $qr1['gid'] = $iQuestionGroupID;
                             $iInsertID = Question::model()->insertRecords($qr1);
                             if (!isset($qr1['qid'])) {
                                 $aSQIDMappings[$oldqid] = $iInsertID;
                             }
                         }
                     }
                     if (returnGlobal('copyanswers') == "Y") {
                         $r1 = Answer::model()->getAnswers(returnGlobal('oldqid'));
                         $aAnswerOptions = $r1->readAll();
                         foreach ($aAnswerOptions as $qr1) {
                             Answer::model()->insertRecords(array('qid' => $iQuestionID, 'code' => $qr1['code'], 'answer' => $qr1['answer'], 'assessment_value' => $qr1['assessment_value'], 'sortorder' => $qr1['sortorder'], 'language' => $qr1['language'], 'scale_id' => $qr1['scale_id']));
                         }
                     }
                     if (returnGlobal('copyattributes') == "Y") {
                         $oOldAttributes = QuestionAttribute::model()->findAll("qid=:qid", array("qid" => returnGlobal('oldqid')));
                         foreach ($oOldAttributes as $oOldAttribute) {
                             $attribute = new QuestionAttribute();
                             $attribute->qid = $iQuestionID;
                             $attribute->value = $oOldAttribute->value;
                             $attribute->attribute = $oOldAttribute->attribute;
                             $attribute->language = $oOldAttribute->language;
                             $attribute->save();
                         }
                     }
                 } else {
                     $qattributes = questionAttributes();
                     $validAttributes = $qattributes[Yii::app()->request->getPost('type')];
                     $aLanguages = array_merge(array(Survey::model()->findByPk($iSurveyID)->language), Survey::model()->findByPk($iSurveyID)->additionalLanguages);
                     foreach ($validAttributes as $validAttribute) {
                         if ($validAttribute['i18n']) {
                             foreach ($aLanguages as $sLanguage) {
                                 $value = Yii::app()->request->getPost($validAttribute['name'] . '_' . $sLanguage);
                                 $iInsertCount = QuestionAttribute::model()->findAllByAttributes(array('attribute' => $validAttribute['name'], 'qid' => $iQuestionID, 'language' => $sLanguage));
                                 if (count($iInsertCount) > 0) {
                                     if ($value != '') {
                                         QuestionAttribute::model()->updateAll(array('value' => $value), 'attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
                                     } else {
                                         QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
                                     }
                                 } elseif ($value != '') {
                                     $attribute = new QuestionAttribute();
                                     $attribute->qid = $iQuestionID;
                                     $attribute->value = $value;
                                     $attribute->attribute = $validAttribute['name'];
                                     $attribute->language = $sLanguage;
                                     $attribute->save();
                                 }
开发者ID:nicbon,项目名称:LimeSurvey,代码行数:67,代码来源:database.php


示例5: deleteAllById

 public static function deleteAllById($questionsIds)
 {
     if (!is_array($questionsIds)) {
         $questionsIds = array($questionsIds);
     }
     Yii::app()->db->createCommand()->delete(Condition::model()->tableName(), array('in', 'qid', $questionsIds));
     Yii::app()->db->createCommand()->delete(QuestionAttribute::model()->tableName(), array('in', 'qid', $questionsIds));
     Yii::app()->db->createCommand()->delete(Answer::model()->tableName(), array('in', 'qid', $questionsIds));
     Yii::app()->db->createCommand()->delete(Question::model()->tableName(), array('in', 'parent_qid', $questionsIds));
     Yii::app()->db->createCommand()->delete(Question::model()->tableName(), array('in', 'qid', $questionsIds));
     Yii::app()->db->createCommand()->delete(DefaultValue::model()->tableName(), array('in', 'qid', $questionsIds));
     Yii::app()->db->createCommand()->delete(QuotaMember::model()->tableName(), array('in', 'qid', $questionsIds));
 }
开发者ID:rouben,项目名称:LimeSurvey,代码行数:13,代码来源:Question.php


示例6: get_question_properties

 /**
  * RPC Routine to return properties of a question of a survey.
  * Returns string
  *
  * @access public
  * @param string $sSessionKey Auth credentials
  * @param int $iQuestionID Id of the question to get properties
  * @param array $aQuestionSettings The properties to get
  * @param string $sLanguage Optional parameter language for multilingual questions
  * @return array The requested values
  */
 public function get_question_properties($sSessionKey, $iQuestionID, $aQuestionSettings, $sLanguage = NULL)
 {
     if ($this->_checkSessionKey($sSessionKey)) {
         Yii::app()->loadHelper("surveytranslator");
         $oQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
         if (!isset($oQuestion)) {
             return array('status' => 'Error: Invalid questionid');
         }
         $iSurveyID = $oQuestion->sid;
         if (Permission::model()->hasSurveyPermission($iSurveyID, 'survey', 'read')) {
             if (is_null($sLanguage)) {
                 $sLanguage = Survey::model()->findByPk($iSurveyID)->language;
             }
             if (!array_key_exists($sLanguage, getLanguageDataRestricted())) {
                 return array('status' => 'Error: Invalid language');
             }
             $oQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID, 'language' => $sLanguage));
             if (!isset($oQuestion)) {
                 return array('status' => 'Error: Invalid questionid');
             }
             $aBasicDestinationFields = Question::model()->tableSchema->columnNames;
             array_push($aBasicDestinationFields, 'available_answers');
             array_push($aBasicDestinationFields, 'subquestions');
             array_push($aBasicDestinationFields, 'attributes');
             array_push($aBasicDestinationFields, 'attributes_lang');
             array_push($aBasicDestinationFields, 'answeroptions');
             array_push($aBasicDestinationFields, 'defaultvalue');
             $aQuestionSettings = array_intersect($aQuestionSettings, $aBasicDestinationFields);
             if (empty($aQuestionSettings)) {
                 return array('status' => 'No valid Data');
             }
             $aResult = array();
             foreach ($aQuestionSettings as $sPropertyName) {
                 if ($sPropertyName == 'available_answers' || $sPropertyName == 'subquestions') {
                     $oSubQuestions = Question::model()->findAllByAttributes(array('parent_qid' => $iQuestionID, 'language' => $sLanguage), array('order' => 'title'));
                     if (count($oSubQuestions) > 0) {
                         $aData = array();
                         foreach ($oSubQuestions as $oSubQuestion) {
                             if ($sPropertyName == 'available_answers') {
                                 $aData[$oSubQuestion['title']] = $oSubQuestion['question'];
                             } else {
                                 $aData[$oSubQuestion['qid']]['title'] = $oSubQuestion['title'];
                                 $aData[$oSubQuestion['qid']]['question'] = $oSubQuestion['question'];
                                 $aData[$oSubQuestion['qid']]['scale_id'] = $oSubQuestion['scale_id'];
                             }
                         }
                         $aResult[$sPropertyName] = $aData;
                     } else {
                         $aResult[$sPropertyName] = 'No available answers';
                     }
                 } else {
                     if ($sPropertyName == 'attributes') {
                         $oAttributes = QuestionAttribute::model()->findAllByAttributes(array('qid' => $iQuestionID, 'language' => null), array('order' => 'attribute'));
                         if (count($oAttributes) > 0) {
                             $aData = array();
                             foreach ($oAttributes as $oAttribute) {
                                 $aData[$oAttribute['attribute']] = $oAttribute['value'];
                             }
                             $aResult['attributes'] = $aData;
                         } else {
                             $aResult['attributes'] = 'No available attributes';
                         }
                     } else {
                         if ($sPropertyName == 'attributes_lang') {
                             $oAttributes = QuestionAttribute::model()->findAllByAttributes(array('qid' => $iQuestionID, 'language' => $sLanguage), array('order' => 'attribute'));
                             if (count($oAttributes) > 0) {
                                 $aData = array();
                                 foreach ($oAttributes as $oAttribute) {
                                     $aData[$oAttribute['attribute']] = $oAttribute['value'];
                                 }
                                 $aResult['attributes_lang'] = $aData;
                             } else {
                                 $aResult['attributes_lang'] = 'No available attributes';
                             }
                         } else {
                             if ($sPropertyName == 'answeroptions') {
                                 $oAttributes = Answer::model()->findAllByAttributes(array('qid' => $iQuestionID, 'language' => $sLanguage), array('order' => 'sortorder'));
                                 if (count($oAttributes) > 0) {
                                     $aData = array();
                                     foreach ($oAttributes as $oAttribute) {
                                         $aData[$oAttribute['code']]['answer'] = $oAttribute['answer'];
                                         $aData[$oAttribute['code']]['assessment_value'] = $oAttribute['assessment_value'];
                                         $aData[$oAttribute['code']]['scale_id'] = $oAttribute['scale_id'];
                                     }
                                     $aResult['answeroptions'] = $aData;
                                 } else {
                                     $aResult['answeroptions'] = 'No available answer options';
                                 }
                             } else {
//.........这里部分代码省略.........
开发者ID:kasutori,项目名称:LimeSurvey,代码行数:101,代码来源:remotecontrol_handle.php


示例7: deleteSurvey

 /**
  * Deletes a survey and all its data
  *
  * @access public
  * @param int $iSurveyID
  * @param bool @recursive
  * @return void
  */
 public function deleteSurvey($iSurveyID, $recursive = true)
 {
     Survey::model()->deleteByPk($iSurveyID);
     if ($recursive == true) {
         if (tableExists("{{survey_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "}}");
         }
         if (tableExists("{{survey_" . intval($iSurveyID) . "_timings}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "_timings}}");
         }
         if (tableExists("{{tokens_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{tokens_" . intval($iSurveyID) . "}}");
         }
         /* Remove User/global settings part : need Question and QuestionGroup*/
         // Settings specific for this survey
         $oCriteria = new CDbCriteria();
         $oCriteria->compare('stg_name', 'last_%', true, 'AND', false);
         $oCriteria->compare('stg_value', $iSurveyID, false, 'AND');
         SettingGlobal::model()->deleteAll($oCriteria);
         // Settings specific for this survey, 2nd part
         $oCriteria = new CDbCriteria();
         $oCriteria->compare('stg_name', 'last_%' . $iSurveyID . '%', true, 'AND', false);
         SettingGlobal::model()->deleteAll($oCriteria);
         // All Group id from this survey for ALL users
         $aGroupId = CHtml::listData(QuestionGroup::model()->findAll(array('select' => 'gid', 'condition' => 'sid=:sid', 'params' => array(':sid' => $iSurveyID))), 'gid', 'gid');
         $oCriteria = new CDbCriteria();
         $oCriteria->compare('stg_name', 'last_question_gid_%', true, 'AND', false);
         if (Yii::app()->db->getDriverName() == 'pgsql') {
             $oCriteria->addInCondition('CAST(stg_value as ' . App()->db->schema->getColumnType("integer") . ')', $aGroupId);
         } else {
             $oCriteria->addInCondition('stg_value', $aGroupId);
         }
         SettingGlobal::model()->deleteAll($oCriteria);
         // All Question id from this survey for ALL users
         $aQuestionId = CHtml::listData(Question::model()->findAll(array('select' => 'qid', 'condition' => 'sid=:sid', 'params' => array(':sid' => $iSurveyID))), 'qid', 'qid');
         $oCriteria = new CDbCriteria();
         $oCriteria->compare('stg_name', 'last_question_%', true, 'OR', false);
         if (Yii::app()->db->getDriverName() == 'pgsql') {
             $oCriteria->addInCondition('CAST(stg_value as ' . App()->db->schema->getColumnType("integer") . ')', $aQuestionId);
         } else {
             $oCriteria->addInCondition('stg_value', $aQuestionId);
         }
         SettingGlobal::model()->deleteAll($oCriteria);
         $oResult = Question::model()->findAllByAttributes(array('sid' => $iSurveyID));
         foreach ($oResult as $aRow) {
             Answer::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             Condition::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             QuestionAttribute::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             DefaultValue::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
         }
         Question::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Assessment::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         QuestionGroup::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         SurveyLanguageSetting::model()->deleteAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
         Permission::model()->deleteAllByAttributes(array('entity_id' => $iSurveyID, 'entity' => 'survey'));
         SavedControl::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         SurveyURLParameter::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         //Remove any survey_links to the CPDB
         SurveyLink::model()->deleteLinksBySurvey($iSurveyID);
         Quota::model()->deleteQuota(array('sid' => $iSurveyID), true);
     }
 }
开发者ID:CSCI-462-01-2016,项目名称:LimeSurvey,代码行数:70,代码来源:Survey.php


示例8: checkCompletedQuota

/**
* checkCompletedQuota() returns matched quotas information for the current response
* @param integer $surveyid - Survey identification number
* @param bool $return - set to true to return information, false do the quota
* @return array|void - nested array, Quotas->Members->Fields, includes quota information matched in session.
*/
function checkCompletedQuota($surveyid, $return = false)
{
    /* Check if session is set */
    if (!isset(App()->session['survey_' . $surveyid]['srid'])) {
        return;
    }
    /* Check is Response is already submitted : only when "do" the quota: allow to send information about quota */
    $oResponse = Response::model($surveyid)->findByPk(App()->session['survey_' . $surveyid]['srid']);
    if (!$return && $oResponse && !is_null($oResponse->submitdate)) {
        return;
    }
    static $aMatchedQuotas;
    // EM call 2 times quotas with 3 lines of php code, then use static.
    if (!$aMatchedQuotas) {
        $aMatchedQuotas = array();
        $quota_info = $aQuotasInfo = getQuotaInformation($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
        // $aQuotasInfo have an 'active' key, we don't use it ?
        if (!$aQuotasInfo || empty($aQuotasInfo)) {
            return $aMatchedQuotas;
        }
        // OK, we have some quota, then find if this $_SESSION have some set
        $aPostedFields = explode("|", Yii::app()->request->getPost('fieldnames', ''));
        // Needed for quota allowing update
        foreach ($aQuotasInfo as $aQuotaInfo) {
            if (count($aQuotaInfo['members']) === 0) {
                continue;
            }
            $iMatchedAnswers = 0;
            $bPostedField = false;
            // Array of field with quota array value
            $aQuotaFields = array();
            // Array of fieldnames with relevance value : EM fill $_SESSION with default value even is unrelevant (em_manager_helper line 6548)
            $aQuotaRelevantFieldnames = array();
            // To count number of hidden questions
            $aQuotaQid = array();
            foreach ($aQuotaInfo['members'] as $aQuotaMember) {
                $aQuotaFields[$aQuotaMember['fieldname']][] = $aQuotaMember['value'];
                $aQuotaRelevantFieldnames[$aQuotaMember['fieldname']] = isset($_SESSION['survey_' . $surveyid]['relevanceStatus'][$aQuotaMember['qid']]) && $_SESSION['survey_' . $surveyid]['relevanceStatus'][$aQuotaMember['qid']];
                $aQuotaQid[] = $aQuotaMember['qid'];
            }
            $aQuotaQid = array_unique($aQuotaQid);
            // For each field : test if actual responses is in quota (and is relevant)
            foreach ($aQuotaFields as $sFieldName => $aValues) {
                $bInQuota = isset($_SESSION['survey_' . $surveyid][$sFieldName]) && in_array($_SESSION['survey_' . $surveyid][$sFieldName], $aValues);
                if ($bInQuota && $aQuotaRelevantFieldnames[$sFieldName]) {
                    $iMatchedAnswers++;
                }
                if (in_array($sFieldName, $aPostedFields)) {
                    // Need only one posted value
                    $bPostedField = true;
                }
            }
            // Condition to count quota : Answers are the same in quota + an answer is submitted at this time (bPostedField) OR all questions is hidden (bAllHidden)
            $bAllHidden = QuestionAttribute::model()->countByAttributes(array('qid' => $aQuotaQid), 'attribute=:attribute', array(':attribute' => 'hidden')) == count($aQuotaQid);
            if ($iMatchedAnswers == count($aQuotaFields) && ($bPostedField || $bAllHidden)) {
                if ($aQuotaInfo['qlimit'] == 0) {
                    // Always add the quota if qlimit==0
                    $aMatchedQuotas[] = $aQuotaInfo;
                } else {
                    $iCompleted = getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);
                    if (!is_null($iCompleted) && (int) $iCompleted >= (int) $aQuotaInfo['qlimit']) {
                        // This remove invalid quota and not completed
                        $aMatchedQuotas[] = $aQuotaInfo;
                    }
                }
            }
        }
    }
    if ($return) {
        return $aMatchedQuotas;
    }
    if (empty($aMatchedQuotas)) {
        return;
    }
    // Now we have all the information we need about the quotas and their status.
    // We need to construct the page and do all needed action
    $aSurveyInfo = getSurveyInfo($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
    $oTemplate = Template::model()->getInstance('', $surveyid);
    $sTemplatePath = $oTemplate->path;
    $sTemplateViewPath = $oTemplate->viewPath;
    $sClientToken = isset($_SESSION['survey_' . $surveyid]['token']) ? $_SESSION['survey_' . $surveyid]['token'] : "";
    // $redata for templatereplace
    $aDataReplacement = array('thissurvey' => $aSurveyInfo, 'clienttoken' => $sClientToken, 'token' => $sClientToken);
    // We take only the first matched quota, no need for each
    $aMatchedQuota = $aMatchedQuotas[0];
    // If a token is used then mark the token as completed, do it before event : this allow plugin to update token information
    $event = new PluginEvent('afterSurveyQuota');
    $event->set('surveyId', $surveyid);
    $event->set('responseId', $_SESSION['survey_' . $surveyid]['srid']);
    // We allways have a responseId
    $event->set('aMatchedQuotas', $aMatchedQuotas);
    // Give all the matched quota : the first is the active
    App()->getPluginManager()->dispatchEvent($event);
    $blocks = array();
//.........这里部分代码省略.........
开发者ID:joaocc,项目名称:LimeSurvey--LimeSurvey,代码行数:101,代码来源:frontend_helper.php


示例9: _checkintegrity


//.........这里部分代码省略.........
             if (!array_key_exists($condition['cqid'], $okQuestion)) {
                 $iRowCount = Question::model()->countByAttributes(array('qid' => $condition['cqid']));
                 if (Question::model()->hasErrors()) {
                     safeDie(Question::model()->getError());
                 }
                 if (!$iRowCount) {
                     $aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CQID'));
                 } else {
                     $okQuestion[$condition['cqid']] = $condition['cqid'];
                 }
             }
         }
         if ($condition['cfieldname']) {
             if (preg_match('/^\\+{0,1}[0-9]+X[0-9]+X*$/', $condition['cfieldname'])) {
                 // only if cfieldname isn't Tag such as {TOKEN:EMAIL} or any other token
                 list($surveyid, $gid, $rest) = explode('X', $condition['cfieldname']);
                 $iRowCount = count(QuestionGroup::model()->findAllByAttributes(array('gid' => $gid)));
                 if (QuestionGroup::model()->hasErrors()) {
                     safeDie(QuestionGroup::model()->getError());
                 }
                 if (!$iRowCount) {
                     $aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CFIELDNAME group!') . " ({$gid}) ({$condition['cfieldname']})");
                 }
             }
         } elseif (!$condition['cfieldname']) {
             $aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No CFIELDNAME field set!') . " ({$condition['cfieldname']})");
         }
     }
     unset($okQuestion);
     unset($aConditions);
     /**********************************************************************/
     /*     Check question attributes                                      */
     /**********************************************************************/
     $question_attributes = QuestionAttribute::model()->findAllBySql('select qid from {{question_attributes}} where qid not in (select qid from {{questions}})');
     if (QuestionAttribute::model()->hasErrors()) {
         safeDie(QuestionAttribute::model()->getError());
     }
     foreach ($question_attributes as $question_attribute) {
         $aDelete['questionattributes'][] = array('qid' => $question_attribute['qid']);
     }
     // foreach
     /**********************************************************************/
     /*     Check default values                                           */
     /**********************************************************************/
     $oCriteria = new CDbCriteria();
     $oCriteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid';
     $oCriteria->condition = 'q.qid IS NULL';
     $aRecords = DefaultValue::model()->findAll($oCriteria);
     $aDelete['defaultvalues'] = count($aRecords);
     if (DefaultValue::model()->hasErrors()) {
         safeDie(DefaultValue::model()->getError());
     }
     /**********************************************************************/
     /*     Check quotas                                                   */
     /**********************************************************************/
     $surveys = Survey::model()->findAll();
     if (Survey::model()->hasErrors()) {
         safeDie(Survey::model()->getError());
     }
     $sids = array();
     foreach ($surveys as $survey) {
         $sids[] = $survey['sid'];
     }
     $oCriteria = new CDbCriteria();
     $oCriteria->addNotInCondition('sid', $sids);
     $aDelete['quotas'] = count(Quota::model()->findAll($oCriteria));
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:67,代码来源:checkintegrity.php


示例10: activateSurvey


//.........这里部分代码省略.........
                $aTableDefinition[$aRow['fieldname']] = "string(20)";
                break;
            case "|":
                $bCreateSurveyDir = true;
                if (strpos($aRow['fieldname'], "_")) {
                    $aTableDefinition[$aRow['fieldname']] = "integer";
                } else {
                    $aTableDefinition[$aRow['fieldname']] = "text";
                }
                break;
            case "ipaddress":
                if ($arSurvey->ipaddr == "Y") {
                    $aTableDefinition[$aRow['fieldname']] = "text";
                }
                break;
            case "url":
                if ($arSurvey->refurl == "Y") {
                    $aTableDefinition[$aRow['fieldname']] = "text";
                }
                break;
            case "token":
                $aTableDefinition[$aRow['fieldname']] = 'string(35)' . $sCollation;
                break;
            case '*':
                // Equation
                $aTableDefinition[$aRow['fieldname']] = "text";
                break;
            case 'R':
                /**
                 * See bug #09828: Ranking question : update allowed can broke Survey DB
                 * If max_subquestions is not set or is invalid : set it to actual answers numbers
                 */
                $nrOfAnswers = Answer::model()->countByAttributes(array('qid' => $aRow['qid'], 'language' => Survey::model()->findByPk($iSurveyID)->language));
                $oQuestionAttribute = QuestionAttribute::model()->find("qid = :qid AND attribute = 'max_subquestions'", array(':qid' => $aRow['qid']));
                if (empty($oQuestionAttribute)) {
                    $oQuestionAttribute = new QuestionAttribute();
                    $oQuestionAttribute->qid = $aRow['qid'];
                    $oQuestionAttribute->attribute = 'max_subquestions';
                    $oQuestionAttribute->value = $nrOfAnswers;
                    $oQuestionAttribute->save();
                } elseif (intval($oQuestionAttribute->value) < 1) {
                    $oQuestionAttribute->value = $nrOfAnswers;
                    $oQuestionAttribute->save();
                }
                $aTableDefinition[$aRow['fieldname']] = "string(5)";
                break;
            default:
                $aTableDefinition[$aRow['fieldname']] = "string(5)";
        }
        if ($arSurvey->anonymized == 'N' && !array_key_exists('token', $aTableDefinition)) {
            $aTableDefinition['token'] = 'string(35)' . $sCollation;
        }
        if ($simulate) {
            $tempTrim = trim($aTableDefinition);
            $brackets = strpos($tempTrim, "(");
            if ($brackets === false) {
                $type = substr($tempTrim, 0, 2);
            } else {
                $type = substr($tempTrim, 0, 2);
            }
            $arrSim[] = array($type);
        }
    }
    if ($simulate) {
        return array('dbengine' => $CI->db->databasetabletype, 'dbtype' => Yii::app()->db->driverName, 'fields' => $arrSim);
    }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:67,代码来源:activate_helper.php


示例11: setMultipleAttributes

 /**
  * Set attributes for multiple questions
  */
 public function setMultipleAttributes()
 {
     $aQidsAndLang = json_decode($_POST['sItems']);
     // List of question ids to update
     $iSid = Yii::app()->request->getPost('sid');
     // The survey (for permission check)
     $aAttributesToUpdate = json_decode($_POST['aAttributesToUpdate']);
     // The list of attributes to updates
     // TODO: this should be get from the question model
     $aValidQuestionTypes = str_split($_POST['aValidQuestionTypes']);
     // The valid question types for thoses attributes
     // Calling th model
     QuestionAttribute::model()->setMultiple($iSid, $aQidsAndLang, $aAttributesToUpdate, $aValidQuestionTypes);
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:17,代码来源:questions.php


示例12: setQuestion

 /**
  * 
  * @param iPlugin $plugin
  * @param string $key
  * @param mixed data Default value to return if key could not be found.
  * @param string $model Optional model name to which the data was attached.
  * @param int $id Optional id of the model instance to which the data was attached.
  * @param string $language Optional language identifier used for storing the setting.
  * 
  * @return boolean
  */
 protected function setQuestion(iPlugin $plugin, $key, $data, $model, $id, $language)
 {
     $baseAttributes = array('sid', 'code', 'qid', 'gid', 'sortorder', 'relevance', 'questiontype', 'randomization');
     // Some keys are stored in the actual question table not in the attributes table.
     if (in_array($key, $baseAttributes)) {
         if ($data == '') {
             $data = null; 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP QuestionGroup类代码示例发布时间:2022-05-23
下一篇:
PHP Question类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap