R/question_parsons.R
question_parsons.Rd
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.
Features (design choices):
Items (except the last) in the right hand column will have a %>%
appended.
Items (except the first) in the right hand column will automatically be indented.
The initial values are shuffled into random answer order.
Limitations:
It does not do any code evaluation
It does not support indentation
It assumes code is from the tidyverse
and only supports the magrittr
pipe %>%
operator
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())
initial | Initial value of answer options. This must be a character vector. |
---|---|
... | One or more answers. Passed to |
problem_type | One of |
orientation | Either |
correct | Text to print for a correct answer (defaults to "Correct!") |
incorrect | Text to print for an incorrect answer (defaults to "Incorrect")
when |
try_again | Text to print for an incorrect answer (defaults to "Incorrect")
when |
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 |
loading | Loading text to display as a placeholder while the question is loaded |
submit_button | Label for the submit button. Defaults to |
try_again_button | Label for the try again button. Defaults to |
allow_retry | Allow retry for incorrect answers. Defaults to |
random_answer_order | Display answers in a random order. |
options | Extra options to be stored in the question object. |
Use question_parsons
inside a learnr
tutorial chunk
For example:
```{r iris} question_parsons( initial = c( "iris", "mutate(...)", "summarize(...)", "print()" ), answer(c( "iris", "mutate(...)", "summarize(...)" ), correct = TRUE) ) ```
On initialization, the initial values are randomized:
As the student drags values to the right column, the magrittr
gets
appended, and items are automatically indented:
## Example of parsons problem inside a learn tutorial if (interactive()) { learnr::run_tutorial("parsons", package = "parsons") }