Skip to content

Commit

Permalink
add options to question (#243)
Browse files Browse the repository at this point in the history
* add options to question

allows for extra options to be stored in a question object.  this will give a native way for extra values to be stored.

* add news item
  • Loading branch information
schloerke committed Jun 18, 2019
1 parent e41ee8b commit c96c872
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ learnr 0.10.0 (unreleased)

* Available tutorial names will be displayed when no `name` parameter or an incorrect `name` is provided to `run_tutorial()`. ([#234](https://github.com/rstudio/learnr/pull/234))

* The `options` parameter was added to `question` to allow custom questions to pass along custom information. See `sortable::sortable_question` for an example. ([#243](https://github.com/rstudio/learnr/pull/243))


## Bug fixes

* Fixed a spurious console warning when running exercises using Pandoc 2.0. ([#154](https://github.com/rstudio/learnr/issues/154))
Expand Down
10 changes: 8 additions & 2 deletions R/quiz.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
#' @param try_again_button Label for the try again button. Defaults to \code{"Submit Answer"}
#' @param allow_retry Allow retry for incorrect answers. Defaults to \code{FALSE}.
#' @param random_answer_order Display answers in a random order.
# TODO-barret link to sortable_question when sortable is added
#' @param options Extra options to be stored in the question object.
#' This is useful when using custom question types.
#' See sortable::sortable_question for an example question implementation that uses the \code{options} parameter.
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -129,7 +133,8 @@ question <- function(text,
submit_button = "Submit Answer",
try_again_button = "Try Again",
allow_retry = FALSE,
random_answer_order = FALSE
random_answer_order = FALSE,
options = list()
) {


Expand Down Expand Up @@ -200,7 +205,8 @@ question <- function(text,
),
loading = quiz_text(loading),
random_answer_order = random_answer_order,
allow_retry = allow_retry
allow_retry = allow_retry,
options = options
)
)
)
Expand Down
6 changes: 5 additions & 1 deletion man/quiz.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c96c872

Please sign in to comment.