diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index fe1fe5363a0..7af5fee9397 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -636,7 +636,7 @@ function run($surveyid,$args) { foreach ($_SESSION[$LEMsessid]['grouplist'] as $gl) { - $gid = $gl[0]; + $gid = $gl['gid']; $qnumber = 0; if ($surveyMode != 'survey') @@ -913,10 +913,10 @@ function checkconditions(value, name, type, evt_type) $_gseq = -1; foreach ($_SESSION[$LEMsessid]['grouplist'] as $gl) { - $gid = $gl[0]; + $gid = $gl['gid']; ++$_gseq; - $groupname = $gl[1]; - $groupdescription = $gl[2]; + $groupname = $gl['group_name']; + $groupdescription = $gl['description']; if ($surveyMode != 'survey' && $gid != $onlyThisGID) { @@ -1095,7 +1095,7 @@ function checkconditions(value, name, type, evt_type) $grel = !LimeExpressionManager::GroupIsIrrelevantOrHidden($gseq); if ($grel) { - $gtitle = LimeExpressionManager::ProcessString($g[1]); + $gtitle = LimeExpressionManager::ProcessString($g['group_name']); echo '

' . flattenText($gtitle) . "

"; } $lastGseq = $stepInfo['gseq']; @@ -1118,7 +1118,7 @@ function checkconditions(value, name, type, evt_type) if ($surveyMode == 'group') { - $indexlabel = LimeExpressionManager::ProcessString($g[1]); + $indexlabel = LimeExpressionManager::ProcessString($g['group_name']); } else { diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index 146a08606ab..2e4f5f97b3e 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -7458,10 +7458,10 @@ function getGroupInfoForEM($surveyid,$lang=NULL) if (isset($_SESSION['survey_'.$surveyid]) && isset($_SESSION['survey_'.$surveyid]['grouplist'])) { $_order=0; $qinfo = array(); - foreach ($_SESSION['survey_'.$surveyid]['grouplist'] as $orderedGid => $info) + foreach ($_SESSION['survey_'.$surveyid]['grouplist'] as $info) { - $gid[$orderedGid]['group_order'] = $_order; - $qinfo[$_order] = $gid[$orderedGid]; + $gid[$info['gid']]['group_order'] = $_order; + $qinfo[$_order] = $gid[$info['gid']]; ++$_order; } } diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index bdab24a0de3..e83c1b647d7 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -2265,25 +2265,33 @@ function UpdateGroupList($surveyid, $language) unset ($_SESSION['survey_'.$surveyid]['grouplist']); $query = "SELECT * FROM {{groups}} WHERE sid=$surveyid AND language='".$language."' ORDER BY group_order"; $result = dbExecuteAssoc($query) or safeDie ("Couldn't get group list
$query
"); //Checked + $groupList = array(); foreach ($result->readAll() as $row) { - $_SESSION['survey_'.$surveyid]['grouplist'][$row['gid']]=array($row['gid'], $row['group_name'], $row['description']); + $group = array( + 'gid' => $row['gid'], + 'group_name' => $row['group_name'], + 'description' => $row['description']); + $groupList[] = $group; + $gidList[$row['gid']] = $group; } - $groupList = $_SESSION['survey_'.$surveyid]['grouplist']; + if (isset($_SESSION['survey_'.$surveyid]['groupReMap']) && count($_SESSION['survey_'.$surveyid]['groupReMap'])>0) { // Now adjust the grouplist $groupRemap = $_SESSION['survey_'.$surveyid]['groupReMap']; - unset ($_SESSION['survey_'.$surveyid]['grouplist']); - - foreach ($groupList as $groupId => $info) { - $newId = $groupId; - if (isset($groupRemap[$groupId])) { - $newId = $groupRemap[$groupId]; + $groupListCopy = $groupList; + foreach ($groupList as $gseq => $info) { + $gid = $info['gid']; + if (isset($groupRemap[$gid])) { + $gid = $groupRemap[$gid]; } - $_SESSION['survey_'.$surveyid]['grouplist'][$newId] = $groupList[$newId]; + $groupListCopy[$gseq] = $gidList[$gid]; } + $groupList = $groupListCopy; } + + $_SESSION['survey_'.$surveyid]['grouplist'] = $groupList; } /**