Experimental. Turn an lss_spec() specification into a
LimeSurvey 6 structure file (.lss, DBVersion 700) that imports
directly through Create survey -> Import. The emitted file can be
read back with read_lss(), checked with audit_lss() and rendered
with render_questionnaire() – so the document reviewers read is
produced from the very file LimeSurvey receives.
Usage
write_lss(spec, file, sid = 100001L, settings = list())Arguments
- spec
An
lss_spec()object, or a plain list with the same structure (it is then validated throughlss_spec()first).- file
Character. Path of the
.lssfile to write.- sid
Integer. Survey id embedded in the file. LimeSurvey assigns a fresh id on import when this one is taken, so the value rarely matters.
- settings
Named list of
surveys-table fields overriding the built-in defaults (e.g.list(anonymized = "Y", showprogress = "Y")). The defaults ship with the package and come from a real LimeSurvey 6 export, scrubbed – seelss_default_surveys_fieldsin the sources for the rationale.
Details
Mapping choices, each validated against real LimeSurvey 6 imports:
Each kind maps to a LimeSurvey type and theme attested by a corpus of real exports (see
lss_kind_mapin the sources). Options of single-choice lists, rankings and array columns are emitted asanswers; options of multiple-choice questions, item batteries and array rows assubquestions; scalar kinds and implicit scales (yes/no, gender, five-point, 5/10-point arrays) emit none.The native
otheroption is emitted asother = "Y"plus the localized attributeother_replace_text. Localized attributes MUST carry the language code: emitted without one, LimeSurvey silently ignores them and shows its default wording. Global attributes (exclude_all_others,max_answers, ...) stay language-less.other_position/other_position_codecontrol where the other option is displayed;exclude_all_othersaccepts several codes separated by;.Relevance equations are translated from the minimal syntax of
lss_spec()into ExpressionScript (code.NAOK == "1").Quotas are emitted with limit zero and the terminate action.
A mandatory or capped ranking also receives
min_answers = 1, overridable through the question'sattributes.
Examples
spec <- lss_spec(
title = "Demo",
groups = list(list(title = "G", questions = list(
list(code = "q1", kind = "single", text = "Oui ou non ?",
options = list(list(text = "Oui"), list(text = "Non")))
)))
)
out <- tempfile(fileext = ".lss")
write_lss(spec, out)
#> ✔ Wrote /tmp/RtmphapTdf/file1b1950486fa1.lss (1 question, 1 group, 0 quotas).
audit_lss(out)
#>
#> ── lssdoc audit ────────────────────────────────────────────────────────────────
#> File: /tmp/RtmphapTdf/file1b1950486fa1.lss
#> Languages: "fr"
#> ✔ No anomalies detected.