本文整理汇总了PHP中getQuestDepsForConditions函数的典型用法代码示例。如果您正苦于以下问题:PHP getQuestDepsForConditions函数的具体用法?PHP getQuestDepsForConditions怎么用?PHP getQuestDepsForConditions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getQuestDepsForConditions函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: set_question_properties
/**
* RPC Routine to set question properties.
*
* @access public
* @param string $sSessionKey Auth credentials
* @param integer $iQuestionID - ID of the question
* @param array|struct $aQuestionData - An array with the particular fieldnames as keys and their values to set on that particular question
* @param string $sLanguage Optional parameter language for multilingual questions
* @return array Of succeeded and failed modifications according to internal validation.
*/
public function set_question_properties($sSessionKey, $iQuestionID, $aQuestionData, $sLanguage = NULL)
{
if ($this->_checkSessionKey($sSessionKey)) {
Yii::app()->loadHelper("surveytranslator");
$oQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
if (is_null($oQuestion)) {
return array('status' => 'Error: Invalid group ID');
}
$iSurveyID = $oQuestion->sid;
if (Permission::model()->hasSurveyPermission($iSurveyID, 'survey', 'update')) {
if (is_null($sLanguage)) {
$sLanguage = Survey::model()->findByPk($iSurveyID)->language;
}
if (!array_key_exists($sLanguage, getLanguageDataRestricted())) {
return array('status' => 'Error: Invalid language');
}
$oQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID, 'language' => $sLanguage));
if (!isset($oQuestion)) {
return array('status' => 'Error: Invalid questionid');
}
// Remove fields that may not be modified
unset($aQuestionData['qid']);
unset($aQuestionData['gid']);
unset($aQuestionData['sid']);
unset($aQuestionData['parent_qid']);
unset($aQuestionData['language']);
unset($aQuestionData['type']);
// Remove invalid fields
$aDestinationFields = array_flip(Question::model()->tableSchema->columnNames);
$aQuestionData = array_intersect_key($aQuestionData, $aDestinationFields);
$aQuestionAttributes = $oQuestion->getAttributes();
if (empty($aQuestionData)) {
return array('status' => 'No valid Data');
}
foreach ($aQuestionData as $sFieldName => $sValue) {
//all the dependencies that this question has to other questions
$dependencies = getQuestDepsForConditions($oQuestion->sid, $oQuestion->gid, $iQuestionID);
//all dependencies by other questions to this question
$is_criteria_question = getQuestDepsForConditions($oQuestion->sid, $oQuestion->gid, "all", $iQuestionID, "by-targqid");
//We do not allow questions with dependencies in the same group to change order - that would lead to broken dependencies
if ((isset($dependencies) || isset($is_criteria_question)) && $sFieldName == 'question_order') {
$aResult[$sFieldName] = 'Questions with dependencies - Order cannot be changed';
continue;
}
$oQuestion->setAttribute($sFieldName, $sValue);
try {
$bSaveResult = $oQuestion->save();
// save the change to database
Question::model()->updateQuestionOrder($oQuestion->gid, $oQuestion->language);
$aResult[$sFieldName] = $bSaveResult;
//unset fields that failed
if (!$bSaveResult) {
$oQuestion->{$sFieldName} = $aQuestionAttributes[$sFieldName];
}
} catch (Exception $e) {
//unset fields that caused exception
$oQuestion->{$sFieldName} = $aQuestionAttributes[$sFieldName];
}
}
return $aResult;
} else {
return array('status' => 'No permission');
}
} else {
return array('status' => 'Invalid Session key');
}
}
开发者ID:kasutori,项目名称:LimeSurvey,代码行数:77,代码来源:remotecontrol_handle.php
示例2: view
public function view($surveyid, $gid, $qid)
{
$aData = array();
// Init general variables
$aData['surveyid'] = $iSurveyID = $surveyid;
$aData['gid'] = $gid;
$aData['qid'] = $qid;
$baselang = Survey::model()->findByPk($iSurveyID)->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");
$survey = Survey::model()->findByPk($iSurveyID);
if (is_null($survey)) {
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 = $survey->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');
$qshowstyle = "";
$aData['qshowstyle'] = $qshowstyle;
$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;
$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;
$aData['display']['menu_bars']['gid_action'] = 'viewquestion';
$aData['questionbar']['buttons']['view'] = true;
///////////
// sidemenu
$aData['sidemenu']['state'] = true;
$aData['sidemenu']['explorer']['state'] = true;
$aData['sidemenu']['explorer']['gid'] = isset($gid) ? $gid : false;
$aData['sidemenu']['explorer']['qid'] = isset($qid) ? $qid : false;
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
// Last question visited : By user (only one by user)
$setting_entry = 'last_question_' . Yii::app()->user->getId();
setGlobalSetting($setting_entry, $qid);
// we need to set the sid for this question
$setting_entry = 'last_question_sid_' . Yii::app()->user->getId();
setGlobalSetting($setting_entry, $iSurveyID);
// we need to set the gid for this question
$setting_entry = 'last_question_gid_' . Yii::app()->user->getId();
setGlobalSetting($setting_entry, $gid);
// Last question for this survey (only one by survey, many by user)
$setting_entry = 'last_question_' . Yii::app()->user->getId() . '_' . $iSurveyID;
setGlobalSetting($setting_entry, $qid);
// we need to set the gid for this question
$setting_entry = 'last_question_' . Yii::app()->user->getId() . '_' . $iSurveyID . '_gid';
setGlobalSetting($setting_entry, $gid);
$aData['surveyIsActive'] = $survey->active !== 'N';
$this->_renderWrappedTemplate('survey/Question', 'question_view', $aData);
}
开发者ID:CSCI-462-01-2016,项目名称:LimeSurvey,代码行数:85,代码来源:questions.php
示例3: _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
示例4: _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
示例5: _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)
{
$clang = $this->getController()->lang;
$baselang = Survey::model()->findByPk($iSurveyID)->language;
//Show Question Details
//Count answer-options for this question
$qrr = Answers::model()->findAllByAttributes(array('qid' => $qid, 'language' => $baselang));
$aData['qct'] = $qct = count($qrr);
//Count sub-questions for this question
$sqrq = Questions::model()->findAllByAttributes(array('parent_qid' => $qid, 'language' => $baselang));
$aData['sqct'] = $sqct = count($sqrq);
$qrrow = Questions::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $iSurveyID, 'language' => $baselang));
$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'] = $clang->gT("Invalid survey ID");
$this->getController()->redirect($this->getController()->createUrl("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;
if (hasSurveyPermission($iSurveyID, 'surveycontent', 'read')) {
if (count(Survey::model()->findByPk($iSurveyID)->additionalLanguages) != 0) {
Yii::app()->loadHelper('surveytranslator');
$tmp_survlangs = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$baselang = Survey::model()->findByPk($iSurveyID)->language;
$tmp_survlangs[] = $baselang;
rsort($tmp_survlangs);
$aData['tmp_survlangs'] = $tmp_survlangs;
}
}
$aData['qtypes'] = $qtypes = getQuestionTypeList('', 'array');
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['clang'] = $clang;
$aData['qrrow'] = $qrrow;
$aData['baselang'] = $baselang;
$aAttributesWithValues = Questions::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()->render('/admin/survey/Question/questionbar_view', $aData, true);
$finaldata['display'] = $questionsummary;
$this->getController()->render('/survey_view', $finaldata);
}
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:85,代码来源:Survey_Common_Action.php
注:本文中的getQuestDepsForConditions函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论