rr-exams

`exams2forms()` in quarto reveal.js


I love engaging students into active retrieval practice using the {exams} and {exams2forms} packages. Embedding webquizzes into quarto html works seamlessly using e.g.

---
format: 
  html:
    embed-resources: true
    css: webex.css
    include-after-body: webex.js
---

# Task
```{r}
#| label: quiz2
#| echo: false
#| message: false
#| results: "asis"
#| warning: false

library("exams2forms")
exm <- list(c("swisscapital.Rmd"))
exams2forms(exm, n = 3)
```

with the webex.css and webex.js files provided here. However, if I change the format from html: to revealjs: the reveals .js seems to interfere with the webex.js and I don't know how to avoid this.


Solution

  • Currently (exams2forms 0.2.0-devel), revealjs is not properly supported, yet. First, exams2forms() does not know that revealjs output should embed a HTML version of the question. Second, the Javascript code enabling schoice/mchoice interactions and the Javascript for obfuscation (added in the current devel version) do not mix well with the Javascript for revealjs.

    The following file works though:

    ---
    format: 
      revealjs:
        embed-resources: true
        css: webex.css
        include-after-body: webex.js
    ---
    
    ## Task
    
    ```{r}
    #| label: quiz2
    #| echo: false
    #| message: false
    #| results: "asis"
    #| warning: false
    
    library("exams2forms")
    knitr::opts_knit$set("out.format" = NULL, "rmarkdown.pandoc.to" = NULL)
    exams2forms("function.Rmd", n = 3, obfuscate = FALSE)
    ```
    

    The opts_knit setting is set to trick exams2forms() into producing HTML output although the document type in revealjs and not html. And then the fill-in-the-blank-type interactions of string exercises (e.g., function.Rmd) and num exercises (e.g., deriv.Rmd) works correctly (without obfuscation).

    I'm not sure what it would take to also support schoice and mchoice...