Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long hash #4

Open
caievelyn opened this issue Jul 22, 2020 · 5 comments
Open

Long hash #4

caievelyn opened this issue Jul 22, 2020 · 5 comments

Comments

@caievelyn
Copy link

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.

@rundel
Copy link
Owner

rundel commented Jul 23, 2020

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.

@davidkane9
Copy link

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.

@caievelyn
Copy link
Author

@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)
    }
  )

@dtkaplan
Copy link

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 ...

  1. 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.
  2. 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.

@rundel
Copy link
Owner

rundel commented Dec 8, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants