Skip to content

Commit

Permalink
Fixed #7011: It is not possible to randomize the order of groups even…
Browse files Browse the repository at this point in the history
… when a randomization groupname is set

dev: grouplist needs to have gseq for index, also updated to always use named keys instead of numbers
  • Loading branch information
mennodekker committed Jan 28, 2013
1 parent 1ec04f6 commit d325df9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
12 changes: 6 additions & 6 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 '<h3>' . flattenText($gtitle) . "</h3>";
}
$lastGseq = $stepInfo['gseq'];
Expand All @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -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;
}
}
Expand Down
26 changes: 17 additions & 9 deletions application/helpers/frontend_helper.php
Expand Up @@ -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<br />$query<br />"); //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;
}

/**
Expand Down

0 comments on commit d325df9

Please sign in to comment.