Challenge scripts
Add setup, check, solve, and cleanup scripts to your challenges
Last updated
Was this helpful?
Add setup, check, solve, and cleanup scripts to your challenges
Last updated
Was this helpful?
Challenge scripts can be written in whatever scripting language you like, such as Bash or Python. There are four types of challenge scripts:
Setup: Automate commands prior to the challenge starting
Check: Determine if users completed specific tasks, runs when Check is clicked
Solve: Automate users work, runs when Skip is clicked
Cleanup: Automate commands once a challenge is completed
Challenge scripts can be added using the Web UI or the Instruqt CLI.
From a Track dashboard page, click the challenge you wish to add a script to.
From the top navigation bar, click Scripts.
Determine which host in the sandbox you want the script to run on.
Add a script to the host's setup
, check
, solve
, or cleanup
script file.
Use challenge setup scripts to:
Create files that are necessary for the challenge.
Send analytics events.
The following example creates an empty file and a pre-filled file that are available in a challenge:
Use challenge check scripts to:
Check if a learner solved a challenge correctly.
Provide a fail message and a hint if the learner failed to solve the challenge.
The following example checks if the learner created a directory called instruqt
. If the learner created the directory, the script returns a success message, and Instruqt continues with the next challenge. If the learner has not created the directory, the script returns a fail message with a hint to the learner, and Instruqt stays at the current challenge.
Alternatively, the following example uses an exit code to process the challenge check. If the check fails, line 5 sends a feedback message prefixed with FAIL:
to the stdout
and line 6 sets the exit code to 1
, which marks the script as unsuccessful:
When a learner skips a challenge.
The following example solves a challenge by creating a directory called instruqt
:
A challenge cleanup script runs asynchronously after the learner completes a challenge.
Use challenge cleanup scripts to remove artefacts that are no longer used for the rest of the track early.
The following example resets an earlier file that the learner changed:
A challenge solve script solves the current challenge to allow the learner to skip ahead if you . Challenge solve scripts run in the following scenarios:
When you issue the instruqt track test
command in Instruqt CLI to .