View source: R/question_numeric.R
question_numeric | R Documentation |
Creates a tutorial question asking the student to submit a number.
question_numeric(
text,
...,
correct = "Correct!",
incorrect = "Incorrect",
try_again = incorrect,
allow_retry = FALSE,
value = NULL,
min = NA,
max = NA,
step = NA,
options = list(),
tolerance = 1.5e-08
)
text |
Question or option text |
... |
Answers created with |
correct |
For |
incorrect |
Text to print for an incorrect answer (defaults to
"Incorrect") when |
try_again |
Text to print for an incorrect answer (defaults to
"Incorrect") when |
allow_retry |
Allow retry for incorrect answers. Defaults to |
value |
Initial value. |
min |
Minimum allowed value |
max |
Maximum allowed value |
step |
Interval to use when stepping between min and max |
options |
Extra options to be stored in the question object. This is
useful when using custom question types. See |
tolerance |
Submitted values within an absolute difference less than or
equal to |
Returns a learnr question of type "learnr_numeric"
.
Other Interactive Questions:
question_checkbox()
,
question_radio()
,
question_text()
,
quiz()
question_numeric(
"What is pi rounded to 2 digits?",
answer(3, message = "Don't forget to use the digits argument"),
answer(3.1, message = "Too few digits"),
answer(3.142, message = "Too many digits"),
answer(3.14, correct = TRUE),
allow_retry = TRUE,
min = 3,
max = 4,
step = 0.01
)
question_numeric(
"Can you think of an even number?",
answer_fn(function(value) {
if (value %% 2 == 0) {
correct("even")
} else if (value %% 2 == 1) {
incorrect("odd")
}
}, label = "Is the number even?"),
step = 1
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.