Skip to content

Commit

Permalink
Fixed issue #05702: Invalid question - probably missing sub-questions…
Browse files Browse the repository at this point in the history
… or language-specific settings for language en

Dev core problem is that groups.group_order can have gaps - needed to ensure groupSeq count is sequential from 0

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12247 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
tmswhite committed Jan 28, 2012
1 parent 1bf0c8b commit ddcd57d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
37 changes: 22 additions & 15 deletions application/helpers/common_helper.php
Expand Up @@ -2322,11 +2322,18 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$aquery.=" ORDER BY group_order, question_order";
$aresult = Yii::app()->db->createCommand($aquery)->queryAll();
$questionSeq=-1; // this is incremental question sequence across all groups
$groupSeq=-1;
$_groupOrder=-1;

foreach ($aresult as $arow) //With each question, create the appropriate field(s))
{
++$questionSeq;


// fix fact taht group_order may have gaps
if ($_groupOrder != $arow['group_order']) {
$_groupOrder = $arow['group_order'];
++$groupSeq;
}
// Conditions indicators are obsolete with EM. However, they are so tightly coupled into LS code that easider to just set values to 'N' for now and refactor later.
$conditions = 'N';
$usedinconditions = 'N';
Expand All @@ -2353,7 +2360,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
if (isset($defaultValues[$arow['qid'].'~0'])) {
$fieldmap[$fieldname]['defaultvalue'] = $defaultValues[$arow['qid'].'~0'];
}
Expand Down Expand Up @@ -2384,7 +2391,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
if (isset($defaultValues[$arow['qid'].'~other'])) {
$fieldmap[$fieldname]['defaultvalue'] = $defaultValues[$arow['qid'].'~other'];
}
Expand Down Expand Up @@ -2412,7 +2419,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
}
break;
}
Expand Down Expand Up @@ -2462,7 +2469,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
$fieldmap[$fieldname]['preg']=$arow['preg'];
$fieldmap[$fieldname]['answerList']=$answerList;
}
Expand All @@ -2489,7 +2496,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
}

$fieldname="{$arow['sid']}X{$arow['gid']}X{$arow['qid']}{$abrow['title']}#1";
Expand All @@ -2506,7 +2513,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
}
}
}
Expand All @@ -2532,7 +2539,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
}
}
}
Expand Down Expand Up @@ -2560,7 +2567,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
}
$fieldname="{$arow['sid']}X{$arow['gid']}X{$arow['qid']}"."_filecount";
$fieldmap[$fieldname]=array("fieldname"=>$fieldname,
Expand All @@ -2579,7 +2586,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
}
}
}
Expand Down Expand Up @@ -2608,7 +2615,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
$fieldmap[$fieldname]['preg']=$arow['preg'];
if (isset($defaultValues[$arow['qid'].'~'.$abrow['qid']])) {
$fieldmap[$fieldname]['defaultvalue'] = $defaultValues[$arow['qid'].'~'.$abrow['qid']];
Expand All @@ -2629,7 +2636,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
}
}
}
Expand All @@ -2648,7 +2655,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
$fieldmap[$fieldname]['other']=$arow['other'];
}
if ($arow['type']=="P")
Expand All @@ -2666,7 +2673,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['hasconditions']=$conditions;
$fieldmap[$fieldname]['usedinconditions']=$usedinconditions;
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
$fieldmap[$fieldname]['other']=$arow['other'];
}
}
Expand All @@ -2675,7 +2682,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['relevance']=$arow['relevance'];
$fieldmap[$fieldname]['grelevance']=$arow['grelevance'];
$fieldmap[$fieldname]['questionSeq']=$questionSeq;
$fieldmap[$fieldname]['groupSeq']=$arow['group_order'];
$fieldmap[$fieldname]['groupSeq']=$groupSeq;
$fieldmap[$fieldname]['preg']=$arow['preg'];
$fieldmap[$fieldname]['other']=$arow['other'];
$fieldmap[$fieldname]['help']=$arow['help'];
Expand Down
8 changes: 5 additions & 3 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -5722,15 +5722,17 @@ function getGroupInfoForEM($surveyid,$lang=NULL)
$data = dbExecuteAssoc($query);

$qinfo = array();
foreach ($data->readAll() as $d)
$_order=0;
foreach ($data as $d)
{
$qinfo[$d['group_order']] = array(
'group_order' => $d['group_order'],
$qinfo[$_order] = array(
'group_order' => $_order,
'gid' => $d['gid'],
'group_name' => $d['group_name'],
'description' => $d['description'],
'grelevance' => $d['grelevance'],
);
++$_order;
}

return $qinfo;
Expand Down

0 comments on commit ddcd57d

Please sign in to comment.