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

PHP QuestionGroup类代码示例

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

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



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

示例1: actionUpdate

 /**
  * Mise  àjour d une fiche
  * @param $id the ID of the model to be displayed
  */
 public function actionUpdate($id)
 {
     $model = Questionnaire::model()->findByPk(new MongoID($id));
     $questionForm = new QuestionForm();
     $questionGroup = new QuestionGroup();
     // collect user input data
     if (isset($_POST['QuestionForm'])) {
         $questionForm->attributes = $_POST['QuestionForm'];
         //traitement ajout de question
         if ($questionForm->validate()) {
             $model = $this->saveQuestionnaireNewQuestion($model, $questionForm);
         }
     }
     if (isset($_POST['QuestionGroup'])) {
         $questionGroup->attributes = $_POST['QuestionGroup'];
         //copie du titre sur l option fr
         $questionGroup->title_fr = $questionGroup->title;
         if ($questionGroup->validate()) {
             $model = $this->saveQuestionnaireNewGroup($model, $questionGroup);
         }
     }
     //set du model sur la questionForm pour generer l arborescende de position de question
     $questionForm->questionnaire = $model;
     $this->render('update', array('model' => $model, 'questionForm' => $questionForm, 'questionGroup' => $questionGroup));
 }
开发者ID:Biobanques,项目名称:cbsd_platform,代码行数:29,代码来源:FicheController.php


示例2: testTypeFunction

 /**
  * testing method return array type
  */
 public function testTypeFunction()
 {
     $model = new QuestionGroup();
     $questionBlocForm = new QuestionBlocForm();
     $questionBlocForm->title = "Test";
     $questionBlocForm->questions = array();
     $questionBlocForm->parent_group = "Test";
     $questionBlocForm->id = "test";
     $questionBlocForm->title_fr = $questionBlocForm->title;
     $questionBloc = new QuestionBloc();
     $questionBloc->title = "Test";
     $questionBloc->questions = array();
     $questionBloc->parent_group = "Test";
     $questionBloc->title_fr = $questionBloc->title;
     $model->copy($questionBlocForm, $questionBloc);
     $this->assertFalse($model->deleteQuestion($model->id));
     $this->assertInternalType('array', $model->rules());
     $this->assertInternalType('array', $model->attributeLabels());
 }
开发者ID:Biobanques,项目名称:cbsd_platform,代码行数:22,代码来源:QuestionGroupTest.php


示例3: _createSampleGroup

 /**
  * This private function creates a sample group
  *
  * @param mixed $iSurveyID  The survey ID that the sample group will belong to
  */
 private function _createSampleGroup($iSurveyID)
 {
     // Now create a new dummy group
     $sLanguage = Survey::model()->findByPk($iSurveyID)->language;
     $aInsertData = array();
     $aInsertData[$sLanguage] = array('sid' => $iSurveyID, 'group_name' => gt('My first question group', 'html', $sLanguage), 'description' => '', 'group_order' => 1, 'language' => $sLanguage, 'grelevance' => '1');
     return QuestionGroup::model()->insertNewGroup($aInsertData);
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:13,代码来源:surveyadmin.php


示例4: _reorderGroup

 private function _reorderGroup($iSurveyID)
 {
     $AOrgData = array();
     parse_str($_POST['orgdata'], $AOrgData);
     $grouporder = 0;
     foreach ($AOrgData['list'] as $ID => $parent) {
         if ($parent == 'root' && $ID[0] == 'g') {
             QuestionGroup::model()->updateAll(array('group_order' => $grouporder), 'gid=:gid', array(':gid' => (int) substr($ID, 1)));
             $grouporder++;
         } elseif ($ID[0] == 'q') {
             if (!isset($questionorder[(int) substr($parent, 1)])) {
                 $questionorder[(int) substr($parent, 1)] = 0;
             }
             Question::model()->updateAll(array('question_order' => $questionorder[(int) substr($parent, 1)], 'gid' => (int) substr($parent, 1)), 'qid=:qid', array(':qid' => (int) substr($ID, 1)));
             Question::model()->updateAll(array('gid' => (int) substr($parent, 1)), 'parent_qid=:parent_qid', array(':parent_qid' => (int) substr($ID, 1)));
             $questionorder[(int) substr($parent, 1)]++;
         }
     }
     LimeExpressionManager::SetDirtyFlag();
     // so refreshes syntax highlighting
     Yii::app()->session['flashmessage'] = gT("The new question group/question order was successfully saved.");
     $this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyID));
 }
开发者ID:nicbon,项目名称:LimeSurvey,代码行数:23,代码来源:surveyadmin.php


示例5: TSVImportSurvey


