Numeric Answer Question
The numeric answer question resource creates questions that expect numerical responses. These questions support exact values, ranges, and precision validation for mathematical calculations and quantitative assessments.
HCL Syntax
Section titled “HCL Syntax”Basic Syntax
Section titled “Basic Syntax”resource "numeric_answer_question" "name" { question = "How many CPU cores does a t3.medium EC2 instance have?" answer = 2}
Full Syntax
Section titled “Full Syntax”resource "numeric_answer_question" "name" { question = "What is the default HTTP port for web servers?" answer = 80
hints = [ "This is a well-known port number", "Most web browsers use this port by default" ]
tags = ["networking", "http", "ports"]}
Fields
Section titled “Fields”Core Configuration
Section titled “Core Configuration”Field | Required | Type | Description |
---|---|---|---|
question | ✓ | string | The question text presented to participants |
answer | ✓ | number | The correct numerical answer |
hints | list(string) | Hints shown to participants when hints are enabled. Defaults to empty list. | |
tags | list(string) | Tags for categorizing and organizing questions. Defaults to empty list. |
Answer Validation
Section titled “Answer Validation”Numeric questions require participants to enter the exact value specified in the answer
field.
Examples
Section titled “Examples”Exact Value Question
Section titled “Exact Value Question”resource "numeric_answer_question" "kubernetes_port" { question = "What is the default port for the Kubernetes API server?" answer = 6443
tags = ["kubernetes", "networking", "api"]}
Memory Calculation Question
Section titled “Memory Calculation Question”resource "numeric_answer_question" "memory_calculation" { question = "How many gigabytes of RAM does a server with 8192 MB have? (Round to nearest whole number)" answer = 8
hints = [ "Convert megabytes to gigabytes", "1024 MB = 1 GB" ]
tags = ["memory", "calculations", "conversions"]}
Resource Calculation Question
Section titled “Resource Calculation Question”resource "numeric_answer_question" "pod_replicas" { question = "If you have 3 worker nodes and want to distribute 9 pod replicas evenly, how many pods per node?" answer = 3
tags = ["kubernetes", "scaling", "calculations"]}
Default Values
Section titled “Default Values”The following defaults are applied automatically:
resource "numeric_answer_question" "name" { hints = [] tags = []}
Validation Rules
Section titled “Validation Rules”- Number format: Answers must be valid integers or decimal numbers
- Exact match: Participant input must exactly match the specified answer value
- Input validation: Participant inputs are validated as numbers before comparison
Usage in Quizzes
Section titled “Usage in Quizzes”Numeric answer questions are referenced in quiz resources:
resource "quiz" "technical_calculations" { questions = [ resource.numeric_answer_question.kubernetes_port, resource.numeric_answer_question.memory_calculation, resource.numeric_answer_question.pod_replicas ]
show_hints = true attempts = 2}
Best Practices
Section titled “Best Practices”- Clear Units: Specify units in the question (MB, GB, seconds, etc.)
- Precise Values: Ensure the expected answer is clearly defined
- Context Clarity: Provide enough context for participants to understand what to calculate
- Realistic Numbers: Use practical values that participants might encounter
- Helpful Hints: Guide the calculation process without giving away the answer
- Educational Value: Use explanations to reinforce the underlying concepts
- Input Validation: Consider what formats participants might use (decimals, integers)
- Avoid Trick Questions: Focus on knowledge and understanding, not mathematical gotchas