This contains a new progress system that can be used by any Lab2 lab. It allows for a level to define a variety of conditions, some of which give the user feedback, and some of which allow the user to continue to the next level.
It was first introduced by Music Lab in #50596. Adapted from that PR's description, here are some key features:
- Each level has a set of validation conditions.
- The level designer writes these in JSON, rather than JavaScript, so we have a clean separation between per-level validation conditions and the lab's internal implementation.
- Conditions that aren't recognised are skipped, allowing level designers to add necessary conditions while lab engineers will later add support for them.
- Level designers can provide feedback messages for specific conditions.
- It's essentially the same system as was built for Star Wars in 2015 here, and AI for Oceans in 2019 here.
And here are some architectural details:
ProgressManagermanages progress, and is lab-agnostic.- A lab-specific validator, such as
MusicValidatorin Music Lab does lab-specific evaluation of progress. It implements the abstractValidatorclass, and is passed intoProgressManager, which knows of nothing more thanValidator. ConditionsCheckeris a helper class which accumulates satisfied conditions for the current execution of user code, and is used by the lab-specific validator implementation. Other labs might benefit from it, though there are alternate techniques to validate code, such as direct code examination, which don't really need to accumulate satisfied conditions over a period of time.- For now, the lab loads the progression data and passes it into
ProgressManagerwhen it instantiates that class. The lab also instantiates the lab-specific validator and gives it access to the components it needs to examine progress.
There is a user-friendly levelbuilder UI for building these validations in a level. Details in #53142.
Sample level data from Music Lab:
code-dot-org/dashboard/config/levels/custom/music/Music Level 2.level
Lines 20 to 37 in 1226e19