learnrhash
learnrhash copied to clipboard
Generalize extract behavior across learnr versions?
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 from extract_hash()
:
Error in `.data[["label"]]`:
! Column `label` not found in `.data`.
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 the label
or the id
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 had type == 'exercise_submission'
instead of the newer learnr label, type == 'exercise'
. So, for that, I figured it might be safe to generalize the filter()
logic in extract_exercises()
and extract_questions()
to filter by startsWith()
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!