Use the parsons
package to create Parsons problems for teaching progamming. You can create custom questions in your learnr
tutorials.
You can install the released version of parsons from CRAN with:
And the development version from GitHub with:
A Parsons problem is a specific type of question, useful for teaching programming, where all the lines of code are given, but the student must provide the correct order.
The parsons()
function has experimental support for parsons problems.
You can add a parsons problem to a learnr
tutorial with the question_parsons()
function:
question_parsons(
initial = c(
"iris",
"mutate(...)",
"summarize(...)",
"print()"
),
pass_if(
c(
"iris",
"mutate(...)",
"summarize(...)"
)
),
fail_if(
~length(.) < 2,
message = "Include at least two answers"
),
fail_if(
function(x){"print()" %in% x},
message = "You should not include print() in your answer"
),
fail_if(
~{.[1] != "iris"},
message = "Your solution should start with 'iris'"
)
)