Search code examples
r-exams

`nops_eval` is not reading the exam ID, how can I control the exam ID reading?


I have about 400 exams in which I defined a custom ID (using the function exams2nops). However, when I use nops_scan none of the IDs is recognized... example:

enter image description here

An exam sample: enter image description here

Is it due to the number of characters in the exam ID?


Solution

  • Yes, the exam ID needs to have exactly 11 digits. I will add a warning about this to exams2nops().

    The "culprit" is this line from the internal read_nops_digits() function:

    body(exams:::read_nops_digits)[[6]]
    ## n <- switch(type, type = 3L, id = 11L, scrambling = 2L)
    

    Thus, when reading the id, the function expects 11 digits. However, I was pleasantly surprised that if you change this 11L to 5L then everything seems to work. You can do so programmatically by making a copy f of this function, changing the 11L to 5L, and overwriting the function in the exams package namespace:

    library("exams")
    f <- exams:::read_nops_digits
    body(f)[[c(6, 3, 4)]] <- 5L
    assignInNamespace("read_nops_digits", f, ns = "exams")
    

    After that running nops_scan() should work as needed in your case.

    Additional comment: Instead of overwriting the read_nops_digits() function programmatically as above, you can also modify the function "by hand" using an editor via:

    fixInNamespace("read_nops_digits", ns = "exams")