From 400c7c8db774d633ad7cb1406feb546bfc8ba706 Mon Sep 17 00:00:00 2001 From: Daniel Hornung <d.hornung@indiscale.com> Date: Wed, 17 Apr 2024 11:50:40 +0200 Subject: [PATCH] DOC: Specifying multiple choice checkboxes. --- src/doc/table-json-conversion/specs.md | 25 +++++++++++++++++++ .../test_table_template_generator.py | 1 + 2 files changed, 26 insertions(+) diff --git a/src/doc/table-json-conversion/specs.md b/src/doc/table-json-conversion/specs.md index 68c54099..b4fe5b71 100644 --- a/src/doc/table-json-conversion/specs.md +++ b/src/doc/table-json-conversion/specs.md @@ -252,6 +252,31 @@ For example, this table defines three coaches for the two trainings from the las | | 2024-02-27 | example.com/mp | Berta | | | 2024-02-27 | example.com/m | Chris | +#### Sepcial case: multiple choice "checkboxes" #### + +As a special case, enum arrays with `"uniqueItems": true` can be represented as multiple columns, +with one column per choice. The choices are denoted as the last `PATH` component, the column type +must be `MULTIPLE_CHOICE`. + +Stored data is denoted as an "x" character in the respective cell, empty cells denote that the item +was not selected. Additionally, the implementation also allows `TRUE` or `1` for selected items, +and `FALSE`, `0` or cells with only whitespace characters for deselected items: + +| `COL_TYPE` | `MULTIPLE_CHOICE` | `MULTIPLE_CHOICE` | `MULTIPLE_CHOICE` | +| `PATH` | `skills` | `skills` | `skills` | +| `PATH` | `Planning` | `Communication` | `Evaluation` | +| `IGNORE` | skills.Planning | skills.Communication | skills.Evaluation | +|------------|-------------------|----------------------|-------------------| +| | x | | X | +| | `" "` | `TRUE` | `FALSE` | +| | 0 | x | 1 | + +These rows correspond to: + +1. Planning, Evaluation +2. Communication +3. Communication, Evaluation + ## Current limitations ## The current implementation still lacks the following: diff --git a/unittests/table_json_conversion/test_table_template_generator.py b/unittests/table_json_conversion/test_table_template_generator.py index cefc792b..61da2142 100644 --- a/unittests/table_json_conversion/test_table_template_generator.py +++ b/unittests/table_json_conversion/test_table_template_generator.py @@ -267,6 +267,7 @@ def test_model_with_indirect_reference(): foreign_keys={"Wrapper": ["Training.name", "Training.url"]}, outfile=None) + def test_model_with_multiple_choice(): _compare_generated_to_known_good( schema_file=rfp("data/multiple_choice_schema.json"), -- GitLab