SCM

Forum: support

Monitor Forum | Start New Thread Start New Thread
RE: possible outdated code for shortanswer case-sensitive variant in moodle question [ Reply ]
By: Achim Zeileis on 2023-04-15 01:18
[forum:49635]
Joan, thanks for pointing this out, very much appreciated!

My code looks a little bit different but essentially follows your suggestion. It is in the development version here on R-Forge now. So if you install that, the usecase=TRUE argument should also work within the cloze exercises.

possible outdated code for shortanswer case-sensitive variant in moodle question [ Reply ]
By: Joan Sanz on 2023-04-14 14:49
[forum:49633]
Hi, it seems that this command doesn't achieve the desired result:

exams2moodle("test.Rmd", cloze = list(usecase = TRUE))

The generated moodle question is not case sensitive. After inspecting the source code and checking the moodle documentation, it seems that the tag ##SHORTANSWER_C## is to be used to obtain a case-sensitive answer string, instead of ##SHORTANSWER##.

As a workaround, I made this modification on exams2moodle.R file (line 629ss.:


if(x$metainfo$clozetype[i] == "string") {
for(j in 1:k) {
tmp <- c(tmp, paste0(ql[j], ' {', points2[i], if (usecase) ':SHORTANSWER_C:%100%' else ':SHORTANSWER:%100%', gsub("}", "\\}", solution[[i]][j], fixed = TRUE),
if(!usecase && tolower(solution[[i]][j]) != solution[[i]][j]) paste0('~%100%', tolower(gsub("}", "\\}", solution[[i]][j], fixed = TRUE))) else NULL,
if(!identical(stringwidth, FALSE)) paste0('~%0%', fstring) else NULL,
'}'))
}
}


Then I used a local copy of it to run my code.
[
These are the commands used in RStudio:

> library("exams"); source("exams2moodle_C.R"); library("tools"); exams2moodle_C("test.Rmd", cloze = list(usecase = TRUE))
]

I think, though, this issue deserves checking from the package author.

In any case, I apologize for the inconveniences or if I'm missing something here. Thanks in advance for your attention.

Thanks to:
Vienna University of Economics and Business Powered By FusionForge