Learn R Programming

shinyquiz (version 0.0.1)

add_choice: Add choices to a quiz question

Description

Add a choice to a quiz question. Used in conjunction with create_question() to generate a question.

Usage

add_choice(text, correct = FALSE)

add_numeric(correct)

add_slider(min = 0, max = 1, default_position = 0.5, correct)

add_text(correct, exact = FALSE)

Value

an object of class 'quizChoice'

an object of class 'quizChoiceNumeric'

an object of class 'quizChoiceSlider'

an object of class 'quizChoiceText'

Arguments

text

Text of the choice answer

correct

Boolean denoting if this choice is correct; numeric for slider or numeric

min

the minimum value of the slider range

max

the maximum value of the slider range

default_position

the default value the slider should take

exact

Boolean denoting if the grader should use exact matching. If FALSE, the user's answer will be compared to the correct answer after trimming whitespace, converting to lower case, and normalizing diacritics. If you wish to use your own normalizing function, please see create_question_raw().

Functions

  • add_choice(): Create a discrete choice

  • add_numeric(): Create a numeric choice

  • add_slider(): Create a slider choice

  • add_text(): Create a free text choice

Author

Joseph Marlo

George Perrett

See Also

create_question()

Examples

Run this code
add_choice('39')
add_choice('39', TRUE)
add_slider(0, 1, 0.5, 0.8)
add_text('Correct answer')

q <- create_question(
 'My question prompt',
 add_choice('39'),
 add_choice('41', TRUE)
)

q1_fuzzy <- create_question('My Label', add_text(correct = ' hEllo'))
q1_fuzzy@grader('Héllo ')
q1_exact <- create_question('My Label', add_text(correct = 'hEllo', exact = TRUE))
q1_exact@grader('Héllo ')

Run the code above in your browser using DataLab