set_quiz_options {shinyquiz} | R Documentation |
Set the options for the quiz
Description
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",
...
)
create_messages(message_correct, message_wrong, message_skipped)
Arguments
ns |
namespace generated from |
messages |
an object of class |
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 |
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 |
... |
other named options to pass to |
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 |
Value
a list
an object of class quizMessages
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)