Skip to content

Add configuration for describing none of the above for selection questions#2428

Merged
stephencdaly merged 14 commits into
mainfrom
add-configuration-for-describing-none-of-the-above
Dec 12, 2025
Merged

Add configuration for describing none of the above for selection questions#2428
stephencdaly merged 14 commits into
mainfrom
add-configuration-for-describing-none-of-the-above

Conversation

@stephencdaly
Copy link
Copy Markdown
Contributor

@stephencdaly stephencdaly commented Dec 10, 2025

What problem does this pull request solve?

Trello card: https://trello.com/c/US6RcfTG

This adds the option "Yes, and let people provide a different answer" for "Should the list include an option for ‘None of the above’?" for selection questions and displays a page to configure the question users will be asked if this is selected.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

@stephencdaly stephencdaly force-pushed the add-configuration-for-describing-none-of-the-above branch 11 times, most recently from 23c48f4 to a9673b9 Compare December 10, 2025 17:53
@stephencdaly stephencdaly marked this pull request as ready for review December 10, 2025 17:54
@stephencdaly stephencdaly force-pushed the add-configuration-for-describing-none-of-the-above branch 9 times, most recently from 6eb532c to d7be5a1 Compare December 11, 2025 12:22
@hannahkc
Copy link
Copy Markdown
Contributor

Content all looks good!

@stephencdaly stephencdaly force-pushed the add-configuration-for-describing-none-of-the-above branch 2 times, most recently from ec9eb82 to b338bc4 Compare December 11, 2025 16:01
@thomasiles thomasiles self-assigned this Dec 12, 2025
Copy link
Copy Markdown
Contributor

@thomasiles thomasiles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great and covers loads of cases I wouldn't have even thought of. It works well testing locally 🏅

@stephencdaly stephencdaly removed the request for review from hannahkc December 12, 2025 15:22
We want to display different text on the page to configure the 'None
of the above' question depending on whether there are fewer or more
than 30 options. In the case of having more than 30 options an
autocomplete component will be shown in forms-runner for the selection
question, and the additional question for 'None of the above' will be
shown on a separate page.

This helper method will be used in the template to decide which text
to show.
Add a route, controller and view for configuring the question text and
whether the input is optional for the "None of the above" option for
selection questions.

This page is shown after the page to add selection options, if the
"Yes, and let people provide a different answer" option is selected
    for "Should the list include an option for ‘None of the above’?"
If enabled, we will show a new option on the selection options page
for a 'Selection from a list of options' question type to allow users
to provide a different answer if they select 'None of the above'.
Move duplicated code to the base class.
Reduce duplication between options_input_spec and
base_options_input_spec by using shared examples
Make it so that users can select "Yes, and let people provide a
different answer" for "Should the list include an option for 'None of
the above'?". Only show this option if the feature flag is enabled.

If either "Yes" or "No" are selected, delete the existing
`none_of_the_above_question` configuration from the DraftQuestion if
it exists.
If the question previously had configuration for users to provide
another answer when "None of the above" was selected, but the answer
for "Should the list include an option for ‘None of the above’?" has
been changed so that we will no longer ask users to provide another
answer - delete the `none_of_the_above_question` from the
`answer_settings` for the draft question.
When the back button is clicked on the page to configure the none of
the above question, we want to make sure the correct option for
whether to include none of the above is selected. To acheive this,
when the selection options page is submitted, as well as setting
`is_optional` based on the selected option, also set
`none_of_the_above_question` to be an empty array in the
answer_settings so we can use this to determine that the "Yes, and let
people provide a different answer" option was selected.
If the user selects "Yes, and let people provide a different answer"
for "Should the list include an option for ‘None of the above’?" on
either the page to add individual selection options or the page to
bulk-add the options in a text box, redirect them to the page to
configure the question for the None of the above option.
If "Yes, and let people provide a different answer" was selected for
"Should the list include an option for ‘None of the above’?", show
the question that will be asked on the edit question page with a link
to change it.

If the question is optional, show " (optional)" after the question.
To be more consistent with how we usually do updates, move updating
the page when submitting the edit question page to the `submit` method
on the QuestionInput.

Previously we would have wanted this to be in the controller as it was
calling forms-api using ActiveResource. But now the Page is updated in
the local database instead.

Improve the tests around this.
This is to handle the case when a user clicks the "Change" link on the
edit question page for a selection question and changes their answer
for "Should the list include an option for ‘None of the above’?" to
"Yes, and let people provide a different answer" but then clicks back
without entering a question text.

In this case, when they come to save their question, remove the blank
hash for none_of_the_above_question in the answer_settings. Form
fillers will be shown a "None of the above" option with no question in
this case.
@stephencdaly stephencdaly force-pushed the add-configuration-for-describing-none-of-the-above branch from b338bc4 to 86a07a6 Compare December 12, 2025 15:22
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2428.admin.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@stephencdaly stephencdaly merged commit 915946b into main Dec 12, 2025
7 checks passed
@stephencdaly stephencdaly deleted the add-configuration-for-describing-none-of-the-above branch December 12, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants