true_or_false: Shortcuts for fixed-choice questions

Description Usage Arguments Details

View source: R/multiple_choice.R

Description

Shortcuts for fixed-choice questions

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
true_or_false(
  prompt,
  right_answer,
  message_right = "You got that right!",
  message_wrong = "Sorry, you missed.",
  points = NA,
  allow_retry = TRUE,
  show_answers = are_answers_on(),
  is_learnr = "learnr" %in% loadedNamespaces()
)

choose_one(
  prompt = "First consonant?",
  choices = list(a = "No, it's not", `+b+` = "Right as rain"),
  inline = TRUE,
  points = NA,
  show_answers = are_answers_on(),
  ...,
  random_answer_order = TRUE,
  allow_retry = TRUE,
  is_learnr = "learnr" %in% loadedNamespaces()
)

Arguments

prompt

Character string prompt for the question

points

Integer number of 'grade points' to associate with the question. Optional.

allow_retry

Logical flag to allow multiple submissions

is_learnr

Is the document being compiled for learnr. This is set automatically. Override it to FALSE if you want to see the question in ordinary markdown format.

choices

A character vector of the choices. Correct choices should be indicated by putting + before and after the text to be displayed to the student. (Remember that mixing numbers and character strings in a vector coerces all entries to character string, which is convenient here.)

inline

Logical flag. If true, lay out the choices horizontally.

random_answer_order

Logical flag to shuffle the order of choices when question is displayed.

Details

The functions true_or_false() and choose_one() are intermediaries to the learnr::question() and learnr::answer() functions. They provide a somewhat more concise way of describing the choices and appropriate feedback and they allow questions to be rendered in an ordinary Rmarkdown document without requiring the "shiny" elements of a learnr document.

When a etude file intended to be used with learnr is compiled on its own, it is setup for the learnr runtime and questions will render in learnr format. (Unless you manually override this with the is_learnr = FALSE option.) But when you include an etude file as a child of a mother document, using the include_etude() function typically, the questions will inherit the settings of that document, which might be an ordinary Rmd document directed to HTML or PDF or Word, etc.

Whether answers are displayed in the non-learnr static renderings depends on the argument show_answers. By default, this uses etude's system for turning on and off answers with the show_answers(TRUE) or show_answers(FALSE) command earlier in the document.


dtkaplan/etude documentation built on Oct. 19, 2020, 7:56 p.m.