Skip to content

Commit

Permalink
Fixed issue #11387: Question appears twice (multiple short text)
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jun 16, 2016
1 parent 1802fbf commit 539e5b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
9 changes: 6 additions & 3 deletions application/helpers/qanda_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2739,9 +2739,12 @@ function do_multipleshorttext($ia)
$ansrow['question'] = ($ansrow['question'] == "")?" ":$ansrow['question'];

// color code missing mandatory questions red
if ($ia[6]=='Y' && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] === '')
if (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] != $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['maxstep']) || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] == $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['prevstep']))
{
$alert = true;
if ($ia[6]=='Y' && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] === '')
{
$alert = true;
}
}

$sDisplayStyle = return_display_style($ia, $aQuestionAttributes, $thissurvey, $myfname);
Expand Down Expand Up @@ -2984,7 +2987,7 @@ function do_multiplenumeric($ia)

// color code missing mandatory questions red
$alert='';

if (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] != $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['maxstep']) || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] == $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['prevstep']))
{
if ($ia[6]=='Y' && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] === '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@

<!--answer_row_inputtext -->
<div id="javatbd<?php echo $myfname; ?>" class="question-item answer-item text-item form-horizontal <?php echo $extraclass;?>" <?php echo $sDisplayStyle;?> >
<?php if($alert):?>
<!-- color code missing mandatory questions red -->
<div class="label label-danger errormandatory" role="alert">
<?php echo $question; ?>
</div>
<?php endif;?>

<div class="form-group row">
<label class='control-label col-xs-12 col-sm-<?php echo $sLabelWidth; ?>' for="answer<?php echo$myfname;?>">
<?php echo $question; ?>
</label>

<?php if ($alert):?>
<!-- color code missing mandatory questions red -->
<div class="col-xs-12 col-sm-<?php echo $sLabelWidth; ?> control-label">
<div class="label label-danger errormandatory pull-right" role="alert">
<?php echo $question; ?>
</div>
</div>
<?php else:?>
<label class='control-label col-xs-12 col-sm-<?php echo $sLabelWidth; ?>' for="answer<?php echo$myfname;?>">
<?php echo $question; ?>
</label>
<?php endif;?>

<div class="col-xs-12 col-sm-<?php echo $sInputContainerWidth; ?>">
<?php echo $prefix; ?>
<input
Expand Down

2 comments on commit 539e5b4

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With other array , in 2.06 we use

$aLastMoveResult=LimeExpressionManager::GetLastMoveResult();
$aMandatoryViolationSubQ=($aLastMoveResult['mandViolation'] && $ia[6] == 'Y') ? explode("|",$aLastMoveResult['unansweredSQs']) : array();
[...]
            if (in_array($myfname, $aMandatoryViolationSubQ))
            {
                $answertext = '<span class="errormandatory">'.$answertext.'</span>';
            }

https://github.com/LimeSurvey/LimeSurvey/blob/2.06lts/application/helpers/qanda_helper.php#L4548

But not with multiple short text. Think it's the best way : step/maxstep can be broken in some "reload" survey situation. Not a big issue, but cleaner i think

See:
https://github.com/LimeSurvey/LimeSurvey/blob/2.06lts/application/helpers/qanda_helper.php#L4548

@LouisGac
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thank you very much

Please sign in to comment.