R6 Class representing a LimeSurvey survey

R6 Class representing a LimeSurvey survey

Details

Create and work with a Survey to programmatically (or interactively) create a survey, export it to a tab separated values file, and import it to LimeSurvey.

Public fields

titles

The title of the survey in the primary language and any additional languages

descriptions

The descriptions of the survey in the primary language and any additional languages

welcomeTexts

The welcome texts of the survey in the primary language and any additional languages

endTexts

The end texts of the survey in the primary language and any additional languages

endURLs

The end URLs of the survey in the primary language and any additional languages

endURLdescriptions

The end URL descriptions of the survey in the primary language and any additional languages

dateformats

The date format to use in the primary language and any additional languages; the index of the option from the dropdown in LimeSurvey (6 is the ISO standard, "YYYY-MM-DD").

numberformats

The number format to use in the primary language and any additional languages (for periods as decimal marks, 0; for commas as decimal marks, 1).

sid

The unique survey identifier; if this is free when importing the survey, this will be used.

gsid

The Survey Group identifier.

admin

The name of the survey administrator

adminemail

The email address of the survey administrator

anonymized

Whether the survey uses anonymized responses (Y or N).

faxto

The contents of the "Fax to" field

format

How to present the survey (Q for question by question; G for group by group; and A for all in one).

savetimings

Whether to save timings of responses (Y or N).

template

The name of the LimeSurvey theme to use.

language

The primary language of the survey.

additional_languages

Any additional languages the survey uses.

datestamp

Whether to datestamp responses (Y or N).

usecookie

Whether to use cookies to enable answer persistence.

allowregister

Whether to allow public registration (Y or N).

allowsave

Whether to allow users to save their responses and returning later (Y or N).

autonumber_start

Where to start autonumbering

autoredirect

Whether to automatically redirect users to a URL (Y or N).

allowprev

Whether to allow users to return to previous pages (Y or N).

printanswers

Whether to allow printing of answer (Y or N).

ipaddr

Whether to store IP addresses (Y or N).

refurl

Whether to store the referring URL (Y or N).

showsurveypolicynotice

Whether to show the data policy notice (Y or N).

publicstatistics

Whether to have public statistics (Y or N).

publicgraphs

Whether to show graphs in public statistics (Y or N).

listpublic

Whether to list the survey publicly (Y or N).

htmlemail

Whether to use HTML format for token emails (Y or N).

sendconfirmation

Whether to send confirmation emails (Y or N).

tokenanswerspersistence

Whether to use token-based response persistence (Y or N).

assessments

Whether to use assessments (Y or N).

usecaptcha

Whether to use CAPTCHA's (Y or N).

usetokens

Whether to use tokens (Y or N).

bounce_email

Where bouncing emails should be sent.

emailresponseto

Where detailed admin notifications emails should be sent.

emailnotificationto

Where a notification should be sent for new responses.

tokenlength

The token length.

showxquestions

Whether to show "There are X questions in this survey" (Y or N).

showgroupinfo

Whether to show group name and info (B for both, ?, or X to show nothing).

shownoanswer

Whether to show the "No answer" option (Y or N).

showqnumcode

Whether to show answer codes or numbers (Y, N, or X to show nothing).

bounceprocessing

Whether to process bouncing emails? (Y or N).

showwelcome

Whether to show the welcome page (Y or N).

showprogress

Whether to show the progress bar (Y or N).

questionindex

Whether to show the question index (0 to disable; can also be set to incremental or full (1 and 2?)).

navigationdelay

The navigation delay in seconds

nokeyboard

Whether to show the on-screen keyboard (Y or N).

alloweditaftercompletion

Whether to allow multiple reponses (N) or to allow updating responses with one token (Y)?

googleanalyticsstyle

The google analytics settings; 0 for None, other values for other settings.

googleanalyticsapikey

The google analytics API key.

groups

The groups in the survey.

tsvData

Used to store the dataframe saved to a file as tab separated values.

Active bindings

get_group_ids

A list of all group ids.

get_group_titles

A list of all group ids.

Methods


Method new()

Create a new survey object.

Usage

Survey$new(
  titles,
  descriptions = "",
  welcomeTexts = "",
  endTexts = "",
  endURLs = "",
  endURLdescriptions = "",
  dateformats = 6,
  numberformats = 0,
  sid = 1,
  gsid = 1,
  admin = "Admin Name",
  adminemail = "email@add.ress",
  anonymized = "Y",
  faxto = "",
  format = "G",
  savetimings = "Y",
  template = "vanilla",
  language = "en",
  additional_languages = "",
  datestamp = "Y",
  usecookie = "N",
  allowregister = "N",
  allowsave = "N",
  autonumber_start = 0,
  autoredirect = "Y",
  allowprev = "N",
  printanswers = "N",
  ipaddr = "N",
  refurl = "N",
  showsurveypolicynotice = "0",
  publicstatistics = "N",
  publicgraphs = "N",
  listpublic = "N",
  htmlemail = "Y",
  sendconfirmation = "N",
  tokenanswerspersistence = "N",
  assessments = "N",
  usecaptcha = "N",
  usetokens = "N",
  bounce_email = "",
  emailresponseto = "",
  emailnotificationto = "",
  tokenlength = 15,
  showxquestions = "N",
  showgroupinfo = "X",
  shownoanswer = "N",
  showqnumcode = "X",
  bounceprocessing = "N",
  showwelcome = "N",
  showprogress = "N",
  questionindex = "0",
  navigationdelay = "0",
  nokeyboard = "N",
  alloweditaftercompletion = "N",
  googleanalyticsstyle = 0,
  googleanalyticsapikey = ""
)

