Skip to content

Commit

Permalink
Fixed issue #11702: Dropdown question : 2 'no answer' if value select…
Browse files Browse the repository at this point in the history
…ed is 0
  • Loading branch information
Shnoulle committed Oct 15, 2016
1 parent c6ccf7b commit a027f11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 7 additions & 7 deletions application/helpers/qanda_helper.php
Expand Up @@ -1235,14 +1235,14 @@ function do_list_dropdown($ia)
// Getting answers
$ansresult = $oQuestion->getOrderedAnswers($aQuestionAttributes['random_order'], $aQuestionAttributes['alphasort'] );

$dropdownSize = '';
$dropdownSize = null;

if (isset($aQuestionAttributes['dropdown_size']) && $aQuestionAttributes['dropdown_size'] > 0)
{
$_height = sanitize_int($aQuestionAttributes['dropdown_size']) ;
$_maxHeight = count($ansresult);

if ((!empty($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]])) && $ia[6] != 'Y' && $ia[6] != 'Y' && SHOW_NO_ANSWER == 1)
if ((!is_null($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]==='') && $ia[6] != 'Y' && $ia[6] != 'Y' && SHOW_NO_ANSWER == 1)
{
++$_maxHeight; // for No Answer
}
Expand All @@ -1252,7 +1252,7 @@ function do_list_dropdown($ia)
++$_maxHeight; // for Other
}

if (!$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]])
if (is_null($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]))
{
++$_maxHeight; // for 'Please choose:'
}
Expand All @@ -1261,7 +1261,7 @@ function do_list_dropdown($ia)
{
$_height = $_maxHeight;
}
$dropdownSize = ' size="'.$_height.'"';
$dropdownSize = $_height;
}

$prefixStyle = 0;
Expand All @@ -1278,11 +1278,11 @@ function do_list_dropdown($ia)
$sOptions = '';

// If no answer previously selected
if (!$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]])
if (is_null($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]==='')
{
$sOptions .= doRender('/survey/questions/list_dropdown/rows/option', array(
'value'=>'',
'opt_select'=>'SELECTED',
'opt_select'=> ($dropdownSize) ? SELECTED : "",/* not needed : first one */
'answer'=>gT('Please choose...')
), true);
}
Expand Down Expand Up @@ -1398,7 +1398,7 @@ function do_list_dropdown($ia)
), true);
}

if (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] != '') && $ia[6] != 'Y' && SHOW_NO_ANSWER == 1)
if (!(is_null($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]==="") && $ia[6] != 'Y' && SHOW_NO_ANSWER == 1)
{
if ($prefixStyle == 1)
{
Expand Down
4 changes: 1 addition & 3 deletions application/views/survey/questions/list_dropdown/answer.php
Expand Up @@ -21,13 +21,11 @@
<label for="answer<?php echo $name; ?>" class="sr-only control-label">
<?php eT('Please choose'); ?>
</label>

<select
class="form-control"
name="<?php echo $name; ?>"
id="answer<?php echo $name; ?>"
<?php echo $dropdownSize; ?>
onchange="<?php echo $checkconditionFunction; ?>(this.value, this.name, this.type);"
<?php echo ($dropdownSize) ? "size=$dropdownSize" : "" ; ?>
>
<?php
// rows/option.php
Expand Down

0 comments on commit a027f11

Please sign in to comment.