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
2 changes: 1 addition & 1 deletion registry/entities/date/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions en
G Questions 1 en
Q D geburtsdatum 1 Wann wurden Sie geboren? en 1
2 changes: 1 addition & 1 deletion registry/entities/decimal/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions en
G Questions 1 en
Q N schlafdauer 1 Wie viele Stunden schlafen Sie durchschnittlich pro Nacht? en 1
2 changes: 1 addition & 1 deletion registry/entities/integer/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions en
G Questions 1 en
Q N alter 1 Wie alt sind Sie? en 1
2 changes: 1 addition & 1 deletion registry/entities/note/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions en
G Questions 1 en
Q X hinweis 1 Im folgenden Abschnitt geht es um Ihre Lebenssituation. en
2 changes: 1 addition & 1 deletion registry/entities/range/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions 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: 1 addition & 1 deletion registry/entities/select_multiple/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions en
G Questions 1 en
Q M wochenende 1 An welchen Tagen des Wochenendes sind Sie erreichbar? en 1
SQ sa Samstag en
SQ so Sonntag en
2 changes: 1 addition & 1 deletion registry/entities/select_multiple_long_list/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions 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
SQ AF Afghanistan en
SQ AX Åland Islands en
Expand Down
2 changes: 1 addition & 1 deletion registry/entities/select_multiple_other/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ S language 1 de de
S format 1 A de
S shownoanswer 1 N de
SL surveyls_title 1 Untitled Survey de
G Questions 1 Questions de
G Questions 1 de
Q M geraetebesitz 1 Welche dieser Geräte besitzen Sie? de Y 1
SQ smart Smartphone de
SQ lapt Laptop de
Expand Down
2 changes: 1 addition & 1 deletion registry/entities/select_one/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions en
G Questions 1 en
Q L bildungsgrad 1 Was ist Ihr höchster Bildungsabschluss? en 1
A 1 Kein Abschluss en
A 2 Haupt- oder Realschulabschluss en
Expand Down
2 changes: 1 addition & 1 deletion registry/entities/select_one_long_list/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions en
G Questions 1 en
Q L geburtsland 1 In welchem Land wurden Sie geboren? en cdlvocab-iso_3166_1 1
A AF Afghanistan en
A AX Åland Islands en
Expand Down
2 changes: 1 addition & 1 deletion registry/entities/select_one_other/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ S language 1 de de
S format 1 A de
S shownoanswer 1 N de
SL surveyls_title 1 Untitled Survey de
G Questions 1 Questions de
G Questions 1 de
Q L aufmerksam 1 Wie sind Sie auf unser Angebot aufmerksam geworden? de Y 1
A such Suchmaschine de
A empf Persönliche Empfehlung de
Expand Down
2 changes: 1 addition & 1 deletion registry/entities/text/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions en
G Questions 1 en
Q S anmerkungen 1 Haben Sie weitere Anmerkungen? en 1
2 changes: 1 addition & 1 deletion registry/entities/time/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Untitled Survey en
G Questions 1 Questions en
G Questions 1 en
Q D aufstehzeit 1 Um wie viel Uhr stehen Sie werktags normalerweise auf? en 1 HH:MM
18 changes: 12 additions & 6 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node
import { basename, dirname, join } from 'node:path';

