| Group | R Documentation |
R6 Class representing a LimeSurvey group
R6 Class representing a LimeSurvey group
A group is mostly just a container for questions.
group_nameThe group name / title / label
descriptionThe group description
grelevanceThe relevance equation for the group
group_orderThe group order (in the survey)
randomization_groupThe randomization group (that the group is a part of)
languageThe language of the group; or primary language, if there are multiple languages.
additional_languagesAny additional languages for the title and description elements.
idThe identifier of the group (a unique number in a survey)
sidThe identifier of the survey that this group belongs to
otherOptionsAny additional options, stored as a named list
by assigning as.list(...).
questionsThe questions in this group
new()Create a new group object. Most of this text comes directly from the TSV manual page at https://www.limesurvey.org/manual/Tab_Separated_Value_survey_structure, so please see that page for more details.
Group$new( group_name = "", description = "", grelevance = 1, group_order = 1, randomization_group = NULL, language = "en", additional_languages = "", id = NULL, sid = NULL, new_id_fun = NULL, uqid = NULL, repo_url = "https://operationalizations.com/questionnaires/json", ... )
group_nameThe title of the group (if there are multiple languages, a named vector where every element is the title in another language and every element's name is the language code).
descriptionThe description of the group (if there are multiple languages, a named vector where every element is the title in another language and every element's name is the language code).
grelevanceThe group's relevance equation
group_orderThe group order (if the group is part of a survey)
randomization_groupThe group's randomization group
languageThe group's only or primary language
additional_languagesAny additional languages
idOptionally, the id of the group.
sidOptionally, the identifier of the survey that this group belongs to.
new_id_funA function to set identifiers (for XML exports, which mirrors MySQL tables and so needs identifiers). By default, new question objects receive this function from the group containing them; and groups receive it from the survey containing them. This ensures that identifiers are always unique in a survey (despite question objects not being able to 'see' anything in the group containing them, and group objects not being able to 'see' anything in the survey containing them; because they 'received' this function from the parent object, and it 'bubbles down' through groups to the questions, those functions still get and set a private identifier property in the 'top-most' object).
uqidA Unique Questionnaire Identifier (UQID) to import a questionnaire and populate the group with it.
repo_urlThe URL to a repo serving the questionnaire with the UQID in JSON.
...Any additional options, stored as a named list in the
otherOptions property by assigning as.list(...).
A new Group object.
add_question()Add a question to a group object.
Group$add_question( code, type = NULL, lsType = NULL, question_order = NULL, ... )
codeThe question code.
typeThe question type.
lsTypeThe question type, as LimeSurvey question type.
question_orderThe question order; automatically filled if left empty; starts counting at 0.
...Additional arguments are used to create the Question using
Question$new.
Invisibly, the thisQuestion object that was just added. Note
that you can further modify this, which will modify the question object
"in" the survey group as well. This allows you to pipe the question
creation on to, for example, add answer options.
export_to_lsg()Export the group as an LSG (xml) file.
Group$export_to_lsg(
file = NULL,
preventOverwriting = limonaid::opts$get("preventOverwriting"),
encoding = limonaid::opts$get("encoding"),
silent = limonaid::opts$get("silent"),
backupLanguage = self$language
)fileThe filename to which to save the file.
preventOverwritingWhether to prevent overwriting.
encodingThe encoding to use
silentWhether to be silent or chatty.
backupLanguageThe language to get content from if not from the primary langage.
parallelWhether to work serially or in parallel.
Invisibly, the Survey object.
clone()The objects of this class are cloneable with this method.
Group$clone(deep = FALSE)
deepWhether to make a deep clone.
myGroup <- limonaid::Group$new(
group_name = "My Group"
);
myGroup$add_question(
"testQuestion1",
questionTexts = "First question",
type="free text (short)"
);
myGroup$add_question(
"testQuestion2",
questionTexts = "Second question",
type="radio"
);
myGroup$questions$testQuestion2$add_answer_option(
"option1",
"First option"
);
myGroup$questions$testQuestion2$add_answer_option(
"option2",
"Second option"
);
cat(as.character(myGroup$export_to_lsg()));
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.