Background
R/exams is a great tool for generating exams for students.
Problem
When a numeric exercise has a large tolerance (extol), an error is thrown:
Error in if (!is.null(extol) && any(extol < 0)) { :
missing value where TRUE/FALSE needed
Is this a bug or am I missing something out?
Minimal example
Here's a minimal exercise that provoked the error:
Question
========
Some text
Solution
========
Some solution
```{r}
sol <- 1e4
sol_tol <- 1e4
```
Meta-information
================
exname: test-debug
extype: num
exsolution: `r fmt(sol, 3)`
extol: `r sol_tol`
I used exams2html to render the exercise:
exams2html(file = "test-debug.Rmd",
edir = "exercises",
dir = "/.")
System info
exams 2.4-0
You need to make sure that both the
exsolutionand theextolactually contain numbers only. However, depending on thescipenoption, large numbers might be converted to strings containing scientific notation.In your example, you avoid the scientific notation by using the
fmt()function inexsolution. But as you do not usefmt()inextol, this gets rendered into a string and not just a number.The problem and corresponding solution are explained in a bit more detail in: Problem with round() function in .Rmd exercise file
In short, either assure that
scipenis sufficiently high or use a formatter likefmt()that assure to display it's input as a plain number only.