View source: R/question_text.R
question_text | R Documentation |
Creates a tutorial question asking the student to enter text. The default
text input is appropriate for short or single-line text entry. For longer
text input, set the rows
and/or cols
argument to create a larger text
area.
When used with answer()
, the student's submission must match the answer
exactly, minus whitespace trimming if enabled with trim = TRUE
. For more
complicated submission evaluation, use answer_fn()
to provide a function
that checks the student's submission. For example, you could provide a
function that evaluates the user's submission using
regular expressions.
question_text(
text,
...,
correct = "Correct!",
incorrect = "Incorrect",
try_again = incorrect,
allow_retry = FALSE,
random_answer_order = FALSE,
placeholder = "Enter answer here...",
trim = TRUE,
rows = NULL,
cols = NULL,
options = list()
)
Returns a learnr question of type "learnr_text"
.
Other Interactive Questions:
question_checkbox()
,
question_numeric()
,
question_radio()
,
quiz()
question_text(
"Please enter the word 'C0rrect' below:",
answer("correct", message = "Don't forget to capitalize"),
answer("c0rrect", message = "Don't forget to capitalize"),
answer("Correct", message = "Is it really an 'o'?"),
answer("C0rrect ", message = "Make sure you do not have a trailing space"),
answer("C0rrect", correct = TRUE),
allow_retry = TRUE,
trim = FALSE
)
# This question uses an answer_fn() to give a hint when we think the
# student is on the right track but hasn't found the value yet.
question_text(
"What's the most popular programming interview question?",
answer("fizz buzz", correct = TRUE, "That's right!"),
answer_fn(function(value) {
if (grepl("(fi|bu)zz", value)) {
incorrect("You're on the right track!")
}
}, label = "fizz or buzz")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.