R markdown PDF: Temporarily hide spoiler code for quiz takers

前端 未结 1 1180
迷失自我
迷失自我 2021-02-15 12:10

I am using R markdown to create a PDF R course. I want to insert a quiz like the following:

---
output: pdf_document
---

What is the class of the following R ob         


        
相关标签:
1条回答
  • 2021-02-15 12:50

    I wasn't thinking of a full shiny app, but something like this .Rmd

    ---
    output: html_document
    ---
    
    ## q1 what is `class(pi)?`
    
    <div id="spoiler" style="display:none">
    
    ```{r}
    class(pi)
    ```
    
    </div>
    
    <button title="Click to show answer" type="button"
       onclick="if(document.getElementById('spoiler') .style.display=='none')
                  {document.getElementById('spoiler') .style.display=''}
                else{document.getElementById('spoiler') .style.display='none'}">
      Show/hide
    </button>
    

    enter image description here

    And then to click

    enter image description here

    0 讨论(0)
提交回复
热议问题