testwhat
testwhat copied to clipboard
Lack of specificity in highlighting when doing complex zooming
For complex zooming in, the highlighting is not specific enough.
Reproducible example (in words)
Take the following exercise:
# solution
j <- 0
for (i in 1:4) {
if (i %% 2 == 0) {
j <- j + 1
}
}
# sct
ex() %>%
check_for() %>%
check_body() %>%
check_if_else() %>%
check_if() %>%
check_code("j + 1")
If a student submits the following code:
# solution
j <- 0
for (i in 1:4) {
if (i %% 2 == 0) {
j <- j + 2
}
}
It should highlight the j <- j + 2
part. Instead, however, the entire if
loop is highlighted.
Even though this is not wrong, it could be more specific.
Reproducible example in code
sol_code <- 'j <- 0
for (i in 1:4) {
if (i %% 2 == 0) {
j <- j + 1
}
}
'
stu_code <- 'j <- 0
for (i in 1:4) {
if (i %% 2 == 0) {
j <- j + 2
}
}
'
library(testwhat)
setup_state(sol_code = sol_code, stu_code = stu_code)
res <- run_until_fail(ex() %>% check_for() %>% check_body() %>% check_if_else() %>% check_if() %>% check_code('j + 1'))
payload <- testwhat:::post_process(res, ex_type="NormalExercise")
payload[c("line_start", "line_end", "column_start", "column_end")]
Results in:
$line_start
[1] 3
$line_end
[1] 5
$column_start
[1] 20
$column_end
[1] 3
While line_start
and line_end
should both be 4.