questmap

0.1.0 • Public • Published

questmap

questmap is a simple helper library for writing webquest exercises.

Installation

npm install questmap

Usage

First, initialize an exercise and export it at the end:

const qm = require('questmap')
 
const exercise = qm()
 
module.exports = exercise

Then, you can add processors and such:

const qm = require('questmap')
 
const exercise = qm()
 
exercise.addVerifySetup(async function () {
  // setup here
})
 
exercise.addProcessor(async function () {
  // processing here
})
 
exercise.addRunCleanup(async function () {
  // cleanup here
})
 
module.exports = exercise

Exercise flow

There's three different stages which we can modify: setup, processor and cleanup. Although it's not required, it's recommended to use them in this way:

  • setup for setting up variables, objects and other things
  • processor to actually check and run exercises
  • cleanup to close connections, clean up variables and such

There's also three different versions of each, one that only runs when the exercise is in Verify mode, one for if it's in Run mode, or one that runs on both:

exercise.addProcessor()
exercise.addRunProcessor()
exercise.addVerifyProcessor()

NOTE: The function arguments to these functions HAVE to be async function (), NOT arrow functions.

Interacting with the exercise

The most important part of exercise verification and running is this. this keeps functions that let us interact with what the user sees, but also contains important contextual variables. Here's a list of what it contains:

this.log(MESSAGE)

Outputs an info message to the user.

this.error(MESSAGE)

Fails the exercise with MESSAGE.

this.end()

Ends the exercise run. If this.error() hasn't been called previously, passes the exercise. This doesn't need to be run, only if you want to end the exercise run early.

this.mode

Contains the mode, e.g. run or verify.

this.bus

Contains the nanobus instance used to talk to the user. It's not recommended to use this directly.

this.file

The path to the solution file passed in by the user.

this.context

The this object used by webquest itself.

Maintainers

This project is a community-owned and maintained project, meaning everyone takes part in caring for its wellbeing. Its current contributors are:

  • @pup (Olivia Hugger)

License

AGPL-3.0+ (see LICENSE)

Readme

Keywords

Package Sidebar

Install

npm i questmap

Weekly Downloads

1

Version

0.1.0

License

AGPL-3.0+

Last publish

Collaborators

  • oceanseraph