fitb: Create a fill-in-the-blank question

Description Usage Arguments Details Examples

View source: R/webex_fns.R

Description

Create a fill-in-the-blank question

Usage

1
2
3
4
5
6
7
8
9
fitb(
  answer,
  width = calculated_width,
  num = NULL,
  ignore_case = FALSE,
  tol = NULL,
  ignore_ws = TRUE,
  regex = FALSE
)

Arguments

answer

The correct answer (can be a vector if there is more than one correct answer).

width

Width of the input box in characters. Defaults to the length of the longest answer.

num

Whether the input is numeric, in which case allow for leading zeroes to be omitted. Determined from the answer data type if not specified.

ignore_case

Whether to ignore case (capitalization).

tol

The tolerance within which numeric answers will be accepted; i.e. if abs(response - true.answer) < tol, the answer is correct (implies num=TRUE).

ignore_ws

Whether to ignore whitespace.

regex

Whether to use regex to match answers (concatenates all answers with '|' before matching).

Details

Writes html code that creates an input box widget. Call this function inline in an RMarkdown document. See the Web Exercises RMarkdown template for examples of its use in RMarkdown.

Examples

1
2
3
4
5
6
7
8
# What is 2 + 2?
fitb(4, num = TRUE)

# What was the name of the Beatles drummer?
fitb(c("Ringo", "Ringo Starr"), ignore_case = TRUE)

# What is pi to three decimal places?
fitb(pi, num = TRUE, tol = .001)

Example output

[1] "<input class='solveme nospaces' size='1' data-answer='[\"4\"]'/>"
[1] "<input class='solveme nospaces ignorecase' size='11' data-answer='[\"Ringo\",\"Ringo Starr\"]'/>"
[1] "<input class='solveme nospaces' data-tol='0.001' size='16' data-answer='[\"3.14159265358979\"]'/>"

webex documentation built on June 10, 2021, 9:09 a.m.