Search code examples
rr-exams

Case insensitive correction of input strings in R/exams in OpenOLAT


This question concerns online exams in OpenOLAT, written with the R/exams function exams2openolat(). I'm asking a question as outlined below (with 4 different versions) where students have to enter a sequence of letters, e.g., J, F, I, ...

Is there a way to have the input processed case insensitively, so that both upper-case letters (as above) and lower-case letters (i.e., j, f, i, ...) are accepted as correct?

i = sample(1:4, 1)

question = concat("...")
correct = c("J,F,I,B,Z,M,L,X,A,C,Q", "N,T,E,Y,Z,H,M,L,A,C,Q", "A,T,L,R,Z,V,C,E,H,M,Q", "P,I,W,J,Z,D,Q,X,E,S,M")
...
answertypes = paste(replicate(11, "string"), collapse = "|")
answerlist = sprintf("%s:",seq(1,11))
exsolution = gsub(",", "\\|", correct[i])
solutionlist = strsplit(gsub(",", "", correct[i]), "")[[1]]

Solution

  • Thanks for the suggestion. This option is available in OpenOlat and in the QTI 2.1 XML format that is used for exchange - however, up to now it was not supported by exams2openolat() and the underlying exams2qti21() function. I have added this now to version 2.4-0 of R/exams. So now you can do

    exams2openolat(..., casesensitive = FALSE)
    

    The default continues to be TRUE. As a worked example you can consider

    exams2openolat(expar("function.Rmd", i = 8), casesensitive = FALSE)
    

    This picks one of the eight available random versions of the function exercise which has the correct answer logLik (note the capital L in the middle). With the option casesensitive = FALSE any other case including loglik, LOGLIK, or LoGlIk is accepted as correct as well.