Generalize extract behavior across learnr versions? #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Colin/other maintainers,
First off, this package has been critical in helping me set up an auto-grading pipeline for an introductory R course I TA'd for, so thank you!
I originally wrote that pipeline in fall 2021 and had hash creation/extraction code working with the then-newest development version of learnr and learnrhash. The relevant learnr tutorial homework assignments are hosted online through a shinyapps.io instance.
This year's class is using the same homework instance (if it ain't broke, don't fix it?), which means the hashes are being encoded using an older version of learnr/learnrhash, but then decoded/extracted back in R using the newest versions of both (specifically,
learnr=0.10.6.9
). (There is a new TA working on the course, so I'm refreshing the auto-grading scripts assuming they will be installing the newest available versions of packages.) I imagine this use case might apply for others as well.I noticed that my older encoded hashes would not extract using the newest version of learnrhash--
extract_exercises()
threw an error that appeared to source fromextract_hash()
:Further, the testthat tests, which helpfully have the hashes hard-coded in, also fail with the same error.
Accordingly, I modified the changes from #19 to call
dplyr::relocate()
on either thelabel
or theid
column, whichever exists.Once I changed that, my older hashes were still giving me an issue--they would return tibbles length 0 from
extract_exercises()
because they still hadtype == 'exercise_submission'
instead of the newer learnr label,type == 'exercise'
. So, for that, I figured it might be safe to generalize thefilter()
logic inextract_exercises()
andextract_questions()
to filter bystartsWith()
instead of strict==
. That way, hashes from older and newer versions should both work presuming the types still start with'question'
and'exercise'
respectively.The tests pass now, and my older hashes extract again. I'm not 100% sure if this also incidentally resolves #18 , but based on the description in that issue, I think it may?
Hope this helps!