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.

Challenge check scripts

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.
Supported scripting languages
You can use any scripting language to write the scripts—for example, bash or Python, where bash is the most common choice for Instruqt.
Let's look at an example of a challenge check script. The following script checks if the learner installed the cowsay package:
Bash
1
#!/bin/bash
2
set -euxo pipefail
3
4
echo "Checking whether cowsay is installed..."
5
6
dpkg -l | grep cowsay || fail-message "Oops, it looks like cowsay is not installed."
Copied!
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.

Challenge solve scripts

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
1
#!/bin/bash
2
set -euxo pipefail
3
4
echo "Installing cowsay..."
5
6
apt -y update
7
apt -y install cowsay
Copied!

Add a challenge check script

Check this topic for how to add a challenge check script:
🔎Lifecycle scripts
Instruqt Dev

Add a challenge solve script

Check this topic for how to add a challenge solve script:
🔎Lifecycle scripts
Instruqt Dev
Perfect! Your content keeps getting richer, making the learning experience more challenging for your learners.