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)
Arguments
- text
Text of the choice answer
- correct
Boolean denoting if this
choice
is correct; numeric forslider
ornumeric
- 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()
.
Value
an object of class 'quizChoice'
an object of class 'quizChoiceNumeric'
an object of class 'quizChoiceSlider'
an object of class 'quizChoiceText'
Functions
add_choice()
: Create a discrete choiceadd_numeric()
: Create a numeric choiceadd_slider()
: Create a slider choiceadd_text()
: Create a free text choice
Examples
add_choice('39')
#> An object of class "quizChoice"
#> Slot "text":
#> [1] "39"
#>
#> Slot "correct":
#> [1] FALSE
#>
add_choice('39', TRUE)
#> An object of class "quizChoice"
#> Slot "text":
#> [1] "39"
#>
#> Slot "correct":
#> [1] TRUE
#>
add_slider(0, 1, 0.5, 0.8)
#> An object of class "quizChoiceSlider"
#> Slot "min":
#> [1] 0
#>
#> Slot "max":
#> [1] 1
#>
#> Slot "default":
#> [1] 0.5
#>
#> Slot "correct":
#> [1] 0.8
#>
add_text('Correct answer')
#> An object of class "quizChoiceText"
#> Slot "correct":
#> [1] "Correct answer"
#>
#> Slot "exact":
#> [1] FALSE
#>
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 ')
#> [1] TRUE
q1_exact <- create_question('My Label', add_text(correct = 'hEllo', exact = TRUE))
q1_exact@grader('Héllo ')
#> [1] FALSE