More documentation

This commit is contained in:
Neale Pickett 2020-10-15 10:23:39 -06:00
parent 1b128247f6
commit 682a6a7f86
3 changed files with 42 additions and 31 deletions

View File

@ -128,7 +128,7 @@ func (mh *MothRequestHandler) PuzzlesOpen(cat string, points int, path string) (
// Log puzzle.json loads // Log puzzle.json loads
if path == "puzzle.json" { if path == "puzzle.json" {
mh.State.LogEvent("load", "", "", "", 0) mh.State.LogEvent("load", mh.participantID, mh.teamID, cat, points)
} }
return return
@ -149,7 +149,7 @@ func (mh *MothRequestHandler) CheckAnswer(cat string, points int, answer string)
return fmt.Errorf("Incorrect answer") return fmt.Errorf("Incorrect answer")
} }
mh.State.LogEvent("corrrect", mh.participantID, mh.teamID, cat, points) mh.State.LogEvent("correct", mh.participantID, mh.teamID, cat, points)
if err := mh.State.AwardPoints(mh.teamID, cat, points); err != nil { if err := mh.State.AwardPoints(mh.teamID, cat, points); err != nil {
return fmt.Errorf("Error awarding points: %s", err) return fmt.Errorf("Error awarding points: %s", err)

View File

@ -24,25 +24,25 @@ Returns the current MOTH event state as a JSON object.
#### Return #### Return
```json ```js
{ {
"Config": { "Config": {
"Devel": false # true means this is a development server "Devel": false // true means this is a development server
}, },
"Messages: "HTML to be rendered as broadcast messages", "Messages: "HTML to be rendered as broadcast messages",
"TeamNames": { "TeamNames": {
"self": "Requesting team name", # Only if regestered team id is a provided "self": "Requesting team name", // Only if regestered team id is a provided
"0": "Team 1 Name", "0": "Team 1 Name",
"1": "Team 2 Name", "1": "Team 2 Name"
... // ...
},
"PointsLog": {
[1602679698, "0", "category", 1], # epochTime, teamID, category, points
...
}, },
"PointsLog": [
[1602679698, "0", "category", 1] // epochTime, teamID, category, points
// ...
],
"Puzzles": { "Puzzles": {
"category": [1, 2, 3, 6], # list of unlocked puzzles for category "category": [1, 2, 3, 6] // list of unlocked puzzles for category
... // ...
} }
} }
``` ```
@ -239,34 +239,34 @@ Content-Length: 397
The special file `puzzle.json` describes a puzzle. It is a JSON object with the following fields: The special file `puzzle.json` describes a puzzle. It is a JSON object with the following fields:
```json ```js
{ {
"Pre": { # Things which appear before the puzzle is solved "Pre": { // Things which appear before the puzzle is solved
"Authors": ["Neale Pickett"], # List of puzzle authors, usually rendered as a footnote "Authors": ["Neale Pickett"], // List of puzzle authors, usually rendered as a footnote
"Attachments": ["tiger.jpg"], # List of files attached to the puzzle "Attachments": ["tiger.jpg"], // List of files attached to the puzzle
"Scripts": [], # List of scripts which should be included in the HTML render of the puzzle "Scripts": [], // List of scripts which should be included in the HTML render of the puzzle
"Body": "<p>Can you find the hidden text?</p><p><img src=\"tiger.jpg\" alt=\"Grr\" /></p>\n", # HTML puzzle body "Body": "<p>Can you find the hidden text?</p><p><img src=\"tiger.jpg\" alt=\"Grr\" /></p>\n", // HTML puzzle body
"AnswerPattern": "", # Regular expression to include in HTML input tag for validation "AnswerPattern": "", // Regular expression to include in HTML input tag for validation
"AnswerHashes": [ # List of SHA265 hashes of correct answers, for client-side answer checking "AnswerHashes": [ // List of SHA265 hashes of correct answers, for client-side answer checking
"f91b1fe875cdf9e969e5bccd3e259adec5a987dcafcbc9ca8da62e341a7f29c6" "f91b1fe875cdf9e969e5bccd3e259adec5a987dcafcbc9ca8da62e341a7f29c6"
] ]
}, },
"Post": { # Things reveal after the puzzle is solved "Post": { // Things reveal after the puzzle is solved
"Objective": "Learn to examine images for hidden text", # Learning objective "Objective": "Learn to examine images for hidden text", // Learning objective
"Success": { # Measures of learning success "Success": { // Measures of learning success
"Acceptable": "Visually examine image to find hidden text", "Acceptable": "Visually examine image to find hidden text",
"Mastery": "Visually examine image to find hidden text" "Mastery": "Visually examine image to find hidden text"
}, },
"KSAs": null # Knowledge, Skills, and Abilities covered by this puzzle "KSAs": null // Knowledge, Skills, and Abilities covered by this puzzle
}, },
"Debug": { # Debugging output used in development: all fields are emptied when making mothballs "Debug": { // Debugging output used in development: all fields are emptied when making mothballs
"Log": [], # Debug message log "Log": [], // Debug message log
"Errors": [], # Errors encountered generating this puzzzle "Errors": [], // Errors encountered generating this puzzzle
"Hints": [ # Hints for instructional assistants to provide to participants "Hints": [ // Hints for instructional assistants to provide to participants
"Zoom in to the image and examine all sections carefully" "Zoom in to the image and examine all sections carefully"
], ],
"Summary": "text in image" # Summary of this puzzle, to help identify it in an overview of puzzles "Summary": "text in image" // Summary of this puzzle, to help identify it in an overview of puzzles
}, },
"Answers": ["sandwich"] # List of answers: empty in production "Answers": ["sandwich"] // List of answers: empty in production
} }
``` ```

View File

@ -54,6 +54,17 @@ Each line has six fields minimum:
Fields after `points` contain extra fields associated with the event. Fields after `points` contain extra fields associated with the event.
### Event types
These may change in the future.
* init: startup of server
* disabled: points accumulation disabled
* enabled: points accumulation re-enabled
* load: puzzle load
* wrong: wrong answer submitted
* correct: correct answer submitted
### Example ### Example
``` ```