Variably Display Instructions
    • 10 Sep 2024
    • 7 Minutes to read

    Variably Display Instructions


    Article summary

    Lab Instructions have a function to allow showing and hiding of lab instructions and lab instruction elements. This is done by setting a lab Variable and then using that lab variable in the lab instructions. This also works in conjunction with labs that use instructions stored in an external repository and displayed in the lab instructions using a Markdown Include - this allows the lab instructions to be displayed dynamically based on the variable in the lab instructions. Additionally, the variable can be selected with an API launch. This allows the lab to show specific content when the lab launches.

    There are two requirements for enabling these features:

    Setting Variables

    The lab variable can be set multiple ways, but only needs to be set once in order to be used in lab instructions. The following methods can be used to set a lab variable:

    Life Cycle Actions (LCA)

    Set the lab variable in an LCA when the virtual machine or cloud environment are in the First Displayable or Resumed event.

    1. On the lab profile, select Edit.

    2. Go to the Life Cycle Actions tab.

    3. Select Add Life Cycle Action.

    4. Select the Action drop-down, then select Execute Script in Virtual Machine, Execute Script in Cloud Platform or Execute Script in Container.

    5. Select the Event drop-down, then select First Displayable or Resumed. This will set the variable in lab when the VM or Cloud environment is first displayed to the user or resumed by the user.

    6. Select the Command Type drop-down and select PowerShell.

    7. For the Command, enter: Set-LabVariable -Name variableName -Value variableValue.

    8. Replace variableName with the name you wish to use for the variable.

    9. Replace variableValue with the value you wish to use for the variable.

    10. Configure the lab instructions to show items based on the variable, by configuring one of the options below.

    For more information about LCAs, see our Life Cycle Action documentation.

    Activity Based Assessments (ABA)

    Set the lab variable in an ABA activity when the user selects the button for the activity in the lab instructions.

    1. On the lab profile, select Edit Instructions.

    2. Select the Activities menu (lightning bolt icon) at the top of the window.

    3. Select New Automated Activity

    4. Enter a name for the activity in the Name field.

    5. Enter instructions in the Instructions field.

    6. Configure the Correct Answer and Incorrect Answer feedback fields.

    7. In the script section, select the Target drop-down and select VM or Cloud subscription you wish to target with the script.

    8. In the Language drop-down menu, select PowerShell. Other options can be used, but this documentation uses PowerShell for demonstration.

    9. For the script, enter: Set-LabVariable -Name variableName -Value variableValue.

    10. Replace variableName with the name you wish to use for the variable.

    11. Replace variableValue with the value you wish to use for the variable.

    12. Configure the lab instructions to show items based on the variable, by configuring one of the options below.

    For more information about ABA, see our Activity Based Assessments documentation.

    Textbox

    Show lab instructions based on text a user enters into a textbox.

    When a user enters text (variable value) into the textbox, any lab instructions or instruction elements that use that variable name will be shown. If a user enters text that does not correspond with a variable name, no lab instructions will be shown based on the user's input.

    It is recommended to provide the variable values in the lab instructions, so that lab users can enter a variable value that corresponds to a variable name.

    1. From the lab profile, select Edit Instructions.

    2. Select the @lab menu and choose @lab.TextBox(name)

    3. Insert this into the section of the lab instructions where you want the drop-down menu to appear.

    4. Replace name with the name you wish to use for the variable name.

    5. When a user enters text (variable value) into the text box, any lab instructions or instruction elements that use that variable name will be shown.

    Drop-down Menu

    Set the lab variable by configuring values in a drop-down menu. The variable is used when a lab user selects one of the options in a drop-down menu.

    1. From the lab profile, select Edit Instructions.

    2. Select the @lab menu and choose @lab.DropDownList(name)[val1,val2]

    3. Insert this into the section of the lab instructions where you want the drop-down menu to appear.

    4. Replace name with the name you wish to use for the variable.

    5. Replace val1 and val2 with variable values. Additional values can be added if needed.

    6. Configure the lab instructions to show or hide items based on the variable, by configuring one of the options below.

    Lab Variables Menu

    1. From the lab profile, select Edit Instructions.

    2. Select the @lab menu and select the Variables tab at the top of the window.

    3. Enter a Name that you wish to use for the variableName.

    4. Enter a Value that you wish to use for the variableValue.

    5. The lab token is generated to the right of the Value field. Copy the token and paste into lab instructions or select Insert, to insert it at the current cursor position in the lab instructions.

    6. Configure the lab instructions to show or hide items based on the variable, by configuring one of the options below.

    Using Variables in a Lab

    Lab instructions and elements can be shown by using the lab variable in the lab instructions. The following methods can use a lab variable that is set by any of the methods above:

    Sections

    Create a section of lab instructions and IDLx elements so they can be called on as one, using the lab variable. Sections are hidden by default and are only shown when a lab variable is set that calls on the section.

    1. From the lab profile, select Edit Instructions.

    2. Enter the following Markdown syntax:

      :::sectionName(variableName=variableValue)
      lab instructions or markdown elements
      :::

    3. Replace sectionName with the name you wish to use for the section.

    4. Replace variableName with the name of the variable you wish to use in the Section.

    5. Replace variableValue with the value paired with the variable you wish to use.

    6. Enter any lab instructions or markdown elements in the Section.

    7. If a lab variable is set in the lab, that matches the variableName and variableValue of the section, it will be shown. Otherwise, the section will be hidden.

    Textbox

    Show lab instructions based on text a user enters into a textbox. The user will enter text (variable value) into the text box that corresponds with a variable name/variable value that was set using one of the methods above and any lab instructions or instruction elements that use that variable name will be shown.

    It is recommended to provide the variable values in the lab instructions, so that lab users can enter a variable value that corresponds to a variable name. If a user enters text that does not correspond with a variable name, no lab instructions will be shown based on the user's input.

    1. From the lab profile, select Edit Instructions.

    2. Select the @lab menu and choose @lab.TextBox(yourVariableNameHere).

    3. Insert this into the section of the lab instructions where you want the drop-down menu to appear.

    4. When a user enters text (variableValue) into the text box, any lab instructions or instruction elements that use that variable name will be shown.

    Drop-down Menu

    Display a drop-down menu in lab instructions, where users can select an option. The options shown in the drop-down menu are variable values that were configured when the drop-down was created in the previous section.

    1. From the lab profile, select Edit Instructions.

    2. Select the @lab menu and choose token for the drop-down menu you created. If you created multiple drop-down menus, they will be listed here.

    3. Insert this into the section of the lab instructions where you want the drop-down menu to appear.

    Dynamic Includes From an External Repository

    Lab instructions can be dynamically displayed based on the variable set in the lab and the variable value appended to the file name in the external repository.

    1. From the lab profile, select Edit Instructions.

    2. If the lab variable is not already set in your lab, use one of the methods above to set a lab variable.

    3. In the lab instructions, enter a Markdown include with a lab variable appended:
      !instructions[](url-@lab.Variable(variableName).md)

    4. Replace url with the URL to the raw file in your external repository.

    5. Replace variableName with the name of the variable you wish to use.

    6. Choose an option:

      • Insert a drop-down menu or textbox is the lab instructions that corresponds to the variable. These can be found in the @lab menu at the top of the window.

      • Assemble a Launch Command URL with the lab variable appended, to launch a lab with lab instructions displayed based on the variable value appended.

    Example

    External repository file name:
    sample1-en.md.
    Include syntax with variable in file name:
    !instructions[](https://raw.githubusercontent.com/user1/sample1-@lab.Variable(language).md)
    In this example, the variable value is en and the variable name is language.

    API Launch

    Launch a lab using the Launch API command to launch a lab for a specified user and use a lab variable in the URL as a parameter.

    1. Assemble the URL for the API command: https://labondemand.com/api/v3/launch?labid=100&userid=555&firstname=Joe&lastname=Smith&email=joe.smith@email.com&variableName=variableValue.

    2. Replace information in the URL with the lab and student information; lab ID, user ID, first name, last name and email address.

    3. Replace variableName with the name of the variable you wish to use.

    4. Replace variableValue with the value of the variable you wish to use.

    For more information about the Launch command, see our Launch command API documentation.


    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.