These are options to be passed to a quiz
.
Usage
set_quiz_options(
ns = shiny::NS("quiz"),
messages,
sandbox = FALSE,
end_on_first_wrong = !sandbox,
class = NULL,
progress_bar = !sandbox,
progress_bar_color = "#609963",
question_heading = "Practice what you've learned",
include_question_title = TRUE,
...
)
create_messages(message_correct, message_wrong, message_skipped)
Arguments
- ns
namespace generated from
shiny::NS()
. When using custom namespaces, the individualcreate_question()
requires the namespace as well.- messages
an object of class
quizMessages
generated fromcreate_messages()
containing the messages to show at the end. If not provided, defaults are used.- sandbox
boolean. Quiz no longer ends of the first wrong, removes the progress bar, and grading does not include unattempted questions. Note that the presence of a random question automatically triggers sandbox mode. It can be overridden with
set_quiz_options(override = TRUE)
.- end_on_first_wrong
Should the quiz immediately end once the user gets one question wrong?
- class
string. A custom CSS class to add to the quiz div
- progress_bar
boolean. Show the progress bar UI at the top of the quiz
- progress_bar_color
Color code for the progress bar background
- question_heading
Default text to show above the question prompt.
- include_question_title
boolean. Should the text "Question #" be included above the prompt? If not included, the green check / red X will not be shown either.
- ...
other named options to pass to
quiz
- message_correct
a string to be shown at the end of the quiz when the user gets all questions correct
- message_wrong
a string to be shown at the end of the quiz when the user gets at least one question wrong
- message_skipped
a string to be shown at the end of the quiz when the user skips the quiz or ends it early
Functions
set_quiz_options()
: Sets the options for aquiz
create_messages()
: Create a messages object
Examples
# set the options when creating the quiz
quiz <- create_quiz(
create_question(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Select nulla.',
add_choice('auctor'),
add_choice('nulla', correct = TRUE)
),
create_question(
'Mauris congue aliquet dui, ut dapibus lorem porttitor sed. Select 600.',
add_choice('600', correct = TRUE),
add_choice('800')
),
options = set_quiz_options(sandbox = TRUE)
)
# or modify the options on a quiz object
quiz@options <- set_quiz_options(sandbox = FALSE)
# adjust the messages shown at the end of the quiz
messages <- create_messages(
'Congrats!',
'Ahh, bummer! Got at least one wrong',
'Looks like you skipped to the end!'
)
quiz@options <- set_quiz_options(messages = messages)