//.........这里部分代码省略.........
    }
    $rownumber = 1;
    $lastglang = '';
    foreach ($adata as $row) {
        $rownumber += 1;
        switch ($row['class']) {
            case 'G':
                // insert group
                $insertdata = array();
                $insertdata['sid'] = $iNewSID;
                $gname = !empty($row['name']) ? $row['name'] : 'G' . $gseq;
                $glang = !empty($row['language']) ? $row['language'] : $baselang;
                // when a multi-lang tsv-file without information on the group id/number (old style) is imported,
                // we make up this information by giving a number 0..[numberofgroups-1] per language.
                // the number and order of groups per language should be the same, so we can also import these files
                if ($lastglang != $glang) {
                    $iGroupcounter = 0;
                }
                $lastglang = $glang;
                //use group id/number from file. if missing, use an increasing number (s.a.)
                $sGroupseq = !empty($row['type/scale']) ? $row['type/scale'] : 'G' . $iGroupcounter++;
                $insertdata['group_name'] = $gname;
                $insertdata['grelevance'] = isset($row['relevance']) ? $row['relevance'] : '';
                $insertdata['description'] = isset($row['text']) ? $row['text'] : '';
                $insertdata['language'] = $glang;
                // For multi language survey: same gid/sort order across all languages
                if (isset($ginfo[$sGroupseq])) {
                    $gid = $ginfo[$sGroupseq]['gid'];
                    $insertdata['gid'] = $gid;
                    $insertdata['group_order'] = $ginfo[$sGroupseq]['group_order'];
                } else {
                    $insertdata['group_order'] = $gseq;
                }
                $newgid = QuestionGroup::model()->insertRecords($insertdata);
                if (!$newgid) {
                    $results['error'][] = $clang->gT("Error") . " : " . $clang->gT("Failed to insert group") . ". " . $clang->gT("Text file row number ") . $rownumber . " (" . $gname . ")";
                    break;
                }
                if (!isset($ginfo[$sGroupseq])) {
                    $results['groups']++;
                    $gid = $newgid;
                    $ginfo[$sGroupseq]['gid'] = $gid;
                    $ginfo[$sGroupseq]['group_order'] = $gseq++;
                }
                $qseq = 0;
                // reset the question_order
                break;
            case 'Q':
                // insert question
                $insertdata = array();
                $insertdata['sid'] = $iNewSID;
                $qtype = isset($row['type/scale']) ? $row['type/scale'] : 'T';
                $qname = isset($row['name']) ? $row['name'] : 'Q' . $qseq;
                $insertdata['gid'] = $gid;
                $insertdata['type'] = $qtype;
                $insertdata['title'] = $qname;
                $insertdata['question'] = isset($row['text']) ? $row['text'] : '';
                $insertdata['relevance'] = isset($row['relevance']) ? $row['relevance'] : '';
                $insertdata['preg'] = isset($row['validation']) ? $row['validation'] : '';
                $insertdata['help'] = isset($row['help']) ? $row['help'] : '';
                $insertdata['language'] = isset($row['language']) ? $row['language'] : $baselang;
                $insertdata['mandatory'] = isset($row['mandatory']) ? $row['mandatory'] : '';
                $lastother = $insertdata['other'] = isset($row['other']) ? $row['other'] : 'N';
                // Keep trace of other settings for sub question
                $insertdata['same_default'] = isset($row['same_default']) ? $row['same_default'] : 0;
                $insertdata['parent_qid'] = 0;
开发者ID:rouben,项目名称:LimeSurvey,代码行数:67,代码来源:import_helper.php


示例6: update

 /**
  * Provides an interface for updating a group
  *
  * @access public
  * @param int $gid
  * @return void
  */
 public function update($gid)
 {
     $gid = (int) $gid;
     $group = QuestionGroup::model()->findByAttributes(array('gid' => $gid));
     $surveyid = $group->sid;
     if (Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'update')) {
         Yii::app()->loadHelper('surveytranslator');
         $grplangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
         $baselang = Survey::model()->findByPk($surveyid)->language;
         array_push($grplangs, $baselang);
         foreach ($grplangs as $grplang) {
             if (isset($grplang) && $grplang != "") {
                 $group_name = $_POST['group_name_' . $grplang];
                 $group_description = $_POST['description_' . $grplang];
                 $group_name = html_entity_decode($group_name, ENT_QUOTES, "UTF-8");
                 $group_description = html_entity_decode($group_description, ENT_QUOTES, "UTF-8");
                 // Fix bug with FCKEditor saving strange BR types
                 $group_name = fixCKeditorText($group_name);
                 $group_description = fixCKeditorText($group_description);
                 $aData = array('group_name' => $group_name, 'description' => $group_description, 'randomization_group' => $_POST['randomization_group'], 'grelevance' => $_POST['grelevance']);
                 $condition = array('gid' => $gid, 'sid' => $surveyid, 'language' => $grplang);
                 $group = QuestionGroup::model()->findByAttributes($condition);
                 foreach ($aData as $k => $v) {
                     $group->{$k} = $v;
                 }
                 $ugresult = $group->save();
                 if ($ugresult) {
                     $groupsummary = getGroupList($gid, $surveyid);
                 }
             }
         }
         Yii::app()->session['flashmessage'] = gT("Question group successfully saved.");
         $this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $surveyid . '/gid/' . $gid));
     }
 }
