LimeSurvey API - Master branch

ExportAnswerFormatter
in package

Table of Contents

Constants

ANSWER_CODE_MAPS  = [\Question::QT_Y_YES_NO_RADIO => ['Y' => 'Yes', 'N' => 'No'], \Question::QT_G_GENDER => ['M' => 'Male', 'F' => 'Female'], \Question::QT_C_ARRAY_YES_UNCERTAIN_NO => ['Y' => 'Yes', 'N' => 'No', 'U' => 'Uncertain'], \Question::QT_E_ARRAY_INC_SAME_DEC => ['I' => 'Increase', 'S' => 'Same', 'D' => 'Decrease']]
Maps question types to their answer code => translation key mappings.
RAW_FALLBACK_TYPES  = [\Question::QT_C_ARRAY_YES_UNCERTAIN_NO, \Question::QT_E_ARRAY_INC_SAME_DEC]
Types where unmatched codes return raw value instead of N/A.

Properties

$answerCache  : SurveyAnswerCache

Methods

__construct()  : mixed
formatFullAnswer()  : mixed
Format a raw answer value to its display text, matching the old export's "full answer" format.
loadAnswers()  : mixed
Load answer data for a survey into the shared cache.
formatArrayDualAnswer()  : mixed
Format array dual scale (1) answer values.
formatListAnswer()  : mixed
Format list-type (L, !) answer values.
formatListWithCommentAnswer()  : mixed
Format list with comment (O) answer values.
formatMultipleChoiceAnswer()  : mixed
Format multiple choice (M/P) answer values.
formatNumericAnswer()  : mixed
Format numeric (N, K) answer values — trim trailing zeros.
lookupAnswerLabel()  : string|null
Look up an answer label from the cached answers.
mapCodeToLabel()  : string
Map an answer code to its translated label using the type's code map.

Constants

ANSWER_CODE_MAPS

Maps question types to their answer code => translation key mappings.

private mixed ANSWER_CODE_MAPS = [\Question::QT_Y_YES_NO_RADIO => ['Y' => 'Yes', 'N' => 'No'], \Question::QT_G_GENDER => ['M' => 'Male', 'F' => 'Female'], \Question::QT_C_ARRAY_YES_UNCERTAIN_NO => ['Y' => 'Yes', 'N' => 'No', 'U' => 'Uncertain'], \Question::QT_E_ARRAY_INC_SAME_DEC => ['I' => 'Increase', 'S' => 'Same', 'D' => 'Decrease']]

RAW_FALLBACK_TYPES

Types where unmatched codes return raw value instead of N/A.

private mixed RAW_FALLBACK_TYPES = [\Question::QT_C_ARRAY_YES_UNCERTAIN_NO, \Question::QT_E_ARRAY_INC_SAME_DEC]

Properties

Methods

formatFullAnswer()

Format a raw answer value to its display text, matching the old export's "full answer" format.

public formatFullAnswer(mixed $value, string|null $type, string $fieldKey[, int|string|null $qid = null ]) : mixed
Parameters
$value : mixed

Raw answer value from the database

$type : string|null

Question type character

$fieldKey : string

Full field key (e.g. "123X456X789SQ001")

$qid : int|string|null = null

Question ID for answer label lookup

Return values
mixed

Formatted display value

loadAnswers()

Load answer data for a survey into the shared cache.

public loadAnswers(int $surveyId, string $language) : mixed
Parameters
$surveyId : int
$language : string

formatArrayDualAnswer()

Format array dual scale (1) answer values.

private formatArrayDualAnswer(mixed $value, string $fieldKey, int|string|null $qid) : mixed
Parameters
$value : mixed
$fieldKey : string
$qid : int|string|null

formatListAnswer()

Format list-type (L, !) answer values.

private formatListAnswer(mixed $value, string $fieldKey, int|string|null $qid) : mixed
Parameters
$value : mixed
$fieldKey : string
$qid : int|string|null

formatListWithCommentAnswer()

Format list with comment (O) answer values.

private formatListWithCommentAnswer(mixed $value, string $fieldKey, int|string|null $qid) : mixed
Parameters
$value : mixed
$fieldKey : string
$qid : int|string|null

formatMultipleChoiceAnswer()

Format multiple choice (M/P) answer values.

private formatMultipleChoiceAnswer(mixed $value, string $fieldKey) : mixed
Parameters
$value : mixed
$fieldKey : string

formatNumericAnswer()

Format numeric (N, K) answer values — trim trailing zeros.

private formatNumericAnswer(mixed $value, int|string|null $qid) : mixed
Parameters
$value : mixed
$qid : int|string|null

lookupAnswerLabel()

Look up an answer label from the cached answers.

private lookupAnswerLabel(int|string|null $qid, int $scaleId, mixed $code) : string|null
Parameters
$qid : int|string|null
$scaleId : int
$code : mixed
Return values
string|null

mapCodeToLabel()

Map an answer code to its translated label using the type's code map.

private mapCodeToLabel(mixed $value, string $type) : string
Parameters
$value : mixed
$type : string
Return values
string

        
On this page

Search results