Catalogue & Element Progress
Intro
Catalogue and element progress tracking is a cornerstone functionality of flowcode. It is important to be able to track a user's progress through the Flowcode elements and the catalogues they are in.
Progress service
To centralise the progress calculation logic, all catalogue and element progress logic is handled in the CatalogueProgressService class. To initiate the class, you need to pass through an OrganisationCatalogue record. This is because all progress is tracked to a specific organisation catalogue, enabling separate progress for two of the same catalogues in an organisation.
The main functions of the CatalogueProgressService are to:
- Store and update field progress within an element
- Calculate Element progress
- Calculate Catalogue progress
Other methods include:
- Determine which fields are still incomplete and required
- Mapping progress data to fields, elements and catalogues based on the given organisation catalogue
Field progress
The main purpose of storing field progress is to store the field value. There are various important data points included in this Model that are explained further in the FieldProgress model docs.
Element progress
Element progress is updated whenever a field progress record is updated via the FieldProgressObserver. The observer will find the relevant organisation catalogue and update the related element progress.
The element progress updater uses the following logic:
- Get all element fields, their children and grandchildren, that are marked as required (using the
allFields()method in the Element model) - Loop through these fields and count the fields that have been marked complete
- Calculate the complete fields over the total fields
| It is important to note that for repeated fields, only the first field counts towards completion
| Only fields marked as required count towards completion
Catalogue progress
Catalogue progress is updated whenever a element progress record is updated via the ElementProgressObserver. The observer will find the relevant organisation catalogue and update the related catalogue progress.
The catalogue progress updater uses the following logic:
- Get all published elements of the catalogue
- Loop through these fields and count the fields that have been marked complete as well as sum their progress (%)
- Cataglogue progress = the average (%) completion of elements
- Cataglogue complete = the total elements is equal to completed elements