Skip to content

Commit

Permalink
Fixed issue : Next button in question menu goes to second question of…
Browse files Browse the repository at this point in the history
… the group if no question ar selected

Dev: same for group
  • Loading branch information
Shnoulle committed Jul 31, 2013
1 parent 501b784 commit 0092261
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions application/helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,18 +682,14 @@ function getGidNext($surveyid, $gid)
if (!$surveyid) {$surveyid=returnGlobal('sid');}
$s_lang = Survey::model()->findByPk($surveyid)->language;

//$gquery = "SELECT gid FROM ".db_table_name('groups')." WHERE sid=$surveyid AND language='{$s_lang}' ORDER BY group_order";

$qresult = Groups::model()->findAllByAttributes(array('sid' => $surveyid, 'language' => $s_lang), array('order'=>'group_order'));

$GidNext="";
$i = 0;
$iNext = 1;

$iNext = 0;
foreach ($qresult as $qrow)
{
$qrow = $qrow->attributes;

if ($gid == $qrow['gid']) {$iNext = $i + 1;}
$i += 1;
}
Expand All @@ -716,19 +712,17 @@ function getQidNext($surveyid, $gid, $qid)
{
$clang = Yii::app()->lang;
$s_lang = Survey::model()->findByPk($surveyid)->language;
$qrows = Questions::model()->findAllByAttributes(array('gid' => $gid, 'sid' => $surveyid, 'language' => $s_lang, 'parent_qid' => 0), array('order'=>'question_order'));


$qrows = Questions::model()->findAllByAttributes(array('gid' => $gid, 'sid' => $surveyid, 'language' => $s_lang, 'parent_qid' => 0), array('order'=>'question_order'));
$i = 0;
$iNext = 1;
if (count($qrows) > 0)
$iNext = 0;

foreach ($qrows as $qrow)
{
foreach ($qrows as $qrow)
{
if ($qid == $qrow->qid) {$iNext = $i + 1;}
$i += 1;
}
if ($qid == $qrow->qid && $qid) {$iNext = $i + 1;}
$i += 1;
}

if ($iNext < count($qrows)) {$QidNext = $qrows[$iNext]->qid;}
else {$QidNext = "";}
return $QidNext;
Expand Down

0 comments on commit 0092261

Please sign in to comment.