开发者ID:venurasasanka,项目名称:LimeSurvey,代码行数:42,代码来源:questiongroups.php


示例7: buildsurveysession


//.........这里部分代码省略.........
    }
    if ($totalquestions == 0) {
        sendCacheHeaders();
        doHeader();
        $redata = compact(array_keys(get_defined_vars()));
        echo templatereplace(file_get_contents($sTemplatePath . "startpage.pstpl"), array(), $redata, 'frontend_helper[1914]');
        echo templatereplace(file_get_contents($sTemplatePath . "survey.pstpl"), array(), $redata, 'frontend_helper[1915]');
        echo "\t<div id='wrapper'>\n" . "\t<p id='tokenmessage'>\n" . "\t" . $clang->gT("This survey does not yet have any questions and cannot be tested or completed.") . "<br /><br />\n" . "\t" . sprintf($clang->gT("For further information please contact %s"), $thissurvey['adminname']) . " (<a href='mailto:{$thissurvey['adminemail']}'>" . "{$thissurvey['adminemail']}</a>)<br /><br />\n" . "\t</p>\n" . "\t</div>\n";
        echo templatereplace(file_get_contents($sTemplatePath . "endpage.pstpl"), array(), $redata, 'frontend_helper[1925]');
        doFooter();
        exit;
    }
    //Perform a case insensitive natural sort on group name then question title of a multidimensional array
    //    usort($arows, 'groupOrderThenQuestionOrder');
    //3. SESSION VARIABLE - insertarray
    //An array containing information about used to insert the data into the db at the submit stage
    //4. SESSION VARIABLE - fieldarray
    //See rem at end..
    if ($tokensexist == 1 && $clienttoken) {
        $_SESSION['survey_' . $surveyid]['token'] = $clienttoken;
    }
    if ($thissurvey['anonymized'] == "N") {
        $_SESSION['survey_' . $surveyid]['insertarray'][] = "token";
    }
    $qtypes = getQuestionTypeList('', 'array');
    $fieldmap = createFieldMap($surveyid, 'full', true, false, $_SESSION['survey_' . $surveyid]['s_lang']);
    // Randomization groups for groups
    $aRandomGroups = array();
    $aGIDCompleteMap = array();
    // first find all groups and their groups IDS
    $criteria = new CDbCriteria();
    $criteria->addColumnCondition(array('sid' => $surveyid, 'language' => $_SESSION['survey_' . $surveyid]['s_lang']));
    $criteria->addCondition("randomization_group != ''");
    $oData = QuestionGroup::model()->findAll($criteria);
    foreach ($oData as $aGroup) {
        $aRandomGroups[$aGroup['randomization_group']][] = $aGroup['gid'];
    }
    // Shuffle each group and create a map for old GID => new GID
    foreach ($aRandomGroups as $sGroupName => $aGIDs) {
        $aShuffledIDs = $aGIDs;
        shuffle($aShuffledIDs);
        $aGIDCompleteMap = $aGIDCompleteMap + array_combine($aGIDs, $aShuffledIDs);
    }
    $_SESSION['survey_' . $surveyid]['groupReMap'] = $aGIDCompleteMap;
    $randomized = false;
    // So we can trigger reorder once for group and question randomization
    // Now adjust the grouplist
    if (count($aRandomGroups) > 0 && !$preview) {
        $randomized = true;
        // So we can trigger reorder once for group and question randomization
        // Now adjust the grouplist
        Yii::import('application.helpers.frontend_helper', true);
        // make sure frontend helper is loaded
        UpdateGroupList($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
        // ... and the fieldmap
        // First create a fieldmap with GID as key
        foreach ($fieldmap as $aField) {
            if (isset($aField['gid'])) {
                $GroupFieldMap[$aField['gid']][] = $aField;
            } else {
                $GroupFieldMap['other'][] = $aField;
            }
        }
        // swap it
        foreach ($GroupFieldMap as $iOldGid => $fields) {
            $iNewGid = $iOldGid;
开发者ID:elcharlygraf,项目名称:Encuesta-YiiFramework,代码行数:67,代码来源:frontend_helper.php


示例8: index

 /**
  * Show printable survey
  */
 function index($surveyid, $lang = null)
 {
     $surveyid = sanitize_int($surveyid);
     if (!Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
         $aData['surveyid'] = $surveyid;
         App()->getClientScript()->registerPackage('jquery-superfish');
         $message['title'] = gT('Access denied!');
         $message['message'] = gT('You do not have sufficient rights to access this page.');
         $message['class'] = "error";
         $this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
     } else {
         $aSurveyInfo = getSurveyInfo($surveyid, $lang);
         if (!$aSurveyInfo) {
             $this->getController()->error('Invalid survey ID');
         }
         SetSurveyLanguage($surveyid, $lang);
         $sLanguageCode = App()->language;
         $templatename = $aSurveyInfo['template'];
         $welcome = $aSurveyInfo['surveyls_welcometext'];
         $end = $aSurveyInfo['surveyls_endtext'];
         $surveyname = $aSurveyInfo['surveyls_title'];
         $surveydesc = $aSurveyInfo['surveyls_description'];
         $surveyactive = $aSurveyInfo['active'];
         $surveytable = "{{survey_" . $aSurveyInfo['sid'] . "}}";
         $surveyexpirydate = $aSurveyInfo['expires'];
         $surveyfaxto = $aSurveyInfo['faxto'];
         $dateformattype = $aSurveyInfo['surveyls_dateformat'];
         Yii::app()->loadHelper('surveytranslator');
         if (!is_null($surveyexpirydate)) {
             $dformat = getDateFormatData($dateformattype);
             $dformat = $dformat['phpdate'];
             $expirytimestamp = strtotime($surveyexpirydate);
             $expirytimeofday_h = date('H', $expirytimestamp);
             $expirytimeofday_m = date('i', $expirytimestamp);
             $surveyexpirydate = date($dformat, $expirytimestamp);
             if (!empty($expirytimeofday_h) || !empty($expirytimeofday_m)) {
                 $surveyexpirydate .= ' &ndash; ' . $expirytimeofday_h . ':' . $expirytimeofday_m;
             }
             sprintf(gT("Please submit by %s"), $surveyexpirydate);
         } else {
             $surveyexpirydate = '';
         }
         //Fix $templatename : control if print_survey.pstpl exist
         if (is_file(getTemplatePath($templatename) . DIRECTORY_SEPARATOR . 'print_survey.pstpl')) {
             $templatename = $templatename;
             // Change nothing
         } elseif (is_file(getTemplatePath(Yii::app()->getConfig("defaulttemplate")) . DIRECTORY_SEPARATOR . 'print_survey.pstpl')) {
             $templatename = Yii::app()->getConfig("defaulttemplate");
         } else {
             $templatename = "default";
         }
         $sFullTemplatePath = getTemplatePath($templatename) . DIRECTORY_SEPARATOR;
         $sFullTemplateUrl = getTemplateURL($templatename) . "/";
         define('PRINT_TEMPLATE_DIR', $sFullTemplatePath, true);
         define('PRINT_TEMPLATE_URL', $sFullTemplateUrl, true);
         LimeExpressionManager::StartSurvey($surveyid, 'survey', NULL, false, LEM_PRETTY_PRINT_ALL_SYNTAX);
         $moveResult = LimeExpressionManager::NavigateForwards();
         $condition = "sid = '{$surveyid}' AND language = '{$sLanguageCode}'";
         $degresult = QuestionGroup::model()->getAllGroups($condition, array('group_order'));
         //xiao,
         if (!isset($surveyfaxto) || !$surveyfaxto and isset($surveyfaxnumber)) {
             $surveyfaxto = $surveyfaxnumber;
             //Use system fax number if none is set in survey.
         }
         $headelements = getPrintableHeader();
         //if $showsgqacode is enabled at config.php show table name for reference
         $showsgqacode = Yii::app()->getConfig("showsgqacode");
         if (isset($showsgqacode) && $showsgqacode == true) {
             $surveyname = $surveyname . "<br />[" . gT('Database') . " " . gT('table') . ": {$surveytable}]";
         } else {
             $surveyname = $surveyname;
         }
         $survey_output = array('SITENAME' => Yii::app()->getConfig("sitename"), 'SURVEYNAME' => $surveyname, 'SURVEYDESCRIPTION' => $surveydesc, 'WELCOME' => $welcome, 'END' => $end, 'THEREAREXQUESTIONS' => 0, 'SUBMIT_TEXT' => gT("Submit Your Survey."), 'SUBMIT_BY' => $surveyexpirydate, 'THANKS' => gT("Thank you for completing this survey."), 'HEADELEMENTS' => $headelements, 'TEMPLATEURL' => PRINT_TEMPLATE_URL, 'FAXTO' => $surveyfaxto, 'PRIVACY' => '', 'GROUPS' => '');
         $survey_output['FAX_TO'] = '';
         if (!empty($surveyfaxto) && $surveyfaxto != '000-00000000') {
             $survey_output['FAX_TO'] = gT("Please fax your completed survey to:") . " {$surveyfaxto}";
         }
         $total_questions = 0;
         $mapquestionsNumbers = array();
         $answertext = '';
         // otherwise can throw an error on line 1617
         $fieldmap = createFieldMap($surveyid, 'full', false, false, $sLanguageCode);
         // =========================================================
         // START doin the business:
         foreach ($degresult->readAll() as $degrow) {
             // ---------------------------------------------------
             // START doing groups
             $deqresult = Question::model()->getQuestions($surveyid, $degrow['gid'], $sLanguageCode, 0, '"I"');
             $deqrows = array();
             //Create an empty array in case FetchRow does not return any rows
             foreach ($deqresult->readAll() as $deqrow) {
                 $deqrows[] = $deqrow;
             }
             // Get table output into array
             // Perform a case insensitive natural sort on group name then question title of a multidimensional array
             usort($deqrows, 'groupOrderThenQuestionOrder');
             if ($degrow['description']) {
//.........这里部分代码省略.........
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:101,代码来源:printablesurvey.php


示例9: 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) . "}}");
         }
         $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:elcharlygraf,项目名称:Encuesta-YiiFramework,代码行数:40,代码来源:Survey.php


示例10: ajaxReloadPositionWidget

 public function ajaxReloadPositionWidget($gid)
 {
     $oQuestionGroup = QuestionGroup::model()->find('gid=:gid', array(':gid' => $gid));
     if (is_a($oQuestionGroup, 'QuestionGroup') && Permission::model()->hasSurveyPermission($oQuestionGroup->sid, 'surveycontent', 'read')) {
         return App()->getController()->widget('ext.admin.survey.question.PositionWidget.PositionWidget', array('display' => 'form_group', 'oQuestionGroup' => $oQuestionGroup));
     }
 }
开发者ID:sickpig,项目名称:LimeSurvey,代码行数:7,代码来源:questions.php


示例11: _reorderGroup

 private function _reorderGroup($iSurveyID)
 {
     $AOrgData = array();
     parse_str($_POST['orgdata'], $AOrgData);
     $grouporder = 0;
     foreach ($AOrgData['list'] as $ID => $parent) {
         if ($parent == 'root' && $ID[0] == 'g') {
             QuestionGroup::model()->updateAll(array('group_order' => $grouporder), 'gid=:gid', array(':gid' => (int) substr($ID, 1)));
             $grouporder++;
         } elseif ($ID[0] == 'q') {
             $qid = (int) substr($ID, 1);
             $gid = (int) substr($parent, 1);
             if (!isset($aQuestionOrder[$gid])) {
                 $aQuestionOrder[$gid] = 0;
             }
             $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
             $oQuestion = Question::model()->findByPk(array("qid" => $qid, 'language' => $sBaseLanguage));
             $oldGid = $oQuestion['gid'];
             if ($oldGid != $gid) {
                 fixMovedQuestionConditions($qid, $oldGid, $gid, $iSurveyID);
             }
             Question::model()->updateAll(array('question_order' => $aQuestionOrder[$gid], 'gid' => $gid), 'qid=:qid', array(':qid' => $qid));
             Question::model()->updateAll(array('gid' => $gid), 'parent_qid=:parent_qid', array(':parent_qid' => $qid));
             $aQuestionOrder[$gid]++;
         }
     }
     LimeExpressionManager::SetDirtyFlag();
     // so refreshes syntax highlighting
     Yii::app()->session['flashmessage'] = gT("The new question group/question order was successfully saved.");
     $this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyID));
 }
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:31,代码来源:surveyadmin.php


示例12: getbuttons

 public function getbuttons()
 {
     $sSummaryUrl = App()->createUrl("/admin/survey/sa/view/surveyid/" . $this->sid);
     $sEditUrl = App()->createUrl("/admin/survey/sa/editlocalsettings/surveyid/" . $this->sid);
     $sDeleteUrl = App()->createUrl("/admin/survey/sa/delete/surveyid/" . $this->sid);
     $sStatUrl = App()->createUrl("/admin/statistics/sa/simpleStatistics/surveyid/" . $this->sid);
     $sAddGroup = App()->createUrl("/admin/questiongroups/sa/add/surveyid/" . $this->sid);
     $sAddquestion = App()->createUrl("/admin/questions/sa/newquestion/surveyid/" . $this->sid);
     $button = '<a class="btn btn-default" href="' . $sSummaryUrl . '" role="button" data-toggle="tooltip" title="' . gT('Survey summary') . '"><span class="glyphicon glyphicon-list-alt" ></span></a>';
     $button .= '<a class="btn btn-default" href="' . $sEditUrl . '" role="button" data-toggle="tooltip" title="' . gT('General settings & texts') . '"><span class="glyphicon glyphicon-pencil" ></span></a>';
     $button .= '<a class="btn btn-default" href="' . $sDeleteUrl . '" role="button" data-toggle="tooltip" title="' . gT('Delete') . '"><span class="text-danger glyphicon glyphicon-trash" ></span></a>';
     if (Permission::model()->hasSurveyPermission($this->sid, 'statistics', 'read') && $this->active == 'Y') {
         $button .= '<a class="btn btn-default" href="' . $sStatUrl . '" role="button" data-toggle="tooltip" title="' . gT('Statistics') . '"><span class="glyphicon glyphicon-stats text-success" ></span></a>';
     }
     if ($this->active != 'Y') {
         $groupCount = QuestionGroup::model()->countByAttributes(array('sid' => $this->sid, 'language' => $this->language));
         //Checked
         if ($groupCount > 0) {
             $button .= '<a class="btn btn-default" href="' . $sAddquestion . '" role="button" data-toggle="tooltip" title="' . gT('Add new question') . '"><span class="icon-add text-success" ></span></a>';
         } else {
             $button .= '<a class="btn btn-default" href="' . $sAddGroup . '" role="button" data-toggle="tooltip" title="' . gT('Add new group') . '"><span class="icon-add text-success" ></span></a>';
         }
     }
     $previewUrl = Yii::app()->createUrl("survey/index/sid/");
     $previewUrl .= '/' . $this->sid;
     //$button = '<a class="btn btn-default open-preview" aria-data-url="'.$previewUrl.'" aria-data-language="'.$this->language.'" href="# role="button" ><span class="glyphicon glyphicon-eye-open"  ></span></a> ';
     return $button;
 }
开发者ID:joaocc,项目名称:LimeSurvey--LimeSurvey,代码行数:28,代码来源:Survey.php


示例13: randomizationGroup

/**
 * Randomization group for groups
 * @param int $surveyid
 * @param array $fieldmap
 * @param boolean $preview
 * @return array ($fieldmap, $randomized)
 */
function randomizationGroup($surveyid, array $fieldmap, $preview)
{
    // Randomization groups for groups
    $aRandomGroups = array();
    $aGIDCompleteMap = array();
    // First find all groups and their groups IDS
    $criteria = new CDbCriteria();
    $criteria->addColumnCondition(array('sid' => $surveyid, 'language' => $_SESSION['survey_' . $surveyid]['s_lang']));
    $criteria->addCondition("randomization_group != ''");
    $oData = QuestionGroup::model()->findAll($criteria);
    foreach ($oData as $aGroup) {
        $aRandomGroups[$aGroup['randomization_group']][] = $aGroup['gid'];
    }
    // Shuffle each group and create a map for old GID => new GID
    foreach ($aRandomGroups as $sGroupName => $aGIDs) {
        $aShuffledIDs = $aGIDs;
        shuffle($aShuffledIDs);
        $aGIDCompleteMap = $aGIDCompleteMap + array_combine($aGIDs, $aShuffledIDs);
    }
    $_SESSION['survey_' . $surveyid]['groupReMap'] = $aGIDCompleteMap;
    $randomized = false;
    // So we can trigger reorder once for group and question randomization
    // Now adjust the grouplist
    if (count($aRandomGroups) > 0 && !$preview) {
        $randomized = true;
        // So we can trigger reorder once for group and question randomization
        // Now adjust the grouplist
        Yii::import('application.helpers.frontend_helper', true);
        // make sure frontend helper is loaded
        UpdateGroupList($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
        // ... and the fieldmap
        // First create a fieldmap with GID as key
        foreach ($fieldmap as $aField) {
            if (isset($aField['gid'])) {
                $GroupFieldMap[$aField['gid']][] = $aField;
            } else {
                $GroupFieldMap['other'][] = $aField;
            }
        }
        // swap it
        foreach ($GroupFieldMap as $iOldGid => $fields) {
            $iNewGid = $iOldGid;
            if (isset($aGIDCompleteMap[$iOldGid])) {
                $iNewGid = $aGIDCompleteMap[$iOldGid];
            }
            $newGroupFieldMap[$iNewGid] = $GroupFieldMap[$iNewGid];
        }
        $GroupFieldMap = $newGroupFieldMap;
        // and convert it back to a fieldmap
        unset($fieldmap);
        foreach ($GroupFieldMap as $aGroupFields) {
            foreach ($aGroupFields as $aField) {
                if (isset($aField['fieldname'])) {
                    $fieldmap[$aField['fieldname']] = $aField;
                    // isset() because of the shuffled flag above
                }
            }
        }
    }
    return array($fieldmap, $randomized);
}
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:68,代码来源:frontend_helper.php


示例14: actionUpdate

 /**
  * Mise  àjour d un formulaire /mode edition
  * @param $id the ID of the model to be displayed
  */
 public function actionUpdate($id)
 {
     $model = Questionnaire::model()->findByPk(new MongoID($id));
     $questionBlocForm = new QuestionBlocForm();
     $questionForm = new QuestionForm();
     $questionGroup = new QuestionGroup();
     // collect user input data
     if (isset($_POST['QuestionForm'])) {
         $questionForm->attributes = $_POST['QuestionForm'];
         if ($questionForm->validatewithId($model)) {
             if ($questionForm->help == "") {
                 $questionForm->help = null;
             }
             //traitement ajout de question
             if ($questionForm->validate()) {
                 $model = $model->saveQuestionnaireNewQuestion($questionForm);
             } else {
                 Yii::app()->user->setFlash('error', Yii::t('common', 'questionNotAdded'));
             }
         } else {
             Yii::app()->user->setFlash('error', Yii::t('common', 'questionNotAdded'));
         }
     }
     if (isset($_POST['QuestionGroup'])) {
         $questionGroup->attributes = $_POST['QuestionGroup'];
         if ($questionGroup->validatewithId($model)) {
             //copie du titre sur l option fr
             $questionGroup->title_fr = $questionGroup->title;
             if ($questionGroup->validate()) {
                 $model = $model->saveQuestionnaireNewGroup($questionGroup);
             }
         } else {
             Yii::app()->user->setFlash('error', Yii::t('common', 'tabNotAdded'));
         }
     }
     if (isset($_POST['QuestionBlocForm'])) {
         $questionBlocForm->attributes = $_POST['QuestionBlocForm'];
         if ($questionBlocForm->validatewithId($model)) {
             $questionBloc = QuestionBloc::model()->findByPk(new MongoId($questionBlocForm->title));
             $questionBlocForm->title_fr = $questionBlocForm->title;
             $computedGroup = new QuestionGroup();
             $computedGroup->copy($questionBlocForm, $questionBloc);
             if ($computedGroup->validate()) {
                 $model = $model->saveQuestionnaireNewGroup($computedGroup);
             }
             if (isset($questionBloc->questions) && $questionBloc->questions != null && count($questionBloc->questions) > 0) {
                 foreach ($questionBloc->questions as $question => $value) {
                     $currentQuestion = Question::model()->findByPk(new MongoId($value));
                     $questionForm->copy($currentQuestion, $computedGroup);
                     $model->saveQuestionnaireNewQuestionBloc($questionForm);
                 }
             }
         } else {
             Yii::app()->user->setFlash('error', Yii::t('common', 'tabNotAdded'));
         }
     }
     if (isset($_POST['old_onglet'])) {
         foreach ($model->questions_group as $onglet) {
             if ($onglet->id == $_POST['old_onglet']) {
                 $onglet->title = $_POST['new_onglet'];
                 $onglet->title_fr = $_POST['new_onglet'];
                 if ($model->save()) {
                     Yii::app()->user->setFlash('success', Yii::t('common', 'tabUpdated'));
                 } else {
                     Yii::app()->user->setFlash('error', Yii::t('common', 'tabNotUpdated'));
                 }
             }
         }
     }
     if (isset($_POST['old_question'])) {
         foreach ($model->questions_group as $onglet) {
             foreach ($onglet->questions as $question) {
                 if ($question->id == $_POST['old_question']) {
                     $question->label = $_POST['new_question'];
                     $question->label_fr = $_POST['new_question'];
                     if ($model->save()) {
                         Yii::app()->user->setFlash('success', Yii::t('common', 'questionUpdated'));
                     } else {
                         Yii::app()->user->setFlash('error', Yii::t('common', 'questionNotUpdated'));
                     }
                 }
             }
         }
     }
     //  set du model sur la questionForm pour generer l arborescende de position de question
     $questionForm->questionnaire = $model;
     $questionGroup->questionnaire = $model;
     $this->render('update', array('model' => $model, 'questionForm' => $questionForm, 'questionGroup' => $questionGroup, 'questionBloc' => $questionBlocForm));
 }
开发者ID:Biobanques,项目名称:cbsd_platform,代码行数:93,代码来源:FormulaireController.php


示例15: menuGroup

 protected function menuGroup($groupId)
 {
     $group = QuestionGroup::model()->findByAttributes(array('gid' => $groupId));
     $menu['title'] = "Group {$group->group_name} (id: {$groupId})";
     $menu['role'] = 'group';
     $menu['imageUrl'] = App()->getConfig('adminimageurl');
     $menu['items']['left'][] = array('alt' => gT('Preview this group'), 'type' => 'link', 'image' => 'preview.png', 'target' => '_blank', 'href' => array('groups/preview', 'id' => $groupId));
     $menu['items']['left'][] = 'separator';
     $menu['items']['left'][] = array('alt' => gT('Edit current question group'), 'type' => 'link', 'image' => 'edit.png', 'href' => array('admin/questiongroups', 'sa' => 'edit', 'surveyid' => $group->sid, 'gid' => $groupId));
     $menu['items']['left'][] = 'separator';
     $menu['items']['left'][] = 'separator';
     $menu['items']['right'][] = array('type' => 'select', 'title' => gT('Questions'), 'name' => 'id', 'route' => 'questions/update', 'values' => Question::model()->findListByAttributes(array('sid' => $group->sid, 'gid' => $groupId), 'code', 'qid'), 'value' => $this->questionId);
     $menu['items']['right'][] = array('alt' => gT('Add new question to group'), 'type' => 'link', 'image' => 'add.png', 'href' => array('questions/create', 'gid' => $groupId));
     return $menu;
 }
开发者ID:BertHankes,项目名称:LimeSurvey,代码行数:15,代码来源:MenuWidget.php


示例16: _checkintegrity

 /**
  * This function checks the LimeSurvey database for logical consistency and returns an according array
  * containing all issues in the particular tables.
  * @returns Array with all found issues.
  */
 protected function _checkintegrity()
 {
     $clang = Yii::app()->lang;
     /*** Plainly delete survey permissions if the survey or user does not exist ***/
     $users = User::model()->findAll();
     $uids = array();
     foreach ($users as $user) {
         $uids[] = $user['uid'];
     }
     $oCriteria = new CDbCriteria();
     $oCriteria->addNotInCondition('uid', $uids, 'OR');
     $surveys = Survey::model()->findAll();
     $sids = array();
     foreach ($surveys as $survey) {
         $sids[] = $survey['sid'];
     }
     $oCriteria->addNotInCondition('entity_id', $sids, 'OR');
     $oCriteria->addCondition("entity='survey'");
     Permission::model()->deleteAll($oCriteria);
     // Deactivate surveys that have a missing response table
     foreach ($surveys as $survey) {
         if ($survey['active'] == 'Y' && !tableExists("{{survey_{$survey['sid']}}}")) {
             Survey::model()->updateByPk($survey['sid'], array('active' => 'N'));
         }
     }
     unset($surveys);
     // Fix subquestions
     fixSubquestions();
     /*** Check for active survey tables with missing survey entry and rename them ***/
     $sDBPrefix = Yii::app()->db->tablePrefix;
     $sQuery = dbSelectTablesLike('{{survey}}\\_%');
     $aResult = dbQueryOrFalse($sQuery);
     foreach ($aResult->readAll() as $aRow) {
         $sTableName = substr(reset($aRow), strlen($sDBPrefix));
         if ($sTableName == 'survey_links' || $sTableName == 'survey_url_parameters') {
             continue;
         }
         $aTableName = explode('_', $sTableName);
         if (isset($aTableName[1]) && ctype_digit($aTableName[1])) {
             $iSurveyID = $aTableName[1];
             if (!in_array($iSurveyID, $sids)) {
                 $sDate = date('YmdHis') . rand(1, 1000);
                 $sOldTable = "survey_{$iSurveyID}";
                 $sNewTable = "old_survey_{$iSurveyID}_{$sDate}";
                 try {
                     $deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
                 } catch (CDbException $e) {
                     die('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:<br />' . htmlspecialchars($e) . '<br />');
                 }
             }
         }
     }
     /*** Check for active token tables with missing survey entry ***/
     $aResult = dbQueryOrFalse(dbSelectTablesLike('{{tokens}}\\_%'));
     foreach ($aResult->readAll() as $aRow) {
         $sTableName = substr(reset($aRow), strlen($sDBPrefix));
         $iSurveyID = substr($sTableName, strpos($sTableName, '_') + 1);
         if (!in_array($iSurveyID, $sids)) {
             $sDate = date('YmdHis') . rand(1, 1000);
             $sOldTable = "tokens_{$iSurveyID}";
             $sNewTable = "old_tokens_{$iSurveyID}_{$sDate}";
             try {
                 $deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
             } catch (CDbException $e) {
                 die('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:<br />' . htmlspecialchars($e) . '<br />');
             }
         }
     }
     /**********************************************************************/
     /*     Check conditions                                               */
     /**********************************************************************/
     $okQuestion = array();
     $sQuery = 'SELECT cqid,cid,cfieldname FROM {{conditions}}';
     $aConditions = Yii::app()->db->createCommand($sQuery)->queryAll();
     foreach ($aConditions as $condition) {
         if ($condition['cqid'] != 0) {
             // skip case with cqid=0 for codnitions on {TOKEN:EMAIL} for instance
             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_mat 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Queue类代码示例发布时间:2022-05-23
下一篇:
PHP QuestionAttribute类代码示例发布时间: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