Skip to content

Commit

Permalink
Fixed issue #6859: Integer values displayed as floating point numbers
Browse files Browse the repository at this point in the history
Fixed issue: Can add dot on integer only numerci question type
Dev: remove all ending 0 to numeric question type, and remove the . if it's at ending
Dev: TODO : move control of numeric/integer in clean external js
  • Loading branch information
Shnoulle committed Nov 21, 2012
1 parent ed01b49 commit a7018f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion application/helpers/common_helper.php
Expand Up @@ -1383,7 +1383,6 @@ function getQuestion($fieldcode)
}

/**
*
* @param type $iSurveyID The Survey ID
* @param type $sFieldCode Field code of the particular field
* @param type $sValue The stored response value
Expand Down
23 changes: 12 additions & 11 deletions application/modules/NumericalQuestion.php
Expand Up @@ -47,21 +47,22 @@ public function getAnswerHTML()
$tiwidth=10;
}

$fValue=rtrim($_SESSION['survey_'.$this->surveyid][$this->fieldname],'0.');// Remove ending . and extra 0
$integeronly=0;
if (trim($aQuestionAttributes['num_value_int_only'])==1)
{
$acomma="";
$integeronly=1;
$extraclass .=" integeronly";
$answertypeclass = " integeronly";
$answertypeclass .= " integeronly";
if(is_numeric($fValue))
{
$fValue=number_format($fValue, 0, '', '');
}
}
else
{
$acomma=getRadixPointData($thissurvey['surveyls_numberformat']);
$acomma = $acomma['seperator'];

}
$sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']);
$sSeperator = $sSeperator['seperator'];
$dispVal = str_replace('.',$sSeperator,$_SESSION['survey_'.$this->surveyid][$this->fieldname]);
$fValue = str_replace('.',$sSeperator,$fValue);

if ($thissurvey['nokeyboard']=='Y')
{
Expand All @@ -77,7 +78,7 @@ public function getAnswerHTML()
$answer = "<p class='question answer-item text-item numeric-item {$extraclass}'>"
. " <label for='answer{$this->fieldname}' class='hide label'>{$clang->gT('Answer')}</label>\n$prefix\t"
. "<input class='text {$answertypeclass}' type=\"text\" size=\"$tiwidth\" name=\"$this->fieldname\" title=\"".$clang->gT('Only numbers may be entered in this field.')."\" "
. "id=\"answer{$this->fieldname}\" value=\"{$dispVal}\" onkeyup='$checkconditionFunction(this.value, this.name, this.type)' "
. "id=\"answer{$this->fieldname}\" value=\"{$fValue}\" onkeyup=\"{$checkconditionFunction}(this.value, this.name, this.type,'onchange',{$integeronly})\" "
. " {$maxlength} />\t{$suffix}\n</p>\n";
if ($aQuestionAttributes['hide_tip']==0)
{
Expand All @@ -97,13 +98,13 @@ public function getDataEntry($idrow, &$fnames, $language)

public function getExtendedAnswer($value, $language)
{
echo Yii::trace(CVarDumper::dumpAsString($value),'vardump');
$value=rtrim($value,"0.");
$aQuestionAttributes = $this->getAttributeValues();
if($aQuestionAttributes['num_value_int_only'])
{
$sValue=number_format($sValue, 0, '', '');
$value=number_format($value, 0, '', '');
}
return $value;
}

public function filter($value, $type)
Expand Down

0 comments on commit a7018f1

Please sign in to comment.