A fieldmap object adds LS source code knowledge and interpretation to the database data about a survey. This enables the code to work with the survey object.

package Gems
subpackage Tracker
copyright Copyright (c) 2011 Erasmus MC
license New BSD License
since Class available since version 1.4

 Methods

Construct a fieldmap object to add LS source code knowledge and interpretation to the database data about a survey.

__construct(integer $sourceSurveyId, string $language, \Zend_Db_Adapter_Abstract $lsDb, \Zend_Translate $translate, \type $tablePrefix) 

Parameters

$sourceSurveyId

integer

Survey ID

$language

string

(ISO) Language

$lsDb

\Zend_Db_Adapter_Abstract

The Lime Survey database connection

$translate

\Zend_Translate

A translate object

$tablePrefix

\type

The prefix to use for all LS tables (in this installation)

Applies the fieldmap data to the model

applyToModel(\MUtil_Model_ModelAbstract $model) 

Parameters

$model

\MUtil_Model_ModelAbstract

Returns an array containing fieldname => label for dropdown list etc.

getFullQuestionList(string $forType = false) : array

.

Parameters

$forType

string

Optional type filter

Returns

arrayfieldname => label

Returns an array of array with the structure: question => string, class => question|question_sub group => is for grouping type => (optional) source specific type answers => string for single types, array for selection of, nothing for no answer

getQuestionInformation() : array

Returns

arrayNested array

Returns an array containing fieldname => label for dropdown list etc.

getQuestionList(string $forType = false) : array

.

Parameters

$forType

string

Optional type filter

Returns

arrayfieldname => label

Changes the keys of the values array to the more readable titles also available in LimeSurvey

mapKeysToTitles(array $values) 

Parameters

$values

array

Changes the keys of the values array to the more readable titles also available in LimeSurvey

mapTitlesToKeys(array $values) 

Parameters

$values

array

Removes all markup from input

removeMarkup(string $text) : string

Parameters

$text

string

Input possibly containing html

Returns

string

The answers table contains code => answer sets per question/language/scale_id

_getAnswersTableName() : string

Returns

stringname of the answers table

The groups table contains group texts per group id / language

_getGroupsTableName() : string

Returns

stringname of the groups table

_getMap()

_getMap() 

Return an array with all possible answers for a given sid/field combination

_getMultiOptions($field) 

Parameters

$field

Field from getFieldMap function

Return a certain question attribute or the default value if it does not exist.

_getQuestionAttribute(string $qid, string $subId, \mxied $default = null) : mixed

Parameters

$qid

string

$subId

string

$default

\mxied

Returns

mixed

The question attributes table contains all non-translateable settings for a question, e.g. 'page_break'

_getQuestionAttributesTableName() : string

Returns

stringname of the question attributes table

The question table contains one row per language per question per survey in LS.

_getQuestionsTableName() : string

All non-text data is replicated over all the question/language rows.

Returns

stringname of the questions table

There exists a survey table for each active survey. The table contains the answers to the survey

_getSurveyTableName() : string

Returns

stringName of survey table for this survey

The survey table contains one row per each survey in LS

_getSurveysTableName() : string

Returns

stringname of the surveys table

Returns

_getType($field) : integer

Parameters

$field

Field from _getMap function

Returns

integer\MUtil_Model::TYPE_ constant

getDateFormats()

getDateFormats($fieldname, $type) 

Parameters

$fieldname

$type

getFieldTableDataType()

getFieldTableDataType($fieldname) 

Parameters

$fieldname

_getFixedAnswers()

_getFixedAnswers($type) 

Parameters

$type

Returns the answers for a matrix or list type question from the answers table

_getHardAnswers(integer $qid, integer $scale_id) 

Uses 1 query to retrieve all answers and serves them as needed

Parameters

$qid

integer

Question ID

$scale_id

integer

Scale ID

Return an array with all possible answers for a given sid/field combination

_getPossibleAnswers($field) 

Parameters

$field

Field from getFieldMap function

Returns a map of databasecode => questioncode

_getTitlesMap() : array

Returns

array

 Properties

 

$_answers

$_answers 

Default

 

$_attributes

$_attributes 

Default

 

$_fieldMap

$_fieldMap 

Default

 

$_hardAnswers

$_hardAnswers 

Default

 

$_titlesMap

$_titlesMap 

Default

 

$cache

$cache : \Zend_Cache_Core

Default

 

The language of this fieldmap

$language : string

Default

 

Limesurvey database adapter

$ldDb : \Zend_Db_Adapter_Abstract

Default

 

The Lime Survey survey Id

$sourceSurveyId : integer

Default

   

Prefix to add to standard table name

$tablePrefix : string

Default

 

$translate

$translate : \Zend_Translate

Default

 Constants

 

ANSWERS_TABLE

ANSWERS_TABLE = 'answers' 
 

ATTRIBUTES_TABLE

ATTRIBUTES_TABLE = 'question_attributes' 
 

GROUPS_TABLE

GROUPS_TABLE = 'groups' 
 

Internal type, used for startdate, submitdate, datestamp fields

INTERNAL = 'stamp' 
 

QUESTIONS_TABLE

QUESTIONS_TABLE = 'questions'