learnrhash
learnrhash copied to clipboard
Long hash
A student tester completed one of the tutorials I wrote with learnrhash. It's a long tutorial, as we are developing them to correspond with chapters of a course textbook. However, the hash at the end was quite long, to the point where the student's RStudio froze and crash because they tried to copy such a long string.
Is there any way to shorten the hashes generated at the end?
And again, really appreciate your work! We're testing with students to iron out any issues now before rolling out to a class of 100-200 students at Harvard in the coming weeks.
Interesting, I haven't tried it with a tutorial that has more than a handful of questions & exercises so I haven't seen anything like this. The current strategy being used is to serialize the internal objects into a raw vector, that raw vector is compressed and then encoded using base64 to give it a valid text representation. The base64 encoding is definitely not efficient but it is the cost of making it into basic text characters.
Did the tutorial have a large number of exercises and did it use gradethis? If that is the case we can probably shrink things somewhat by stripping some of the unnecessary fields.
I don't have the coding chops to suggest a PR, but would be really nice is an option which allows one to skip the copy/paste by-hand step of working with the hash. Something like:
learnrhash::encoder_rds()
which produces an rds object which a user could then download, submit, and so on. The rds object would just be the hash, or it might be a tibble with two columns: name and hash, where the name is gotten by asking for it.
@rundel It did have a large number of exercises, but did not use gradethis.
Here is the following code I'm using to produce the .rds like @davidkane9 mentioned:
learnrhash::encoder_ui(
ui_before = shiny::div(
"When you have completed this tutorial, follow these steps:",
br(),
tags$ol(
tags$li("Click Generate Submission"),
tags$li("Copy and paste the hash generated into the \"Hash\" textbox"),
tags$li("Press 'Create responses.rds'. Nothing will pop up, but this will create an .rds file of your hashed responses."),
tags$li("Download the .rds file. A window will pop up asking you where to place the downloaded file. Upload this file to the appropriate Canvas assignment."))
)
)
fluidPage(
mainPanel(
div(id = "form",
textInput("hash", "Hash", ""),
actionButton("submit", "Create responses.rds", class = "btn-primary"),
downloadButton("downloadData", "Download responses.rds")
)
)
)
learnrhash::encoder_logic()
observeEvent(input$submit,{
hash_id <<- input$hash
responses <<- data.frame("Hash" = hash_id)
})
output$downloadData <- downloadHandler(
filename = "tutorial_1_responses.rds",
content = function(file) {
write_rds(responses, file)
}
)
Is there any reason why the hash needs to be displayed?
I've integrated your system into <github.com/dtkaplan/submitr>
with a few changes ...
- Instead of displaying the hash, I display a message saying that the hash has been generated, as in the attached png file. After 10 or 15 seconds, the message starts to disappear so that the user knows they have to start the submission process again.
- There's just one button to start the submission process. No need to generate the hash and then copy it by pressing another button.
In submitr
I collect {learnr}
events rather than querying the state objects. I don't know that this is a better approach than {learnrhash}
, but it does give me the ability to winnow down the submissions to just the events I care about. A quick test with 24 submissions, mostly code exercises, corresponded to a hash with about 1600 characters.
It seems like a common cause of the hashes being long is due to the exercises including their output - this is particularly the case when the output includes an image. We have added the strip_output
argument to encoder_logic
if this data is not needed and it should help keep hash sizes down.