From 400fdcd0c51d15ddeb517916587359ba86ed1b71 Mon Sep 17 00:00:00 2001 From: petechd <53475968+petechd@users.noreply.github.com> Date: Fri, 4 Mar 2022 07:41:35 +0000 Subject: [PATCH] Add introduction guidance (#140) --- schemas/blocks/introduction.json | 11 ++- schemas/common_definitions.json | 15 ++++ schemas/questions/definitions.json | 9 -- schemas/questions/types/calculated.json | 2 +- schemas/questions/types/date_range.json | 2 +- schemas/questions/types/general.json | 2 +- .../questions/types/mutually_exclusive.json | 2 +- .../test_introduction_with_guidance.json | 85 +++++++++++++++++++ 8 files changed, 114 insertions(+), 14 deletions(-) create mode 100644 tests/schemas/valid/test_introduction_with_guidance.json diff --git a/schemas/blocks/introduction.json b/schemas/blocks/introduction.json index 851508f7..1d224bf1 100644 --- a/schemas/blocks/introduction.json +++ b/schemas/blocks/introduction.json @@ -32,7 +32,16 @@ "$ref": "https://eq.ons.gov.uk/common_definitions.json#/contents" } }, - "additionalProperties": false + "additionalProperties": true, + "required": ["id"], + "anyOf": [ + { + "required": ["title"] + }, + { + "required": ["contents"] + } + ] } }, "preview_content": { diff --git a/schemas/common_definitions.json b/schemas/common_definitions.json index 939429b1..ec0d0414 100644 --- a/schemas/common_definitions.json +++ b/schemas/common_definitions.json @@ -42,6 +42,9 @@ }, { "required": ["definition"] + }, + { + "required": ["guidance"] } ], "properties": { @@ -59,6 +62,9 @@ }, "definition": { "$ref": "https://eq.ons.gov.uk/common_definitions.json#/definition" + }, + "guidance": { + "$ref": "https://eq.ons.gov.uk/common_definitions.json#/guidance" } }, "additionalProperties": false @@ -406,5 +412,14 @@ "interviewer_only": { "description": "Marks the page as for the interviewer only. Only applies for questionnaires that will be completed by an interviewer.", "type": "boolean" + }, + "guidance": { + "description": "Question or contents guidance", + "type": "object", + "properties": { + "contents": { + "$ref": "https://eq.ons.gov.uk/common_definitions.json#/contents" + } + } } } diff --git a/schemas/questions/definitions.json b/schemas/questions/definitions.json index 249631b5..f0fa6b57 100644 --- a/schemas/questions/definitions.json +++ b/schemas/questions/definitions.json @@ -17,15 +17,6 @@ } ] }, - "question_guidance": { - "description": "Question guidance", - "type": "object", - "properties": { - "contents": { - "$ref": "https://eq.ons.gov.uk/common_definitions.json#/contents" - } - } - }, "summary": { "description": "TextField string concatenations for the summary page", "properties": { diff --git a/schemas/questions/types/calculated.json b/schemas/questions/types/calculated.json index 15af13bb..a0ef1637 100644 --- a/schemas/questions/types/calculated.json +++ b/schemas/questions/types/calculated.json @@ -23,7 +23,7 @@ "$ref": "https://eq.ons.gov.uk/common_definitions.json#/question_definitions" }, "guidance": { - "$ref": "https://eq.ons.gov.uk/questions/definitions.json#/question_guidance" + "$ref": "https://eq.ons.gov.uk/common_definitions.json#/guidance" }, "type": { "type": "string", diff --git a/schemas/questions/types/date_range.json b/schemas/questions/types/date_range.json index b4b70de9..5881c2f1 100644 --- a/schemas/questions/types/date_range.json +++ b/schemas/questions/types/date_range.json @@ -23,7 +23,7 @@ "$ref": "https://eq.ons.gov.uk/common_definitions.json#/non_empty_string" }, "guidance": { - "$ref": "https://eq.ons.gov.uk/questions/definitions.json#/question_guidance" + "$ref": "https://eq.ons.gov.uk/common_definitions.json#/guidance" }, "type": { "type": "string", diff --git a/schemas/questions/types/general.json b/schemas/questions/types/general.json index 88059839..4fdb6135 100644 --- a/schemas/questions/types/general.json +++ b/schemas/questions/types/general.json @@ -26,7 +26,7 @@ "$ref": "https://eq.ons.gov.uk/common_definitions.json#/question_definitions" }, "guidance": { - "$ref": "https://eq.ons.gov.uk/questions/definitions.json#/question_guidance" + "$ref": "https://eq.ons.gov.uk/common_definitions.json#/guidance" }, "summary": { "$ref": "https://eq.ons.gov.uk/questions/definitions.json#/summary" diff --git a/schemas/questions/types/mutually_exclusive.json b/schemas/questions/types/mutually_exclusive.json index 75213843..3ff1c123 100644 --- a/schemas/questions/types/mutually_exclusive.json +++ b/schemas/questions/types/mutually_exclusive.json @@ -26,7 +26,7 @@ "$ref": "https://eq.ons.gov.uk/common_definitions.json#/question_definitions" }, "guidance": { - "$ref": "https://eq.ons.gov.uk/questions/definitions.json#/question_guidance" + "$ref": "https://eq.ons.gov.uk/common_definitions.json#/guidance" }, "type": { "type": "string", diff --git a/tests/schemas/valid/test_introduction_with_guidance.json b/tests/schemas/valid/test_introduction_with_guidance.json new file mode 100644 index 00000000..bb2e21b5 --- /dev/null +++ b/tests/schemas/valid/test_introduction_with_guidance.json @@ -0,0 +1,85 @@ +{ + "mime_type": "application/json/ons/eq", + "language": "en", + "schema_version": "0.0.1", + "data_version": "0.0.3", + "survey_id": "144", + "theme": "default", + "title": "Test introduction", + "legal_basis": "Notice is given under section 999 of the Test Act 2000", + "metadata": [ + { + "name": "user_id", + "type": "string" + }, + { + "name": "period_id", + "type": "string" + }, + { + "name": "ru_name", + "type": "string" + }, + { + "name": "ru_ref", + "type": "string" + }, + { + "name": "trad_as", + "type": "string", + "optional": true + } + ], + "questionnaire_flow": { + "type": "Linear", + "options": {} + }, + "sections": [ + { + "id": "introduction-section", + "title": "Introduction", + "groups": [ + { + "id": "introduction-group", + "title": "General Business Information", + "blocks": [ + { + "id": "introduction", + "type": "Introduction", + "primary_content": [ + { + "id": "business-details", + "title": "You are completing this for ESSENTIAL ENTERPRISE LTD.", + "contents": [ + { + "guidance": { + "contents": [ + { + "title": "Coronavirus (COVID-19) guidance", + "description": "Explain your figures in the comment section to minimise us contacting you and to help us tell an industry story" + } + ] + } + } + ] + } + ] + }, + { + "type": "Interstitial", + "id": "general-business-information-completed", + "content": { + "title": "Section complete", + "contents": [ + { + "description": "
You have successfully completed this section
" + } + ] + } + } + ] + } + ] + } + ] +}