Add a script to check challenge execution
Guide learners through your learning experience.
This guide explains how to add a script that checks the challenge execution.
Instruqt provides check scripts that monitor challenge execution by the learner as part of the challenge lifecycle scripts. A challenge check script runs when the learner clicks Check on a challenge page and verifies if the learner has correctly solved the challenge. If the learner has done well, the track continues. Otherwise, the track pauses, and the learner gets a hint to solve the challenge.
Let's look at an example of a challenge check script. The following script checks if the learner installed the cowsay package:
Bash
#!/bin/bash
set -euxo pipefail
echo "Checking whether cowsay is installed..."
dpkg -l | grep cowsay || fail-message "Oops, it looks like cowsay is not installed."
Note the bash boolean OR operator:
||
. The code in line 6 translates to list all installed packages, and if cowsay is not found in the list, the script sends a failure message.Check scripts go hand in hand with solve scripts. Solve scripts run when the learner clicks Skip (if enabled) for a challenge. And solve scripts also run when you execute a
instruqt track test
command. In that case, solve scripts mimic a learner that solves the challenge.Here is a challenge solve script that solves the challenge by installing the cowsay package:
Bash
#!/bin/bash
set -euxo pipefail
echo "Installing cowsay..."
apt -y update
apt -y install cowsay
Check this topic for how to add a challenge check or solve script:
Perfect! Your content keeps getting richer, making the learning experience more challenging for your learners.
Last modified 5mo ago