0

I am working on an interactive module using R-markdown and compiling in HTML. I have been trying to use r/Exams as working with learnr was a super pain in the ass without using a shiny server. I have been testing question creation using a simple example. In a separate .rmd file (called quiz01.Rmd) I have the following:

---
title: "Quiz01"
output: 
  html_document:
    css: "css/styles.css"
---
\```{r echo = FALSE}
library("exams")
\```

Question
========
What is my name?

Answerlist
----------
* Amy
* Betty
* Cara
* Demi

Solution
========
My name is Amy!

Answerlist
----------
* True
* False
* False
* False

Meta-information
================
exname: Bridgekeeper
extype: schoice
exsolution: `\r mchoice2string(solutions)`
exshuffle: 3

Then, in my main document where I would like the question to be asked, I have a code chunk that reads:

\```{r setup, echo = FALSE, message = FALSE, warning = FALSE}
library("exams")
exams2html("quiz01.Rmd")
\```

I have been through lots of examples and have followed them to the best of my knowledge. I think I may be missing something in the set-up or something to get this to run! Any help getting this to work would be great!

Thanks, Amy

UPDATE: Thanks for your feedback!

I am working on an online module for students to explore randomness. Within this, I would like a multiple-choice question that allows them to select an answer, check if it is correct, and then try again if it is not. The question could have 1 correct answer if that is easier than having more than one correct answer. This question would be nested within the rest of the rmd/html file. For example, this would be before the question:

<body>
    <ul><li>Discussion time! Before moving on, talk in pairs or groups about the possible flaws with this definition. Can you think of examples when this definition wouldn't work?</li></ul>
</body>

Followed by: Question: So, what do you think might be wrong with the no-pattern definition? (Select all that apply) Answer Options: Long run sequences may contain patterned segments, such as HTHTH in a coin-toss sequence. TRUE Short sequences may be patterned as they aren't usually as representative as long run sequences. TRUE The random device (for example, a coin) remembers what happened previously and knows to make sure no patterns are present in the sequence. FALSE The random device (for example, a coin) does not remember what happened so a pattern cannot be made. FALSE

Then, if a FALSE answer is selected, the following is shown: Not quite! A random device (for example, a coin or spinner) does not remember what happened previously in the sequence but a pattern can still occur! Each outcome is independent so is not affected by the last outcome and has no effect on the next! Try again (Hint: there are two correct options).

Or, if the TRUE answers are selected, the following is shown: If you selected option 1 and 2 - spot on! Short sequences are typically less representative than long sequences. Thinking short run sequences should be representative is a bias called the Representativeness Heuristic. Short sequences can be patterned and still be random!

Again, the second TRUE option could be removed so there is only one option that is correct.

The header for the rmd file is:

---
title: "Defining Randomness"
output: 
  html_document:
    css: "css/styles.css"
---

Output could then be like: Header of module question/answer

Hope that clarifies things! Thanks again :)

A.May
  • 11
  • 4
  • I'm not fully sure what you want to do and it would help if you could streamline the question a bit more. Some comments: (a) Just using `exams2html("quiz01.Rmd")` generates a HTML file but in a temporary directory and tries to display it on screen. Presumably you want something like `exams2html("quiz01.Rmd", dir = ".")`. (b) If you don't want R/exams to set up the final HTML files but want to do that yourself, it's likely easier to write your own `x <- xexams("quiz01.Rmd", ...)` call that produces without a `writer`. (c) The `exsolution` in your example should just be `1000`, I guess. – Achim Zeileis May 12 '21 at 14:58
  • This might also be useful for you: https://stackoverflow.com/questions/62315622/using-r-exams-in-bookdown-document-especially-for-html-output – Achim Zeileis May 12 '21 at 14:59
  • If you can describe more clearly what you would like to get out of R/exams, I can probably write up some guidance in a proper answer. – Achim Zeileis May 12 '21 at 15:00
  • Thanks very much! I'll check out the link and hopefully the additional info clarifies what I'm hoping to do! – A.May May 12 '21 at 22:37
  • OK, much clearer, thanks. I think the best answer to that question at the moment is in the discussion linked above. So maybe you can try to explore that first. And if you have remaining questions, modify your post accordingly. – Achim Zeileis May 13 '21 at 01:26

0 Answers0