Skip to content

Quiz

The quiz resource creates interactive knowledge assessments with multiple question types. Users must answer questions correctly to complete the quiz, with configurable attempts, hints, and answer visibility.

As a lab author, you use quizzes to assess and reinforce learning:

  • Knowledge Assessment: Evaluate user understanding of concepts, procedures, and technical knowledge covered in the lab
  • Learning Reinforcement: Help users consolidate their learning through active recall and application of concepts
  • Progress Checkpoints: Create assessment points throughout the lab to verify comprehension before moving forward

Quizzes transform passive reading into active learning experiences that improve knowledge retention and skill development.

resource "quiz" "name" {
questions = [
resource.single_choice_question.question1,
resource.multiple_choice_question.question2
]
}
resource "quiz" "name" {
questions = [
resource.single_choice_question.basics,
resource.multiple_choice_question.concepts,
resource.text_answer_question.short_answer,
resource.numeric_answer_question.calculation
]
show_hints = true
show_answers = false
attempts = 3
}

quiz

FieldRequiredTypeDescription
questionslist(reference to single_choice_question, multiple_choice_question, text_answer_question, numeric_answer_question)List of question resources for the quiz
show_hintsboolWhether to show hints to users. Defaults to false.
show_answersboolWhether to show correct answers after completion. Defaults to false.
attemptsnumberMaximum number of attempts allowed. Defaults to -1 (unlimited).

The quiz can include any combination of these question types:

Question Type Reference Description
Single Choice resource.single_choice_question.name One correct answer from multiple options
Multiple Choice resource.multiple_choice_question.name Multiple correct answers from options
Text Answer resource.text_answer_question.name Free-form text response
Numeric Answer resource.numeric_answer_question.name Numerical response with optional precision
  • Questions: Must reference valid question resources
  • Attempts: Must be greater than 0 or -1 for unlimited attempts
  • Question order: Questions are presented in the order specified in the array

The following defaults are applied automatically:

resource "quiz" "name" {
show_hints = false
show_answers = false
attempts = -1 # Unlimited attempts
}
resource "quiz" "docker_basics" {
questions = [
resource.single_choice_question.what_is_docker,
resource.multiple_choice_question.docker_benefits
]
}
resource "quiz" "final_exam" {
questions = [
resource.single_choice_question.concepts,
resource.multiple_choice_question.best_practices,
resource.text_answer_question.explain_process,
resource.numeric_answer_question.calculate_resources
]
show_hints = false
show_answers = true
attempts = 2
}
resource "quiz" "practice_session" {
questions = [
resource.single_choice_question.easy_question,
resource.multiple_choice_question.medium_question,
resource.text_answer_question.hard_question
]
show_hints = true
show_answers = true
attempts = -1 # Unlimited attempts for practice
}
resource "quiz" "comprehensive_test" {
questions = [
resource.single_choice_question.theory_basics,
resource.multiple_choice_question.practical_applications,
resource.text_answer_question.describe_workflow,
resource.numeric_answer_question.calculate_capacity,
resource.single_choice_question.troubleshooting
]
show_hints = false
show_answers = false
attempts = 3
}

Quizzes must be referenced in instruction pages using the activities map and <instruqt-quiz> component:

resource "page" "assessment" {
title = "Knowledge Assessment"
file = "instructions/chapter2/assessment.md"
activities = {
final_quiz = resource.quiz.docker_basics
}
}

Then in your markdown file:

## Test Your Knowledge
<instruqt-quiz id="final_quiz"></instruqt-quiz>
  1. Presentation: Questions are shown in the order specified
  2. Interaction: Participants select/enter answers
  3. Hints: Available if show_hints = true
  4. Submission: Answers are validated
  5. Results: Feedback provided based on configuration
  6. Retry: Additional attempts if available and needed
  1. Question Variety: Mix different question types for comprehensive assessment
  2. Logical Order: Arrange questions from basic to advanced concepts
  3. Appropriate Attempts: Use 2-3 attempts for assessments, unlimited for practice
  4. Hint Usage: Enable hints for learning-focused quizzes, disable for formal assessments
  5. Answer Visibility: Show answers for practice, hide for formal evaluations
  6. Question Quality: Write clear, unambiguous questions with meaningful distractors
  7. Content Alignment: Ensure questions align with the instructional content