From 74f4ee3ee6b9632adff9a0c1bdae946f4eae4b86 Mon Sep 17 00:00:00 2001 From: Gabriel Jenik Date: Tue, 11 Jan 2022 13:04:36 -0300 Subject: [PATCH] Fixed issue #17720: Wrong statistics with Other answers in single choice questions (#2203) Co-authored-by: encuestabizdevgit --- application/helpers/admin/statistics_helper.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/application/helpers/admin/statistics_helper.php b/application/helpers/admin/statistics_helper.php index aa616c8322d..a063a0be2b7 100644 --- a/application/helpers/admin/statistics_helper.php +++ b/application/helpers/admin/statistics_helper.php @@ -1451,9 +1451,9 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s // just count the number of 'other' values - that way with failing Javascript the statistics don't get messed up /* This query selects a count of responses where "other" has been selected */ foreach ($oResponses as $oResponse) { - $sResponseColumn = $al[2]; - $column = substr($sResponseColumn, 0, strlen($sResponseColumn) - 5); - if ($column == '-oth-' && !empty($oResponse->$sResponseColumn)) { + $otherValueColumn = $al[2]; + $answerOptionColumn = substr($otherValueColumn, 0, strlen($otherValueColumn) - 5); + if (!empty($oResponse->$answerOptionColumn) && $oResponse->$answerOptionColumn == '-oth-') { $row += 1; } } @@ -2223,9 +2223,9 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi // just count the number of 'other' values - that way with failing Javascript the statistics don't get messed up /* This query selects a count of responses where "other" has been selected */ foreach ($oResponses as $oResponse) { - $sResponseColumn = $al[2]; - $column = substr($sResponseColumn, 0, strlen($sResponseColumn) - 5); - if ($column == '-oth-' && !empty($oResponse->$sResponseColumn)) { + $otherValueColumn = $al[2]; + $answerOptionColumn = substr($otherValueColumn, 0, strlen($otherValueColumn) - 5); + if (!empty($oResponse->$answerOptionColumn) && $oResponse->$answerOptionColumn == '-oth-') { $row += 1; } }