Add a challenge to a track
Make your tracks interactive with challenges.
This guide explains how to add a challenge to a track from Web UI and Instruqt CLI.
A challenge is a task in a track that the learner has to solve. To the learner, a challenge has two screens:
The first screen is the Notes screen, and the second screen is the Assignment screen:
  • The Notes screen shows while the challenge is loading.
  • The Assignment screen is the hands-on part of a challenge, with a two-pane layout. The left pane lets the learner interact with the sandbox, and the right pane shows the assignment text.

Challenge definition

The challenges definition consist of the following parts:
  • Description The description defines several challenge settings and the assignment text:
    • Title
    • Slug
    • Type
    • Assignment This is the assignment text in Markdown. In general, you introduce the challenge here to the learner. And describe what is expected from the learner to solve the challenge.
    • Teaser
  • Notes Notes are displayed while a challenge is loading. And are meant to present learning content to the learner. Notes are great to give the learner some introduction. Or to provide background information about your software. You can add notes to a challenge in the following formats:
    • Text
    • Image
    • Video
    If you choose Text , you can enter your content in Markdown. If you choose Image or Video , you can enter the URL of the image or video.
  • Tabs Tabs define the components that the learner can work with inside a challenge. For example, a Shell terminal or a text editor. You can make the following tab types available:
    • Services
    • Terminals
    • Editors
    • Websites
    • External apps
  • Scripts Scripts execute automatically when specific challenge lifecycle actions occur, like starting a challenge. You use scripts to set up a challenge or check if the learner solved the challenge. You can add the following scripts for a challenge:
    • setup
    • check
    • solve
    • cleanup
    See the topics Add a script to check challenge execution and Lifecycle scripts for more information about scripts.

Before you begin

You must have already built a track to which you can add a challenge. Follow the guide Create a track from a template if needed.

Add a challenge

Pick the Web UI or the Instruqt CLI route depending on your preference:
🌐 Web UI
πŸ’» Instruqt CLI
  1. 1.
    Open your browser and go to play.instruqt.com. ↳ Instruqt shows your content.
  2. 2.
    Click the TRACK_NAME of the track you want to add a challenge to. ↳ Instruqt shows the corresponding Track overview page.
  3. 3.
    Click Add challenge.
  4. 4.
    In the Title field, enter your title for the new challenge.
  5. 5.
    In the Slug field, enter your slug.
  6. 6.
    In the Editor tab, enter your assignment text in Markdown. For example:
    1
    Step 1
    2
    ======
    3
    ​
    4
    Click "Explorer" > "NPM Scripts" to open the corresponding panel.
    5
    Run the "test" task from it.
    6
    ​
    7
    The tests should run, and you should see the failing one in the terminal panel.
    8
    ​
    9
    Step 2
    10
    ======
    11
    ​
    12
    Update the function in src/sum.ts to correctly return the sum.
    13
    At this point, you might want to re-run the tests to see whether the fix is helping.
    14
    ​
    15
    Check
    16
    =====
    17
    ​
    18
    To complete this track, press **Check**. It will run the tests and pass if all the tests are passing.
    Copied!
    Besides regular Markdown, Instruqt supports expandable sections inside the assignment text. You create an expandable section by:
    1. 1.
      Entering a section title: Step 1
    2. 2.
      Entering a string of = signs beneath the title: =====
    3. 3.
      Entering the section text: Click "Explorer" > "NPM Scripts" to...
  7. 7.
    In the Teaser field, enter your teaser for the new challenge.
  8. 8.
    Click Save to add the new challenge. ↳ Instruqt shows the Track overview page again.
  9. 9.
    Click Edit on the challenge you just added.
  10. 10.
    Click Notes, followed by New note to add a note that Instruqt shows to the learner before the challenge starts.
  11. 11.
    In the Editor tab, enter your note.
  12. 12.
    Notice the Markdown Cheat Sheet link for help on Markdown.
  13. 13.
    Click Save.
  14. 14.
    Click Tabs, followed by New tab to add a terminal to the challenge that the learner can work with.
  15. 15.
    In the Title field, enter Shell or any title you like.
  16. 16.
    In the Type list, select Terminal.
  17. 17.
    Click Save.
  18. 18.
    Click Back. ↳ Instruqt shows the Track overview page again and your challenge is ready to be played and tested.
  1. 1.
    Activate your track directory:
    1
    cd DIRECTORY_NAME
    Copied!
    ⇨ Replace DIRECTORY_NAME with your track directory.
  2. 2.
    Add a challenge to the track
    1
    instruqt challenge create --title "CHALLENGE_TITLE"
    Copied!
    ⇨ Replace CHALLENGE_TITLE with your title. ↳ Instruqt CLI creates a new subdirectory for the added challenge. The subdirectory's name is derived from the challenge title. For example, if the title is "How to create a Docker container", the subdirectory's name will be xx-how-to-create-a-docker-container . Where xx is the sequence number of the challenge within the track. Inside the subdirectory, you will find these configuration files:
    1
    β”œβ”€β”€ assignment.md
    2
    β”œβ”€β”€ check-container
    3
    β”œβ”€β”€ cleanup-container
    4
    β”œβ”€β”€ setup-container
    5
    └── solve-container
    Copied!
    assignment.md contains the challenge properties, notes, and the assignment text. The other files are script files that run at specific moments in the lifecycle of a challenge.

