Allow arbitrary metadata on puzzles

This commit is contained in:
Neale Pickett 2024-01-03 14:28:50 -07:00
parent 124b879f03
commit 6a6860b5da
3 changed files with 21 additions and 6 deletions

View File

@ -8,10 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Answer hashes are now the first 4 characters of the hex-encoded SHA1 digest - Answer hashes are now the first 4 characters of the hex-encoded SHA1 digest
- Reworked the built-in theme - Reworked the built-in theme
- [moth.mjs](theme/moth.mjs) is now the standard MOTH library for ECMAScript
- Devel mode no longer accepts an empty team ID - Devel mode no longer accepts an empty team ID
- messages.html moved into theme - messages.html moved into theme
### Added
- [moth.mjs](theme/moth.mjs) is now the standard MOTH library for ECMAScript
- Exported state now includes "Enabled" boolean - Exported state now includes "Enabled" boolean
- New `Extra` field on puzzles will allow addition of arbitrary fields to be attached to puzzles.
PNNL's SCTR Osprey will use this to standardize fields for their custom theme,
but it can be generally used for anything.
## [v4.4.11] - 2023-04-11 ## [v4.4.11] - 2023-04-11
### Changed ### Changed

View File

@ -60,6 +60,13 @@ type Puzzle struct {
// AnswerHashes contains hashes of all answers for this puzzle // AnswerHashes contains hashes of all answers for this puzzle
AnswerHashes []string AnswerHashes []string
// Answers lists all acceptable answers, omitted in mothballs
Answers []string
// Extra is send unchanged to the client.
// Eventually, Objective, KSAs, and Success will move into Extra.
Extra map[string]any
// Objective is the learning objective for this puzzle // Objective is the learning objective for this puzzle
Objective string Objective string
@ -74,9 +81,6 @@ type Puzzle struct {
// Mastery describes the work required to be considered mastering this puzzle's conceptss // Mastery describes the work required to be considered mastering this puzzle's conceptss
Mastery string Mastery string
} }
// Answers lists all acceptable answers, omitted in mothballs
Answers []string
} }
func (puzzle *Puzzle) computeAnswerHashes() { func (puzzle *Puzzle) computeAnswerHashes() {

View File

@ -178,11 +178,17 @@ class Puzzle {
this.Answers ||= [] this.Answers ||= []
this.Attachments ||= [] this.Attachments ||= []
this.Authors ||= [] this.Authors ||= []
this.Scripts ||= []
this.Debug ||= {}
this.Debug.Errors ||= [] this.Debug.Errors ||= []
this.Debug.Hints ||= [] this.Debug.Hints ||= []
this.Debug.Log ||= [] this.Debug.Log ||= []
this.KSAs ||= [] this.Extra ||= {}
this.Scripts ||= []
// Be ready to handle a future revision to the Puzzle structure
this.Objective ||= this.Extra.Objective
this.KSAs ||= this.Extra.KSAs || []
this.Success ||= this.Extra.Success || {}
} }
/** /**