question_parsons: Parsons problem question for learnr tutorials (experimental).

Description Usage Arguments Creating a parsons question Examples

View source: R/question_parsons.R

Description

Add Parsons Problem tasks to your learnr tutorials. The student can drag-and-drop the answer options into the desired order.

This is a highly experimental, initial attempt at making Parsons problems in learnr tutorials. Parsons problems is a type of programming assignment where the student must order statements in the correct order.

If the task also includes indentation of the statements, it's called a second-order Parsons problem. Note that second order problems have not yet been implemented.

Figure: Parsons submit state

Features (design choices):

Limitations:

Usage

1
2
3
4
5
6
7
question_parsons(initial, ..., problem_type = c("base", "ggplot2",
  "tidyverse"), orientation = c("horizontal", "vertical"),
  correct = "Correct!", incorrect = "Incorrect",
  try_again = incorrect, message = NULL, post_message = NULL,
  loading = c("Loading: "), submit_button = "Give feedback",
  try_again_button = "Try Again", allow_retry = TRUE,
  random_answer_order = TRUE, options = sortable_options())

Arguments

initial

Initial value of answer options. This must be a character vector.

...

One or more answers. Passed to learnr::question().

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 +.

orientation

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

correct

Text to print for a correct answer (defaults to "Correct!")

incorrect

Text to print for an incorrect answer (defaults to "Incorrect") when allow_retry is FALSE.

try_again

Text to print for an incorrect answer (defaults to "Incorrect") when allow_retry is TRUE.

message

Additional message to display along with correct/incorrect feedback. This message is always displayed after a question submission.

post_message

Additional message to display along with correct/incorrect feedback. If allow_retry is TRUE, this message will only be displayed after the correct submission. If allow_retry is FALSE, it will produce a second message alongside the message message value.

loading

Loading text to display as a placeholder while the question is loaded

submit_button

Label for the submit button. Defaults to "Submit Answer"

try_again_button

Label for the try again button. Defaults to "Submit Answer"

allow_retry

Allow retry for incorrect answers. Defaults to FALSE.

random_answer_order

Display answers in a random order.

options

Extra options to be stored in the question object.

Creating a parsons question

Use question_parsons inside a learnr tutorial chunk

For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
```{r iris}
question_parsons(
 initial = c(
  "iris",
  "mutate(...)",
  "summarize(...)",
  "print()"
 ),
 answer(c(
  "iris",
   "mutate(...)",
  "summarize(...)"
  ), correct = TRUE)
)
```

On initialization, the initial values are randomized:

Figure: Parsons initial state

As the student drags values to the right column, the magrittr gets appended, and items are automatically indented:

Figure: Parsons submit state

Examples

1
2
3
4
## Example of parsons problem inside a learn tutorial
if (interactive()) {
  learnr::run_tutorial("parsons", package = "parsons")
}

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