Life cycle scripts

What are life cycle scripts?

Life cycle scripts are used to interact with the environment of a student, and to run commands on certain events while a student plays your track. Scripts are responsible for:

  • ​Setting up the scenario your students will follow, by configuring applications and starting services.

  • ​Checking the student's work, and providing feedback to student on their progress.

  • Clean up resources when the student has completed a challenge or track.

  • Enabling automated tests for your content by solving challenges.

You typically write scripts in Bash, but you can write them in any language supported on your environment.

You can also use life cycle scripts to publish events to external systems. For example, you can publish an event when a user starts a track. Use the script parameters to correlate these events with data in your own systems.

Scripts types

There are four types of challenge life cycle scripts:

And one track life cycle scripts:

​

Script parameters

The Instruqt platform injects a set of parameters, through environment variables, into every script. The following environment variables are available:

Environment Variable

Description

INSTRUQT_TRACK_ID

The ID of the track

INSTRUQT_CHALLENGE_ID

The ID of the challenge that the script is running on. This can be empty, in case of a track cleanup script.

INSTRUQT_PARTICIPANT_ID

The ID of the participant. This value is guaranteed to be unique for every play of a track, i.e. when a user starts the same track twice, the IDs will differ.

INSTRUQT_TRACK_INVITE_ID

The ID of the track invite. Will only be present if the user got access to the track via an invite.

INSTRUQT_USER_ID

The ID of the user. This value uniquely identifies a user. This value can be empty, in case a script is run as part of a pooled instance.

INSTRUQT_USER_NAME

The full name of the user (as they have entered it when creating their account). *

INSTRUQT_USER_EMAIL

The email address of the user *

* This value will only be present if the user has given consent to share their details. For example, when a student started a track through a track invite.