Dance levels can include validation feedback configured with validation_code
. There is a general consensus that many students do not read level instructions carefully so that validation feedback is critical for students to engage successfully with a given activity.
Currently (January 2024), there are two versions of Dance Party progressions:
The following table includes functions and variables that are used in the 2019 Dance Party and/or Dance Party AI Edition progression. The column is checked if the code is used in the respective progression. Note that additional support was added to code-dot-org/dance-party
for the 2023 AI Edition to provide more targeted feedback for users.
Name | Description | 2019 Dance | 2023 AI |
---|---|---|---|
pass() |
A function that is called when a user 'passes' a level | ✓ | ✓ |
fail(<validation feedback string key>) |
A function that is called when a user 'fails' a level - the parameter is the feedback string key which is displayed to give user's targeted feedback/help | ✓ | ✓ |
getCurrentPalette() |
A function that returns a string that represents the current background palette | ✓ | |
getUserBlockTypes() |
A function that returns an array of strings that represent block type names in a user's program | ✓ | |
world.aiBlockCalled |
A boolean that is set true if the AI block has been executed and false otherwise |
✓ | |
world.aiBlockContextUserEventKey |
Used in conjunction with setFuncContext - a string that represents the event key ('up', 'down', ...) within the context of when the AI block is executed - Although this variable is not used in the 2019 nor 2023 Dance Party progressions, it could be helpful in future Dance Party progressions. |
✓ | |
world.aiBlockHasInvalidParams |
A boolean that is set true if the AI block is executed with undefined parameters (emojis) |
✓ | |
world.bg_effect |
A string that represents the current background effect | ✓ | |
world.fg_effect |
A string that represents the current foreground effect | ✓ | |
world.keysPressed |
A set that is assigned strings that represent keys pressed during the running of a user's program | ✓ | ✓ |
world.spriteGroupsCalledToChangeMove |
An array of strings that represent sprite groups called to change dance move via changeMoveEachLR |
✓ | |
world.spriteStyles |
An array of strings that represent the sprite costumes that have been added to a user's program | ✓ | |
world.validationState |
Object that is used to save state during the running of the user's program for validation purposes, e.g., World.validationState[index] = sprite.getAnimationLabel() |
✓ | ✓ |
getTime('measures') |
A function that returns a number | ✓ | ✓ |
setFuncContext(type, key) |
A function defined in p5.dance.js and added to api.js - this function is called on in executeFuncs defined in p5.dance.interpreted to set a function's context eventType and event key |
✓ | |
sprites |
An array of sprites in a user's program - defined in api.js |
✓ | ✓ |
sprite.current_move |
A number that represents the index of a sprite's current dance move in MOVE_NAMES array |
✓ | |
sprite.getAnimationLabel() |
A function that returns a string that represents a sprite's current animation, e.g., anim0 - this function is defined in code-dot-org/p5.play |
✓ | ✓ |
sprite.scale |
A number that represents the scale of a sprite - 0.3 is the default value for a backup dance and 1.0 is the default value for a lead dancer |
✓ | |
sprite.tint |
A string that represent the color of a sprite | ✓ |
Note that world
variables are accessed in .level
files with World
, e.g., World.spriteStyles
, and functions defined in p5.dance.js
are accessed in .level
files with nativeAPI
, e.g., nativeAPI.pass()
. Functions and variables defined in api.js
are accessed as is, e.g., sprites
.
Validation code is usually configured via levelbuilder by content editors. However, Dance Party validation code has been written by engineers because of the lack of documentation and the unfriendly API. For easier reference, the following google docs contain all of the validation code for the two Dance Party progressions compiled from the .level files. (Example of .level validation code from Dance Party AI Edition level 2)
Dance Party 2019 validation code (google doc)
Dance Party: AI Edition validation code (google doc)
When Dance Party is migrated to lab2
, there is strong interest in revamping validation support so that content editors have better documentation and support in writing validation code more independently.