Skip to content

Commit

Permalink
Improve ability to spot multiple choice questions
Browse files Browse the repository at this point in the history
  • Loading branch information
timpaul committed May 2, 2024
1 parent 76a84df commit 80fd97f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions app/views/answer-types.njk
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@
}) }}
{% endmacro %}

{# Single choice #}
{# SINGLE CHOICE #}

{% macro single_choice(question, options) %}
{% macro single_choice(question, hint, options) %}
{{ govukRadios({
name: "selection",
fieldset: {
Expand All @@ -314,13 +314,16 @@
classes: "govuk-fieldset__legend--l"
}
},
hint: {
text: hint
},
items: options
}) }}
{% endmacro %}

{# Multiple choice #}
{# MULTIPLE CHOICE #}

{% macro multiple_choice(question, options) %}
{% macro multiple_choice(question, hint, options) %}
{{ govukCheckboxes({
name: "selection",
fieldset: {
Expand All @@ -331,7 +334,7 @@
}
},
hint: {
text: "Select all that apply."
text: hint
},
items: options
}) }}
Expand Down
4 changes: 2 additions & 2 deletions app/views/form.njk
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@
{{ answerType.yes_no(currentPageJSON.question_text, currentPageJSON.hint_text) }}

{% elif currentPageJSON.answer_type == "single_choice" %}
{{ answerType.single_choice(currentPageJSON.question_text, currentPageJSON.options) }}
{{ answerType.single_choice(currentPageJSON.question_text, currentPageJSON.hint_text, currentPageJSON.options) }}

{% elif currentPageJSON.answer_type == "multiple_choice" %}
{{ answerType.multiple_choice(currentPageJSON.question_text, currentPageJSON.options) }}
{{ answerType.multiple_choice(currentPageJSON.question_text, currentPageJSON.hint_text, currentPageJSON.options) }}

{% else %}
<h1 class="govuk-heading-l">
Expand Down
2 changes: 1 addition & 1 deletion data/extract-form-questions.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"answer_type": {
"type": "string",
"description": "The type of question being asked, based on the fields. If a question contains square boxes, it's probably a multiple_choice question. If it's asking how many of something there is, it's probably a number question.",
"description": "The type of question being asked, based on the fields. If any part of the question contains text like 'Tick the boxes...' it's a multiple_choice question. If a question contains square boxes it's a multiple_choice question. If it's asking how many of something there is, it's a number question.",
"enum": ["number", "email", "name", "national_insurance_number", "phone_number", "organisation_name", "address", "date", "single_choice", "multiple_choice", "text", "yes_no_question"]
},
"answer_settings": {
Expand Down

0 comments on commit 80fd97f

Please sign in to comment.