Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ gives these `S` rows:
| S | format | A |
| S | shownoanswer | N |
| S | allowprev | Y |
| S | allowsave | Y |
| S | showxquestions | N |
| S | allowsave | Y |
| S | showqnumcode | X |

Only the settings in `convention:surveySettings` (`limesurveySettings`) pass
Expand All @@ -262,11 +262,20 @@ setting or an invalid value is dropped with a `setting-invalid` warning.
`format`, `language` and `additional_languages` come from the form (`style:
pages`, `default_language`, the `label::<lang>` columns), so their columns are
dropped with that warning too. `limesurvey_shownoanswer` overrides
formtransform's default `shownoanswer=N` (`--show-no-answer`). LimeSurvey's own
defaults are not changed: without the columns the TSV is as before.
formtransform's default `shownoanswer=N` (`--show-no-answer`).

**Defaults (behaviour change, #240).** Without the columns, formtransform
writes `allowprev=Y` (a Previous button) and `showxquestions=N` (no "This
survey contains 74 questions" line, which counts hidden and filtered questions
and overstates the length) next to `shownoanswer=N`, because LimeSurvey's own
defaults (`allowprev=N`, `showxquestions=Y`) are poor for most XLSForm surveys.
A form that sets `limesurvey_allowprev` or `limesurvey_showxquestions` wins,
including `N` / `Y`. `--no-setting-defaults` (option `surveySettingDefaults:
false`) leaves both out, so LimeSurvey's defaults apply. The reverse path
skips the three defaults, so a form round-trips as authored.

The way back reads the `S` rows into the same columns (except
`shownoanswer=N`, formtransform's default), and the DDI keeps each as a
formtransform's three defaults), and the DDI keeps each as a
`cdl:setting` note like any other setting, so XLSForm → DDI → XLSForm keeps them.

## Errors and warnings
Expand Down
6 changes: 4 additions & 2 deletions registry/conventions/surveySettings.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
}
],
"limesurveySettings": {
"description": "LimeSurvey survey settings (the surveys table) set from optional settings-sheet columns named <prefix><setting>, e.g. limesurvey_allowprev = Y. Each becomes an `S <setting>` row of the TSV, which LimeSurvey's TSV import writes into the survey (formtransform#228). ODK and Kobo ignore the columns. Only the settings listed here are passed through: an unknown setting or a value outside its list is dropped with a `setting-invalid` warning. Y/N settings also take yes/no and true/false, in any case. The reverse path reads every listed S row back into its column, except a value formtransform writes by default. In DDI each is a cdl:setting note like any other setting (convention:ddiFields).",
"description": "LimeSurvey survey settings (the surveys table) set from optional settings-sheet columns named <prefix><setting>, e.g. limesurvey_allowprev = Y. Each becomes an `S <setting>` row of the TSV, which LimeSurvey's TSV import writes into the survey (formtransform#228). ODK and Kobo ignore the columns. Only the settings listed here are passed through: an unknown setting or a value outside its list is dropped with a `setting-invalid` warning. Y/N settings also take yes/no and true/false, in any case. The reverse path reads every listed S row back into its column, except a value formtransform writes by default (the `defaults`: shownoanswer=N, allowprev=Y, showxquestions=N; a form's column overrides them, and the allowprev and showxquestions defaults can be turned off with the surveySettingDefaults option). In DDI each is a cdl:setting note like any other setting (convention:ddiFields).",
"prefix": "limesurvey_",
"lsTsvRow": "S <setting>",
"ddiPath": "stdyDscr/notes[@type='cdl:setting'][@subject='limesurvey_<setting>']",
Expand All @@ -96,7 +96,9 @@
"format": "`style: pages` gives G (a page per group), anything else A (all in one)"
},
"defaults": {
"shownoanswer": "N"
"shownoanswer": "N",
"allowprev": "Y",
"showxquestions": "N"
},
"settings": {
"allowprev": {
Expand Down
2 changes: 2 additions & 0 deletions registry/entities/date/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q D geburtsdatum 1 Wann wurden Sie geboren? en 1
2 changes: 2 additions & 0 deletions registry/entities/decimal/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q N schlafdauer 1 Wie viele Stunden schlafen Sie durchschnittlich pro Nacht? en 1
2 changes: 2 additions & 0 deletions registry/entities/grid/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G 1 Vertrauen in Institutionen 1 en
Q F institutionen 1 en 1
Expand Down
2 changes: 2 additions & 0 deletions registry/entities/hidden/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q S partner 1 Partnerkennung (über den Link vorbelegt) en 1 1
Expand Down
2 changes: 2 additions & 0 deletions registry/entities/integer/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q N alter 1 Wie alt sind Sie? en 1 1
2 changes: 2 additions & 0 deletions registry/entities/note/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q X hinweis 1 Im folgenden Abschnitt geht es um Ihre Lebenssituation. en
2 changes: 2 additions & 0 deletions registry/entities/range/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q N zufriedenheit 1 Wie zufrieden sind Sie insgesamt? (0 = gar nicht, 10 = voll) en 1 0 10 1
2 changes: 2 additions & 0 deletions registry/entities/select_multiple/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q M wochenende 1 An welchen Tagen des Wochenendes sind Sie erreichbar? en 1
Expand Down
2 changes: 2 additions & 0 deletions registry/entities/select_multiple_long_list/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q M besuchtelaender 1 Welche dieser Länder haben Sie bereits besucht? Mehrere Antworten möglich. en cdlvocab-iso_3166_1 1
Expand Down
2 changes: 2 additions & 0 deletions registry/entities/select_multiple_other/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 de de
S format 1 A de
S shownoanswer 1 N de
S allowprev 1 Y de
S showxquestions 1 N de
SL surveyls_title 1 Untitled Survey de
G Questions 1 de
Q M geraetebesitz 1 Welche dieser Geräte besitzen Sie? de Y 1 Sonstiges (bitte angeben)
Expand Down
2 changes: 2 additions & 0 deletions registry/entities/select_one/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q L bildungsgrad 1 Was ist Ihr höchster Bildungsabschluss? en 1
Expand Down
2 changes: 2 additions & 0 deletions registry/entities/select_one_long_list/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q L geburtsland 1 In welchem Land wurden Sie geboren? en cdlvocab-iso_3166_1 1
Expand Down
2 changes: 2 additions & 0 deletions registry/entities/select_one_other/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 de de
S format 1 A de
S shownoanswer 1 N de
S allowprev 1 Y de
S showxquestions 1 N de
SL surveyls_title 1 Untitled Survey de
G Questions 1 de
Q L aufmerksam 1 Wie sind Sie auf unser Angebot aufmerksam geworden? de Y 1 Sonstiges (bitte angeben)
Expand Down
2 changes: 2 additions & 0 deletions registry/entities/text/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q S anmerkungen 1 Haben Sie weitere Anmerkungen? en 1
2 changes: 2 additions & 0 deletions registry/entities/time/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class type/scale name relevance text help language validation em_validation_q ma
S language 1 en en
S format 1 A en
S shownoanswer 1 N en
S allowprev 1 Y en
S showxquestions 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 en
Q D aufstehzeit 1 Um wie viel Uhr stehen Sie werktags normalerweise auf? en 1 HH:MM
5 changes: 5 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ Options:
--no-end-note Do not promote an "end" note to surveyls_endtext
--no-other-pattern Do not collapse the _other question pattern into a native "other"
--show-no-answer Keep the "no answer" option on non-mandatory questions
--no-setting-defaults
Do not write the survey settings allowprev=Y and
showxquestions=N (LimeSurvey's own defaults apply)
--sanitize Accept names and answer codes outside LimeSurvey's limits
(k23_ars, -98): they are sanitized (k23ars, n98) and each
change is recorded in the mapping
Expand Down Expand Up @@ -261,6 +264,7 @@ async function cmdXlsform2lstsv(argv: string[]): Promise<void> {
'no-end-note': { type: 'boolean', default: false },
'no-other-pattern': { type: 'boolean', default: false },
'show-no-answer': { type: 'boolean', default: false },
'no-setting-defaults': { type: 'boolean', default: false },
sanitize: { type: 'boolean', default: false },
mapping: { type: 'string' },
'skip-validation': { type: 'boolean', default: false },
Expand All @@ -277,6 +281,7 @@ async function cmdXlsform2lstsv(argv: string[]): Promise<void> {
convertEndNote: !values['no-end-note'],
convertOtherPattern: !values['no-other-pattern'],
hideNoAnswer: !values['show-no-answer'],
surveySettingDefaults: !values['no-setting-defaults'],
};
if (values.language || values.title || values['group-name']) {
config.defaults = {
Expand Down
8 changes: 8 additions & 0 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ export interface LstsvConfig {
*/
hideNoAnswer?: boolean;

/**
* Write formtransform's LimeSurvey survey-setting defaults `allowprev=Y`
* (Previous button) and `showxquestions=N` (no question count) unless the
* form sets them with `limesurvey_*` columns (default: true, #240)
*/
surveySettingDefaults?: boolean;

/**
* Suppress LimeSurvey's automatic per-question tips — e.g. "Only numbers may
* be entered in this field." (numeric) or "Select all that apply" (multiple
Expand Down Expand Up @@ -87,6 +94,7 @@ export const defaultConfig: LstsvConfig = {
convertOtherPattern: true,
convertMarkdown: true,
hideNoAnswer: true,
surveySettingDefaults: true,
hideQuestionTips: true,

defaults: {
Expand Down
4 changes: 2 additions & 2 deletions src/conventions/surveySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const LIMESURVEY_SETTING_PREFIX: string = RULE.prefix;

const SETTINGS: Readonly<Record<string, SettingSpec>> = RULE.settings;
const DERIVED: Readonly<Record<string, string>> = RULE.derived;
/** What formtransform writes when the form sets nothing (`shownoanswer=N`). */
/** What formtransform writes when the form sets nothing (`shownoanswer=N`, `allowprev=Y`, `showxquestions=N`). */
export const LIMESURVEY_SETTING_DEFAULTS: Readonly<Record<string, string>> =
RULE.defaults;
const TRUE_VALUES = new Set<string>(RULE.trueValues);
Expand Down Expand Up @@ -90,7 +90,7 @@ export function limesurveySettingsOf(
/**
* The way back: a TSV's `S` rows as `limesurvey_<setting>` columns. Only the
* supported settings with a valid value, and not a value formtransform writes
* by default (`shownoanswer=N`), so a converted form comes back as authored.
* by default (`LIMESURVEY_SETTING_DEFAULTS`), so a converted form comes back as authored.
*/
export function limesurveySettingColumns(
sRows: readonly { name: string; text: string }[],
Expand Down
6 changes: 4 additions & 2 deletions src/generated/conventions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@
}
],
"limesurveySettings": {
"description": "LimeSurvey survey settings (the surveys table) set from optional settings-sheet columns named <prefix><setting>, e.g. limesurvey_allowprev = Y. Each becomes an `S <setting>` row of the TSV, which LimeSurvey's TSV import writes into the survey (formtransform#228). ODK and Kobo ignore the columns. Only the settings listed here are passed through: an unknown setting or a value outside its list is dropped with a `setting-invalid` warning. Y/N settings also take yes/no and true/false, in any case. The reverse path reads every listed S row back into its column, except a value formtransform writes by default. In DDI each is a cdl:setting note like any other setting (convention:ddiFields).",
"description": "LimeSurvey survey settings (the surveys table) set from optional settings-sheet columns named <prefix><setting>, e.g. limesurvey_allowprev = Y. Each becomes an `S <setting>` row of the TSV, which LimeSurvey's TSV import writes into the survey (formtransform#228). ODK and Kobo ignore the columns. Only the settings listed here are passed through: an unknown setting or a value outside its list is dropped with a `setting-invalid` warning. Y/N settings also take yes/no and true/false, in any case. The reverse path reads every listed S row back into its column, except a value formtransform writes by default (the `defaults`: shownoanswer=N, allowprev=Y, showxquestions=N; a form's column overrides them, and the allowprev and showxquestions defaults can be turned off with the surveySettingDefaults option). In DDI each is a cdl:setting note like any other setting (convention:ddiFields).",
"prefix": "limesurvey_",
"lsTsvRow": "S <setting>",
"ddiPath": "stdyDscr/notes[@type='cdl:setting'][@subject='limesurvey_<setting>']",
Expand All @@ -1137,7 +1137,9 @@
"format": "`style: pages` gives G (a page per group), anything else A (all in one)"
},
"defaults": {
"shownoanswer": "N"
"shownoanswer": "N",
"allowprev": "Y",
"showxquestions": "N"
},
"settings": {
"allowprev": {
Expand Down
6 changes: 4 additions & 2 deletions src/generated/conventions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ const conventions = {
}
],
"limesurveySettings": {
"description": "LimeSurvey survey settings (the surveys table) set from optional settings-sheet columns named <prefix><setting>, e.g. limesurvey_allowprev = Y. Each becomes an `S <setting>` row of the TSV, which LimeSurvey's TSV import writes into the survey (formtransform#228). ODK and Kobo ignore the columns. Only the settings listed here are passed through: an unknown setting or a value outside its list is dropped with a `setting-invalid` warning. Y/N settings also take yes/no and true/false, in any case. The reverse path reads every listed S row back into its column, except a value formtransform writes by default. In DDI each is a cdl:setting note like any other setting (convention:ddiFields).",
"description": "LimeSurvey survey settings (the surveys table) set from optional settings-sheet columns named <prefix><setting>, e.g. limesurvey_allowprev = Y. Each becomes an `S <setting>` row of the TSV, which LimeSurvey's TSV import writes into the survey (formtransform#228). ODK and Kobo ignore the columns. Only the settings listed here are passed through: an unknown setting or a value outside its list is dropped with a `setting-invalid` warning. Y/N settings also take yes/no and true/false, in any case. The reverse path reads every listed S row back into its column, except a value formtransform writes by default (the `defaults`: shownoanswer=N, allowprev=Y, showxquestions=N; a form's column overrides them, and the allowprev and showxquestions defaults can be turned off with the surveySettingDefaults option). In DDI each is a cdl:setting note like any other setting (convention:ddiFields).",
"prefix": "limesurvey_",
"lsTsvRow": "S <setting>",
"ddiPath": "stdyDscr/notes[@type='cdl:setting'][@subject='limesurvey_<setting>']",
Expand All @@ -1146,7 +1146,9 @@ const conventions = {
"format": "`style: pages` gives G (a page per group), anything else A (all in one)"
},
"defaults": {
"shownoanswer": "N"
"shownoanswer": "N",
"allowprev": "Y",
"showxquestions": "N"
},
"settings": {
"allowprev": {
Expand Down
2 changes: 1 addition & 1 deletion src/pipelines/lstsv2xlsform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CLI: `formtransform lstsv2xlsform <input.tsv>`.
| F + SQ + A | `begin_group appearance=table-list` + child `select_one`s | inverts the grid → F encoding |
| SL welcome/end text | `note` named `welcome` / `end` | inverts note promotion |
| per-language rows | `label::<lang>` / `hint::<lang>` | direct |
| S rows | settings (`default_language`, `form_title`, `style`, and `limesurvey_<setting>` for each supported survey setting) | convention:surveySettings `limesurveySettings`; `shownoanswer=N`, formtransform's default, isn't read back |
| S rows | settings (`default_language`, `form_title`, `style`, and `limesurvey_<setting>` for each supported survey setting) | convention:surveySettings `limesurveySettings`; `shownoanswer=N`, `allowprev=Y` and `showxquestions=N`, formtransform's defaults, aren't read back |
| `relevance`, `em_validation_q` | `relevant`, `constraint` | reverse-transpiled — see below |
| `answer_order=random` (L, `!`), `subquestion_order=random` (M), legacy `random_order=1` | `parameters: randomize=true` | convention:randomOrder; a `keep_codes_order` code that isn't in `exclude_all_others` comes back as `fixed=yes` on its choice; exclusive answers come back from `exclude_all_others` |
| `array_filter = q` | `choice_filter: selected(${q}, name)` | convention:choiceFilter. A filter the forward path recoded (`selected(${q}, <column>)`) comes back on the codes LimeSurvey stores, not the list's own |
Expand Down
Loading
Loading