Git Product home page Git Product logo

riddlr's Introduction

riddlr

A package for making coding challenges, largely inspired by the learnr package.

Installation

Install the package off of GitHub via

devtools::install_github("dgkf/riddlr")

Quick Start

Try out some examples:

Building a single question shiny app

library(shiny)

app_file <- system.file("example", "shiny", "single_question", "app.R", package = "riddlr")
shinyAppFile(app_file)

Rendering a searchable question catalog shiny app

library(shiny)

app_file <- system.file("example", "shiny", "question_catalog", "app.R", package = "riddlr")
shinyAppFile(app_file)

Community Shout-outs

learnr

A lot of this package is inspired by learnr, with early versions being built directly into learnr's Rmarkdown framework. The scope is slightly different, being an evaluation tool rather than a learning tool. From this slight change in perspective, there were a few features that learnr couldn't accommodate.

  • easily testing code against multiple test cases, whereas learnr only handles a single input
  • timeout per test case (or timeout with a grace period for feedback)
  • hooks for triggering database logs
  • easier addition of markdown-formatted help dialogs

Could this all be contributed back to the learnr package? Absolutely, but ensuring code quality, reusability and consistency within the learnr framework wasn't within scope for the proof-of-concept.

shinyAce

A lot of work was put into giving a comfortable programming interface with staple features like improved code completion, help-text popups, parsing errors and warnings noted in the code form gutter. All of these features were first added internally as part of the proof-of-concept, but were later contributed back to the shinyAce package.

A huge thank you goes out to @vnijs and @detule for giving great feedback on such a large body of new features and diligently checking many edge cases that would have gone unaddressed.

riddlr's People

Contributors

abidawson avatar dgkf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

abidawson

riddlr's Issues

riddlr quizes

Add in a "quiz" as a series of riddles with a global clock that persists through all riddles.

What this needs

  • A new class representing the collection of riddles and additional quiz parameters
    • whether a user should be able to do mulitple submissions
    • whether a user should get feedback about whether their solution is correct
    • global clock
  • A way of producing a quiz shiny module
    • which adds a submission callback that automatically redirects to the next question
    • possibly with quiz question table-of-contents; would be awesome if the table of contents was reactive to quickly display whether the question is skipped, wrong or correct.
    • somewhere where the time remaining is displayed; display could turn red when X% of time is remaining
  • A yaml template to make it easy to specify a quiz from a collection of riddles

Add more riddles!

This package ships with 3 riddles now, but i would be great to have a wider selection. If you're interested in contributing, take a look at some of the existing riddles. In particular, Riddle #1 has notes to a new riddle author about how to modify this file as a template to develop a new riddle.

For this public release, I'd prefer if questions are relatively generic with minimal field-specific terminology. Also remember that users may choose to approach problems in a number of different ways, so it's advised to keep your expected solution output as generic as possible. In most cases, this means that you want to produce a simple value or vector, avoiding issues with package classes and object attributes.

Unit Conversions riddle disconnects the app

hi @dgkf,

Thanks for a nice package and app! I did all 3 riddles :) For some reason the Unit Conversions disconnects my session when I submit the following solution. If you have a chance to see the log in shinyapps.io that would be great to know what's going on.

new_ages <- vector("character")

for (age in ages) {
  for (u_i in seq_along(conversions)) {
    new_age <- trunc(age * conversions[u_i], 1)
    if (new_age >= 1) {
      suffix <- ""
      if (new_age > 1) suffix <- "s"
      char_it <- paste(new_age, paste0(names(conversions)[u_i], suffix), "old")
      print(char_it)
      new_ages = append(new_ages, char_it)
      break
    }
  }
}

new_ages

image

riddlr refactor

This project kicked off largely as a proof of concept and focused only on getting a working app out the door while exploring the feasibility of making a "real-world" programming environment available within a shiny app (with code completion, ability to load libraries, syntax checking and available documentation).

I think the feasibility was proven, but the code isn't necessarily approachable. There's a lot of assumed structure being passed around as lists without any constructors.

There are a few things that would tremendously help to keep the code maintainable:

  1. riddle, riddle_grader and riddle_grader_test constructors
    • riddle(<prompt>, <grader>)
    • riddle_grader(<solution>, <list(<riddle_grader_test>)>)
    • riddle_grader_test(<input>, <timeout>, <grace_timeout>)
  2. Add parse_riddle_rmd_dir to build a catalog from a directory of Rmd files.
  3. Rename riddle and riddle_ui shiny module constructors to shinyRiddle and shinyRiddleUI and migrate to using riddle class as input instead of independent fields.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.