Maintainer: Michel Grautstück
Q Quiz is one tool of the Q toolbox to render quizes containing questions of type multiple choice, number guess and map point guess. It also includes the rendering of answer statistics for each question type. Test it in the playground.
git clone [email protected]:nzzdev/Q-quiz.git
cd ./Q-quiz
nvm use
npm install
jspm install
npm run build
The following environment variables must be specified when starting the tool:
COUCH_DB_USER
- couchdb user for accessing the answer-store databaseCOUCH_DB_PASS
- couchdb password for accessing the answer-store databaseCOUCH_DB_URL_Q_QUIZ
- url to the answer-store databaseCOUCH_DB_URL_Q_ITEMS
- url to the q-items database (used for the statistics)ENRICO_API_URL
- url to enrico used to give article recommendationsENRICO_PRODUCTS
- array of publications which should be queried for article recommendationsIMAGE_SERVICE_URL
- url to the image service - It should contain a URL with 3 parameters that will get replaced before the URL is used to load the images.{key}
will be replaced by the string Q-server stored as the key when the file got uploaded through Q-servers/file
endpoint provided by the file plugin{width}
is replaced by the width the image should be loaded{format}
will bepng
orwebp
(apicture
element is used in the HTML with multiplesource
elements) Example:https://q-images.nzz.ch/{key}?width={width}&format={format}
MAP
- object containing properties (style url, attribution) for the map required by the mappointguess question type
Please have a look at the test environment for examples on what this variables should look like.
Start the Q dev server:
npx @nzz/q-cli server
Run the Q tool:
node dev.js
The testing framework used in this repository is Code.
Run the tests:
npm run test
When changing or implementing...
- A
route
, it needs to be tested in thee2e-tests.js
file - Something on the frontend, it needs to be tested in the
dom-tests.js
file
We provide automatically built docker images at https://hub.docker.com/r/nzzonline/q-quiz/. There are three options for deployment:
- use the provided images
- build your own docker images
- deploy the service using another technology
- Deploy
nzzonline/q-quiz
to a docker environment - Set the ENV variables as described in the configuration section
The tool structure follows the general structure of each Q tool. Further information can be found in Q server documentation - Developing tools.
Q-Quiz supports four question types multiple choice
, number guess
, map point guess
and number poll
. Each of them requires a question, and have additional configuration parameters, like min or max values. The questions multiple choice
, number guess
and map point guess
require a correct answer and will evaluate results. A version of number-guess
, called number-poll
does not require correct answer. The questions types are implemented as ES6 classes and each follow the same structure.
This is the default endpoint called for web targets. It returns the markup, stylesheets and scripts . The svelte framework is used to generate the markup. The scripts get transpiled to a jspm bundle and get loaded by the jspm loader on client-side.
The frontend communicates with the answer-service to store all the entered answers, get statistics on a single question or get the total score.
This endpoint is responsible for saving an answer
object in the quiz answer database.
This endpoint takes the item
and an array of answer
objects and returns a score object with properties maxScore
and achievedScore
based on the submitted answers.
This endpoint takes the question type
, itemId
, questionId
and optionally an answerId
as input and returns a stats object with parameters betterThanPercentage
, betterThanCount
, diffPercentage
, numberOfSameAnswers
, totalAnswers
. This information is used to display sentences like Nur 10 Prozent aller anderen lagen noch weiter daneben als Sie
after the user entered an answer.
This endpoint takes the questionId
, width
, height
and bounding box as parameter and returns a heatmap visualizing other map point guesses.
This endpoint takes the itemId
, questionId
and width as parameter and stripplot svg visualizing other number guesses.
There are on options for this tool.
Copyright (c) 2019 Neue Zürcher Zeitung. All rights reserved.
This software is published under the MIT license.