Lifecycle scripts

What are lifecycle scripts?

Lifecycle scripts execute inside of the sandbox environment to setup and tear down challenges, give your learners feedback on their solution, or to automatically solve a challenge.

It is common to write the scripts in Bash, but you can write them in any language supported on your environment.

Scripts types

There are four types of challenge lifecycle scripts:

And one track life cycle scripts:

You can also use lifecycle 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.

Script parameters

The Instruqt platform injects a set of parameters using environment variables into every script:

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. It is only present if the user accessed the track via an invite link.

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 *

INSTRUQT_PRIVACY_POLICY_CONSENT

Whether the user accepted the organization's privacy policy.

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