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
16 changes: 15 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@ on:
name: Generate Html und Publish

jobs:
validate:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Run html generation
run: |
npm ci
npm run generate_docs

deploy-build:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -27,7 +41,7 @@ jobs:
git config --global user.email "mechtel@iqb.hu-berlin.de"
git config --global user.name "Martin Mechtel"
git checkout gh-pages
git reset --hard main
git reset --hard origin/main
- name: Run html generation
run: |
npm ci
Expand Down
108 changes: 100 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,107 @@
[![License: CC0-1.0](https://img.shields.io/badge/License-CC0_1.0-lightgrey.svg)](http://creativecommons.org/publicdomain/zero/1.0/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![npm](https://img.shields.io/npm/v/%40iqbspecs%2Fcoding-scheme)](https://www.npmjs.com/package/@iqbspecs/coding-scheme)

This package contains of the data specification for coding assessment output.
This package contains the data specification for coding assessment output.

* JSON Schema (see `coding-scheme.schema.json`)
* Schema documentation based on [AsyncAPI Generator](https://github.com/asyncapi/generator)
* type definitions for TypeScript (see npm-link above)
It provides:

Read more:
- **JSON Schema**: `coding-scheme.schema.json`
- **Schema documentation**: generated into `public/` (based on [AsyncAPI Generator](https://github.com/asyncapi/generator))
- **TypeScript types** for the schema (`CodingSchemeData`, `VariableCodingData`, `CodeData`, ...)
- A small helper class **`CodingScheme`** for reading/writing versioned scheme JSON

* [All specifications of IQB](https://iqb-specifications.github.io/) (German only)
* [Learn about TBA](https://iqb-berlin.github.io/tba-info/) (German only)
* [Releases with change notes](https://github.com/iqb-specifications/coding-scheme/releases)
## Installation

```bash
npm i @iqbspecs/coding-scheme
```

## Usage (TypeScript)

Import from the package root:

```ts
import {
CodingScheme,
type CodingSchemeData,
type VariableCodingData,
CodingSchemeVersionMajor,
CodingSchemeVersionMinor,
} from "@iqbspecs/coding-scheme";
```

### Parse a scheme and re-serialize it

`CodingScheme` accepts either a JSON string or a parsed object.

```ts
const raw = '{"version":"3.3","variableCodings":[]}';
const scheme = new CodingScheme(raw);

// normalized, versioned JSON string
const normalized = scheme.toString();
```

### Check compatibility of a scheme version

```ts
const status = CodingScheme.checkVersion({
version: "3.3",
variableCodings: [],
} satisfies CodingSchemeData);

// 'OK' | 'MAJOR_LESS' | 'MAJOR_GREATER' | 'MINOR_GREATER'
```

The current library version constants are:

- **`CodingSchemeVersionMajor`**: `3`
- **`CodingSchemeVersionMinor`**: `3`

### Types

The package exports the schema types from `coding-scheme.interface.ts`, including:

- **`CodingSchemeData`**: top-level object with `version` and `variableCodings`
- **`VariableCodingData`**: per-variable coding configuration
- **`CodeData`**, **`RuleSet`**, **`CodingRule`**: rule-driven coding definitions

## Public API exports

In addition to the TypeScript types, the package exports constants and helpers from `coding-scheme.ts`:

- **`CodingScheme`**
- **State constants**:
- `validStatesForDerivingValue`
- `validStatesForDerivingCode`
- `validStatesToStartDeriving`
- `statesToReplaceByDeriveError`
- **Rule constants**:
- `RuleMethodParameterCount`
- `numericRules`
- `booleanRules`
- **Derive constants**:
- `deriveMethodsFromValue`
- `DeriveConcatDelimiter`

## Schema validation and documentation generation (repo)

This repository includes scripts to validate and generate documentation.

- **Validate schema against test cases**:

```bash
npm run test_schema
```

- **Generate HTML docs into `public/`**:

```bash
npm run generate_docs
```

## Read more

- [All specifications of IQB](https://iqb-specifications.github.io/) (German only)
- [Learn about TBA](https://iqb-berlin.github.io/tba-info/) (German only)
- [Releases with change notes](https://github.com/iqb-specifications/coding-scheme/releases)
41 changes: 23 additions & 18 deletions make_doc/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
asyncapi: 2.5.0
asyncapi: 3.0.0
id: "urn:iqb-specifications:coding-scheme"
defaultContentType: application/json
info:
title: coding-scheme
description: Rules and instructions for coding assessment output.
license:
name: CC0 1.0
url: https://creativecommons.org/publicdomain/zero/1.0/
version: " - click on schema id to expand"
contact:
name: Home of iqb-specifications (German only)
url: https://iqb-specifications.github.io/
title: coding-scheme
description: Rules and instructions for coding assessment output.
license:
name: CC0 1.0
url: https://creativecommons.org/publicdomain/zero/1.0/
version: " - click on schema id to expand"
contact:
name: Home of iqb-specifications (German only)
url: https://iqb-specifications.github.io/

channels:
iqb_data_structures:
subscribe:
operationId: 'Please select one schema'
message:
messageId: select_schema
iqb_data_structures:
address: iqb_data_structures
messages:
select_schema:
payload:
$ref: "#/components/schemas/response"

components:
schemas:
response:
$ref: '../coding-scheme.schema.json'
schemas:
response:
$ref: "./coding-scheme.schema.json"
Loading