Skip to content

Commit

Permalink
Dev Fixed problematic comments
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Nov 22, 2017
1 parent 9974ac8 commit f0f4e7f
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions application/core/plugins/ExportSTATAxml/STATAxmlWriter.php
Expand Up @@ -37,12 +37,9 @@ function __construct($pluginsettings)
$this->separator = ',';
$this->hasOutputHeader = false;
$this->statafileversion = $pluginsettings['statafileversion']['current'];
if ($this->statafileversion >= 117) // 117 is the version number of the .dta/xml format for stata version 13
{
if ($this->statafileversion >= 117) { // 117 is the version number of the .dta/xml format for stata version 13
$this->maxStringLength = 2045; // for Stata version 13 and above
}
else
{
} else {
$this->maxStringLength = 244; // for older Stata versions
}
}
Expand Down Expand Up @@ -303,8 +300,7 @@ function createStataFieldmap($survey, $sLanguage, $oOptions)
*/
protected function STATAvarname($sVarname)
{
if (!preg_match("/^([a-z]|[A-Z])+.*$/", $sVarname)) //var starting with a number?
{
if (!preg_match("/^([a-z]|[A-Z])+.*$/", $sVarname)) { //var starting with a number?
$sVarname = "v".$sVarname; //add a leading 'v'
}
$sVarname = str_replace(array(
Expand Down Expand Up @@ -455,43 +451,31 @@ protected function updateCustomresponsemap()
7=string
*/
$numberresponse = trim($response);
if ($this->customFieldmap['info']['surveyls_numberformat'] == 1) // if settings: decimal seperator==','
{
if ($this->customFieldmap['info']['surveyls_numberformat'] == 1) { // if settings: decimal seperator==','
$numberresponse = str_replace(',', '.', $response); // replace comma with dot so STATA can use float variables
}

if (is_numeric($numberresponse)) // deal with numeric responses/variables
{
if (ctype_digit($numberresponse)) // if it contains only digits (no dot) --> non-float number
{
if ($numberresponse >= $this->minByte && $numberresponse <= $this->maxByte)
{
if (is_numeric($numberresponse)) { // deal with numeric responses/variables
if (ctype_digit($numberresponse)) { // if it contains only digits (no dot) --> non-float number
if ($numberresponse >= $this->minByte && $numberresponse <= $this->maxByte) {
$iDatatype = 2; //this response is of STATA type 'byte'
}
elseif ($numberresponse >= $this->minInt && $numberresponse <= $this->maxInt)
{
} elseif ($numberresponse >= $this->minInt && $numberresponse <= $this->maxInt) {
$iDatatype = 3; // and this is is 'int'
}
else
{
if ($this->customFieldmap['questions'][$this->headersSGQA[$iVarid]]['type'] == 'D') // if datefield then a 'double' data type is needed
{
} else {
if ($this->customFieldmap['questions'][$this->headersSGQA[$iVarid]]['type'] == 'D') { // if datefield then a 'double' data type is needed
$iDatatype = 6; // double
}
else
{
} else {
$iDatatype = 4; //long
}
}
}
else //non-integer numeric response
{
else { //non-integer numeric response
$iDatatype = 5; // float
$response = $numberresponse; //replace in customResponsemap: value with '.' as decimal
}
}
else // non-numeric response
{
else
{ // non-numeric response
$iDatatype = 7; //string
$iStringlength = strlen($response); //for strings we need the length for the format and the data type
}
Expand All @@ -512,8 +496,7 @@ protected function updateCustomresponsemap()
$aStatatypelist[$this->headersSGQA[$iVarid]]['type'] = $iDatatype;

// if datatype is a string, set needed stringlength
if ($iDatatype == 7)
{
if ($iDatatype == 7) {
// Does the variable need a higher stringlength because of the current response?
if ($aStatatypelist[$this->headersSGQA[$iVarid]]['format'] < $iStringlength)
$aStatatypelist[$this->headersSGQA[$iVarid]]['format'] = $iStringlength;
Expand Down Expand Up @@ -678,8 +661,7 @@ public function close()
{
foreach ($aScales as $iScaleID => $aAnswercodes)
{
if (!array_key_exists($iQid, $this->aQIDnonumericalAnswers)) //if QID is not one of those with nonnumeric answers
{ // write value label
if (!array_key_exists($iQid, $this->aQIDnonumericalAnswers)) { //if QID is not one of those with nonnumeric answers write value label
$xml->startElement('vallab');
$xml->writeAttribute('name', 'vall'.$iQid.$iScaleID);
foreach ($aAnswercodes as $iAnscode => $aAnswer)
Expand Down

0 comments on commit f0f4e7f

Please sign in to comment.