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


PHP QuestionGroup类代码示例

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


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


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