我想在一个块中使用循环来渲染quiz
库函数的多个对象。正在编译文件没有问题learnr
,但渲染不正确。它正在呈现文本,而不是应该呈现的问题。R
html-markdown
这是我的可重现代码,目前无法正确呈现:
---
title: ""
output: learnr::tutorial
runtime: shiny_prerendered
description: ""
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(learnr)
```
```{r, q-part2, echo=FALSE, results='asis'}
words_lst <- structure(list(eng = c("bathroom", "bedroom", "dining room",
"door", "house", "kitchen", "garden", "neighbor", "office", "attic",
"living room"), nl = c("de badkamer", "de slaapkamer", "de eetkamer",
"de deur", "het huis", "de keuken", "de tuin", "de buurman",
"het kantoor", "de zolder", "de woonkamer")), row.names = c(NA,
-11L), class = "data.frame")
for(i in seq_along(words_lst)){
quiz(caption = paste0(i),
question_text(paste0("Translate: ", words_lst[i,1L]),
answer("C0rrect ", message = "Make sure you do not have a trailing space"),
answer(trimws(words_lst[i, 2L]), correct = TRUE),
incorrect = paste0("Gebruik: ", sub("\\s.*", "", words_lst[i,2L])),
allow_retry = TRUE,
trim = TRUE,
placeholder = "schrijf het juist antwoord"
))
}
```