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

Make shiny modules for quiz questions (instead of htmlwidgets) #194

Merged
merged 67 commits into from
Apr 9, 2019

Conversation

schloerke
Copy link
Collaborator

@schloerke schloerke commented Oct 5, 2018

Fixes #192
Fixes #173
Fixes #109
Fixes #217

Will make a separate PR for text box input-based questions (included)

* upstream/master:
  Highlight code and exercise area (rstudio#185)
  save metadata information using dput vs deparse (rstudio#190)
* master:
  Aggressive Prerender checks within rmarkdown (rstudio#179)
… mechanisms

use s3 methods for
* question_initialize_input
* question_completed_input
* question_is_valid
* question_is_correct
* question_disable_selector (will probably remove)
@jcheng5
Copy link
Member

jcheng5 commented Oct 16, 2018

  1. Looks like there are some TODO-barret comments left, do any of those need to be addressed?
  2. Are you aware of any backward-incompatible changes in this PR? I've only started skimming but I vaguely recall you saying you were getting rid of the quiz function?

@jcheng5
Copy link
Member

jcheng5 commented Oct 16, 2018

To (partially) answer my own question, the question() arguments correct and incorrect have been renamed to correct_message and incorrect_message. Do you really want to break backward compat for that? (The examples still use the old param names btw)

@jcheng5
Copy link
Member

jcheng5 commented Oct 16, 2018

I can't get this to work in RStudio. It seems to me like the S3 methods are not registered properly. This is what I'm testing with:

---
title: "learnr test"
output: learnr::tutorial
runtime: shiny_prerendered
---

```{r setup, include=FALSE}
library(learnr)
```

```{r one}
question("Where are you right now? (select ALL that apply)",
 answer("Planet Earth", correct = TRUE),
 answer("Pluto"),
 answer("At a computing device", correct = TRUE),
 answer("In the Milky Way", correct = TRUE),
 incorrect_message = paste0("Incorrect. You're on Earth, ",
                    "in the Milky Way, at a computer.")
)
```

Instead of the report launching, I get each individual answer launching in a new window. If I use devtools::load_all I get different behavior, where the structure of the question is dumped into the output as text.

Update: Oh, interesting. I had some local changes to htmltools that caused this. Seems to almost be working now, other than the missing import declarations I mentioned below.

@jcheng5
Copy link
Member

jcheng5 commented Oct 16, 2018

Also there seem to be a lot of missing import declarations, R CMD check will point them out.

Copy link
Member

@jcheng5 jcheng5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try again after you get the right imports in place so it works in RStudio.

I'll have some feedback about question_module_server as well, we can discuss that after I am actually able to run tutorials.

* master:
  Bump rmarkdown version to >= v1.12.0 (rstudio#220)
  Explaining that the example is just an example (rstudio#203)
  Adding missing word 'in' to sentence. (rstudio#200)
  Converting _it's_ (it is) to _its_ (possessive). (rstudio#201)
@schloerke schloerke changed the title [WIP] Make shiny modules for quiz questions (instead of htmlwidgets) Make shiny modules for quiz questions (instead of htmlwidgets) Apr 9, 2019
@schloerke schloerke merged commit 314c031 into rstudio:master Apr 9, 2019
@schloerke schloerke deleted the text_answer branch November 14, 2019 16:06
sjgknight pushed a commit to sjgknight/learnr that referenced this pull request Aug 10, 2021
…io#194)

* First pass at making a radio shiny app. Commenting for now to see changes going further

* encode quiz question / answer text to be UTF-8

* first pass at abstract radio shiny app

* add checkbox to shiny app questions

* always display the default incorrect / correct message in addition to extra messages

* first pass at a text input question

* add the option back to the answer object for legacy

* ignore atom config folder for local settings

* failed attempt to use raw shiny module. moving towards using a `rmarkdown::shiny_prerendered_chunk`

* use dput_to_string instead of list_to_string

* checkbox is working with simpler s3 method calls and leveraging shiny mechanisms

use s3 methods for
* question_initialize_input
* question_completed_input
* question_is_valid
* question_is_correct
* question_disable_selector (will probably remove)

* checkbox and text questions work (without disable)

* questions do not depend upon shinyjs to disable elements

* move slickquiz / slickquiz tutorial css to rstudio-theme

* comments for mutate_tags

* do not double encode quiz_text content

* use knit_print.question and not question_to_shiny

* add more TODOs

* submit question submission event

* more todos

* make sure answers submitted are not generated with random ids

* get a prior submission for a given question

* rewrite question reactivity to depend only on submitted answer

* set up userData$learnr_state

This allows for waiting for a round trip from the browser to make sure information is initialized.  Once initialized, prior question submissions can be retrieved.

Without this, questions will try to retrieve information too early.  Questions should not be displayed until prior submission is retrieved.  Do not want to display a blip of temp state.

* allow for local development to work as localhost

* default the ui to display "loading..." - Seems better than a pure vertial jump when loaded

* add temp sleep command to visually see "loading..."

* remove %>% usage

* importFrom utils getFromNamespace

* make quizes work with shiny based questions

* enforce question_is_correct_value return objects

* return only the single question restore value when restoring a question

* Join similar message types line break

space out with to <br/> tags

* move finished todos with comments away from other todos

* first pass at passing r cmd check

* first pass at removing slickQuiz

* update todos and fix s3 class value in question_stop

* document

* add comment about localhost and devtools::load_all()

* remove more of slickquiz and the question_submission http-handler

* reduce the set of ids supplied in a question

* wrap a question answer container in a div to allow for styles to be applied

* ignore tmp tutorials

* update js queries

* do not double record event

* remove question_submission init progress event and restore submission

* broadcast question event submission to client

* match js css classes

* tell the client when the app has loaded about the restoring answer

* do not notify the client about quiz questions being correct. but do add submitted answer

* save question reset on server side

* make the question's shiny ui have a wrapping div for each question

* barret validate that chunk lables do not have unwanted characters to function better on JS side

* have NS id be the chunk label

* more answers -> answer storage names

* fix str_trim to trim all white space on right side

* display a loading item until the question loads

* when a question is reset with try_again, remove all matching progress events and add a corresponding not completed event

* if knitr is not in progress, no need to verify the chunk name

* pass R cmd check

* update notes

* move answer -> answer officially. add comment for docs

* export methods to be found at execution time. ignore all tutorial .html files.
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

Successfully merging this pull request may close these issues.

None yet

2 participants