Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looping 2.5 - Simple Repeating Blocks in List Collector (No Item Progress Tracking) #1100

Merged
merged 10 commits into from
May 16, 2023

Conversation

kylelawsonAND
Copy link
Contributor

@kylelawsonAND kylelawsonAND commented May 4, 2023

What is the context of this PR?

This PR is a partial implementation of Looping 2.5 repeating blocks for List Collectors.

The QuestionnaireSchema has been augmented to capture repeating blocks when normal blocks are captured at schema launch time in _get_blocks_by_id(self) -> dict[str, ImmutableDict].
The _parent_id_map also has these repeating blocks added to it and considers their parent to be a the list collector block.
Answers from repeating blocks consider their containing block to be the repeating block (via _block_for_answer(self, answer_id: str) -> ImmutableDict | None).
Public methods added to check if a block or answer is in repeating blocks.

ListCollectorBlock collects the repeating block answers for each list item when collecting related answers via _get_related_answers(self, list_model: ListModel) -> dict[str, list[dict]] | None.
A new protected method was added to support this _get_blocks_for_repeating_blocks(self, list_model: ListModel) -> list[dict]:.
This method finds answers from the ListModel that belong to repeating blocks via the new methods in the QuestionnaireSchema. It tracks the blocks that these answers belong to and returns mutable deep copies of them.

The block factory has a new block mapping for the new ListRepeatingBlock block type.

ListAction has had a protected method _is_returning_to_section_summary(self) -> bool added to remove code duplication in the containing class as well as in its inheritors.
This method is used to determine when to navigate to the section summary for previous and next locations.

ListAddQuestion has had a new attribute self._list_item_id: str | None = None added. This is to aid navigation from this block to the repeating blocks if the add block has already been submitted previously.
get_next_location_url(self) augmented to navigate to the first repeating block if repeating blocks exist.

ListRepeatingBlock is a new handler which inherits from ListEditQuestion as its methods and overrides are suitable for use by ListRepeatingBlock.
get_next_location_url(self) -> str overridden to:

  • return to section summary if the attribute self._return_to == "section-summary" and it can validly navigate there.
  • navigate to the next repeating block if one exists
  • continue to the next location on the path as normal

listrepeatingblock.html template added which only extends list-action.html like other list actions.

list_collector_repeating_blocks_section_summary.json test schema added which has two repeating blocks each with two answers to be provided.

How to review

The current implementation makes sense and covers the happy path of completing the Looping 2.5 journey - without the list collector summary showing list item completeness or enforcing returning to list items repeating blocks if they were skipped.

Make use of the new test schema list_collector_repeating_blocks_section_summary.json when testing this.

Pre-existing tests should be passing but if they fail they will be fixed in a future PR.

Future PRs

  • Tracking list item completeness
  • Enforcing list item completeness before proceeding from list collection
  • Displaying list item completeness on list collector summary
  • Unit testing
  • Functional testing
  • Additional test schemas
  • Type hinting files/methods touched by this feature impl

@kylelawsonAND kylelawsonAND marked this pull request as draft May 4, 2023 15:37
@kylelawsonAND kylelawsonAND changed the title Feat/looping 2.5 simple list collector Looping 2.5 - Simple List Collector (No Item Progress Tracking) May 12, 2023
@kylelawsonAND kylelawsonAND marked this pull request as ready for review May 12, 2023 12:57
@kylelawsonAND kylelawsonAND changed the title Looping 2.5 - Simple List Collector (No Item Progress Tracking) Looping 2.5 - Simple Repeating Blocks in List Collector (No Item Progress Tracking) May 12, 2023
@kylelawsonAND
Copy link
Contributor Author

@kylelawsonAND kylelawsonAND merged commit 7bda62b into feat/looping-2.5 May 16, 2023
@kylelawsonAND kylelawsonAND deleted the feat/looping-2.5-simple-list-collector branch May 16, 2023 08:54
kylelawsonAND added a commit that referenced this pull request Jun 26, 2023
* Initial repeating blocks test schema

* Schema for repeating blocks and section summary incomplete + ListCollector Question handling many add types by enum.

* Repeating blocks are presented to the user and can be answered however are not posted correctly and navigation not tested.

