Skip to content

Commit

Permalink
Dev: allow plugin to use easily own function in export answers
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Jul 8, 2014
1 parent 4ec280a commit 201914b
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions application/helpers/admin/export/Writer.php
Expand Up @@ -154,6 +154,44 @@ public function getHeadingText(SurveyObj $oSurvey, FormattingOptions $oOptions,
return $textHead;
}

/**
* Return the answer text according to options
*
* @param Survey $oSurvey
* @param FormattingOptions $oOptions
* @param string $fieldName
* @param string $sValue
* @return string
*/
public function getLongAnswer(SurveyObj $oSurvey, FormattingOptions $oOptions, $fieldName,$sValue)
{
return $this->transformResponseValue(
$oSurvey->getFullAnswer($fieldName, $sValue, $this->translator, $this->languageCode);
$oSurvey->fieldMap[$column]['type'],
$oOptions,
$fieldName,
);
}

/**
* Return the answer text according to options
*
* @param Survey $oSurvey
* @param FormattingOptions $oOptions
* @param string $fieldName
* @param string $sValue
* @return string
*/
public function getShortAnswer(SurveyObj $oSurvey, FormattingOptions $oOptions, $fieldName,$sValue)
{
return $this->transformResponseValue(
$oSurvey->$sValue,
$oSurvey->fieldMap[$column]['type'],
$oOptions,
$fieldName,
);
}

/**
* Performs a transformation of the response value based on the value, the
* type of field the value is a response for, and the FormattingOptions.
Expand Down Expand Up @@ -232,8 +270,6 @@ final public function write(SurveyObj $oSurvey, $sLanguageCode, FormattingOption
$value = $this->getHeadingCode($oSurvey, $oOptions, $sColumn);
break;
}

//$this->output.=$this->csvEscape($value).$this->separator;
$headers[] = $value;
}
}
Expand All @@ -250,19 +286,11 @@ final public function write(SurveyObj $oSurvey, $sLanguageCode, FormattingOption
{
switch ($oOptions->answerFormat) {
case 'long':
$elementArray[] = $this->transformResponseValue(
$oSurvey->getFullAnswer($column, $value, $this->translator, $this->languageCode),
$oSurvey->fieldMap[$column]['type'],
$oOptions,
$column);
$elementArray[] = $this->getLongAnswer($oSurvey, $oOptions, $column,$value);
break;
default:
case 'short':
$elementArray[] = $this->transformResponseValue(
$value,
$oSurvey->fieldMap[$column]['type'],
$oOptions,
$column);
$elementArray[] = $this->getShortAnswer($oSurvey, $oOptions, $column,$value);
break;
}
}
Expand Down

0 comments on commit 201914b

Please sign in to comment.