本文整理汇总了PHP中QuestionAttribute类的典型用法代码示例。如果您正苦于以下问题:PHP QuestionAttribute类的具体用法?PHP QuestionAttribute怎么用?PHP QuestionAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QuestionAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
//.........这里部分代码省略.........
*
*/
if ($sAction == 'copyquestion') {
if (returnGlobal('copysubquestions') == "Y") {
$aSQIDMappings = array();
$r1 = Question::model()->getSubQuestions(returnGlobal('oldqid'));
$aSubQuestions = $r1->readAll();
foreach ($aSubQuestions as $qr1) {
$qr1['parent_qid'] = $iQuestionID;
if (isset($aSQIDMappings[$qr1['qid']])) {
$qr1['qid'] = $aSQIDMappings[$qr1['qid']];
} else {
$oldqid = $qr1['qid'];
unset($qr1['qid']);
}
$qr1['gid'] = $iQuestionGroupID;
$iInsertID = Question::model()->insertRecords($qr1);
if (!isset($qr1['qid'])) {
$aSQIDMappings[$oldqid] = $iInsertID;
}
}
}
if (returnGlobal('copyanswers') == "Y") {
$r1 = Answer::model()->getAnswers(returnGlobal('oldqid'));
$aAnswerOptions = $r1->readAll();
foreach ($aAnswerOptions as $qr1) {
Answer::model()->insertRecords(array('qid' => $iQuestionID, 'code' => $qr1['code'], 'answer' => $qr1['answer'], 'assessment_value' => $qr1['assessment_value'], 'sortorder' => $qr1['sortorder'], 'language' => $qr1['language'], 'scale_id' => $qr1['scale_id']));
}
}
/**
* Copy attribute
*/
if (returnGlobal('copyattributes') == "Y") {
$oOldAttributes = QuestionAttribute::model()->findAll("qid=:qid", array("qid" => returnGlobal('oldqid')));
foreach ($oOldAttributes as $oOldAttribute) {
$attribute = new QuestionAttribute();
$attribute->qid = $iQuestionID;
$attribute->value = $oOldAttribute->value;
$attribute->attribute = $oOldAttribute->attribute;
$attribute->language = $oOldAttribute->language;
$attribute->save();
}
}
// Since 2.5, user can edit attribute while copying
$qattributes = questionAttributes();
$validAttributes = $qattributes[Yii::app()->request->getPost('type')];
$aLanguages = array_merge(array(Survey::model()->findByPk($iSurveyID)->language), Survey::model()->findByPk($iSurveyID)->additionalLanguages);
foreach ($validAttributes as $validAttribute) {
if ($validAttribute['i18n']) {
foreach ($aLanguages as $sLanguage) {
$value = Yii::app()->request->getPost($validAttribute['name'] . '_' . $sLanguage);
$iInsertCount = QuestionAttribute::model()->findAllByAttributes(array('attribute' => $validAttribute['name'], 'qid' => $iQuestionID, 'language' => $sLanguage));
if (count($iInsertCount) > 0) {
if ($value != '') {
QuestionAttribute::model()->updateAll(array('value' => $value), 'attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
} else {
QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
}
} elseif ($value != '') {
$attribute = new QuestionAttribute();
$attribute->qid = $iQuestionID;
$attribute->value = $value;
$attribute->attribute = $validAttribute['name'];
$attribute->language = $sLanguage;
$attribute->save();
}
示例2: do_array_dual
function do_array_dual($ia)
{
global $thissurvey;
$aLastMoveResult = LimeExpressionManager::GetLastMoveResult();
$aMandatoryViolationSubQ = $aLastMoveResult['mandViolation'] && $ia[6] == 'Y' ? explode("|", $aLastMoveResult['unansweredSQs']) : array();
$repeatheadings = Yii::app()->getConfig("repeatheadings");
$minrepeatheadings = Yii::app()->getConfig("minrepeatheadings");
$extraclass = "";
$answertypeclass = "";
// Maybe not
$caption = "";
// Just leave empty, are replaced after
$inputnames = array();
$labelans1 = array();
$labelans = array();
/*
* Get Question Attributes
*/
$aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]);
// Get questions and answers by defined order
if ($aQuestionAttributes['random_order'] == 1) {
$ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY " . dbRandom();
} else {
$ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY question_order";
}
$ansresult = dbExecuteAssoc($ansquery);
//Checked
$aSubQuestions = $ansresult->readAll();
$anscount = count($aSubQuestions);
$lquery = "SELECT * FROM {{answers}} WHERE scale_id=0 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
$lresult = dbExecuteAssoc($lquery);
//Checked
$aAnswersScale0 = $lresult->readAll();
$lquery1 = "SELECT * FROM {{answers}} WHERE scale_id=1 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
$lresult1 = dbExecuteAssoc($lquery1);
//Checked
$aAnswersScale1 = $lresult1->readAll();
// Set attributes
if ($aQuestionAttributes['use_dropdown'] == 1) {
$useDropdownLayout = true;
$extraclass .= " dropdown-list";
$answertypeclass .= " dropdown";
$doDualScaleFunction = "doDualScaleDropDown";
// javascript funtion to lauch at end of answers
$caption = gT("A table with a subquestion on each row, with two answers to provide on each line. Please select the answers.");
} else {
$useDropdownLayout = false;
$extraclass .= " radio-list";
$answertypeclass .= " radio";
$doDualScaleFunction = "doDualScaleRadio";
$caption = gT("A table with one subquestion on each row and two answers to provide on each row. The related answer options are in the top table header row.");
}
if (ctype_digit(trim($aQuestionAttributes['repeat_headings'])) && trim($aQuestionAttributes['repeat_headings'] != "")) {
$repeatheadings = intval($aQuestionAttributes['repeat_headings']);
$minrepeatheadings = 0;
}
$leftheader = trim($aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '' ? $leftheader = $aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']] : '';
$rightheader = trim($aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '' ? $aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']] : '';
$answerwidth = trim($aQuestionAttributes['answer_width']) != '' ? $aQuestionAttributes['answer_width'] : 20;
// Find if we have rigth and center text
$sQuery = "SELECT count(question) FROM {{questions}} WHERE parent_qid=" . $ia[0] . " and scale_id=0 AND question like '%|%'";
$rigthCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
$rightexists = $rigthCount > 0;
// $right_exists: flag to find out if there are any right hand answer parts. leaving right column but don't force with
$sQuery = "SELECT count(question) FROM {{questions}} WHERE parent_qid=" . $ia[0] . " and scale_id=0 AND question like '%|%|%'";
$centerCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
$centerexists = $centerCount > 0;
// $center_exists: flag to find out if there are any center hand answer parts. leaving center column but don't force with
// Label and code for input
foreach ($aAnswersScale0 as $lrow) {
$labels0[] = array('code' => $lrow['code'], 'title' => $lrow['answer']);
}
foreach ($aAnswersScale1 as $lrow) {
$labels1[] = array('code' => $lrow['code'], 'title' => $lrow['answer']);
}
if (count($aAnswersScale0) > 0 && $anscount) {
$answer = "";
$fn = 1;
// Used by repeat_heading
// No drop-down
if ($useDropdownLayout === false) {
$aData = array();
$aData['answertypeclass'] = $answertypeclass;
$columnswidth = 100 - $answerwidth;
$labelans0 = array();
$labelans1 = array();
$labelcode0 = array();
$labelcode1 = array();
foreach ($aAnswersScale0 as $lrow) {
$labelans0[] = $lrow['answer'];
$labelcode0[] = $lrow['code'];
}
foreach ($aAnswersScale1 as $lrow) {
$labelans1[] = $lrow['answer'];
$labelcode1[] = $lrow['code'];
}
$numrows = count($labelans0) + count($labelans1);
// Add needed row and fill some boolean: shownoanswer, rightexists, centerexists
$shownoanswer = $ia[6] != "Y" && SHOW_NO_ANSWER == 1;
if ($shownoanswer) {
//.........这里部分代码省略.........
示例3: index
//.........这里部分代码省略.........
# }
}
}
}
if (!$iQuestionID) {
Yii::app()->setFlashMessage($clang->gT("Question could not be created."), 'error');
} else {
if ($sAction == 'copyquestion') {
if (returnGlobal('copysubquestions') == "Y") {
$aSQIDMappings = array();
$r1 = Question::model()->getSubQuestions(returnGlobal('oldqid'));
while ($qr1 = $r1->read()) {
$qr1['parent_qid'] = $iQuestionID;
if (isset($aSQIDMappings[$qr1['qid']])) {
$qr1['qid'] = $aSQIDMappings[$qr1['qid']];
} else {
$oldqid = $qr1['qid'];
unset($qr1['qid']);
}
$qr1['gid'] = $iQuestionGroupID;
$iInsertID = Question::model()->insertRecords($qr1);
if (!isset($qr1['qid'])) {
$aSQIDMappings[$oldqid] = $iInsertID;
}
}
}
if (returnGlobal('copyanswers') == "Y") {
$r1 = Answer::model()->getAnswers(returnGlobal('oldqid'));
while ($qr1 = $r1->read()) {
Answer::model()->insertRecords(array('qid' => $iQuestionID, 'code' => $qr1['code'], 'answer' => $qr1['answer'], 'assessment_value' => $qr1['assessment_value'], 'sortorder' => $qr1['sortorder'], 'language' => $qr1['language'], 'scale_id' => $qr1['scale_id']));
}
}
if (returnGlobal('copyattributes') == "Y") {
$oOldAttributes = QuestionAttribute::model()->findAll("qid=:qid", array("qid" => returnGlobal('oldqid')));
foreach ($oOldAttributes as $oOldAttribute) {
$attribute = new QuestionAttribute();
$attribute->qid = $iQuestionID;
$attribute->value = $oOldAttribute->value;
$attribute->attribute = $oOldAttribute->attribute;
$attribute->language = $oOldAttribute->language;
$attribute->save();
}
}
} else {
$qattributes = questionAttributes();
$validAttributes = $qattributes[Yii::app()->request->getPost('type')];
$aLanguages = array_merge(array(Survey::model()->findByPk($iSurveyID)->language), Survey::model()->findByPk($iSurveyID)->additionalLanguages);
foreach ($validAttributes as $validAttribute) {
if ($validAttribute['i18n']) {
foreach ($aLanguages as $sLanguage) {
$value = Yii::app()->request->getPost($validAttribute['name'] . '_' . $sLanguage);
$iInsertCount = QuestionAttribute::model()->findAllByAttributes(array('attribute' => $validAttribute['name'], 'qid' => $iQuestionID, 'language' => $sLanguage));
if (count($iInsertCount) > 0) {
if ($value != '') {
QuestionAttribute::model()->updateAll(array('value' => $value), 'attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
} else {
QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
}
} elseif ($value != '') {
$attribute = new QuestionAttribute();
$attribute->qid = $iQuestionID;
$attribute->value = $value;
$attribute->attribute = $validAttribute['name'];
$attribute->language = $sLanguage;
$attribute->save();
}
示例4: index
//.........这里部分代码省略.........
}
}
if (!$iQuestionID) {
Yii::app()->setFlashMessage(gT("Question could not be created."), 'error');
} else {
if ($sAction == 'copyquestion') {
if (returnGlobal('copysubquestions') == "Y") {
$aSQIDMappings = array();
$r1 = Question::model()->getSubQuestions(returnGlobal('oldqid'));
$aSubQuestions = $r1->readAll();
foreach ($aSubQuestions as $qr1) {
$qr1['parent_qid'] = $iQuestionID;
if (isset($aSQIDMappings[$qr1['qid']])) {
$qr1['qid'] = $aSQIDMappings[$qr1['qid']];
} else {
$oldqid = $qr1['qid'];
unset($qr1['qid']);
}
$qr1['gid'] = $iQuestionGroupID;
$iInsertID = Question::model()->insertRecords($qr1);
if (!isset($qr1['qid'])) {
$aSQIDMappings[$oldqid] = $iInsertID;
}
}
}
if (returnGlobal('copyanswers') == "Y") {
$r1 = Answer::model()->getAnswers(returnGlobal('oldqid'));
$aAnswerOptions = $r1->readAll();
foreach ($aAnswerOptions as $qr1) {
Answer::model()->insertRecords(array('qid' => $iQuestionID, 'code' => $qr1['code'], 'answer' => $qr1['answer'], 'assessment_value' => $qr1['assessment_value'], 'sortorder' => $qr1['sortorder'], 'language' => $qr1['language'], 'scale_id' => $qr1['scale_id']));
}
}
if (returnGlobal('copyattributes') == "Y") {
$oOldAttributes = QuestionAttribute::model()->findAll("qid=:qid", array("qid" => returnGlobal('oldqid')));
foreach ($oOldAttributes as $oOldAttribute) {
$attribute = new QuestionAttribute();
$attribute->qid = $iQuestionID;
$attribute->value = $oOldAttribute->value;
$attribute->attribute = $oOldAttribute->attribute;
$attribute->language = $oOldAttribute->language;
$attribute->save();
}
}
} else {
$qattributes = questionAttributes();
$validAttributes = $qattributes[Yii::app()->request->getPost('type')];
$aLanguages = array_merge(array(Survey::model()->findByPk($iSurveyID)->language), Survey::model()->findByPk($iSurveyID)->additionalLanguages);
foreach ($validAttributes as $validAttribute) {
if ($validAttribute['i18n']) {
foreach ($aLanguages as $sLanguage) {
$value = Yii::app()->request->getPost($validAttribute['name'] . '_' . $sLanguage);
$iInsertCount = QuestionAttribute::model()->findAllByAttributes(array('attribute' => $validAttribute['name'], 'qid' => $iQuestionID, 'language' => $sLanguage));
if (count($iInsertCount) > 0) {
if ($value != '') {
QuestionAttribute::model()->updateAll(array('value' => $value), 'attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
} else {
QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid AND language=:language', array(':attribute' => $validAttribute['name'], ':qid' => $iQuestionID, ':language' => $sLanguage));
}
} elseif ($value != '') {
$attribute = new QuestionAttribute();
$attribute->qid = $iQuestionID;
$attribute->value = $value;
$attribute->attribute = $validAttribute['name'];
$attribute->language = $sLanguage;
$attribute->save();
}
示例5: deleteAllById
public static function deleteAllById($questionsIds)
{
if (!is_array($questionsIds)) {
$questionsIds = array($questionsIds);
}
Yii::app()->db->createCommand()->delete(Condition::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(QuestionAttribute::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(Answer::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(Question::model()->tableName(), array('in', 'parent_qid', $questionsIds));
Yii::app()->db->createCommand()->delete(Question::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(DefaultValue::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(QuotaMember::model()->tableName(), array('in', 'qid', $questionsIds));
}
示例6: get_question_properties
/**
* RPC Routine to return properties of a question of a survey.
* Returns string
*
* @access public
* @param string $sSessionKey Auth credentials
* @param int $iQuestionID Id of the question to get properties
* @param array $aQuestionSettings The properties to get
* @param string $sLanguage Optional parameter language for multilingual questions
* @return array The requested values
*/
public function get_question_properties($sSessionKey, $iQuestionID, $aQuestionSettings, $sLanguage = NULL)
{
if ($this->_checkSessionKey($sSessionKey)) {
Yii::app()->loadHelper("surveytranslator");
$oQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
if (!isset($oQuestion)) {
return array('status' => 'Error: Invalid questionid');
}
$iSurveyID = $oQuestion->sid;
if (Permission::model()->hasSurveyPermission($iSurveyID, 'survey', 'read')) {
if (is_null($sLanguage)) {
$sLanguage = Survey::model()->findByPk($iSurveyID)->language;
}
if (!array_key_exists($sLanguage, getLanguageDataRestricted())) {
return array('status' => 'Error: Invalid language');
}
$oQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID, 'language' => $sLanguage));
if (!isset($oQuestion)) {
return array('status' => 'Error: Invalid questionid');
}
$aBasicDestinationFields = Question::model()->tableSchema->columnNames;
array_push($aBasicDestinationFields, 'available_answers');
array_push($aBasicDestinationFields, 'subquestions');
array_push($aBasicDestinationFields, 'attributes');
array_push($aBasicDestinationFields, 'attributes_lang');
array_push($aBasicDestinationFields, 'answeroptions');
array_push($aBasicDestinationFields, 'defaultvalue');
$aQuestionSettings = array_intersect($aQuestionSettings, $aBasicDestinationFields);
if (empty($aQuestionSettings)) {
return array('status' => 'No valid Data');
}
$aResult = array();
foreach ($aQuestionSettings as $sPropertyName) {
if ($sPropertyName == 'available_answers' || $sPropertyName == 'subquestions') {
$oSubQuestions = Question::model()->findAllByAttributes(array('parent_qid' => $iQuestionID, 'language' => $sLanguage), array('order' => 'title'));
if (count($oSubQuestions) > 0) {
$aData = array();
foreach ($oSubQuestions as $oSubQuestion) {
if ($sPropertyName == 'available_answers') {
$aData[$oSubQuestion['title']] = $oSubQuestion['question'];
} else {
$aData[$oSubQuestion['qid']]['title'] = $oSubQuestion['title'];
$aData[$oSubQuestion['qid']]['question'] = $oSubQuestion['question'];
$aData[$oSubQuestion['qid']]['scale_id'] = $oSubQuestion['scale_id'];
}
}
$aResult[$sPropertyName] = $aData;
} else {
$aResult[$sPropertyName] = 'No available answers';
}
} else {
if ($sPropertyName == 'attributes') {
$oAttributes = QuestionAttribute::model()->findAllByAttributes(array('qid' => $iQuestionID, 'language' => null), array('order' => 'attribute'));
if (count($oAttributes) > 0) {
$aData = array();
foreach ($oAttributes as $oAttribute) {
$aData[$oAttribute['attribute']] = $oAttribute['value'];
}
$aResult['attributes'] = $aData;
} else {
$aResult['attributes'] = 'No available attributes';
}
} else {
if ($sPropertyName == 'attributes_lang') {
$oAttributes = QuestionAttribute::model()->findAllByAttributes(array('qid' => $iQuestionID, 'language' => $sLanguage), array('order' => 'attribute'));
if (count($oAttributes) > 0) {
$aData = array();
foreach ($oAttributes as $oAttribute) {
$aData[$oAttribute['attribute']] = $oAttribute['value'];
}
$aResult['attributes_lang'] = $aData;
} else {
$aResult['attributes_lang'] = 'No available attributes';
}
} else {
if ($sPropertyName == 'answeroptions') {
$oAttributes = Answer::model()->findAllByAttributes(array('qid' => $iQuestionID, 'language' => $sLanguage), array('order' => 'sortorder'));
if (count($oAttributes) > 0) {
$aData = array();
foreach ($oAttributes as $oAttribute) {
$aData[$oAttribute['code']]['answer'] = $oAttribute['answer'];
$aData[$oAttribute['code']]['assessment_value'] = $oAttribute['assessment_value'];
$aData[$oAttribute['code']]['scale_id'] = $oAttribute['scale_id'];
}
$aResult['answeroptions'] = $aData;
} else {
$aResult['answeroptions'] = 'No available answer options';
}
} else {
//.........这里部分代码省略.........
示例7: deleteSurvey
/**
* Deletes a survey and all its data
*
* @access public
* @param int $iSurveyID
* @param bool @recursive
* @return void
*/
public function deleteSurvey($iSurveyID, $recursive = true)
{
Survey::model()->deleteByPk($iSurveyID);
if ($recursive == true) {
if (tableExists("{{survey_" . intval($iSurveyID) . "}}")) {
Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "}}");
}
if (tableExists("{{survey_" . intval($iSurveyID) . "_timings}}")) {
Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "_timings}}");
}
if (tableExists("{{tokens_" . intval($iSurveyID) . "}}")) {
Yii::app()->db->createCommand()->dropTable("{{tokens_" . intval($iSurveyID) . "}}");
}
/* Remove User/global settings part : need Question and QuestionGroup*/
// Settings specific for this survey
$oCriteria = new CDbCriteria();
$oCriteria->compare('stg_name', 'last_%', true, 'AND', false);
$oCriteria->compare('stg_value', $iSurveyID, false, 'AND');
SettingGlobal::model()->deleteAll($oCriteria);
// Settings specific for this survey, 2nd part
$oCriteria = new CDbCriteria();
$oCriteria->compare('stg_name', 'last_%' . $iSurveyID . '%', true, 'AND', false);
SettingGlobal::model()->deleteAll($oCriteria);
// All Group id from this survey for ALL users
$aGroupId = CHtml::listData(QuestionGroup::model()->findAll(array('select' => 'gid', 'condition' => 'sid=:sid', 'params' => array(':sid' => $iSurveyID))), 'gid', 'gid');
$oCriteria = new CDbCriteria();
$oCriteria->compare('stg_name', 'last_question_gid_%', true, 'AND', false);
if (Yii::app()->db->getDriverName() == 'pgsql') {
$oCriteria->addInCondition('CAST(stg_value as ' . App()->db->schema->getColumnType("integer") . ')', $aGroupId);
} else {
$oCriteria->addInCondition('stg_value', $aGroupId);
}
SettingGlobal::model()->deleteAll($oCriteria);
// All Question id from this survey for ALL users
$aQuestionId = CHtml::listData(Question::model()->findAll(array('select' => 'qid', 'condition' => 'sid=:sid', 'params' => array(':sid' => $iSurveyID))), 'qid', 'qid');
$oCriteria = new CDbCriteria();
$oCriteria->compare('stg_name', 'last_question_%', true, 'OR', false);
if (Yii::app()->db->getDriverName() == 'pgsql') {
$oCriteria->addInCondition('CAST(stg_value as ' . App()->db->schema->getColumnType("integer") . ')', $aQuestionId);
} else {
$oCriteria->addInCondition('stg_value', $aQuestionId);
}
SettingGlobal::model()->deleteAll($oCriteria);
$oResult = Question::model()->findAllByAttributes(array('sid' => $iSurveyID));
foreach ($oResult as $aRow) {
Answer::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
Condition::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
QuestionAttribute::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
DefaultValue::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
}
Question::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
Assessment::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
QuestionGroup::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
SurveyLanguageSetting::model()->deleteAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
Permission::model()->deleteAllByAttributes(array('entity_id' => $iSurveyID, 'entity' => 'survey'));
SavedControl::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
SurveyURLParameter::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
//Remove any survey_links to the CPDB
SurveyLink::model()->deleteLinksBySurvey($iSurveyID);
Quota::model()->deleteQuota(array('sid' => $iSurveyID), true);
}
}
示例8: checkCompletedQuota
/**
* checkCompletedQuota() returns matched quotas information for the current response
* @param integer $surveyid - Survey identification number
* @param bool $return - set to true to return information, false do the quota
* @return array|void - nested array, Quotas->Members->Fields, includes quota information matched in session.
*/
function checkCompletedQuota($surveyid, $return = false)
{
/* Check if session is set */
if (!isset(App()->session['survey_' . $surveyid]['srid'])) {
return;
}
/* Check is Response is already submitted : only when "do" the quota: allow to send information about quota */
$oResponse = Response::model($surveyid)->findByPk(App()->session['survey_' . $surveyid]['srid']);
if (!$return && $oResponse && !is_null($oResponse->submitdate)) {
return;
}
static $aMatchedQuotas;
// EM call 2 times quotas with 3 lines of php code, then use static.
if (!$aMatchedQuotas) {
$aMatchedQuotas = array();
$quota_info = $aQuotasInfo = getQuotaInformation($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
// $aQuotasInfo have an 'active' key, we don't use it ?
if (!$aQuotasInfo || empty($aQuotasInfo)) {
return $aMatchedQuotas;
}
// OK, we have some quota, then find if this $_SESSION have some set
$aPostedFields = explode("|", Yii::app()->request->getPost('fieldnames', ''));
// Needed for quota allowing update
foreach ($aQuotasInfo as $aQuotaInfo) {
if (count($aQuotaInfo['members']) === 0) {
continue;
}
$iMatchedAnswers = 0;
$bPostedField = false;
// Array of field with quota array value
$aQuotaFields = array();
// Array of fieldnames with relevance value : EM fill $_SESSION with default value even is unrelevant (em_manager_helper line 6548)
$aQuotaRelevantFieldnames = array();
// To count number of hidden questions
$aQuotaQid = array();
foreach ($aQuotaInfo['members'] as $aQuotaMember) {
$aQuotaFields[$aQuotaMember['fieldname']][] = $aQuotaMember['value'];
$aQuotaRelevantFieldnames[$aQuotaMember['fieldname']] = isset($_SESSION['survey_' . $surveyid]['relevanceStatus'][$aQuotaMember['qid']]) && $_SESSION['survey_' . $surveyid]['relevanceStatus'][$aQuotaMember['qid']];
$aQuotaQid[] = $aQuotaMember['qid'];
}
$aQuotaQid = array_unique($aQuotaQid);
// For each field : test if actual responses is in quota (and is relevant)
foreach ($aQuotaFields as $sFieldName => $aValues) {
$bInQuota = isset($_SESSION['survey_' . $surveyid][$sFieldName]) && in_array($_SESSION['survey_' . $surveyid][$sFieldName], $aValues);
if ($bInQuota && $aQuotaRelevantFieldnames[$sFieldName]) {
$iMatchedAnswers++;
}
if (in_array($sFieldName, $aPostedFields)) {
// Need only one posted value
$bPostedField = true;
}
}
// Condition to count quota : Answers are the same in quota + an answer is submitted at this time (bPostedField) OR all questions is hidden (bAllHidden)
$bAllHidden = QuestionAttribute::model()->countByAttributes(array('qid' => $aQuotaQid), 'attribute=:attribute', array(':attribute' => 'hidden')) == count($aQuotaQid);
if ($iMatchedAnswers == count($aQuotaFields) && ($bPostedField || $bAllHidden)) {
if ($aQuotaInfo['qlimit'] == 0) {
// Always add the quota if qlimit==0
$aMatchedQuotas[] = $aQuotaInfo;
} else {
$iCompleted = getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);
if (!is_null($iCompleted) && (int) $iCompleted >= (int) $aQuotaInfo['qlimit']) {
// This remove invalid quota and not completed
$aMatchedQuotas[] = $aQuotaInfo;
}
}
}
}
}
if ($return) {
return $aMatchedQuotas;
}
if (empty($aMatchedQuotas)) {
return;
}
// Now we have all the information we need about the quotas and their status.
// We need to construct the page and do all needed action
$aSurveyInfo = getSurveyInfo($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
$oTemplate = Template::model()->getInstance('', $surveyid);
$sTemplatePath = $oTemplate->path;
$sTemplateViewPath = $oTemplate->viewPath;
$sClientToken = isset($_SESSION['survey_' . $surveyid]['token']) ? $_SESSION['survey_' . $surveyid]['token'] : "";
// $redata for templatereplace
$aDataReplacement = array('thissurvey' => $aSurveyInfo, 'clienttoken' => $sClientToken, 'token' => $sClientToken);
// We take only the first matched quota, no need for each
$aMatchedQuota = $aMatchedQuotas[0];
// If a token is used then mark the token as completed, do it before event : this allow plugin to update token information
$event = new PluginEvent('afterSurveyQuota');
$event->set('surveyId', $surveyid);
$event->set('responseId', $_SESSION['survey_' . $surveyid]['srid']);
// We allways have a responseId
$event->set('aMatchedQuotas', $aMatchedQuotas);
// Give all the matched quota : the first is the active
App()->getPluginManager()->dispatchEvent($event);
$blocks = array();
//.........这里部分代码省略.........
示例9: _checkintegrity
//.........这里部分代码省略.........
if (!array_key_exists($condition['cqid'], $okQuestion)) {
$iRowCount = Question::model()->countByAttributes(array('qid' => $condition['cqid']));
if (Question::model()->hasErrors()) {
safeDie(Question::model()->getError());
}
if (!$iRowCount) {
$aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CQID'));
} else {
$okQuestion[$condition['cqid']] = $condition['cqid'];
}
}
}
if ($condition['cfieldname']) {
if (preg_match('/^\\+{0,1}[0-9]+X[0-9]+X*$/', $condition['cfieldname'])) {
// only if cfieldname isn't Tag such as {TOKEN:EMAIL} or any other token
list($surveyid, $gid, $rest) = explode('X', $condition['cfieldname']);
$iRowCount = count(QuestionGroup::model()->findAllByAttributes(array('gid' => $gid)));
if (QuestionGroup::model()->hasErrors()) {
safeDie(QuestionGroup::model()->getError());
}
if (!$iRowCount) {
$aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CFIELDNAME group!') . " ({$gid}) ({$condition['cfieldname']})");
}
}
} elseif (!$condition['cfieldname']) {
$aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No CFIELDNAME field set!') . " ({$condition['cfieldname']})");
}
}
unset($okQuestion);
unset($aConditions);
/**********************************************************************/
/* Check question attributes */
/**********************************************************************/
$question_attributes = QuestionAttribute::model()->findAllBySql('select qid from {{question_attributes}} where qid not in (select qid from {{questions}})');
if (QuestionAttribute::model()->hasErrors()) {
safeDie(QuestionAttribute::model()->getError());
}
foreach ($question_attributes as $question_attribute) {
$aDelete['questionattributes'][] = array('qid' => $question_attribute['qid']);
}
// foreach
/**********************************************************************/
/* Check default values */
/**********************************************************************/
$oCriteria = new CDbCriteria();
$oCriteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid';
$oCriteria->condition = 'q.qid IS NULL';
$aRecords = DefaultValue::model()->findAll($oCriteria);
$aDelete['defaultvalues'] = count($aRecords);
if (DefaultValue::model()->hasErrors()) {
safeDie(DefaultValue::model()->getError());
}
/**********************************************************************/
/* Check quotas */
/**********************************************************************/
$surveys = Survey::model()->findAll();
if (Survey::model()->hasErrors()) {
safeDie(Survey::model()->getError());
}
$sids = array();
foreach ($surveys as $survey) {
$sids[] = $survey['sid'];
}
$oCriteria = new CDbCriteria();
$oCriteria->addNotInCondition('sid', $sids);
$aDelete['quotas'] = count(Quota::model()->findAll($oCriteria));
示例10: activateSurvey
//.........这里部分代码省略.........
$aTableDefinition[$aRow['fieldname']] = "string(20)";
break;
case "|":
$bCreateSurveyDir = true;
if (strpos($aRow['fieldname'], "_")) {
$aTableDefinition[$aRow['fieldname']] = "integer";
} else {
$aTableDefinition[$aRow['fieldname']] = "text";
}
break;
case "ipaddress":
if ($arSurvey->ipaddr == "Y") {
$aTableDefinition[$aRow['fieldname']] = "text";
}
break;
case "url":
if ($arSurvey->refurl == "Y") {
$aTableDefinition[$aRow['fieldname']] = "text";
}
break;
case "token":
$aTableDefinition[$aRow['fieldname']] = 'string(35)' . $sCollation;
break;
case '*':
// Equation
$aTableDefinition[$aRow['fieldname']] = "text";
break;
case 'R':
/**
* See bug #09828: Ranking question : update allowed can broke Survey DB
* If max_subquestions is not set or is invalid : set it to actual answers numbers
*/
$nrOfAnswers = Answer::model()->countByAttributes(array('qid' => $aRow['qid'], 'language' => Survey::model()->findByPk($iSurveyID)->language));
$oQuestionAttribute = QuestionAttribute::model()->find("qid = :qid AND attribute = 'max_subquestions'", array(':qid' => $aRow['qid']));
if (empty($oQuestionAttribute)) {
$oQuestionAttribute = new QuestionAttribute();
$oQuestionAttribute->qid = $aRow['qid'];
$oQuestionAttribute->attribute = 'max_subquestions';
$oQuestionAttribute->value = $nrOfAnswers;
$oQuestionAttribute->save();
} elseif (intval($oQuestionAttribute->value) < 1) {
$oQuestionAttribute->value = $nrOfAnswers;
$oQuestionAttribute->save();
}
$aTableDefinition[$aRow['fieldname']] = "string(5)";
break;
default:
$aTableDefinition[$aRow['fieldname']] = "string(5)";
}
if ($arSurvey->anonymized == 'N' && !array_key_exists('token', $aTableDefinition)) {
$aTableDefinition['token'] = 'string(35)' . $sCollation;
}
if ($simulate) {
$tempTrim = trim($aTableDefinition);
$brackets = strpos($tempTrim, "(");
if ($brackets === false) {
$type = substr($tempTrim, 0, 2);
} else {
$type = substr($tempTrim, 0, 2);
}
$arrSim[] = array($type);
}
}
if ($simulate) {
return array('dbengine' => $CI->db->databasetabletype, 'dbtype' => Yii::app()->db->driverName, 'fields' => $arrSim);
}
示例11: setMultipleAttributes
/**
* Set attributes for multiple questions
*/
public function setMultipleAttributes()
{
$aQidsAndLang = json_decode($_POST['sItems']);
// List of question ids to update
$iSid = Yii::app()->request->getPost('sid');
// The survey (for permission check)
$aAttributesToUpdate = json_decode($_POST['aAttributesToUpdate']);
// The list of attributes to updates
// TODO: this should be get from the question model
$aValidQuestionTypes = str_split($_POST['aValidQuestionTypes']);
// The valid question types for thoses attributes
// Calling th model
QuestionAttribute::model()->setMultiple($iSid, $aQidsAndLang, $aAttributesToUpdate, $aValidQuestionTypes);
}
示例12: setQuestion
/**
*
* @param iPlugin $plugin
* @param string $key
* @param mixed data Default value to return if key could not be found.
* @param string $model Optional model name to which the data was attached.
* @param int $id Optional id of the model instance to which the data was attached.
* @param string $language Optional language identifier used for storing the setting.
*
* @return boolean
*/
protected function setQuestion(iPlugin $plugin, $key, $data, $model, $id, $language)
{
$baseAttributes = array('sid', 'code', 'qid', 'gid', 'sortorder', 'relevance', 'questiontype', 'randomization');
// Some keys are stored in the actual question table not in the attributes table.
if (in_array($key, $baseAttributes)) {
if ($data == '') {
$data = null;
}
$result = $this->setQuestionBase($id, $key, $data);
} else {
$attributes = array('qid' => $id, 'attribute' => $key, 'language' => $language);
$record = QuestionAttribute::model()->findByAttributes($attributes);
if (is_null($record)) {
// New setting
$record = QuestionAttribute::model()->populateRecord($attributes);
$record->setIsNewRecord(true);
}
// Serialize arrays and objects only for question attributes..
if (is_array($data) || is_object($data)) {
$record->value = json_encode($data);
$record->serialized = true;
} else {
$record->value = $data;
$record->serialized = false;
}
$result = $record->save();
}
return $result;
}
示例13: getQuestionAttributes
/**
* Returns Question attribute array name=>value
*
* @access public
* @param int $iQuestionID
* @return array
*/
public function getQuestionAttributes($iQuestionID)
{
$iQuestionID = (int) $iQuestionID;
static $aQuestionAttributesStatic = array();
// TODO : replace by Yii::app()->cache
// Limit the size of the attribute cache due to memory usage
$aQuestionAttributesStatic = array_splice($aQuestionAttributesStatic, -1000, null, true);
if (isset($aQuestionAttributesStatic[$iQuestionID])) {
return $aQuestionAttributesStatic[$iQuestionID];
}
$aQuestionAttributes = array();
$oQuestion = Question::model()->find("qid=:qid", array('qid' => $iQuestionID));
// Maybe take parent_qid attribute before this qid attribute
if ($oQuestion) {
$aLanguages = array_merge(array(Survey::model()->findByPk($oQuestion->sid)->language), Survey::model()->findByPk($oQuestion->sid)->additionalLanguages);
// Get all atribute set for this question
$sType = $oQuestion->type;
$aAttributeNames = questionAttributes();
$aAttributeNames = $aAttributeNames[$sType];
$oAttributeValues = QuestionAttribute::model()->findAll("qid=:qid", array('qid' => $iQuestionID));
$aAttributeValues = array();
foreach ($oAttributeValues as $oAttributeValue) {
if ($oAttributeValue->language) {
$aAttributeValues[$oAttributeValue->attribute][$oAttributeValue->language] = $oAttributeValue->value;
} else {
$aAttributeValues[$oAttributeValue->attribute] = $oAttributeValue->value;
}
}
// Fill with aQuestionAttributes with default attribute or with aAttributeValues
// Can not use array_replace due to i18n
foreach ($aAttributeNames as $aAttribute) {
if ($aAttribute['i18n'] == false) {
if (isset($aAttributeValues[$aAttribute['name']])) {
$aQuestionAttributes[$aAttribute['name']] = $aAttributeValues[$aAttribute['name']];
} else {
$aQuestionAttributes[$aAttribute['name']] = $aAttribute['default'];
}
} else {
foreach ($aLanguages as $sLanguage) {
if (isset($aAttributeValues[$aAttribute['name']][$sLanguage])) {
$aQuestionAttributes[$aAttribute['name']][$sLanguage] = $aAttributeValues[$aAttribute['name']][$sLanguage];
} else {
$aQuestionAttributes[$aAttribute['name']][$sLanguage] = $aAttribute['default'];
}
}
}
}
} else {
return false;
// return false but don't set $aQuestionAttributesStatic[$iQuestionID]
}
$aQuestionAttributesStatic[$iQuestionID] = $aQuestionAttributes;
return $aQuestionAttributes;
}
示例14: 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);
}
}
示例15: do_array_dual
function do_array_dual($ia)
{
global $thissurvey;
$aLastMoveResult = LimeExpressionManager::GetLastMoveResult();
$aMandatoryViolationSubQ = $aLastMoveResult['mandViolation'] && $ia[6] == 'Y' ? explode("|", $aLastMoveResult['unansweredSQs']) : array();
$repeatheadings = Yii::app()->getConfig("repeatheadings");
$minrepeatheadings = Yii::app()->getConfig("minrepeatheadings");
$extraclass = "";
$answertypeclass = "";
// Maybe not
$caption = "";
// Just leave empty, are replaced after
$inputnames = array();
$labelans1 = array();
$labelans = array();
$aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]);
if ($aQuestionAttributes['random_order'] == 1) {
$ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY " . dbRandom();
} else {
$ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY question_order";
}
$ansresult = dbExecuteAssoc($ansquery);
//Checked
$aSubQuestions = $ansresult->readAll();
$anscount = count($aSubQuestions);
$lquery = "SELECT * FROM {{answers}} WHERE scale_id=0 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
$lresult = dbExecuteAssoc($lquery);
//Checked
$aAnswersScale0 = $lresult->readAll();
$lquery1 = "SELECT * FROM {{answers}} WHERE scale_id=1 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
$lresult1 = dbExecuteAssoc($lquery1);
//Checked
$aAnswersScale1 = $lresult1->readAll();
if ($aQuestionAttributes['use_dropdown'] == 1) {
$useDropdownLayout = true;
$extraclass .= " dropdown-list";
$answertypeclass .= " dropdown";
$doDualScaleFunction = "doDualScaleDropDown";
// javascript funtion to lauch at end of answers
$caption = gT("An array with sub-question on each line, with 2 answers to provide on each line. You have to select the answer.");
} else {
$useDropdownLayout = false;
$extraclass .= " radio-list";
$answertypeclass .= " radio";
$doDualScaleFunction = "doDualScaleRadio";
$caption = gT("An array with sub-question on each line, with 2 answers to provide on each line. The answers are contained in the table header. ");
}
if (ctype_digit(trim($aQuestionAttributes['repeat_headings'])) && trim($aQuestionAttributes['repeat_headings'] != "")) {
$repeatheadings = intval($aQuestionAttributes['repeat_headings']);
$minrepeatheadings = 0;
}
if (trim($aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '') {
$leftheader = $aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']];
} else {
$leftheader = '';
}
if (trim($aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '') {
$rightheader = $aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']];
} else {
$rightheader = '';
}
if (trim($aQuestionAttributes['answer_width']) != '') {
$answerwidth = $aQuestionAttributes['answer_width'];
} else {
$answerwidth = 20;
}
// Find if we have rigth and center text
// TODO move "|" to attribute
$sQuery = "SELECT count(question) FROM {{questions}} WHERE parent_qid=" . $ia[0] . " and scale_id=0 AND question like '%|%'";
$rigthCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
$rightexists = $rigthCount > 0;
// $right_exists: flag to find out if there are any right hand answer parts. leaving right column but don't force with
$sQuery = "SELECT count(question) FROM {{questions}} WHERE parent_qid=" . $ia[0] . " and scale_id=0 AND question like '%|%|%'";
$centerCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
$centerexists = $centerCount > 0;
// $center_exists: flag to find out if there are any center hand answer parts. leaving center column but don't force with
// Label and code for input
foreach ($aAnswersScale0 as $lrow) {
$labels0[] = array('code' => $lrow['code'], 'title' => $lrow['answer']);
}
foreach ($aAnswersScale1 as $lrow) {
$labels1[] = array('code' => $lrow['code'], 'title' => $lrow['answer']);
}
if (count($aAnswersScale0) > 0 && $anscount) {
$answer = "";
$fn = 1;
// Used by repeat_heading
if ($useDropdownLayout === false) {
$columnswidth = 100 - $answerwidth;
foreach ($aAnswersScale0 as $lrow) {
$labelans0[] = $lrow['answer'];
$labelcode0[] = $lrow['code'];
}
foreach ($aAnswersScale1 as $lrow) {
$labelans1[] = $lrow['answer'];
$labelcode1[] = $lrow['code'];
}
$numrows = count($labelans0) + count($labelans1);
// Add needed row and fill some boolean: shownoanswer, rightexists, centerexists
$shownoanswer = $ia[6] != "Y" && SHOW_NO_ANSWER == 1;
//.........这里部分代码省略.........