Forum: support

Monitor Forum | Start New Thread Start New Thread
RE: import questions from learnr? [ Reply ]
By: Achim Zeileis on 2021-04-16 00:35
Debbie, it took longer than I had hoped but I finally put together a new "exams2learnr" package that facilitates embedding R/exams exercises into learnr tutorials. You can install it from R-Forge (not on CRAN, yet) via

install.packages("exams2learnr", repos = "")

The main function is exams2learnr() that can be used inside learnr tutorials - either to set up individual questions or an entire quiz.

Two example tutorials are provided within the package: learnr_quiz.Rmd and learnr_questions.Rmd. See ?exams2learnr for more details.

For convenience and quickly trying out whether exercises work as intended, there is also a run_quiz() function that creates a learnr tutorial on the fly and immediately calls rmarkdown::run().

It would be great if you could have a look at the package and provide feedback! I'm not a real learnr user and it's not unlikely that someone with more learnr experience (like you) would have made different choices in the workflow.

Best wishes & thanks in advance!

RE: import questions from learnr? [ Reply ]
By: Debbie Yuster on 2020-08-11 02:01
Thanks very much, I really appreciate your looking into this!

RE: import questions from learnr? [ Reply ]
By: Achim Zeileis on 2020-08-11 00:13
Thanks for the feedback, Debbie. I'm thinking that probably this should be an exams2learnr() interface with arguments as consistent as possible with other exams2xyz() interfaces. Some of the aspects that would be needed for that, however, are not fully clear to me. That's also why I tried to get in touch with Barret Schloerke, the learnr maintainer. So far I don't have any feedback from him but maybe he is traveling or on vacation. So I'll wait a bit more before asking him again.

RE: import questions from learnr? [ Reply ]
By: Debbie Yuster on 2020-08-11 00:00
Hi Achim,

I've had a chance to play around with writing simple questions in R/exams and converting them to QTI and learnr using the script you wrote - thanks again. I wanted to revisit the idea of a learnr_quiz function that you mentioned a couple messages upthread. I think it would be great to have a function that can take a vector of exercises as an argument, and generate a basic learnr quiz, with all of the problems presented in one section (they can be wrapped inside a learnr "quiz"), no need for item-level customization. Perhaps the function call would be:
learnr_quiz(elearn_exams, [title = "Quiz 7"], [allow_retry = TRUE]), where elearn_exams is a vector of exercises, and the second and third arguments are optional.

Even without such a function, I'm off to a good start with what I already have. The quizzes will be fairly short so it wouldn't be terrible to do the conversion at the single-question level, as you did to get me started.


RE: import questions from learnr? [ Reply ]
By: Achim Zeileis on 2020-07-27 14:19
Debbie, thanks for the feedback, much appreciated. I look forward to hearing about your experiences and thoughts.

I also contacted Barret Schloerke, the learnr maintainer, and asked him whether he had any thoughts on this. If this leads to further progress, I'll also report back here.

RE: import questions from learnr? [ Reply ]
By: Debbie Yuster on 2020-07-27 14:06
Achim, thank you so much! This is great, I was able to run your document to produce the Shiny app. As far as whether it's better to produce single questions, quizzes, etc, I'm still not sure what my workflow will be. My main goal was simply to have a single location for the problem source files, which I can then export to Canvas, learnr, etc. So it looks like your files accomplish that, and I can write and maintain the questions in R/exams format. As I develop the questions(starting sometime in August), I will see what workflow works best, and will be back in touch if I'm not able to figure it out on my own. Thanks again, I really appreciate your help.


RE: import questions from learnr? [ Reply ]
By: Achim Zeileis on 2020-07-27 10:14
[forum:47977] (8) downloads
Attached is an updated version with some improvements and more comments in the code.

RE: import questions from learnr? [ Reply ]
By: Achim Zeileis on 2020-07-27 01:35
[forum:47976] (6) downloads
Debbie, I've written a small function learnr_question() that can take the output of xexms() as shown in the SO answer I posted previously and turn it into a learnr question. It's in the attached .zip file.

Also included in the .zip is a small .Rmd that calls xexams() with a couple of exercises included in the R/exams package, see:

Subsequently, every single question must be converted with learnr_question(). It would also be possible to write a similar function learnr_quiz() that generates an entire quiz based on the R/exams output. I wasn't sure, though, what the most natural interface would be for this (all in one section? separate sections? all questions with same optional arguments?).

Let me know if this is enough to get you started...

RE: import questions from learnr? [ Reply ]
By: Debbie Yuster on 2020-07-24 14:57
Achim, thanks so much for the info and pointers. I agree with you about learnr's purpose being much broader than multiple choice problems.
One of my colleagues wants to use learnr (1) to make use of answer recording via the learnrhash package and (2) to offer students a consistent experience, since they will be already using learnr for more complex interactive tutorials like you mentioned.

I will read in more detail the post you linked and try to figure all this out. Thanks again for your help and ideas!


RE: import questions from learnr? [ Reply ]
By: Achim Zeileis on 2020-07-24 02:47
Debbie, thanks for your interest!

We've had discussions with some R/exams users about the possibility of a learnr interface but I think nobody tried to write an exams2learnr() function yet. The main reason why I didn't try to do so, yet, is that the strength of "learnr" in my opinion are the more complex exercises closely guiding the user through a certain coding process. And this doesn't map well to the simpler exercises in R/exams.

However, the simple multiple-choice and single-choice questions in learner should not be so hard to get from mchoice/schoice exercises in R/exams. This would be similar to what I showed here:

Maybe webex might be a more lightweight solution than learnr for you as well?

import questions from learnr? [ Reply ]
By: Debbie Yuster on 2020-07-23 15:11
Hello, I'm new to the R community (so of course, also new to R/exams). I'm planning to assign videos to my students this Fall, and will be developing simple multiple choice quizzes to follow each video. I'd like to make these quizzes available to colleagues in both the 'learnr' format as well as QTI or some other LMS/VLE-friendly format (mine is Canvas). Rather than copy/pasting to create each question twice, I'm looking for a tool which can convert the questions automatically. Presumably the more sensible direction is learnr -> QTI, so I would code questions in learnr and then convert the problems so they can be imported into Canvas. For more info on how questions are formatted in learnr (originating from Rmd files), see

It doesn't look like the exams package supports this, is that right? Does anyone know of a tool that does? I'd love to make use of the exams package's ability to export in any format, what a great feature!


Thanks to:
Vienna University of Economics and Business Powered By FusionForge