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.
Use Cases
Section titled “Use Cases”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.
HCL Syntax
Section titled “HCL Syntax”Basic Syntax
Section titled “Basic Syntax”resource "quiz" "name" { questions = [ resource.single_choice_question.question1, resource.multiple_choice_question.question2 ]}
Full Syntax
Section titled “Full Syntax”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}
Fields
Section titled “Fields”Core Configuration
Section titled “Core Configuration”Field | Required | Type | Description |
---|---|---|---|
questions | ✓ | list(reference to single_ , multiple_ , text_ , numeric_ ) | List of question resources for the quiz |
show_ | bool | Whether to show hints to users. Defaults to false. | |
show_ | bool | Whether to show correct answers after completion. Defaults to false. | |
attempts | number | Maximum number of attempts allowed. Defaults to -1 (unlimited). |
Supported Question Types
Section titled “Supported Question Types”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 |
Validation Rules
Section titled “Validation Rules”- 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
Default Values
Section titled “Default Values”The following defaults are applied automatically:
resource "quiz" "name" { show_hints = false show_answers = false attempts = -1 # Unlimited attempts}
Examples
Section titled “Examples”Basic Knowledge Check
Section titled “Basic Knowledge Check”resource "quiz" "docker_basics" { questions = [ resource.single_choice_question.what_is_docker, resource.multiple_choice_question.docker_benefits ]}
Comprehensive Assessment
Section titled “Comprehensive Assessment”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}
Practice Quiz with Hints
Section titled “Practice Quiz with Hints”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}
Mixed Question Types
Section titled “Mixed Question Types”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}
Usage in Pages
Section titled “Usage in Pages”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>
Question Flow
Section titled “Question Flow”- Presentation: Questions are shown in the order specified
- Interaction: Participants select/enter answers
- Hints: Available if
show_hints = true
- Submission: Answers are validated
- Results: Feedback provided based on configuration
- Retry: Additional attempts if available and needed
Best Practices
Section titled “Best Practices”- Question Variety: Mix different question types for comprehensive assessment
- Logical Order: Arrange questions from basic to advanced concepts
- Appropriate Attempts: Use 2-3 attempts for assessments, unlimited for practice
- Hint Usage: Enable hints for learning-focused quizzes, disable for formal assessments
- Answer Visibility: Show answers for practice, hide for formal evaluations
- Question Quality: Write clear, unambiguous questions with meaningful distractors
- Content Alignment: Ensure questions align with the instructional content