Skip to content

feat(ddi): every group a varGrp, variables in survey order (#152) - #157

Merged
jstet merged 2 commits into
mainfrom
feat/152-ddi-structure
Sep 27, 2026
Merged

jstet merged 2 commits into
mainfrom
feat/152-ddi-structure

Conversation

@jstet

@jstet jstet commented Sep 27, 2026

Copy link
Copy Markdown
Member

Closes #152. Part 2 of #155.

What changes

  • Every group is a <varGrp>.
    • A plain group uses the XSD's own type="section", as agreed with qwacback; type="other" stays reserved for the semi-open pair.
    • A section lists its direct <var>s in @var and its direct child groups in @varGrp. Child groups are sections, grids, a select_multiple's multipleResp, and an other pair's varGrp.
    • The label goes in txt (one per xml:lang) and in concept.
    • @ID is VG_<path> and @name is the group path, as grids already did.
    • A group with no variable under it (e.g. only notes) gets no varGrp.
  • Group conditions (follow-up to Convention: carry relevant/constraint in DDI as typed <notes> plus <universe> prose #151):
  • Survey order: <var>s follow the survey instead of being bucketed as grids, then multi-selects, then pairs, then the rest. The data CSV columns (getDdiColumnNames) follow the same order, so header = <var> order still holds.
<varGrp ID="VG_person" name="person" type="section" var="V_beruf V_bildung" varGrp="VG_sprachen VG_quelle">
  <txt>Person</txt>
  <txt xml:lang="en">Person</txt>
  <concept>Person</concept>
</varGrp>

Behaviour to be aware of

  • Column order changes. The data CSV's column order changes for any form that isn't already in role order. Names and API are unchanged, and the header still matches <var> order.
  • Sections are new elements. qwacback skips section today (qwacback#37).
  • LimeSurvey's "Questions" wrapper: LimeSurvey needs every question in a group, so xlsform2lstsv wraps top-level questions in one called "Questions". lstsv2ddi can't tell it from an authored group, so it becomes a section. lstsv2ddiRoundtrip.test.ts ignores that one wrapper.

Still open (#153)

  • The group hint.
  • Keeping a note row separate from the hint that follows it: this comes with the postQTxt hint move.

Checks

  • vitest: 1243 passed. New: tests/ts/unit/ddi/structure.test.ts, covering nesting, grids inside sections, empty groups, languages, and var and column order.
  • pytest validation and codegen: 127 passed, 3 xfailed.
    • The XSD and Schematron checks pass on every snapshot.
    • The two KNOWN_INVALID fixtures fail with the same errors as before.
    • The Schematron varGrp/@type list now includes section, taken from the registry (type:begin_group).
  • npm run validate and the drift check are clean.

🤖 Generated with Claude Code

jstet and others added 2 commits September 27, 2026 18:08
- A plain group is a `<varGrp type="section">` (the XSD's own type;
  `other` stays the semi-open pair's). It lists its direct `<var>`s in @var
  and its direct child groups (sections, grids, a select_multiple's
  multipleResp, an other pair's varGrp) in @vargrp. Label in `txt` per
  xml:lang and `concept`. A group with no variable under it has none.
- A group's own `relevant` is its `universe` and `cdl:relevant` note
  (grids too). A variable's note now carries only its own condition; its
  universe still states its groups' conditions as well.
- `<var>`s, and the data CSV columns with them, follow the survey instead
  of being bucketed by role.

Variables carry their group chain (`Variable.groups`). lstsv2ddi turns
every LimeSurvey group into a section, including the "Questions" group
xlsform2lstsv wraps top-level questions in; the round-trip test ignores
that one.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…owed (#152)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jstet
jstet merged commit 0b8ae1c into main Sep 27, 2026
4 checks passed
@jstet
jstet deleted the feat/152-ddi-structure branch September 27, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DDI round trips: keep question order, every group, and notes apart from hints

1 participant