Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/master' into global_participants
  • Loading branch information
olleharstedt committed Sep 22, 2016
2 parents a1828b1 + 1829e4e commit 13d780d
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions application/helpers/qanda_helper.php
Expand Up @@ -4794,16 +4794,6 @@ function do_array($ia)
$aQuestions = $ansresult->readAll();
$anscount = count($aQuestions);
$fn = 1;
$numrows = count($labels);

if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1)
{
++$numrows;
}
if ($right_exists)
{
++$numrows;
}

$trbc = '';
$inputnames=array();
Expand All @@ -4829,20 +4819,36 @@ function do_array($ia)

$options = array();

// Dropdown representation is en exception - even if mandatory or SHOW_NO_ANSWER is disable a neutral option needs to be shown where the mandatory case asks actively
$options[0]['text'] = ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1)?gT('No answer'):gT('Please choose...');
$options[0]['value'] = ' ';
$options[0]['selected'] = (!isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]) || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '')?'SELECTED':'';

// Other options
/* Dropdown representation : first choice (activated) must be Please choose... if there are no actual answer */
$showNoAnswer= $ia[6] != 'Y' && SHOW_NO_ANSWER == 1; // Tag if we must show no-answer
if(!isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]) || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] === '')
{
$options[]=array(
'text'=> gT('Please choose...'),
'value'=> '',
'selected'=>''
);
$showNoAnswer=false;
}
// Real options
foreach ($labels as $i=>$lrow)
{
$y=$i+1; // $options[0] ]defined just above
$options[$y]['value'] = $lrow['code'];
$options[$y]['selected'] = (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == $lrow['code'])?'SELECTED':'';
$options[$y]['text'] = flattenText($lrow['answer']);
$options[]=array(
'value'=>$lrow['code'],
'selected'=>($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == $lrow['code'])? SELECTED :'',
'text'=> flattenText($lrow['answer'])
);
}

/* Add the now answer if needed */
if($showNoAnswer)
{
$options[]=array(
'text'=> gT('No answer'),
'value'=> '',
'selected'=> ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]==='') ? SELECTED :'',
);
}
unset($showNoAnswer);
$sRows .= doRender('/survey/questions/arrays/array/dropdown/rows/answer_row', array(
'myfname' => $myfname,
'answertext' => $answertext,
Expand Down

0 comments on commit 13d780d

Please sign in to comment.