parsons_problem: Create a parsons problem (experimental).

Description Usage Arguments References Examples

View source: R/parsons_problem.R

Description

This function implements the parsons problem, as exposed by question_parsons(). Most users will only use this function inside a learnr tutorial, so please see the documentation at question_parsons()

Usage

1
2
3
4
5
6
parsons_problem(initial, text = c("Drag from here",
  "Construct your solution here"), header = NULL, input_id, group_name,
  problem_type = c("base", "ggplot2", "tidyverse"),
  class = "default-sortable default-parsons",
  options = sortable_options(), orientation = c("horizontal",
  "vertical"))

Arguments

initial

Vector with initial values for problem (to appear in left column). Note: this must be a super-set of all answers.

text

Vector of headings for each column.

header

Text that appears at the top of the bucket list. (This is encoded as an HTML <p> tag, so not strictly speaking a header.)

input_id

Character vector of input_id to pass (individually) to rank_list().

group_name

Passed to SortableJS as the group name. Also the input value set in Shiny. (input[[group_name]])

problem_type

One of base, ggplot2 or tidyverse, indicating the type of problem statement. For tidyverse, the resulting answer will automatically append a %>% at the end of each answer, and for ggplot2 every line will be followed by a +.

class

A css class applied to the rank list. This can be used to define custom styling.

options

Options to be supplied to sortable_js object. See sortable_options for more details

orientation

Either horizontal or vertical, and specifies the layout of the components on the page.

References

https://js-parsons.github.io/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## Example of a shiny app
if (interactive()) {
  app <- system.file("shiny-examples/parsons_app.R", package = "parsons")
  shiny::runApp(app)
}
## -- example-parsons -----------------------------------------------------

## Parson's problem

parsons_problem(
  header = "This is an example of a Parsons problem",
  text = c("Drag from here", "Construct your solution here"),
  initial = c(
      "iris",
      "mutate(...)",
      "summarize(...)",
      "print()"
  ),
  input_id = "input_parsons"
)


parsons_problem(
  initial = c(
    "iris",
    "mutate(...)",
    "summarize(...)",
    "print()"
  ),
  input_id = "input_parsons"
)

rstudio/parsons documentation built on Nov. 5, 2019, 4:17 a.m.