本文整理汇总了PHP中getQuestionTypeList函数的典型用法代码示例。如果您正苦于以下问题:PHP getQuestionTypeList函数的具体用法?PHP getQuestionTypeList怎么用?PHP getQuestionTypeList使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getQuestionTypeList函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _questionbar
/**
* Shows admin menu for question
* @param int Survey id
* @param int Group id
* @param int Question id
* @param string action
*/
function _questionbar($iSurveyID, $gid, $qid, $action = null)
{
$baselang = Survey::model()->findByPk($iSurveyID)->language;
//Show Question Details
$qrrow = Question::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $iSurveyID, 'language' => $baselang));
if (is_null($qrrow)) {
return;
}
// Throw 404 ....
$questionsummary = "<div class='menubar'>\n";
// Check if other questions in the Survey are dependent upon this question
$condarray = getQuestDepsForConditions($iSurveyID, "all", "all", $qid, "by-targqid", "outsidegroup");
$sumresult1 = Survey::model()->findByPk($iSurveyID);
if (is_null($sumresult1)) {
Yii::app()->session['flashmessage'] = gT("Invalid survey ID");
$this->getController()->redirect(array("admin/index"));
}
// if surveyid is invalid then die to prevent errors at a later time
$surveyinfo = $sumresult1->attributes;
$surveyinfo = array_map('flattenText', $surveyinfo);
$aData['activated'] = $surveyinfo['active'];
$qrrow = $qrrow->attributes;
$aData['languagelist'] = Survey::model()->findByPk($iSurveyID)->getAllLanguages();
$aData['qtypes'] = $qtypes = getQuestionTypeList('', 'array');
// Warning of lack of sub-questions or answers
$aWarnings = array();
if ($qtypes[$qrrow['type']]['answerscales'] > 0 && !Answer::model()->count("qid=:qid AND language=:language and scale_id=0", array(':qid' => $qid, ':language' => $baselang))) {
$aWarnings[] = array('url' => App()->createUrl("admin/questions", array("sa" => "answeroptions", "surveyid" => $iSurveyID, "gid" => $gid, "qid" => $qid)), 'img' => 'answers_20.png', 'text' => gT("You need to add answer options to this question.", 'unescaped'), 'help' => gT("Edit answer options for this question.", 'unescaped'));
} elseif ($qtypes[$qrrow['type']]['answerscales'] > 1 && !Answer::model()->count("qid=:qid AND language=:language and scale_id=1", array(':qid' => $qid, ':language' => $baselang))) {
$aWarnings[] = array('url' => App()->createUrl("admin/questions", array("sa" => "answeroptions", "surveyid" => $iSurveyID, "gid" => $gid, "qid" => $qid)), 'img' => 'answers_20.png', 'text' => gT("You need to add answer options to this question.", 'unescaped'), 'help' => gT("Edit answer options for this question.", 'unescaped'));
}
if ($qtypes[$qrrow['type']]['subquestions'] > 0 && !Question::model()->count("parent_qid=:qid AND language=:language and scale_id=0", array(':qid' => $qid, ':language' => $baselang))) {
$aWarnings[] = array('url' => App()->createUrl("admin/questions", array("sa" => "subquestions", "surveyid" => $iSurveyID, "gid" => $gid, "qid" => $qid)), 'img' => $qtypes[$qrrow['type']]['subquestions'] > 1 ? "subquestions2d_20.png" : "subquestions_20.png", 'text' => gT("You need to add subquestions options to this question.", 'unescaped'), 'help' => gT("Edit subquestions options for this question.", 'unescaped'));
} elseif ($qtypes[$qrrow['type']]['subquestions'] > 1 && !Question::model()->count("parent_qid=:qid AND language=:language and scale_id=1", array(':qid' => $qid, ':language' => $baselang))) {
$aWarnings[] = array('url' => App()->createUrl("admin/questions", array("sa" => "subquestions", "surveyid" => $iSurveyID, "gid" => $gid, "qid" => $qid)), 'img' => 'subquestions2d_20.png', 'text' => gT("You need to add subquestions to this question.", 'unescaped'), 'help' => gT("Edit subquestions for this question.", 'unescaped'));
}
$aData['aWarnings'] = $aWarnings;
if ($action == 'editansweroptions' || $action == "editsubquestions" || $action == "editquestion" || $action == "editdefaultvalues" || $action == "editdefaultvalues" || $action == "copyquestion") {
$qshowstyle = "style='display: none'";
} else {
$qshowstyle = "";
}
$aData['qshowstyle'] = $qshowstyle;
$aData['action'] = $action;
$aData['surveyid'] = $iSurveyID;
$aData['qid'] = $qid;
$aData['gid'] = $gid;
$aData['qrrow'] = $qrrow;
$aData['baselang'] = $baselang;
$aAttributesWithValues = Question::model()->getAdvancedSettingsWithValues($qid, $qrrow['type'], $iSurveyID, $baselang);
$DisplayArray = array();
foreach ($aAttributesWithValues as $aAttribute) {
if ($aAttribute['i18n'] == false && isset($aAttribute['value']) && $aAttribute['value'] != $aAttribute['default'] || $aAttribute['i18n'] == true && isset($aAttribute['value'][$baselang]) && $aAttribute['value'][$baselang] != $aAttribute['default']) {
if ($aAttribute['inputtype'] == 'singleselect') {
$aAttribute['value'] = $aAttribute['options'][$aAttribute['value']];
}
/*
if ($aAttribute['name']=='relevance')
{
$sRelevance = $aAttribute['value'];
if ($sRelevance !== '' && $sRelevance !== '1' && $sRelevance !== '0')
{
LimeExpressionManager::ProcessString("{" . $sRelevance . "}"); // tests Relevance equation so can pretty-print it
$aAttribute['value']= LimeExpressionManager::GetLastPrettyPrintExpression();
}
}
*/
$DisplayArray[] = $aAttribute;
}
}
$aData['advancedsettings'] = $DisplayArray;
$aData['condarray'] = $condarray;
$aData['sImageURL'] = Yii::app()->getConfig('adminimageurl');
$aData['iIconSize'] = Yii::app()->getConfig('adminthemeiconsize');
$questionsummary .= $this->getController()->renderPartial('/admin/survey/Question/questionbar_view', $aData, true);
$finaldata['display'] = $questionsummary;
$this->getController()->renderPartial('/survey_view', $finaldata);
}
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:85,代码来源:Survey_Common_Action.php
示例2: index
/**
* Database::index()
*
* @param mixed $sa
* @return
*/
function index($sa = null)
{
$sAction = Yii::app()->request->getPost('action');
$iSurveyID = isset($_POST['sid']) ? $_POST['sid'] : returnGlobal('sid');
$iQuestionGroupID = returnGlobal('gid');
$iQuestionID = returnGlobal('qid');
// TODO: This variable seems to be never set or used in any function call?
$sDBOutput = '';
$oFixCKeditor = new LSYii_Validators();
$oFixCKeditor->fixCKeditor = true;
$oFixCKeditor->xssfilter = false;
if ($sAction == "updatedefaultvalues" && Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update')) {
$aSurveyLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($aSurveyLanguages, $sBaseLanguage);
Question::model()->updateAll(array('same_default' => Yii::app()->request->getPost('samedefault') ? 1 : 0), 'sid=:sid ANd qid=:qid', array(':sid' => $iSurveyID, ':qid' => $iQuestionID));
$arQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
$sQuestionType = $arQuestion['type'];
$aQuestionTypeList = getQuestionTypeList('', 'array');
if ($aQuestionTypeList[$sQuestionType]['answerscales'] > 0 && $aQuestionTypeList[$sQuestionType]['subquestions'] == 0) {
for ($iScaleID = 0; $iScaleID < $aQuestionTypeList[$sQuestionType]['answerscales']; $iScaleID++) {
foreach ($aSurveyLanguages as $sLanguage) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage))) {
$this->_updateDefaultValues($iQuestionID, 0, $iScaleID, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage), true);
}
if (!is_null(Yii::app()->request->getPost('other_' . $iScaleID . '_' . $sLanguage))) {
$this->_updateDefaultValues($iQuestionID, 0, $iScaleID, 'other', $sLanguage, Yii::app()->request->getPost('other_' . $iScaleID . '_' . $sLanguage), true);
}
}
}
}
if ($aQuestionTypeList[$sQuestionType]['subquestions'] > 0) {
foreach ($aSurveyLanguages as $sLanguage) {
$arQuestions = Question::model()->findAllByAttributes(array('sid' => $iSurveyID, 'gid' => $iQuestionGroupID, 'parent_qid' => $iQuestionID, 'language' => $sLanguage, 'scale_id' => 0));
for ($iScaleID = 0; $iScaleID < $aQuestionTypeList[$sQuestionType]['subquestions']; $iScaleID++) {
foreach ($arQuestions as $aSubquestionrow) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage . '_' . $aSubquestionrow['qid']))) {
$this->_updateDefaultValues($iQuestionID, $aSubquestionrow['qid'], $iScaleID, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage . '_' . $aSubquestionrow['qid']), true);
}
}
}
}
}
if ($aQuestionTypeList[$sQuestionType]['answerscales'] == 0 && $aQuestionTypeList[$sQuestionType]['subquestions'] == 0) {
foreach ($aSurveyLanguages as $sLanguage) {
// Qick and dirty insert for yes/no defaul value
// write the the selectbox option, or if "EM" is slected, this value to table
if ($sQuestionType == 'Y') {
/// value for all langs
if (Yii::app()->request->getPost('samedefault') == 1) {
$sLanguage = $aSurveyLanguages[0];
// turn
} else {
$sCurrentLang = $sLanguage;
// edit the next lines
}
if (Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage) == 'EM') {
// Case EM, write expression to database
$this->_updateDefaultValues($iQuestionID, 0, 0, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage . '_EM'), true);
} else {
// Case "other", write list value to database
$this->_updateDefaultValues($iQuestionID, 0, 0, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage), true);
}
///// end yes/no
} else {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage . '_0'))) {
$this->_updateDefaultValues($iQuestionID, 0, 0, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage . '_0'), true);
}
}
}
}
Yii::app()->session['flashmessage'] = gT("Default value settings were successfully saved.");
LimeExpressionManager::SetDirtyFlag();
if ($sDBOutput != '') {
echo $sDBOutput;
} else {
if (Yii::app()->request->getPost('close-after-save') === 'true') {
$this->getController()->redirect(array('admin/questions/sa/view/surveyid/' . $iSurveyID . '/gid/' . $iQuestionGroupID . '/qid/' . $iQuestionID));
}
$this->getController()->redirect(array('admin/questions/sa/editdefaultvalues/surveyid/' . $iSurveyID . '/gid/' . $iQuestionGroupID . '/qid/' . $iQuestionID));
}
}
if ($sAction == "updateansweroptions" && Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update')) {
Yii::app()->loadHelper('database');
$aSurveyLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($aSurveyLanguages, $sBaseLanguage);
$arQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
$sQuestionType = $arQuestion['type'];
// Checked)
$aQuestionTypeList = getQuestionTypeList('', 'array');
$iScaleCount = $aQuestionTypeList[$sQuestionType]['answerscales'];
//First delete all answers
Answer::model()->deleteAllByAttributes(array('qid' => $iQuestionID));
//.........这里部分代码省略.........
开发者ID:joaocc,项目名称:LimeSurvey--LimeSurvey,代码行数:101,代码来源:database.php
示例3: index
/**
* Load edit/new question screen depending on $action.
*
* @access public
* @param string $sa subaction
* @param int $surveyid
* @param int $gid
* @param int $qid
* @return void
*/
public function index($sa, $surveyid, $gid, $qid = null)
{
App()->getClientScript()->registerPackage('qTip2');
$action = $sa;
$surveyid = $iSurveyID = sanitize_int($surveyid);
$gid = sanitize_int($gid);
if (isset($qid)) {
$qid = sanitize_int($qid);
}
$aViewUrls = array();
$aData['surveyid'] = $surveyid;
$aData['gid'] = $gid;
$aData['qid'] = $qid;
$aData['display']['menu_bars']['surveysummary'] = 'viewgroup';
$aData['display']['menu_bars']['gid_action'] = 'addquestion';
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
$aData['questiongroupbar']['savebutton']['form'] = 'frmeditgroup';
$aData['questiongroupbar']['saveandclosebutton']['form'] = 'frmeditgroup';
$aData['questiongroupbar']['closebutton']['url'] = 'admin/questions/sa/view/surveyid/' . $surveyid . '/gid/' . $gid . '/qid/' . $qid;
Yii::app()->session['FileManagerContext'] = "create:question:{$surveyid}";
if (Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
$surveyinfo = getSurveyInfo($surveyid);
Yii::app()->loadHelper('admin/htmleditor');
Yii::app()->loadHelper('surveytranslator');
if (isset($_POST['sortorder'])) {
$postsortorder = sanitize_int($_POST['sortorder']);
}
$aData['adding'] = $adding = $action == 'addquestion';
$aData['copying'] = $copying = $action == 'copyquestion';
$questlangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
$baselang = Survey::model()->findByPk($surveyid)->language;
$questlangs[] = $baselang;
$questlangs = array_flip($questlangs);
// Prepare selector Mode TODO: with and without image
if (!$adding) {
Yii::app()->session['FileManagerContext'] = "edit:question:{$surveyid}";
$aData['display']['menu_bars']['qid_action'] = 'editquestion';
$egresult = Question::model()->findAllByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'qid' => $qid));
foreach ($egresult as $esrow) {
if (!array_key_exists($esrow->language, $questlangs)) {
// Language Exists, BUT ITS NOT ON THE SURVEY ANYMORE.
$esrow->delete();
} else {
$questlangs[$esrow->language] = 99;
}
if ($esrow->language == $baselang) {
$esrow = $esrow->attributes;
$basesettings = array('question_order' => $esrow['question_order'], 'other' => $esrow['other'], 'mandatory' => $esrow['mandatory'], 'type' => $esrow['type'], 'title' => $esrow['title'], 'preg' => $esrow['preg'], 'question' => $esrow['question'], 'help' => $esrow['help']);
}
}
if (!$egresult) {
$this->getController()->error('Invalid question id');
}
while (list($key, $value) = each($questlangs)) {
if ($value != 99) {
$arQuestion = new Question();
$arQuestion->qid = $qid;
$arQuestion->sid = $surveyid;
$arQuestion->gid = $gid;
$arQuestion->type = $basesettings['type'];
$arQuestion->title = $basesettings['title'];
$arQuestion->question = $basesettings['question'];
$arQuestion->preg = $basesettings['preg'];
$arQuestion->help = $basesettings['help'];
$arQuestion->other = $basesettings['other'];
$arQuestion->mandatory = $basesettings['mandatory'];
$arQuestion->question_order = $basesettings['question_order'];
$arQuestion->language = $key;
$arQuestion->insert();
}
}
$eqresult = Question::model()->with('groups')->together()->findByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'qid' => $qid, 'language' => $baselang));
} else {
// This is needed to properly color-code content if it contains replacements
LimeExpressionManager::StartProcessingPage(false, Yii::app()->baseUrl, true);
// so can click on syntax highlighting to edit questions
}
$qtypelist = getQuestionTypeList('', 'array');
$qDescToCode = 'qDescToCode = {';
$qCodeToInfo = 'qCodeToInfo = {';
foreach ($qtypelist as $qtype => $qdesc) {
$qDescToCode .= " '{$qdesc['description']}' : '{$qtype}', \n";
$qCodeToInfo .= " '{$qtype}' : '" . ls_json_encode($qdesc) . "', \n";
}
$aData['qTypeOutput'] = "{$qDescToCode} 'null':'null' }; \n {$qCodeToInfo} 'null':'null' };";
if (!$adding) {
if (is_object($eqresult->groups)) {
$eqrow = array_merge($eqresult->attributes, $eqresult->groups->attributes);
} else {
//.........这里部分代码省略.........
开发者ID:CSCI-462-01-2016,项目名称:LimeSurvey,代码行数:101,代码来源:questions.php
示例4: _questionbar
/**
* Shows admin menu for question
*
* @param int Survey id
* @param int Group id
* @param int Question id
* @param string action
*/
function _questionbar($aData)
{
if (isset($aData['questionbar'])) {
if (is_object($aData['oSurvey'])) {
$iSurveyID = $aData['surveyid'];
$oSurvey = $aData['oSurvey'];
$gid = $aData['gid'];
$qid = $aData['qid'];
// action
$action = !empty($aData['display']['menu_bars']['qid_action']) ? $aData['display']['menu_bars']['qid_action'] : null;
$baselang = $oSurvey->language;
//Show Question Details
//Count answer-options for this question
$qrr = Answer::model()->findAllByAttributes(array('qid' => $qid, 'language' => $baselang));
$aData['qct'] = $qct = count($qrr);
//Count sub-questions for this question
$sqrq = Question::model()->findAllByAttributes(array('parent_qid' => $qid, 'language' => $baselang));
$aData['sqct'] = $sqct = count($sqrq);
$qrrow = Question::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $iSurveyID, 'language' => $baselang));
if (is_null($qrrow)) {
return;
}
$questionsummary = "<div class='menubar'>\n";
// Check if other questions in the Survey are dependent upon this question
$condarray = getQuestDepsForConditions($iSurveyID, "all", "all", $qid, "by-targqid", "outsidegroup");
$surveyinfo = $oSurvey->attributes;
$surveyinfo = array_map('flattenText', $surveyinfo);
$aData['activated'] = $surveyinfo['active'];
$qrrow = $qrrow->attributes;
$aData['languagelist'] = $oSurvey->getAllLanguages();
$aData['qtypes'] = $qtypes = getQuestionTypeList('', 'array');
$aData['action'] = $action;
$aData['surveyid'] = $iSurveyID;
$aData['qid'] = $qid;
$aData['gid'] = $gid;
$aData['qrrow'] = $qrrow;
$aData['baselang'] = $baselang;
$aAttributesWithValues = Question::model()->getAdvancedSettingsWithValues($qid, $qrrow['type'], $iSurveyID, $baselang);
$DisplayArray = array();
foreach ($aAttributesWithValues as $aAttribute) {
if ($aAttribute['i18n'] == false && isset($aAttribute['value']) && $aAttribute['value'] != $aAttribute['default'] || $aAttribute['i18n'] == true && isset($aAttribute['value'][$baselang]) && $aAttribute['value'][$baselang] != $aAttribute['default']) {
if ($aAttribute['inputtype'] == 'singleselect') {
$aAttribute['value'] = $aAttribute['options'][$aAttribute['value']];
}
$DisplayArray[] = $aAttribute;
}
}
$aData['advancedsettings'] = $DisplayArray;
$aData['condarray'] = $condarray;
$questionsummary .= $this->getController()->renderPartial('/admin/survey/Question/questionbar_view', $aData, true);
$finaldata['display'] = $questionsummary;
$this->getController()->renderPartial('/survey_view', $finaldata);
} else {
Yii::app()->session['flashmessage'] = gT("Invalid survey ID");
$this->getController()->redirect(array("admin/index"));
}
}
}
开发者ID:jgianpiere,项目名称:lime-survey,代码行数:66,代码来源:Survey_Common_Action.php
示例5: set_question_sub_questions
public function set_question_sub_questions($sSessionKey, $iSurveyID, $iQuestionID, $data)
{
$data_array = unserialize($data);
Yii::app()->loadHelper('database');
$aSurveyLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($aSurveyLanguages, $sBaseLanguage);
$arQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
$sQuestionType = $arQuestion['type'];
// Checked
$aQuestionTypeList = getQuestionTypeList('', 'array');
$iScaleCount = $aQuestionTypeList[$sQuestionType]['subquestions'];
//$clang = $this->getController()->lang;
// First delete any deleted ids
//$aDeletedQIDs = explode(' ', trim($data));
$aDeletedQIDs = explode('+', $data_array['deletedqids']);
$iQuestionGroupID = $data_array['gid'];
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
$aDeletedQIDs = array_unique($aDeletedQIDs, SORT_NUMERIC);
foreach ($aDeletedQIDs as $iDeletedQID) {
$iDeletedQID = (int) $iDeletedQID;
if ($iDeletedQID > 0) {
// don't remove undefined
$iInsertCount = Question::model()->deleteAllByAttributes(array('qid' => $iDeletedQID));
if (!$iInsertCount) {
return "Failed to delete answer";
}
}
}
//Determine ids by evaluating the hidden field
$aRows = array();
$aCodes = array();
$aOldCodes = array();
foreach ($data_array as $key => $value) {
$key = explode('_', $key);
if ($key[0] == 'answer') {
$aRows[$key[3]][$key[1]][$key[2]] = $value;
}
if ($key[0] == 'code') {
$aCodes[$key[2]][] = $value;
}
if ($key[0] == 'oldcode') {
$aOldCodes[$key[2]][] = $value;
}
}
$aInsertQID = array();
for ($iScaleID = 0; $iScaleID < $iScaleCount; $iScaleID++) {
foreach ($aSurveyLanguages as $sLanguage) {
$iPosition = 0;
$test = '';
foreach ($aRows[$iScaleID][$sLanguage] as $subquestionkey => $subquestionvalue) {
$test .= $subquestionvalue . ', ';
// create a new sub question
if (substr($subquestionkey, 0, 3) != 'new') {
$oSubQuestion = Question::model()->find("qid=:qid AND language=:language", array(":qid" => $subquestionkey, ':language' => $sLanguage));
$oSubQuestion->question_order = $iPosition + 1;
$oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
$oSubQuestion->question = $subquestionvalue;
$oSubQuestion->scale_id = $iScaleID;
// update the old sub questions
} else {
if (!isset($aInsertQID[$iScaleID][$iPosition])) {
$oSubQuestion = new Question();
$oSubQuestion->sid = $iSurveyID;
$oSubQuestion->gid = $iQuestionGroupID;
$oSubQuestion->question_order = $iPosition + 1;
$oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
$oSubQuestion->question = $subquestionvalue;
$oSubQuestion->parent_qid = $iQuestionID;
$oSubQuestion->language = $sLanguage;
$oSubQuestion->scale_id = $iScaleID;
// update old sub questions
} else {
$oSubQuestion = Question::model()->find("qid=:qid AND language=:language", array(":qid" => $aInsertQID[$iScaleID][$iPosition], ':language' => $sLanguage));
if (!$oSubQuestion) {
$oSubQuestion = new Question();
}
$oSubQuestion->sid = $iSurveyID;
$oSubQuestion->gid = $iQuestionGroupID;
$oSubQuestion->question_order = $iPosition + 1;
$oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
$oSubQuestion->question = $subquestionvalue;
$oSubQuestion->parent_qid = $iQuestionID;
$oSubQuestion->language = $sLanguage;
$oSubQuestion->scale_id = $iScaleID;
}
}
$bSubQuestionResult = $oSubQuestion->save();
if ($bSubQuestionResult) {
if (substr($subquestionkey, 0, 3) != 'new' && isset($aOldCodes[$iScaleID][$iPosition]) && $aCodes[$iScaleID][$iPosition] !== $aOldCodes[$iScaleID][$iPosition]) {
Condition::model()->updateAll(array('cfieldname' => '+' . $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID . $aCodes[$iScaleID][$iPosition], 'value' => $aCodes[$iScaleID][$iPosition]), 'cqid=:cqid AND cfieldname=:cfieldname AND value=:value', array(':cqid' => $iQuestionID, ':cfieldname' => $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID, ':value' => $aOldCodes[$iScaleID][$iPosition]));
}
if (!isset($aInsertQID[$iScaleID][$iPosition])) {
$aInsertQID[$iScaleID][$iPosition] = $oSubQuestion->qid;
}
} else {
$aErrors = $oSubQuestion->getErrors();
if (count($aErrors)) {
foreach ($aErrors as $sAttribute => $aStringErrors) {
foreach ($aStringErrors as $sStringErrors) {
//.........这里部分代码省略.........
开发者ID:sevenearths,项目名称:limesurvey-api-test,代码行数:101,代码来源:remotecontrol_handle.php
示例6: array
$groups[$questionType['group']] = array();
}
$groups[$questionType['group']][$key] = $questionType['description'];
}
$this->widget('ext.bootstrap.widgets.TbSelect2', array('data' => $groups, 'name' => 'type', 'options' => array('width' => '300px', 'minimumResultsForSearch' => 1000), 'events' => array(), 'htmlOptions' => array('id' => 'question_type', 'options' => array($eqrow['type'] => array('selected' => true)))));
$script = '$("#question_type option").addClass("questionType");';
App()->getClientScript()->registerScript('add_class_to_options', $script);
} else {
$aQtypeData = array();
foreach (getQuestionTypeList($eqrow['type'], 'array') as $key => $questionType) {
$aQtypeData[] = array('code' => $key, 'description' => $questionType['description'], 'group' => $questionType['group']);
}
echo CHtml::dropDownList('type', 'category', CHtml::listData($aQtypeData, 'code', 'description', 'group'), array('class' => 'none', 'id' => 'question_type', 'options' => array($eqrow['type'] => array('selected' => true))));
}
} else {
$qtypelist = getQuestionTypeList('', 'array');
echo "{$qtypelist[$eqrow['type']]['description']} - " . gT("Cannot be changed (survey is active)");
?>
<input type='hidden' name='type' id='question_type' value='<?php
echo $eqrow['type'];
?>
' />
<?php
}
?>
</li>
<?php
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:31,代码来源:editQuestion_view.php
示例7: activate
/**
* Function responsible to activate survey.
*
* @access public
* @param int $iSurveyID
* @return void
*/
public function activate($iSurveyID)
{
if (!Permission::model()->hasSurveyPermission($iSurveyID, 'surveyactivation', 'update')) {
die;
}
$iSurveyID = (int) $iSurveyID;
$aData = array();
$aData['sidemenu']['state'] = false;
$aData['aSurveysettings'] = getSurveyInfo($iSurveyID);
$aData['surveyid'] = $iSurveyID;
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
// Die if this is not possible
if (!isset($aData['aSurveysettings']['active']) || $aData['aSurveysettings']['active'] == 'Y') {
$this->getController()->error('Survey not active');
}
$qtypes = getQuestionTypeList('', 'array');
Yii::app()->loadHelper("admin/activate");
if (empty($_POST['ok'])) {
if (isset($_GET['fixnumbering']) && $_GET['fixnumbering']) {
fixNumbering($_GET['fixnumbering'], $iSurveyID);
}
// Check consistency for groups and questions
$failedgroupcheck = checkGroup($iSurveyID);
$failedcheck = checkQuestions($iSurveyID, $iSurveyID, $qtypes);
$aData['failedcheck'] = $failedcheck;
$aData['failedgroupcheck'] = $failedgroupcheck;
$aData['aSurveysettings'] = getSurveyInfo($iSurveyID);
$this->_renderWrappedTemplate('survey', 'activateSurvey_view', $aData);
} else {
$survey = Survey::model()->findByAttributes(array('sid' => $iSurveyID));
if (!is_null($survey)) {
$survey->anonymized = Yii::app()->request->getPost('anonymized');
$survey->datestamp = Yii::app()->request->getPost('datestamp');
$survey->ipaddr = Yii::app()->request->getPost('ipaddr');
$survey->refurl = Yii::app()->request->getPost('refurl');
$survey->savetimings = Yii::app()->request->getPost('savetimings');
$survey->save();
Survey::model()->resetCache();
// Make sure the saved values will be picked up
}
$aResult = activateSurvey($iSurveyID);
if (isset($aResult['error'])) {
$aViewUrls['output'] = "<br />\n<div class='messagebox ui-corner-all'>\n";
if ($aResult['error'] == 'surveytablecreation') {
$aViewUrls['output'] .= "<div class='alert alert-warning' role='alert'>" . gT("Survey table could not be created.") . "</div>\n";
} else {
$aViewUrls['output'] .= "<div class='alert alert-success' role='alert'>" . gT("Timings table could not be created.") . "</div>\n";
}
$aViewUrls['output'] .= "<strong class='text-warning'>" . gT("Database error!!") . "\n " . "\n" . "<pre>" . var_export($aResult['error'], true) . "</pre>\n\n <a href='" . Yii::app()->getController()->createUrl("admin/survey/sa/view/surveyid/" . $iSurveyID) . "'>" . gT("Main Admin Screen") . "</a>\n</strong><br/>";
} else {
$warning = isset($aResult['warning']) ? true : false;
$allowregister = $survey->allowregister == 'Y' ? true : false;
$onclickAction = convertGETtoPOST(Yii::app()->getController()->createUrl("admin/tokens/sa/index/surveyid/" . $iSurveyID));
$closedOnclickAction = convertGETtoPOST(Yii::app()->getController()->createUrl("admin/tokens/sa/index/surveyid/" . $iSurveyID));
$noOnclickAction = convertGETtoPOST(Yii::app()->getController()->createUrl("admin/survey/sa/view/surveyid/" . $iSurveyID));
$activationData = array('iSurveyID' => $iSurveyID, 'warning' => $warning, 'allowregister' => $allowregister, 'onclickAction' => $onclickAction, 'closedOnclickAction' => $closedOnclickAction, 'noOnclickAction' => $noOnclickAction);
$aViewUrls['output'] = $this->getController()->renderPartial('/admin/survey/_activation_feedback', $activationData, true);
}
$this->_renderWrappedTemplate('survey', $aViewUrls, $aData);
}
}
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:69,代码来源:surveyadmin.php
示例8: buildsurveysession
//.........这里部分代码省略.........
$aEnterTokenData = array();
$aEnterTokenData['bNewTest'] = false;
$aEnterTokenData['bDirectReload'] = false;
$aEnterTokenData['error'] = $secerror;
$aEnterTokenData['iSurveyId'] = $surveyid;
$aEnterTokenData['sKpClass'] = $kpclass;
// ???
$aEnterTokenData['sLangCode'] = $sLangCode;
if (isset($_GET['bNewTest']) && $_GET['newtest'] == "Y") {
$aEnterTokenData['bNewTest'] = true;
}
// If this is a direct Reload previous answers URL, then add hidden fields
if (isset($loadall) && isset($scid) && isset($loadname) && isset($loadpass)) {
$aEnterTokenData['bDirectReload'] = true;
$aEnterTokenData['sCid'] = $scid;
$aEnterTokenData['sLoadname'] = htmlspecialchars($loadname);
$aEnterTokenData['sLoadpass'] = htmlspecialchars($loadpass);
}
$FlashError = "";
// Scenario => Captcha required
if ($scenarios['captchaRequired'] && !$preview) {
list($renderCaptcha, $FlashError) = testCaptcha($aEnterTokenData, $subscenarios, $surveyid, $loadsecurity);
}
// Scenario => Token required
if ($scenarios['tokenRequired'] && !$preview) {
//Test if token is valid
list($renderToken, $FlashError) = testIfTokenIsValid($subscenarios, $thissurvey, $aEnterTokenData, $clienttoken);
}
//If there were errors, display through yii->FlashMessage
if ($FlashError !== "") {
$aEnterTokenData['errorMessage'] = $FlashError;
}
$renderWay = getRenderWay($renderToken, $renderCaptcha);
$redata = compact(array_keys(get_defined_vars()));
renderRenderWayForm($renderWay, $redata, $scenarios, $sTemplateViewPath, $aEnterTokenData, $surveyid);
// Reset all the session variables and start again
resetAllSessionVariables($surveyid);
// Multi lingual support order : by REQUEST, if not by Token->language else by survey default language
if (returnGlobal('lang', true)) {
$language_to_set = returnGlobal('lang', true);
} elseif (isset($oTokenEntry) && $oTokenEntry) {
// If survey have token : we have a $oTokenEntry
// Can use $oTokenEntry = Token::model($surveyid)->findByAttributes(array('token'=>$clienttoken)); if we move on another function : this par don't validate the token validity
$language_to_set = $oTokenEntry->language;
} else {
$language_to_set = $thissurvey['language'];
}
// Always SetSurveyLanguage : surveys controller SetSurveyLanguage too, if different : broke survey (#09769)
SetSurveyLanguage($surveyid, $language_to_set);
UpdateGroupList($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
$totalquestions = Question::model()->getTotalQuestions($surveyid);
$iTotalGroupsWithoutQuestions = QuestionGroup::model()->getTotalGroupsWithoutQuestions($surveyid);
// Fix totalquestions by substracting Test Display questions
$iNumberofQuestions = Question::model()->getNumberOfQuestions($surveyid);
$_SESSION['survey_' . $surveyid]['totalquestions'] = $totalquestions - (int) reset($iNumberofQuestions);
// 2. SESSION VARIABLE: totalsteps
setTotalSteps($surveyid, $thissurvey, $totalquestions);
// Break out and crash if there are no questions!
if ($totalquestions == 0 || $iTotalGroupsWithoutQuestions > 0) {
$redata = compact(array_keys(get_defined_vars()));
breakOutAndCrash($redata, $sTemplateViewPath, $totalquestions, $iTotalGroupsWithoutQuestions, $thissurvey);
}
//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']);
//$seed = ls\mersenne\getSeed($surveyid, $preview);
// Randomization groups for groups
list($fieldmap, $randomized1) = randomizationGroup($surveyid, $fieldmap, $preview);
// Randomization groups for questions
list($fieldmap, $randomized2) = randomizationQuestion($surveyid, $fieldmap, $preview);
$randomized = $randomized1 || $randomized2;
if ($randomized === true) {
$fieldmap = finalizeRandomization($fieldmap);
$_SESSION['survey_' . $surveyid]['fieldmap-' . $surveyid . $_SESSION['survey_' . $surveyid]['s_lang']] = $fieldmap;
$_SESSION['survey_' . $surveyid]['fieldmap-' . $surveyid . '-randMaster'] = 'fieldmap-' . $surveyid . $_SESSION['survey_' . $surveyid]['s_lang'];
}
// TMSW Condition->Relevance: don't need hasconditions, or usedinconditions
$_SESSION['survey_' . $surveyid]['fieldmap'] = $fieldmap;
initFieldArray($surveyid, $fieldmap);
// Prefill questions/answers from command line params
prefillFromCommandLine($surveyid);
if (isset($_SESSION['survey_' . $surveyid]['fieldarray'])) {
$_SESSION['survey_' . $surveyid]['fieldarray'] = array_values($_SESSION['survey_' . $surveyid]['fieldarray']);
}
//Check if a passthru label and value have been included in the query url
checkPassthruLabel($surveyid, $preview, $fieldmap);
Yii::trace('end', 'survey.buildsurveysession');
//traceVar($_SESSION['survey_' . $surveyid]);
}
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:101,代码来源:frontend_helper.php
示例9: index
/**
* Database::index()
*
* @param mixed $action
* @return
*/
function index($sa = null)
{
$action = Yii::app()->request->getPost('action');
$clang = $this->getController()->lang;
$postsid = returnGlobal('sid');
$postgid = returnGlobal('gid');
$postqid = returnGlobal('qid');
$postqaid = returnGlobal('qaid');
$databaseoutput = '';
$surveyid = returnGlobal('sid');
$gid = returnGlobal('gid');
$qid = returnGlobal('qid');
// if $action is not passed, check post data.
if (Yii::app()->getConfig('filterxsshtml') && Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1) {
$filter = new CHtmlPurifier();
$filter->options = array('URI.AllowedSchemes' => array('http' => true, 'https' => true));
$xssfilter = true;
} else {
$xssfilter = false;
}
if ($action == "updatedefaultvalues" && hasSurveyPermission($surveyid, 'surveycontent', 'update')) {
$questlangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
$baselang = Survey::model()->findByPk($surveyid)->language;
array_unshift($questlangs, $baselang);
Questions::model()->updateAll(array('same_default' => Yii::app()->request->getPost('samedefault') ? 1 : 0), 'sid=:sid ANd qid=:qid', array(':sid' => $surveyid, ':qid' => $qid));
$resrow = Questions::model()->findByAttributes(array('qid' => $qid));
$questiontype = $resrow['type'];
$qtproperties = getQuestionTypeList('', 'array');
if ($qtproperties[$questiontype]['answerscales'] > 0 && $qtproperties[$questiontype]['subquestions'] == 0) {
for ($scale_id = 0; $scale_id < $qtproperties[$questiontype]['answerscales']; $scale_id++) {
foreach ($questlangs as $language) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $scale_id . '_' . $language))) {
$this->_updateDefaultValues($qid, 0, $scale_id, '', $language, Yii::app()->request->getPost('defaultanswerscale_' . $scale_id . '_' . $language), true);
}
if (!is_null(Yii::app()->request->getPost('other_' . $scale_id . '_' . $language))) {
$this->_updateDefaultValues($qid, 0, $scale_id, 'other', $language, Yii::app()->request->getPost('other_' . $scale_id . '_' . $language), true);
}
}
}
}
if ($qtproperties[$questiontype]['subquestions'] > 0) {
foreach ($questlangs as $language) {
$sqresult = Questions::model()->findAllByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'parent_qid' => $qid, 'language' => $language, 'scale_id' => 0));
for ($scale_id = 0; $scale_id < $qtproperties[$questiontype]['subquestions']; $scale_id++) {
foreach ($sqresult as $aSubquestionrow) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $scale_id . '_' . $language . '_' . $aSubquestionrow['qid']))) {
$this->_updateDefaultValues($qid, $aSubquestionrow['qid'], $scale_id, '', $language, Yii::app()->request->getPost('defaultanswerscale_' . $scale_id . '_' . $language . '_' . $aSubquestionrow['qid']), true);
}
}
}
}
}
if ($qtproperties[$questiontype]['answerscales'] == 0 && $qtproperties[$questiontype]['subquestions'] == 0) {
foreach ($questlangs as $language) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_0_' . $language . '_0'))) {
$this->_updateDefaultValues($postqid, 0, 0, '', $language, Yii::app()->request->getPost('defaultanswerscale_0_' . $language . '_0'), true);
}
}
}
Yii::app()->session['flashmessage'] = $clang->gT("Default value settings were successfully saved.");
LimeExpressionManager::SetDirtyFlag();
if ($databaseoutput != '') {
echo $databaseoutput;
} else {
$this->getController()->redirect($this->getController()->createUrl('admin/survey/sa/view/surveyid/' . $surveyid . '/gid/' . $gid . '/qid/' . $qid));
}
}
if ($action == "updateansweroptions" && hasSurveyPermission($surveyid, 'surveycontent', 'update')) {
Yii::app()->loadHelper('database');
$anslangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
$baselang = Survey::model()->findByPk($surveyid)->language;
$alllanguages = $anslangs;
array_unshift($alllanguages, $baselang);
$resrow = Questions::model()->findByAttributes(array('qid' => $qid));
$questiontype = $resrow['type'];
// Checked)
$qtypes = getQuestionTypeList('', 'array');
$scalecount = $qtypes[$questiontype]['answerscales'];
$count = 0;
$invalidCode = 0;
$duplicateCode = 0;
//require_once("../classes/inputfilter/class.inputfilter_clean.php");
//$myFilter = new InputFilter('','',1,1,1);
//First delete all answers
Answers::model()->deleteAllByAttributes(array('qid' => $qid));
LimeExpressionManager::RevertUpgradeConditionsToRelevance($surveyid);
for ($scale_id = 0; $scale_id < $scalecount; $scale_id++) {
$maxcount = (int) Yii::app()->request->getPost('answercount_' . $scale_id);
for ($sortorderid = 1; $sortorderid < $maxcount; $sortorderid++) {
$code = sanitize_paranoid_string(Yii::app()->request->getPost('code_' . $sortorderid . '_' . $scale_id));
if (Yii::app()->request->getPost('oldcode_' . $sortorderid . '_' . $scale_id)) {
$oldcode = sanitize_paranoid_string(Yii::app()->request->getPost('oldcode_' . $sortorderid . '_' . $scale_id));
if ($code !== $oldcode) {
Conditions::model()->updateAll(array('value' => $code), 'cqid=:cqid AND value=:value', array(':cqid' => $qid, ':value' => $oldcode));
//.........这里部分代码省略.........
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:101,代码来源:database.php
示例10: ShowSurveyLogicFile
/**
* Create HTML view of the survey, showing everything that uses EM
* @param <type> $sid
* @param <type> $gid
* @param <type> $qid
*/
public static function ShowSurveyLogicFile($sid, $gid = NULL, $qid = NULL, $LEMdebugLevel = 0, $assessments = false)
{
// Title
// Welcome
// G1, name, relevance, text
// *Q1, name [type], relevance [validation], text, help, default, help_msg
// SQ1, name [scale], relevance [validation], text
// A1, code, assessment_value, text
// End Message
$LEM =& LimeExpressionManager::singleton();
$LEM->sPreviewMode = 'logic';
$aSurveyInfo = getSurveyInfo($sid, $_SESSION['LEMlang']);
$allErrors = array();
$warnings = 0;
$surveyOptions = array('assessments' => $aSurveyInfo['assessments'] == 'Y', 'hyperlinkSyntaxHighlighting' => true);
$varNamesUsed = array();
// keeps track of whether variables have been declared
if (!is_null($qid)) {
$surveyMode = 'question';
LimeExpressionManager::StartSurvey($sid, 'question', $surveyOptions, false, $LEMdebugLevel);
$qseq = LimeExpressionManager::GetQuestionSeq($qid);
$moveResult = LimeExpressionManager::JumpTo($qseq + 1, true, false, true);
} else {
if (!is_null($gid)) {
$surveyMode = 'group';
LimeExpressionManager::StartSurvey($sid, 'group', $surveyOptions, false, $LEMdebugLevel);
$gseq = LimeExpressionManager::GetGroupSeq($gid);
$moveResult = LimeExpressionManager::JumpTo($gseq + 1, true, false, true);
} else {
$surveyMode = 'survey';
LimeExpressionManager::StartSurvey($sid, 'survey', $surveyOptions, false, $LEMdebugLevel);
$moveResult = LimeExpressionManager::NavigateForwards();
}
}
$qtypes = getQuestionTypeList('', 'array');
if (is_null($moveResult) || is_null($LEM->currentQset) || count($LEM->currentQset) == 0) {
return array('errors' => 1, 'html' => sprintf($LEM->gT('Invalid question - probably missing sub-questions or languag
|
请发表评论