DBCDK / quiz

Other
0 stars 1 forks source link

Travis Waffle Coverage

Quiz

This is the source code, for the quiz tool on https://quiz.dbc.dk. In order to try out the quiz-editing part, you need a clientId/clientSecret to login, which danish libraries can get via a request to DBC, see description on https://openplatform.dbc.dk

Embedding

The quiz can be embedded in other websites like this:

<div id="quizElem"></div>
<script>
  var quiz;
  function initOpenPlatformQuiz() {
    quiz = new openPlatformQuiz.Widget({
      elemId: 'quizElem',
      extraSpacing: true,
      openPlatformToken: 'fd9e275eeb36295971719a77df354f84e9f21ab3',
      quizId: 'ffdfa65b-4b14-4bec-a4bb-5f2938eca897',
      onDone: function(result) {
        console.log(result);
      }
    });
  }
</script>
<script src="https://quiz.dbc.dk/widget.js" async defer></script>

The openPlatformToken has to be retrieved dynamically, as usual for openplatform access.

If extraSpacing is true, extra spacing is added to the embedded quiz, so it has at least the same height as the screen.

Approach to embedding is inspired by how YouTube and Google Maps are embedded. With regard to IFrame vs JavaScript approach, - embedding via JavaScript is choosen as this allows a more responsive view.

Statistics about agency can be submitted with the statisticsEvent method, a la:

openPlatformQuiz.statisticsEvent({
    openPlatformToken: '18396c0d40f002d48809f946f96d314c1e01bcf0',
    quizId: 'ffdfa65b-4b14-4bec-a4bb-5f2938eca897',
    type: 'agency',
    subtype: '770100'
})

onDone is used for getting the quiz state after the quiz has finished.

Development

Current version uses create-react-app, so just npm install, and then npm start for development. This might later change to nwb or Neutrino (as recommended by create-react-app) to support npm package building.

Designwise we try to follow the guidelines Material Design. This simplifies and improves the visual design process, by avoiding a lot of bikeshedding, and having a common language. We use the components from Material-UI, and the same approach with JSS for styling.

State management is done using redux/thunk/immutable. All dispatches and state access happens through action creators and selectors.

Code style is enforced using prettier.

Changelog

2018-11-28 Changes based on user feedback

Changes based on user feedback, and various fixes. Ready for release when help-texts are updated.

2018-11-07 statistics, search, and minor changes

2018-10-24 quiz.dbc.dk, image-upload, videos, markdown-text, fixes

2018-10-10 Quizzes stored in OpenPlatform

2018-09-26 Basic UI for editing single quiz up and running

2018-09-12 Initial Admin user interface

2018-08-29 Draft data structures and initial barebone widget

2018-08-15 (sprint skipped due to vacation etc).

2018-08-01 Initial setup and backend