learnrhash icon indicating copy to clipboard operation
learnrhash copied to clipboard

Problems with encoder

Open ghost opened this issue 4 years ago • 6 comments

There seems to be a discrepancy between the help for encoder_ui() and what is stated on the github site (see below) about how to use it. In particular, the help in R for this package says we need to specify ui_before() and ui_after() etc. When I run the code below, I get a page long hash and no "COPY" button.

Submit

learnrhash::encoder_logic()
learnrhash::encoder_ui()

ghost avatar Sep 23 '20 17:09 ghost

We removed the copy button since it wasn't working well on shinyapps.io (potentially due to security measures). However I just tried things out and the rest behave as expected. If you have a reproducible example with output you're seeing, I'd be happy to help figure out what might be going wrong.

mine-cetinkaya-rundel avatar Sep 25 '20 22:09 mine-cetinkaya-rundel

`--- title: "A closer look at ggplot" tutorial: id: "edu.washington.stat.rstudio.01-ggplot-basics" version: 1.1 output: learnr::tutorial: progressive: true allow_skip: true

runtime: shiny_prerendered


knitr::opts_chunk$set(echo = FALSE)


#devtools::install_github("rundel/learnrhash")


library(learnr)
library(tidyverse)

library(learnrhash)


ggplot(data=iris,mapping=aes(x=Sepal.Width,y=Sepal.Length)) +
   geom_point()+
  facet_wrap(facets=vars(Species),nrow=1) 

Wrap Up

Congratulations on making it through this very brisk introduction to ggplot! There is tons more you could do with ggplot; the key is to keep trying and learning.

learnrhash::encoder_logic()
learnrhash::encoder_ui()

`

ghost avatar Sep 27 '20 00:09 ghost

When I run the above, I see the "Generate hash button" and when I click on it, I get a hash that goes on forever.

image

ghost avatar Sep 27 '20 00:09 ghost

Thanks for the reprex @grover4!

I can reproduce this and have created an example that's a little more simple. It seems to me like learnrhash fails when the answer to an exercise is a plot. If you replace the exercise code with 1+1 or mtcars learnrhash is able to encode the output properly.

    ---
    title: "Minimal example"
    output: learnr::tutorial
    runtime: shiny_prerendered
    ---
    
    ```{r include = FALSE}
    library(learnr)
    library(learnrhash)
    ```
    
    ```{r ex, exercise = TRUE}
    plot(cars)
    ```
    
    ```{r context = "server"}
    learnrhash::encoder_logic()
    ```
    
    ```{r echo = FALSE}
    learnrhash::encoder_ui()
    ```

mine-cetinkaya-rundel avatar Sep 29 '20 06:09 mine-cetinkaya-rundel

makes sense, @mine-cetinkaya-rundel ! I didn't remember that it was encoding the answers...

ghost avatar Sep 29 '20 19:09 ghost

The newest version on github now has the strip_output option for encoder_logic which will remove any output (including plots) and this should help keep the hash sizes manageable.

I've also added select hash and copy hash buttons back to the encoder ui - they seem to be working well but testing is still a bit limited.

rundel avatar Dec 08 '20 14:12 rundel