Skip to content

Commit

Permalink
Fixed issue : order of scale X subquestion in array number and text
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Mar 14, 2020
1 parent 63c6584 commit 5678aec
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions application/models/SurveyDynamic.php
Expand Up @@ -804,7 +804,6 @@ public function getQuestionArray($oQuestion, $oResponses, $bHonorConditions, $su
$aQuestionAttributes['helpSrc'] = $oQuestion->help;
$result = LimeExpressionManager::ProcessString($oQuestion->help, 40, NULL, 1, 1);
$aQuestionAttributes['help'] = $result;

if (count($oQuestion->subquestions) > 0) {
$aQuestionAttributes['subquestions'] = array();
foreach ($oQuestion->subquestions as $oSubquestion) {
Expand Down Expand Up @@ -864,10 +863,7 @@ public function getQuestionArray($oQuestion, $oResponses, $bHonorConditions, $su
if ($aQuestionAttributes['questionclass'] === 'date') {
$aQuestionAttributes['dateformat'] = getDateFormatDataForQID($aQuestionAttributes, array_merge(self::$survey->attributes, $oQuestion->survey->languagesettings[$oQuestion->language]->attributes));
}

$aQuestionAttributes['answervalue'] = isset($oResponses[$fieldname]) ? $oResponses[$fieldname] : null;


if ((in_array($oQuestion->type, ["!", "L", "O", "F", "H"]))
|| ($oQuestion->type=='T' && $oQuestion->parent_qid != 0) ) {

Expand Down Expand Up @@ -955,8 +951,14 @@ public function getQuestionArray($oQuestion, $oResponses, $bHonorConditions, $su

}

/* Second (X) scale for array text and array number */
if ($oQuestion->parent_qid != 0 && in_array($oQuestion->parents['type'], [";", ":"])) {
foreach (Question::model()->findAllByAttributes(array('parent_qid' => $aQuestionAttributes['parent_qid'], 'scale_id' => ($oQuestion->parents['type'] == '1' ? 2 : 1))) as $oScaleSubquestion) {
$oScaleXSubquestions = Question::model()->findAll(array(
'condition' => "parent_qid = :parent_qid and scale_id = :scale_id",
'order' => "question_order ASC",
'params' => array('parent_qid' => $aQuestionAttributes['parent_qid'], 'scale_id' => 1),
));
foreach ($oScaleXSubquestions as $oScaleSubquestion) {
$tempFieldname = $fieldname.'_'.$oScaleSubquestion->title;
$aQuestionAttributes['answervalues'][$oScaleSubquestion->title] = isset($oResponses[$tempFieldname]) ? $oResponses[$tempFieldname] : null;
$aQuestionAttributes['answervalueslabels'][$oScaleSubquestion->title] = isset($oScaleSubquestion->question) ? $oScaleSubquestion->question : null;
Expand Down

0 comments on commit 5678aec

Please sign in to comment.