Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
642 views
in Technique[技术] by (71.8m points)

r - Cloze question combining mchoice and num import in Moodle

I created a cloze question combining mchoice and num. However I cannot import the question in Moodle as it says Error importing question Invalid embedded answers (Cloze) question (One of the answers should have a score of 100% so it is possible to get full marks for this question.). If I turn it into a single mchoice question (deleting the num question) or I turn it into a single num chestion (deleting the mchoice part) it works. I could not find such an example on r-exams.org, that is why I turned here.

This is my Code:

```{r data generation, echo = FALSE, results = "hide"}
library(exams)
Fragen=data.frame(
  Fragen=c(
    "Vergleich Schlachtgewicht (g) m?nnlicher und weiblicher Hühner (H?hne/Hennen) der gleichen Linie.",
    "Untersuchung der Anzahl Insektenarten, welche auf unterschiedlichen Feldern vorkommen (Magerwiese, Klee, je 10 Felder).",
    "Untersuchung Sulfatgehalt (mg) bei Wasserproben aus der Limmat. Die Proben wurden an zwei unterschiedlichen Stellen entnommen (Limmatquai, Werdinsel, w?hrend 14 Tagen)",
    "Untersuchung Kürbisgewicht (kg) bei Düngung mit Gülle oder Kompost"),
  Stichprobe1=c("Hahn","Magerwiese","Limmatquai","Guelle"),
  Stichprobe2=c("Henne","Klee","Werdinsel","Kompost"),
  mean1=c(2500,50,250,10),
  mean2=c(2000,20,200,12),
  sd1=c(300,20,50,5),
  sd2=c(300,10,40,5),
  n=c(20,10,14,16)
)
n=sample(4,1)

## DATA
x1=abs(round(rnorm(Fragen$n[n],Fragen$mean1[n],Fragen$sd1[n])))
x2=abs(round(rnorm(Fragen$n[n],Fragen$mean2[n],Fragen$sd2[n])))
datadf=data.frame(x1,x2)
names(datadf)=c(as.character(Fragen$Stichprobe1[n]),as.character(Fragen$Stichprobe2[n]))
write.csv(datadf, "stichproben.csv", row.names = FALSE, quote = FALSE)

alpha=0.05
ps1=shapiro.test(x1)$p.value
ps2=shapiro.test(x2)$p.value
pf=var.test(x1,x2)$p.value
if (ps1 > alpha & ps2 > alpha) {
  if (pf > alpha) {
    p=t.test(x1,x2,var.equal = TRUE)$p.value
  }else{
    p=t.test(x1,x2,var.equal = FALSE)$p.value
  }
}else{
  p=wilcox.test(x1,x2)$p.value
}
p
msol=c(ps1>alpha & ps2>alpha, pf>alpha,TRUE)
msol
```

Question
========

`r Fragen$Fragen[n]`

Die Daten sind im File [stichproben.csv](stichproben.csv). 

Answerlist
----------
* Die Stichproben sind normalverteilt
* Die Varianzen sind homogen
* Die Stichproben sind unabh?ngig
* Führe den am besten geeigneten Test durch und kopiere den p-Wert ins Feld:

Solution
========

```{r solutionlist, echo = FALSE, results = "asis"}

```

Meta-information
================
exname: t-Test unabhaengig
extype: cloze
exsolution: `r mchoice2string(msol)`|`r format(p)`
exclozetype: mchoice|num
extol: `r format(0.01*p)`
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

New answer (Edit: 2020-06-07)

The current R/exams development version on R-Forge (2.4-0) has been improved for better support of mchoice elements in cloze questions. Running your exams2moodle("stichproben.Rmd") yields an exercise like this in Moodle:

Moodle screenshot

Caveat: By default this uses Moodle's evaluation rule for multiple-choice questions where each incorrect checkbox eliminates one correct checkbox. In principle, it is possible to change the eval rule in exams2moodle() but this does not work in all settings. Apparently, if the Moodle percentages only add up approximately but not exactly to 100%, they are not read correctly. My reading is that this is a bug in Moodle. See also below.

Old answer (2020-05-17)

Multiple-choice questions where multiple answers are correct are a bit tricky within Moodle cloze exercises. My understanding is that these were not actually allowed up to a certain point (see the discussion at https://moodle.org/mod/forum/discuss.php?d=213016). Hence, we have only examples with cloze exercises containing single-choice elements but not multiple-choice-elements.

[Note: Jargon is not unified across systems. "Single choice" in R/exams is called "multiple choice, single answer" in Moodle. And "multiple choice" in R/exams is called "multiple choice, multiple answer" in Moodle. Here, I use the shorter jargon as employed by R/exams.]

Actually, I thought that Moodle still didn't support multiple-choice questions as elements in cloze exercises. This would also be consistent with the error message you got, requesting exactly one correct answer yielding 100%.

However, it turns out that under certain conditions it actually works. First, you need to choose a MULTIRESPONSE rather than MULTICHOICE type in exams2moodle() (i.e., this could be fixed on the R/exams side). Second, the percentages of the correct answers needs to sum to exactly 100%. Unfortunately, this conflicts with Moodle requiring 33.33333% as the input for 1/3 of the points. I didn't find a solution to this - other than avoiding the situation where exactly three answers are correct.

As an example I copied your code above into a file stichproben.Rmd and then ran:

set.seed(77)
exams2moodle("stichproben.Rmd", name = "stichproben", cloze = list(
  cloze_mchoice_display = "MULTIRESPONSE",
  eval = list(partial = TRUE, rule = "false2")
))

Note that the seed is important as it leads to only two out of three items in the multiple-choice question being correct. The eval rule is chosen such that 50% of the points are subtracted if the incorrect item is chosen. This all works as intended in Moodle.

However, running the code above using set.seed(1) before, leads to all three items in the multiple-choice question being correct. Then I still get the error message quoted in your question and - as pointed out above - I don't know if/how this can be avoided. I didn't find a solution. Hence, personally, I would rather avoid mchoice elements in cloze questions and use several schoice elements instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...