When Submitting Answer - NameError: name 'r' is not defined
Closed this issue · 3 comments
[Updated to provide more details]
I have installed pygradethis and gradethispython but am getting "Error occurred while evaluating 'exercise.checker'" in the learnR markdown and the following in the R Markdown terminal:
Error occurred while evaluating 'exercise.checker': KeyError: 'e'
Detailed traceback:
File "/home/smondesire/.local/lib/python3.9/site-packages/pygradethis/python_grade_learnr.py", line 148, in python_grade_learnr
message="Error occured while checking the submission. {e}".format(e),
I am running python 3.9.12 and R 4.1.3. When I run python-check.Rmd and press Submit Answer, I get the error "Error occurred while checking the submission." in py_grade_learnr.R. I removed the try/except and I get the error below, that the 'r' variable is not defined: a 'r' not defined error in python_grade_learnr.
Listening on http://127.0.0.1:6348
Error occurred while evaluating 'exercise.checker': NameError: name 'r' is not defined
Detailed traceback:
File "/home/me/.local/lib/python3.9/site-packages/pygradethis/python_grade_learnr.py", line 139, in python_grade_learnr
check_code_conditions = eval(check_code_source, {}, r)
Warning in selectChildren(jobs, timeout) :
cannot wait for child 90057 as it does not exist
Loading required namespace: testthat
Warning in selectChildren(jobs, timeout) :
cannot wait for child 90066 as it does not exist
Hi @DrMondesire 👋 Thank you for opening this issue. I was actually running into the same thing and I'm happy you have created this issue to track/fix this. We're currently resuming work on these packages and will investigate how to deal with this since that special r
object comes from the {reticulate}
>>> r
<__main__.R object at 0x11d4dc910>
>>> r.x
2.0
So my guess is during import time the r
is not available and we attempt to use it for the current code leading the the error.
Notes for us later: it might not even be necessary to have the r
object in the context of learnr
/gradethis
because we really want to be using the envir_prep
/ envir_result
objects for exercises checking code to have access to any objects we might need to grade.
This should be fixed now that we're not using the r
object. In the future, that object might have uses and we'll figure out better ways of importing it.