import { ConversionConfig } from './config/ConfigManager.js';
import { defaultConfig } from './config/types.js';
import type { LstsvConfig } from './config/types.js';
import { resolveFileChoices } from './fileChoices.js';
import { lstsvToDataCsv, lstsvToDdiXml } from './pipelines/lstsv2ddi/index.js';
import { lstsvToXlsform } from './pipelines/lstsv2xlsform/index.js';
Expand Down Expand Up @@ -57,6 +58,8 @@ Options:
-o, --output <file> Write TSV to <file> (default: stdout)
--title <text> Override the survey title
--language <code> Default language code (default: en, or settings default_language)
--group-name <text> Name of the group created when the form has none
(LimeSurvey needs one; default: "Questions")
--no-markdown Do not render markdown labels/hints to HTML
--no-welcome-note Do not promote a "welcome" note to surveyls_welcometext
--no-end-note Do not promote an "end" note to surveyls_endtext
Expand Down Expand Up @@ -223,6 +226,7 @@ async function cmdXlsform2lstsv(argv: string[]): Promise<void> {
output: { type: 'string', short: 'o' },
title: { type: 'string' },
language: { type: 'string' },
'group-name': { type: 'string' },
'no-markdown': { type: 'boolean', default: false },
'no-welcome-note': { type: 'boolean', default: false },
'no-end-note': { type: 'boolean', default: false },
Expand All @@ -236,18 +240,20 @@ async function cmdXlsform2lstsv(argv: string[]): Promise<void> {

const bytes = readInput(positionals, xlsform2lstsvHelp);

const config: Partial<ConversionConfig> = {
const config: Partial<LstsvConfig> = {
convertMarkdown: !values['no-markdown'],
convertWelcomeNote: !values['no-welcome-note'],
convertEndNote: !values['no-end-note'],
convertOtherPattern: !values['no-other-pattern'],
hideNoAnswer: !values['show-no-answer'],
};
if (values.language || values.title) {
if (values.language || values.title || values['group-name']) {
config.defaults = {
language: (values.language as string) ?? 'en',
groupName: 'Questions',
surveyTitle: (values.title as string) ?? 'Untitled Survey',
language: (values.language as string) ?? defaultConfig.defaults.language,
groupName:
(values['group-name'] as string) ?? defaultConfig.defaults.groupName,
surveyTitle:
(values.title as string) ?? defaultConfig.defaults.surveyTitle,
description: '',
};
}
Expand Down
5 changes: 4 additions & 1 deletion src/pipelines/xlsform2lstsv/groupEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ export class GroupEmitter {
// ('en'). A group row whose language differs from the survey base language
// fails LimeSurvey's activation consistency check (e.g. a German-base survey
// with an English-only "Questions" group).
// The group only exists because LimeSurvey needs one: give it the
// configured name (defaults.groupName) and no description, rather than
// repeating the name as a description nobody wrote.
this.rowEmitter.emitForEachLanguage(
() => ({ class: 'G', name: groupName, text: groupName }),
() => ({ class: 'G', name: groupName, text: '' }),
'direct',
);

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/surveys/basic_survey/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ S language 1 en en
S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Basic Survey en
G Questions 1 Questions en
G Questions 1 en
Q S respondentname 1 What is your name? en Y 1
Q N age 1 What is your age? en Y 1
Q L consent 1 Do you consent to participate? en Y 1
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/surveys/validation_relevance_survey/tsv.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ S format 1 A en
S shownoanswer 1 N en
SL surveyls_title 1 Validation and Relevance Test en
SL surveyls_welcometext 1 Validation and Relevance Test Survey en
G Questions 1 Questions en
G Questions 1 en
Q S username 1 Username en self != '' 1
Q N age 1 Age en self >= 18 and self <= 120 1
Q N price 1 Price en self > 0 and self < 1000 1
Expand Down
31 changes: 31 additions & 0 deletions tests/ts/unit/conversionSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,34 @@ describe('settings combinations', () => {
expect(defaultRows).toEqual(explicitRows);
});
});

describe('default group (#74)', () => {
const groupRow = async (config: Record<string, unknown> = {}) =>
(
await convertAndParse(
[{ type: 'text', name: 'q', label: 'Q' }],
[],
undefined,
config,
)
).find((r) => r.class === 'G');

test('has the configured name and no invented description', async () => {
const g = await groupRow({
defaults: {
language: 'en',
groupName: 'Fragen',
surveyTitle: 'T',
description: '',
},
});
expect(g?.name).toBe('Fragen');
expect(g?.text ?? '').toBe('');
});

test('defaults to "Questions", still without a description', async () => {
const g = await groupRow();
expect(g?.name).toBe('Questions');
expect(g?.text ?? '').toBe('');
});
});
Loading