ropensci / ozunconf19

OzUnconf19
http://ozunconf19.ropensci.org/
21 stars 5 forks source link

Create lightweight HTML / JS quizzes (quizlite) #5

Open njtierney opened 4 years ago

njtierney commented 4 years ago

In teaching this semester, I've found myself wanting to use a quiz format for slides, so students can quiz themselves. I'm not interested really in storing the results of a quiz, just a way for people to test themselves locally.

Currently the only way to do this in R is through learnr package.

One of the downsides to this is that you need a server to power the quiz. This makes sense when you want to evaluate or run R code, but when I want a simple multi choice or TRUE / FALSE quiz, it doesn't really fit.

I would like to make a package that implements a similar API to learnr

I asked the folks at learnr about this here: https://github.com/rstudio/learnr/issues/282 - and it looks like the best way forward is to create our own package for this, and if we can, try to mimic the learnr API as close as we can.

Example usage

Perhaps (from here) like so:

```{r quiz1, echo=FALSE}
quiz(caption = "Quiz 1",
  question("What number is the letter A in the *English* alphabet?",
    answer("8"),
    answer("14"),
    answer("1", correct = TRUE),
    answer("23")
  ),
  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 = "Incorrect. You're on Earth, in the Milky Way, at a computer."
  )
)


## Related work

- https://www.sitepoint.com/simple-javascript-quiz/
- https://community.rstudio.com/t/create-questions-and-quiz-in-learnr-rmarkdown-document/17951

- https://github.com/markdly/rmarkdown-quiz
- https://github.com/jverzani/questionr
- http://flavioazevedo.com/stats-and-r-blog/2017/1/3/r-course-05-practicals-n2

- Slidify? Perhaps factor it out into an r package? https://slidify.github.io/iquiz/#1
- https://crumplab.github.io/Blog.html#adding_quizzes_to_static_r_markdown_websites
- https://github.com/CrumpLab/rmslickquiz
- https://github.com/jchamill/jquery-quiz

- perhaps embed a google form sheet?...
MitchStares commented 4 years ago

I am all for this! We could utilise htmlwidgets save_widget() function to export the html, either in an enclosed file or with the dependencies separate. I use this a lot with leaflet to export maps to a shareable format. We could potentially leverage some of those features from the leaflet API and htmlwidgets existing package. Leveraging htmlwidgets would also have the added benefit of embedding quizzes into markdown documents for class exercises.

njtierney commented 4 years ago

Sounds good!

I am not familiar with save_widget, but sounds neat!

One of my plans of attack for this was to use something like https://github.com/edwindj/whisker and/or https://github.com/tidyverse/glue to create some HTML templating for the quiz.

The other plan was to use R to interface with https://github.com/jchamill/jquery-quiz and create the quiz that way - it sounds like save_widget() can help transport that?

MitchStares commented 4 years ago

Depending on how we want to go about this and what functionality we would like it to have, I think the htmlwidgets (https://github.com/ramnathv/htmlwidgets) package is an excellent starting point.

Functions like scaffoldWidget() add the minimal code to implement an html widget into an R package and may be a good jumping-off point. From a brief look, it will give us the windowed interface and all the necessary dependencies we should need. From there we can hopefully use your suggestions to create the html templating.

I think working with htmlwidgets as a major dependancy will give a lot of functionality like embedding into rmarkdowns etc. I think using jquery is a given and from a brief look, jquery-quiz looks sick.

I'll try put some serious planning/thinking time into this before December but knowing my schedule...doubtful.

Maschette commented 4 years ago

The xprmntr package by Danielle Navaro may be worth looking at as well for this. It is quite early in development but I have been using it for creating small quizzes.

djnavarro commented 4 years ago

There's also the jaysire package here: it's intended to support behavioural experiments more generally, but it will do surveys and quizzes easily enough. You can write it within R but the final result is a website that runs entirely on clientside javascript

https://djnavarro.github.io/jaysire/

I'm working on cleaning up the documentation and (because obviously psychologists usually do want to be able to store the results!) making it easier to deploy to Google App Engine, but for the simpler examples @njtierney has in mind, it might be awfully close to suitable as it currently stands. Of course, if anyone would like to help me out with the development... :slightly_smiling_face:

MitchStares commented 4 years ago

That is excellent @djnavarro Very clean from the looks of it. I like the idea but unless I'm wrong, you cant embed these inside R markdowns. For my own teaching/tutorial purposes, Id really like a simple syntax like those in your package, but one that can be implemented as both a standalone html and inside a Rmarkdown html page. Not sure if others hold the same ideas I do, but thats my opinion. I'd be happy to help with development where possible though :)

njtierney commented 4 years ago

Project is at https://github.com/ropenscilabs/quizlite