Skip to content

Commit

Permalink
Fixed issue #16891: PHP 7.4 + debug : PHP Notice with numeric questio…
Browse files Browse the repository at this point in the history
…n type

Fixed issue #16892: When reload response ; multinumerci shown 0000 at end of string
Dev: same fix than master
Dev: deprecated qanda_helper/do_multiplenumeric
  • Loading branch information
Shnoulle committed Dec 10, 2020
1 parent 736baf2 commit faba8b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Expand Up @@ -167,7 +167,17 @@ public function getRows()

$sDisplayStyle = '';

$dispVal = $this->setDefaultIfEmpty($this->aSurveySessionArray[$myfname],'');
$dispVal = $this->setDefaultIfEmpty($this->aSurveySessionArray[$myfname],'');
if ($dispVal && is_string($dispVal)) {
// Fix reloaded DECIMAL value
if ($dispVal[0] == ".") {
// issue #15684 mssql SAVE 0.01 AS .0100000000, set it at 0.0100000000
$dispVal = "0" . $dispVal;
}
if (strpos($dispVal, ".")) {
$dispVal = rtrim(rtrim($dispVal, "0"), ".");
}
}
$dispVal = str_replace('.', $this->sSeparator, $dispVal);

if (!$this->useSliderLayout) {
Expand Down
19 changes: 14 additions & 5 deletions application/helpers/qanda_helper.php
Expand Up @@ -1932,8 +1932,11 @@ function do_multipleshorttext($ia)
return array($answer, $inputnames);
}

// -----------------------------------------------------------------
// @todo: Can remove DB query by passing in answer list from EM
/**
* @deprecated 4.?.?
* @see RenderMultipleNumerical
* @see DataSetMultipleNumerical
*/
function do_multiplenumeric($ia)
{
global $thissurvey;
Expand Down Expand Up @@ -2323,9 +2326,15 @@ function do_numerical($ia)
$sSeparator = getRadixPointData($thissurvey['surveyls_numberformat']);
$sSeparator = $sSeparator['separator'];

// Fix the display value : Value is stored as decimal in SQL then return dot and 0 after dot. Seems only for numerical question type
if (strpos($fValue, ".")) {
$fValue = rtrim(rtrim($fValue, "0"), ".");
if ($fValue && is_string($fValue)) {
// Fix reloaded DECIMAL value
if ($fValue[0] == ".") {
// issue #15684 mssql SAVE 0.01 AS .0100000000, set it at 0.0100000000
$fValue = "0" . $fValue;
}
if (strpos($fValue, ".")) {
$fValue = rtrim(rtrim($fValue, "0"), ".");
}
}
$fValue = str_replace('.', $sSeparator, $fValue);

Expand Down

0 comments on commit faba8b6

Please sign in to comment.