使用多个单选题 R/考试创建完形填空题

问题描述 投票:0回答:1

我没有完全掌握 R,但我正在尝试使用 R/Exams 包来创建不同的考试版本,但我在创建包含多个单项选择题的完形填空式问题时遇到了困难。我这样做是因为在回答接下来的 3 个问题之前,我需要分析一个数字。

我认为语法可能是这样的:

Question
==========
Use the following gel image to answer the following questions:

![]("Image.png")

Question 1
Question 2
Question 3

AnswerList
-----------

* Answer A
* Answer B
* Answer C
* Answer D
* Answer E
* Answer F


* Answer A
* Answer B
* Answer C
* Answer D
* Answer E

* Answer A
* Answer B
* Answer C
* Answer D
* Answer E

Meta-information
===============
extype: cloze
exclozetype: schoice|schoice|schoice
exsolution: 000010|00010|00010
exshuffle: TRUE

我在网上没有找到任何东西,我陷入了困境。如果有人可以提供帮助,我将非常感激并提前致谢!

r r-markdown r-exams
1个回答
0
投票

最小示例:

你快完成了,干得好!您只需告诉系统下拉交互应放置在练习中的位置即可。您可以使用

##ANSWER1##
等而不是
Question 1
来完成此操作。因此,当您替换三行时

Question 1
Question 2
Question 3

##ANSWER1##
##ANSWER2##
##ANSWER3##

然后练习就开始了!

更详细的示例:

软件包中附带了一个类似但更复杂的示例,该示例使用更多 R 代码进行随机化,您可以通过

exams2canvas("vowels.Rmd")
进行尝试。该文件的源代码是:

```{r, include=FALSE}
## Vowels and their quality
vowels <- voweltab <- rbind(
  c("i", "close", "front", "unrounded"),
  c("e", "close-mid", "front", "unrounded"),
  c("ɛ", "open-mid", "front", "unrounded"),
  c("a", "open", "front", "unrounded"),
  c("ɑ", "open", "back", "unrounded"),
  c("ɔ", "open-mid", "back", "rounded"),
  c("o", "close-mid", "back", "rounded"),
  c("u", "close", "back", "rounded"),
  c("y", "close", "front", "rounded"),
  c("ø", "close-mid", "front", "rounded"),
  c("œ", "open-mid", "front", "rounded"),
  c("ɶ", "open", "front", "rounded"),
  c("ɒ", "open", "back", "rounded"),
  c("ʌ", "open-mid", "back", "unrounded"),
  c("ɤ", "close-mid", "back", "unrounded"),
  c("ɯ", "close", "back", "unrounded"),
  c("ɨ", "close", "central", "unrounded"),
  c("ʉ", "close", "central", "rounded")
)
vowels <- cbind(vowels, "", "", "")

## Vowel quality parameters
height <- c("close", "near-close", "close-mid", "mid", "open-mid", "near-open", "open")
front_back <- c("front", "front centralized", "central", "back centralized", "back")
lips <- c("unrounded", "rounded")

## Binary coding of features
match_mchoice <- function(true, options) {
  x <- match(true, options)
  sapply(x, function(i) paste(append(rep(0, length(options) - 1), 1, after = i - 1), collapse = ""))
}
vowels[, 5] <- match_mchoice(vowels[,2], height)
vowels[, 6] <- match_mchoice(vowels[,3], front_back)
vowels[, 7] <- match_mchoice(vowels[,4], lips)

## Casually selecting two vowels
vowels <- vowels[sample(1:nrow(vowels), 2), ]

## Possible answers and correct solution
ans <- rep(c(height, front_back, lips), 2)
sol <- paste(t(vowels[, 5:7]), collapse = "|")
```

Question
========
Describe the following Cardinal vowels according to the three parameters
vowel height, frontness-backness, and lip rounding:

1. [`r vowels[1,1]`] is the ##ANSWER1## ##ANSWER2## ##ANSWER3## vowel.
2. [`r vowels[2,1]`] is the ##ANSWER4## ##ANSWER5## ##ANSWER6## vowel.

```{r, echo=FALSE, results="asis"}
answerlist(ans, markup = "markdown")
```

Solution
========
For an overview of the 18 Cardinal vowels see <https://en.wikipedia.org/wiki/Cardinal_vowels>.

1. [`r vowels[1,1]`] is the `r vowels[1,2]` `r vowels[1,3]` `r vowels[1,4]` vowel.
2. [`r vowels[2,1]`] is the `r vowels[2,2]` `r vowels[2,3]` `r vowels[2,4]` vowel.

Meta-information
================
exname: Cardinal vowels
extype: cloze
exclozetype: schoice|schoice|schoice|schoice|schoice|schoice
exsolution: `r sol`
© www.soinside.com 2019 - 2024. All rights reserved.