* List Collector now always enters add_block & both add_block and edit_block go to repeating_blocks if existing.

* make format

* edit_block does not lead to repeating_blocks. All repeating_blocks show on list collector summary.

* Blocks in repeating_blocks calculated upfront. Answers from repeating_blocks shown on list collector summary underneath the relevant list item.

* Reverting list_collector handler and fixing invalid use of set

* Return to summary reused throughout ListActions

* Adding list item completion progress to progress_store and loading this upon block GET.

* Looping 2.5 - Simple Repeating Blocks in List Collector (No Item Progress Tracking) (#1100)

* Schema for repeating blocks and section summary incomplete + ListCollector Question handling many add types by enum.

* Repeating blocks are presented to the user and can be answered however are not posted correctly and navigation not tested.

* List Collector now always enters add_block & both add_block and edit_block go to repeating_blocks if existing.

* make format

* edit_block does not lead to repeating_blocks. All repeating_blocks show on list collector summary.

* Blocks in repeating_blocks calculated upfront. Answers from repeating_blocks shown on list collector summary underneath the relevant list item.

* Reverting list_collector handler and fixing invalid use of set

* Return to summary reused throughout ListActions

* Fixing existing questionnaire store tests broken by adding list item progress.

* Added remove list item progress to progress store and called from questionnaire store updater.

* List Item Progress tracked with the section and list item id keyed progresses.

* List Item Progress starts with list item add, adding the add block to the list items list of completed locations

* Make response expiry date mandatory (#1104)

* Reverting change to serialize() method naming + removing dev only chnage.

* Bind additional contexts to flush requests (#1108)

* Addressing comments to simplify progress evaluation logic + adding cached property for repeating block ids.

* Schemas v3.56.0 (#1110)

* Addressing comments regarding common usage of first incomplete repeating blocks to evaluate completeness.

* Augmenting comment in capture_dependent_sections_for_list(self, list_name)

* Bug fix to repeating block cache, list section deps reverted to dict of lists, renamed method for removing list items.

* Removing get_completed_block_ids from questionnaire store updater as it is duplicate of router.is_block_complete

* Preliminary impl for list item row icons - breaks tests

* Feat/looping 2.5 list item progress (#1105)

* Schema for repeating blocks and section summary incomplete + ListCollector Question handling many add types by enum.

* Repeating blocks are presented to the user and can be answered however are not posted correctly and navigation not tested.

* List Collector now always enters add_block & both add_block and edit_block go to repeating_blocks if existing.

* make format

* edit_block does not lead to repeating_blocks. All repeating_blocks show on list collector summary.

* Blocks in repeating_blocks calculated upfront. Answers from repeating_blocks shown on list collector summary underneath the relevant list item.

* Reverting list_collector handler and fixing invalid use of set

* Return to summary reused throughout ListActions

* Adding list item completion progress to progress_store and loading this upon block GET.

* Fixing existing questionnaire store tests broken by adding list item progress.

* Added remove list item progress to progress store and called from questionnaire store updater.

* List Item Progress tracked with the section and list item id keyed progresses.

* List Item Progress starts with list item add, adding the add block to the list items list of completed locations

* Reverting change to serialize() method naming + removing dev only chnage.

* Addressing comments to simplify progress evaluation logic + adding cached property for repeating block ids.

* Addressing comments regarding common usage of first incomplete repeating blocks to evaluate completeness.

* Augmenting comment in capture_dependent_sections_for_list(self, list_name)

* Bug fix to repeating block cache, list section deps reverted to dict of lists, renamed method for removing list items.

* Removing get_completed_block_ids from questionnaire store updater as it is duplicate of router.is_block_complete

* Fixing tests broken by list collector icon render changes

* Fixing incorrect formatting and rewording a type hint

* Cleaned up evaluation of list item icon.

* Schemas v3.57.0 (#1113)

* Reverting accidental reversion of a file

* Schemas v3.57.1 (#1115)

* Schemas v3.58.0 (#1116)

* Implement "progress" value source (#1044)

Co-authored-by: Rhys Berrow <[email protected]

* Fix handling of invalid values in form numerical inputs  (#1111)

* Passing only section id and bool for repeating blocks for list context and using kwargs where possible.

* Adding missing list context constructor arg

* Enforcing kwargs on _build_list_items_context

* Merge conflict resolution with main.

* Running make format

* Adding list collector with repeating blocks fixture and testing the repeating blocks are mapped by id correctly when schema loads.

* Completing unit testing of additions to QuestionnaireSchema

* Update Chromedriver to version 113 (#1118)

* update chromedriver

* temporarily comment out line, to be fixed separately

* ListContext unit tests

* Updating list collector summary to correctly acquire related answers and avoid breaks when list collector with same name appears twice.

* Enforcing kwargs on update_section_status and make format

* Feat/Grand calculated summary (#1107)

* initial ideas

* Implementation closer to calculated summaries

* better test schemas and routing evaluation

* get routing working

* dont need section id

* make routing better, start adding tests

* start fixing test schemas

* Two further schema fixes

* Fix remaining schema issue

* Add integration test

* Add functional test

* Functional tests for routing and answers not on the path

* Changing an answer updates GCS progress

* Add schema for overlapping answers

* Functionally test skip-question in grand calculated summary

* Add tests for GCS routing

* Fix errors caused by merge

* type hints, comments, remove some duplication

* fix formatting

* Update translation templates

* remove accidental update

* Fix some type hints

* Use validator branch and update test description

* refactor GCS answer format

* Fix lint and test errors

* Address PR comments

* improve context and coverage of test schemas

* Fix invalid schema and add invalid routing test

* Fix line length in test

* test schema linting

* Fix routing bug

* Make schema easier to follow

* Linting

* partial fix to routing

* Add addtional routing test case

* Remove arg from new test case

* Routing to next incomplete block for summaries

* linting error

* remove arg from router tests

* PR comments

* PR Comment

* Amend comment and improve dependencies function

* Handle merge errors

* fix gcs routing within same section

* Add test for GCS with progress value source

* Remove backtick

* update chromedriver

* Revert "update chromedriver"

This reverts commit a2e3698.

* Fix schema labels

* Revert validator branch to latest

* Integration tests started

* Fix dynamic answers functional test (#1121)

* Repeating blocks integration test suite complete

* Schemas v3.59.0 (#1130)

* Make format

* running and fixing mypy

* Merge with main and format and lint

* Fixing linting errors and pointing to relevant validator

* Fixing validator tag typo

* Schemas v3.60.0 (#1133)

* Fixing mocker patch of renamed method

* make format

* Update to chromedriver v114 (#1134)

* Functional test progress

* Add DESNZ theme (#1131)

* Schemas v3.61.0 (#1139)

* Adding functional test for editing repeating block answers from section summary

* Asserting completing list items in func tests and editing from section summary.

* Misc type hinting

* Misc type hinting

* Formatting

* Consolidating duplicate func test helper method and fixing typos.

* Linting, formatting and merging with feat prepop.

* Fixing broken tests

* Linting, formatting and cleaning up merge with main

* ListRepeatingBlock now extends to ListAction and does not invoke parent handle_post.

* Addressing PR comments 16-6-23

* Reverting local test changes.

* Reverting local test changes by formatting

* Reverting local test changes by formatting

* Adding additional docs and type hints to ProgressStore

* Addressing PR comments.

* Fixing list collector (no RP) icons

* Removing person icon change.

* Adding repeating blocks to the submission payload and renaming list name in test schema.

* Adding test coverage for repeating block answers in submission payload.

* Reformat

* Adding func test and schema for a repeating blocks LC on a hub questionnaire.

* Fixing test broken in prev commit.

* Reformatting.

* Updating naming of progress store methods follwoing convos.

* Updating comment

* Updating comment

* Formatting

* Addressing comments

* Remvovign whitespace from schema

* Amending naming and type hinting in list collector block  summary and adding context to list collector RP schema.

* Changing to unit and currency in simple RB schema.

* Formatting

* Removing redundant test schema

* Using latest validator

---------

Co-authored-by: petechd <[email protected]>
Co-authored-by: Mebin Abraham <[email protected]>
Co-authored-by: Guilhem <[email protected]>
Co-authored-by: Katie Gardner_ONS <[email protected]>
Co-authored-by: Rhys Berrow <[email protected]>
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.

1 participant