Arguments

titles

The titles of the survey in the primary language and optionally any addiitonal languages.

descriptions

The descriptions of the survey in the primary language and any additional languages

welcomeTexts

The welcome texts of the survey in the primary language and any additional languages

endTexts

The end texts of the survey in the primary language and any additional languages

endURLs

The end URLs of the survey in the primary language and any additional languages

endURLdescriptions

The end URL descriptions of the survey in the primary language and any additional languages

dateformats

The date formats to use in the primary language and any additional languages; the index of the option from the dropdown in LimeSurvey (6 is the ISO standard, "YYYY-MM-DD").

numberformats

The number formats to use in the primary language and any additional languages (for periods as decimal marks, 0; for commas as decimal marks, 1).

sid

The unique survey identifier; if this is free when importing the survey, this will be used.

gsid

The Survey Group identifier.

admin

The name of the survey administrator

adminemail

The email address of the survey administrator

anonymized

Whether the survey uses anonymized responses (Y or N).

faxto

The contents of the "Fax to" field

format

How to present the survey (Q for question by question; G for group by group; and A for all in one).

savetimings

Whether to save timings of responses (Y or N).

template

The name of the LimeSurvey theme to use.

language

The primary language of the survey.

additional_languages

Any additional languages the survey uses.

datestamp

Whether to datestamp responses (Y or N).

usecookie

Whether to use cookies to enable answer persistence.

allowregister

Whether to allow public registration (Y or N).

allowsave

Whether to allow users to save their responses and returning later (Y or N).

autonumber_start

Where to start autonumbering

autoredirect

Whether to automatically redirect users to a URL (Y or N).

allowprev

Whether to allow users to return to previous pages (Y or N).

printanswers

Whether to allow printing of answer (Y or N).

ipaddr

Whether to store IP addresses (Y or N).

refurl

Whether to store the referring URL (Y or N).

showsurveypolicynotice

Whether to show the data policy notice (Y or N).

publicstatistics

Whether to have public statistics (Y or N).

publicgraphs

Whether to show graphs in public statistics (Y or N).

listpublic

Whether to list the survey publicly (Y or N).

htmlemail

Whether to use HTML format for token emails (Y or N).

sendconfirmation

Whether to send confirmation emails (Y or N).

tokenanswerspersistence

Whether to use token-based response persistence (Y or N).

assessments

Whether to use assessments (Y or N).

usecaptcha

Whether to use CAPTCHA's (Y or N).

usetokens

Whether to use tokens (Y or N).

bounce_email

Where bouncing emails should be sent.

emailresponseto

Where detailed admin notifications emails should be sent.

emailnotificationto

Where a notification should be sent for new responses.

tokenlength

The token length.

showxquestions

Whether to show "There are X questions in this survey" (Y or N).

showgroupinfo

Whether to show group name and info (Y, N, or X to show nothing).

shownoanswer

Whether to show the "No answer" option (Y or N).

showqnumcode

Whether to show answer codes or numbers (Y, N, or X to show nothing).

bounceprocessing

Whether to process bouncing emails? (Y or N).

showwelcome

Whether to show the welcome page (Y or N).

showprogress

Whether to show the progress bar (Y or N).

questionindex

Whether to show the question index (0 to disable; can also be set to incremental or full (1 and 2?)).

navigationdelay

The navigation delay in seconds

nokeyboard

Whether to show the on-screen keyboard (Y or N).

alloweditaftercompletion

Whether to allow multiple reponses (N) or to allow updating responses with one token (Y)?

googleanalyticsstyle

The google analytics settings; 0 for None, other values for other settings.

googleanalyticsapikey

The google analytics API key.

Returns

A new Survey object.


Method add_group()

Add a group to a survey object.

Usage

Survey$add_group(titles, descriptions = "", relevance = 1, random_group = "")

Arguments

titles

The group's title, either as a named character vector where each element is the group title in a different language, and every element's name is the language code; or as a single character value, in which case the survey's primary language is used.

descriptions

The group description, either as a named character vector where each element is the group description in a different language, and every element's name is the language code; or as a single character value, in which case the survey's primary language is used.

relevance

The group's relevance equation.

random_group

The group's randomization group.

Returns

Invisibly, the Survey object.


Method add_question()

Add a question to a survey object.

Usage

Survey$add_question(groupId, code, type = NULL, lsType = NULL, ...)

Arguments

groupId

The id of the group to add the question to.

code

The question code.

type

The question type.

lsType

The question type, as LimeSurvey question type.

...

Additional arguments are used to create the Question using Question$new.

Returns

Invisibly, the Survey object.


Method export_to_tsv()

Export the survey as a tab separated values file (see https://manual.limesurvey.org/Tab_Separated_Value_survey_structure).

Usage

Survey$export_to_tsv(
  file,
  preventOverwriting = limonaid::opts$get("preventOverwriting"),
  parallel = TRUE,
  encoding = limonaid::opts$get("encoding"),
  silent = limonaid::opts$get("silent"),
  backupLanguage = self$language
)

Arguments

file

The filename to which to save the file.

preventOverwriting

Whether to prevent overwritting.

parallel

Whether to work serially or in parallel.

encoding

The encoding to use

silent

Whether to be silent or chatty.

backupLanguage

The language to get content from if not from the primary langage.

Returns

Invisibly, the Survey object.


Method find_group_id()

Find the numeric group identifier by group title.

Usage

Survey$find_group_id(title, titleLanguage = NULL)

Arguments

title

The survey title.

titleLanguage

The language in which to search.

Returns

Invisibly, the Survey object.


Method clone()

The objects of this class are cloneable with this method.

Usage

Survey$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.