This package contains the data specification for coding assessment output.
It provides:
- JSON Schema:
coding-scheme.schema.json - Schema documentation: generated into
public/(based on AsyncAPI Generator) - TypeScript types for the schema (
CodingSchemeData,VariableCodingData,CodeData, ...) - A small helper class
CodingSchemefor reading/writing versioned scheme JSON
npm i @iqbspecs/coding-schemeImport from the package root:
import {
CodingScheme,
type CodingSchemeData,
type VariableCodingData,
CodingSchemeVersionMajor,
CodingSchemeVersionMinor,
} from "@iqbspecs/coding-scheme";CodingScheme accepts either a JSON string or a parsed object.
const raw = '{"version":"3.4","variableCodings":[]}';
const scheme = new CodingScheme(raw);
// normalized, versioned JSON string
const normalized = scheme.toString();const status = CodingScheme.checkVersion({
version: "3.4",
variableCodings: [],
} satisfies CodingSchemeData);
// 'OK' | 'MAJOR_LESS' | 'MAJOR_GREATER' | 'MINOR_GREATER'The current library version constants are:
CodingSchemeVersionMajor:3CodingSchemeVersionMinor:5
For SUM_SCORE, SUM_CODE and CONCAT_CODE, the derived variable can opt in
through sourceParameters.processing:
TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL: replace contributions fromDISPLAYEDsources, including displayed checkbox defaults such asfalse.TAKE_EMPTY_AS_ZERO_IF_PARTIAL: replace contributions fromINVALIDsources whose value is exactlynull,""or[]. Neitherfalsenor0is empty.
Both options are disabled by default. Replacement requires at least one source
with status CODING_COMPLETE. Pending codings are never replaced and yield
DERIVE_PENDING when all other sources are coded or explicitly allowed partials.
Otherwise the existing status and error precedence applies. With no coded or
pending source, the existing aggregation is preserved, including mixtures of
DISPLAYED and empty INVALID: there is no automatic zero score or x_x.
Replacement happens only inside this derivation; original source status, value,
code and score remain unchanged. The replacement contribution is score 0 for
SUM_SCORE, code 0 for SUM_CODE, and the text placeholder x for
CONCAT_CODE. Thus 0_x differs from two genuinely coded zeros (0_0). The
placeholder is part of the derived text value, not a new code ID. Sorting also
applies to placeholders when SORT is enabled. Other derivation methods,
including the existing SOLVER policies, are unaffected.
The package exports the schema types from coding-scheme.interface.ts, including:
CodingSchemeData: top-level object withversionandvariableCodingsVariableCodingData: per-variable coding configurationCodeData,RuleSet,CodingRule: rule-driven coding definitions
In addition to the TypeScript types, the package exports constants and helpers from coding-scheme.ts:
CodingScheme- State constants:
validStatesForDerivingValuevalidStatesForDerivingCodevalidStatesToStartDerivingstatesToReplaceByDeriveError
- Rule constants:
RuleMethodParameterCountnumericRulesbooleanRules
- Derive constants:
deriveMethodsFromValueDeriveConcatDelimiter
This repository includes scripts to validate and generate documentation.
- Validate schema against test cases:
npm run test_schema- Generate HTML docs into
public/:
npm run generate_docs- All specifications of IQB (German only)
- Learn about TBA (German only)
- Releases with change notes