Finish the challenge

The added challenge only has a skeleton so far. To finish the challenge, you can set the challenge properties and enter the assignment text in the file assignment.md . This file contains a section with challenge properties and a section with the assignment text:
1
# Challenge properties (YAML)
2
---
3
slug: how-to-create-a-docker-container
4
id: zedez3ar9msm
5
type: challenge
6
title: How to create a Docker container
7
teaser: A short description of the challenge.
8
notes:
9
- type: text
10
contents: |-
11
Replace this text with your own text
12
which can span multiple lines by adding "|-"
13
in front of your text.
14
tabs:
15
- title: Shell
16
type: terminal
17
hostname: docker-vm
18
difficulty: basic
19
timelimit: 600
20
---
21
# Assignment text (Markdown)
22
​
23
​
Copied!
Multi-line note
Precede the text of your note in the contents property with |- for adding a multi-line text.

​

Change challenge properties

Take the following steps to change the challenge properties:
  1. 1.
    Open the file assignment.md in your editor.
  2. 2.
    Change the properties of your liking.
    For example:
    • Change property teaser to "Learn how to create a Docker container"
    • Change property tabs: title to "Terminal"
    • Change property notes: contents to:
      1
      # Learn about Docker
      2
      3
      In this challenge, you'll create a container.
      4
      Please wait while we boot a virtual machine for you.
      Copied!
    ​
    See the Challenges topic details about challenge properties.
    ​
  3. 3.
    Save the file assignment.md
  4. 4.
    Go to Instruqt CLI and deploy the updated track:
    1
    instruqt track push
    Copied!
    ​

Add the assignment text to the challenge

  1. 1.
    Open the file assignment.md in your editor.
  2. 2.
    Enter your assignment text in Markdown in the Assingment text section .
    For example:
    1
    πŸ§ͺ Creating a Docker container
    2
    =======================
    3
    ​
    4
    Use this command to build a Docker container:
    5
    ​
    6
    ```
    7
    docker build -t my-service .
    8
    ```
    9
    ​
    10
    🏁 Finish
    11
    =========
    12
    ​
    13
    To complete the
    14
    challenge, press **Check**."
    Copied!
    ​
  3. 3.
    Save the file assignment.md
  4. 4.
    Go to Instruqt CLI and deploy the updated track:
    1
    instruqt track push
    Copied!
    ↳ The track with the new challenge is ready to play and test now.
Delete a challenge
To delete a challenge:
  1. 1.
    Open your browser and go to play.instruqt.com. ↳ Instruqt shows your My content page.
  2. 2.
    Click the track from which you want to delete a challenge.
  3. 3.
    Click Edit on the challenge that you want to delete. ↳ The Update challenge page opens.
  4. 4.
    Click Delete this challenge. ↳ A confirmation pop-up opens.
  5. 5.
    Click OK.
Nice work! Play your track to see if everything works the way you want.