R6 Class representing a LimeSurvey question
R6 Class representing a LimeSurvey question
A question has at least a code and a primary language.
The human-readable question types are (with some additional variants also being valid, in any case the literal labels used at https://manual.limesurvey.org/Question_object_types#Current_question_types):
"array dual scale
"
"5 point choice
"
"5 point array
"
"10 point array
"
"yes/no/uncertain array
"
"date
"
"increase/same/decrease array
"
"array
" (this is the "array (flexible labels)
" type)
"gender
"
"array by column
"
"language switch
"
"multiple numerical input
",
"radio
" (this is the "list
" type)
"checkboxes
" (this is the "multiple choice
" type)
"numerical input
",
"list with comment
"
"multiple choice with comments
"
"multiple short text
"
"ranking
"
"short text
"
"long text
"
"huge text
"
"text display
"
"yes/no
"
"multiple texts array
",
"multiple dropdown array
"
"file
"
"dropdown
"
"equation
".
code
The code of the question.
id
The identifier of the question (a unique number in a survey)
type
The question type.
lsType
The question type in LimeSurvey's format.
questionTexts
The question text(s) in all languages.
helpTexts
The question help text(s) in all languages.
relevance
The relevance.
validation
The question's validation.
language
The primary language of the question.
answerOptions
The answer options in the question.
subquestions
The subquestions in the question.
mandatory
Whether the question is mandatory (Y
or N
).
other
Whether the question has an 'other' option (Y
or N
).
otherReplaceTexts
If the question has an 'other' option, its label if the default label should be overwritten (multilingual).
default
The default value.
same_default
Not entirely sure what this does.
array_filter
The question code of the array filter question to apply.
cssclass
The CSS class(es) to apply to this question.
hide_tip
Whether to hide the tip (Y
or N
).
otherOptions
Any additional options, stored as a named list
by assigning as.list(...)
.
new()
Create a new question object. Most of this text comes directly from the TSV manual page at https://manual.limesurvey.org/Tab_Separated_Value_survey_structure, so please see that page for more details.
Question$new(
code,
type = NULL,
lsType = NULL,
id = NULL,
questionTexts = "",
helpTexts = "",
relevance = 1,
validation = "",
mandatory = "N",
other = "N",
otherReplaceTexts = "",
default = "",
same_default = "0",
array_filter = "",
cssclass = "",
hide_tip = "",
language = "en",
...
)
code
The question code.
type
The human-readable question type (see details).
lsType
The type as LimeSurvey type ("1
"; "5
"; "A
" to "Y
",
except "J
", "V
" and "W
"; "!
"; ":
"; ";
"; "*
"; or "|
" --see
https://manual.limesurvey.org/Question_object_types#Current_question_types).
id
The identifier of the question (in a survey).
questionTexts
The question text(s).
helpTexts
The help text(s).
relevance
The question's relevance equation.
validation
The question's validation.
mandatory
Whether the question is mandatory (Y
or N
);.
other
Whether the question has an 'other' option (Y
or N
).
otherReplaceTexts
If the question has an 'other' option, its label if the default label should be overwritten (multilingual).
default
The default value.
same_default
Y
for true, in which case any default value set
for the primary language applies to other languages.
array_filter
The question code of the array filter question to apply.
cssclass
The CSS class(es) to apply to this question.
hide_tip
Whether to hide the tip (Y
or N
).
language
The question's primary language.
...
Any additional options, stored as a named list in the
otherOptions
property by assigning as.list(...)
.
add_answer_option()
Add an answer option to a question. Most of this text comes directly from the TSV manual page at https://manual.limesurvey.org/Tab_Separated_Value_survey_structure, so please see that page for more details.
add_subquestion()
Add a subquestion to a question. Most of this text comes directly from the TSV manual page at https://manual.limesurvey.org/Tab_Separated_Value_survey_structure, so please see that page for more details.
Question$add_subquestion(
code,
subquestionTexts,
relevance = "",
helpTexts = NULL,
type.scale = 0,
validation = "",
mandatory = "",
default = "",
same_default = ""
)
code
The subquestions code.
subquestionTexts
The subquestion text(s).
relevance
When to show this subquestion.
helpTexts
As far as I know not yet implemented in LimeSurvey; but the TSV help page says "(Future) to support subquestion-level help".
type.scale
0
or 1
, depending upon question type (e.g. array
text will have two scales)0 or 1, depending upon question type (e.g.
array text will have two scales)."
validation
As far as I know not yet implemented in LimeSurvey; but the TSV help page says "(Future) to support subquestion-level regular expression validation (e.g. for address parts)"
mandatory
As far as I know not yet implemented in LimeSurvey; but the TSV help page says "(Future) to support subquestion-level mandatory (e.g. make only a few subquestions mandatory)"
default
If set, then this is the default value for the subquestion (inserted into defaultvalues table).
same_default
If set, then the default for the primary language is used for all other languages.