learnr is an open source package for R that extends R markdown documents into interactive tutorials. learnr implements code chunks termed exercises that allow users to execute R code and see its results. Use this tag for questions regarding exercise setup, creation of interactive tutorial questions, and grading of exercise answers.
Questions tagged [learnr]
42 questions
5
votes
0 answers
Resetting quizzes in the R package learnr
I am developing an interactive quiz using the learnr package and Shiny and have noticed that once I select a response to a question, the package corrects my answer but I'm unable to reset the question to the default, restarting the R session doesn't…

Rodney Beard
- 89
- 9
4
votes
2 answers
Line break or soft break after paste
I have this dataframe:
df <- structure(list(letters = c("A", "B", "C", "D"), Number = 1:4,
Info = c("additionalinfo", "additionalinfo", "additionalinfo",
"additionalinfo")), class = "data.frame", row.names = c("1",
"2", "3", "4"))
…

TarJae
- 72,363
- 6
- 19
- 66
3
votes
0 answers
custom css is not working in learnr tutorial
I would like to use custom css in my learnr tutorial.
This is how I placed my css.
The location of my rmd file: testing/testing.Rmd
The location of css file: testing/css/custom.css
---
title: "Hello, Tutorial!"
output:
learnr::tutorial:
css:…

user2360397
- 31
- 4
3
votes
1 answer
Using R/Markdown fails inside learnr question
Motivation: I want to write an interface that uses questions from the R package exams in learnr questions/quizzes. In R/exams each question is either an R/Markdown (Rmd) or R/LaTeX (Rnw) file with a certain structure specifying question, solution,…

Achim Zeileis
- 15,710
- 1
- 39
- 49
3
votes
1 answer
Set number of attempts for learnr:tutorial question before moving on to the next question?
I am creating a homework problem with learnr:tutorial. I want to give the students 3 attempts to solve the problem before moving to the next section. I have progressive: true and allow_skip: false
But at the moment, there is unlimited try again and…

Maral Dorri
- 468
- 5
- 17
3
votes
2 answers
learnr: How to invalidate stored worked locally by changing ID and version?
I am developing tutorials with the learnr package. During the iterative testing process, I would need to invalidate the tutorial file.
I followed the explanation from Preserving Work, added ID and version to the yaml header.
But whenever I changed…

petzi
- 1,430
- 1
- 17
- 32
2
votes
1 answer
Fail to run "learnr_questions.Rmd" from exams2learnr
I tried to run the example file "learnr_questions.Rmd" that comes as an example in exams2learnr package. The chunk:
exams2learnr("swisscapital.Rmd", allow_retry = TRUE, incorrect = "Incorrect, try again.")
generates "Invalid 'definition' argument"…

Eduardo-Uresti
- 57
- 3
2
votes
1 answer
what is the rsconnect command to deploy a learnr site?
I have a simple one-page learnr site containing several quizzes. It works fine and deploys fine when I press the Deploy ("Publish the application") button in rstudio IDE. I would like to be able to do this programmatically. I have tried commands…

Steve Powell
- 1,646
- 16
- 26
2
votes
2 answers
Create an open ended question with learnr:tutorial in r
I want to allow students to input their student ID at the beginning of every quiz they take. There are no correct answers as long as they input a 7 digit number. This is what I have right now but the function does not run when the defined answers…

Maral Dorri
- 468
- 5
- 17
2
votes
1 answer
Programmatically create a question_text with multiple answers in r learnr:tutorial
I have the following code with 4 correct answers. I want the students to input all 4 of them. Instead of defining 24 permutations of the answers, I want 4 field boxes that would only accept an answer once.
question_text(
"Input all paths:",
…

Maral Dorri
- 468
- 5
- 17
2
votes
1 answer
Is there a way to import questions and answers from a spreadsheet into a learnr quiz?
I am new to R so thank you in advance for your patience.
I would like to create a multiple choice quiz in R using the learnr package (the quiz content is not about r code). I have all of the questions, response options, and correct answers in a…

stefcorrect
- 23
- 3
2
votes
2 answers
Is there a way to use common css in learnr tutorials?
In the learnr R package, one suggestion for distribution is to bundle up tutorials into a package. However, to include custom css for a tutorial, it seems to require putting your .css file inside the unique subdirectory associated with each tutorial…

Daniel McDonald
- 41
- 2
2
votes
0 answers
Change language learnr tutorial
I've made a small tutorial with the learnr package (+ gradethis) in R. The buttons for the tutorial are currently in english (e.g. submit answer, run code). Since my tutorial is in Dutch, it'd be better if the buttons were also in Dutch.
Does anyone…

Jolien J
- 177
- 2
- 12
2
votes
0 answers
How to save changes from a learnr tutorial for grading?
I have just got started with making tutorials in learnr package.
I have used the template for the demo tutorial:
When I go on "Run Document", this allows me to write in the RStudio window that opens all the answers I have for the questions. However,…

Codrin Mironiuc
- 121
- 1
- 6
2
votes
1 answer
Change submit button with learnr package
I am using the learnr package and I would like to know if there is an easy way to change the caption of the submit button? Instead of "Submit Answer", I would like to change it to "Validate", for example. I could not find information in the package…

Philippe Massicotte
- 1,321
- 12
- 24