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.
Use Cases
Section titled “Use Cases”As a lab author, you use numeric answer questions to assess quantitative knowledge:
- Configuration Values: Assess knowledge of specific numeric settings, ports, timeouts, or limits in system configurations
- Resource Calculations: Test understanding of resource requirements, capacity planning, or performance calculations
- Technical Specifications: Evaluate recall of specific numeric values from documentation, standards, or best practices
Numeric answer questions provide precise assessment of quantitative technical knowledge and calculation abilities.
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
| Field | Type | Required | Description |
|---|---|---|---|
question | string | ✓ | The question that learners will answer |
answer | number | ✓ | The correct numeric answer |
exact | bool | — | Enable for exact numeric matching, disable for approximate matching with tolerance Default true |
hints | list(string) | — | Optional hints that can be revealed to help learners |
tags | list(string) | — | Optional tags for organizing and filtering questions |
Answer Validation
Section titled “Answer Validation”Numeric questions require users 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"]}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 users to understand what to calculate
- Realistic Numbers: Use practical values that users 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 users might use (decimals, integers)
- Avoid Trick Questions: Focus on knowledge and understanding, not mathematical gotchas
