在学习者RMarkdown文档中交互式创建问题和测验

时间:2018-11-10 01:10:09

标签: r r-markdown

我想用learnr文件夹中的文件在RMarkdown中创建一个responses教程,其中包含问题,视频和测验的数据。 我在responses文件夹中有三个csv文件:

[1] "responses/20181109-163432_question.csv" "responses/20181109-163437_video.csv"   
[3] "responses/20181109-163442_quiz.csv"    

learnr R降价中,使用YAML:

title: "Create Question/Video/Quiz"
output: 
  learnr::tutorial:
    progressive: true
    allow_skip: true
runtime: shiny_prerendered

我想遍历这些文件,如果是question文件,请创建问题模板,如果是video,请创建视频模板,如果是quiz,请创建测验模板

我说的模板是指learnr函数:

question模板为:

```{r letter-a, echo=FALSE}

    question("What number is the letter A in the English alphabet?",
      answer("8"),
      answer("14"),
      answer("1", correct = TRUE),
      answer("23"),
      random_answer_order = TRUE
    )
```

视频模板为:

```{r}
# Video Title
![](https://youtu.be/zNzZ1PfUDNk){width="90%"}
``` 

测验模板为:

``{r quiz1, echo=FALSE}
quiz(caption = "Quiz 1",
  question("What number is the letter A in the *English* alphabet?",
    answer("8"),
    answer("14"),
    answer("1", correct = TRUE),
    answer("23")
  ),
  question("Where are you right now? (select ALL that apply)",
    answer("Planet Earth", correct = TRUE),
    answer("Pluto"),
    answer("At a computing device", correct = TRUE),
    answer("In the Milky Way", correct = TRUE),
    incorrect = "Incorrect. You're on Earth, in the Milky Way, at a computer."
  )
)
```

注意:这些模板取自learnr tutorial

0 个答案:

没有答案