-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from nzzdev/release-1.9.1
Release 1.9.1
- Loading branch information
Showing
34 changed files
with
9,175 additions
and
8,602 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
dist: trusty | ||
sudo: true | ||
services: | ||
- docker | ||
- docker | ||
language: node_js | ||
node_js: | ||
- '10' | ||
- "10" | ||
cache: | ||
directories: | ||
- node_modules | ||
- jspm_packages | ||
install: | ||
- npm install -g jspm | ||
- npm install | ||
- jspm -v | ||
- jspm install | ||
- npm install -g jspm | ||
- npm install | ||
- jspm install | ||
before_script: | ||
- DOCKER_IMAGE_NAME="q-quiz" | ||
- DOCKER_TAG=$TRAVIS_BRANCH | ||
- DOCKER_IMAGE_NAME="q-quiz" | ||
- DOCKER_TAG=${TRAVIS_BRANCH//[^a-zA-Z0-9\_\-\.]/_} | ||
script: | ||
- npm run build | ||
- npm run test | ||
- docker build -t $DOCKER_IMAGE_NAME:$DOCKER_TAG . | ||
- echo $DOCKER_PASSWORD | docker login -u="$DOCKER_USERNAME" --password-stdin; docker tag $DOCKER_IMAGE_NAME:$DOCKER_TAG | ||
nzzonline/$DOCKER_IMAGE_NAME:$DOCKER_TAG; docker push nzzonline/$DOCKER_IMAGE_NAME:$DOCKER_TAG; | ||
- if [ "$TRAVIS_BRANCH" == "staging" ]; then docker run --rm -it -e RANCHER_URL -e CATTLE_ACCESS_KEY | ||
-e CATTLE_SECRET_KEY etlweather/gaucho upgrade $RANCHER_SERVICE_ID_STAGING --auto_complete | ||
--start_first --imageUuid="docker:nzzonline/$DOCKER_IMAGE_NAME:$DOCKER_TAG" || true; | ||
fi | ||
cache: | ||
directories: | ||
- node_modules | ||
- npm run build | ||
- npm run test | ||
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker build -t $DOCKER_IMAGE_NAME:$DOCKER_TAG .; fi' | ||
after_success: | ||
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo $DOCKER_PASSWORD | docker login -u="$DOCKER_USERNAME" --password-stdin; docker tag $DOCKER_IMAGE_NAME:$DOCKER_TAG nzzonline/$DOCKER_IMAGE_NAME:$DOCKER_TAG; docker push nzzonline/$DOCKER_IMAGE_NAME:$DOCKER_TAG; fi' | ||
notifications: | ||
slack: | ||
secure: securekey | ||
secure: cGKGD1gKHQEJgb6zEElK3lnJNhAT2nWF/0a35TQ+WMrEK5KawMJa/xyD93jOCYW13swKlXyYkgQLMpC5yh2LejChVnsVJ4vzxJvEd7OIPabZ/87UUT0XzfSBmAl96DjpJxQ1WhTiiSnr7DTmu61SQoXjhcBLrWzE63wzhvbE/kljv1hPOfVjLWIg6TNMwxc9g40hfqkd3Bc/P69Iw/4L4TqYnNuAXncvAtcPmtfxuTFUXY4N/zHuhiG/MKoq2g1DWqYNLUUh1NmG+fusFu7IhgYGwKdIFqhEoPfAJNxivuflalYOVDA3oBENaAU347CnxgHSwO2X+Mw+c0lG9w8gxGcUUsYmv8kZ32kPvBPrt3IFHTRseQvMk8lWfyhRoecucFbv6Z1y2disBsoP5Y2jILimv6jXkqP8TYGYyX3IMjpydA4qN27yRNJF2O1HHBj3W2nGW0nrjyCUttrSrOjJ6jS4zf7jXcb1xEL1iblk7Y5u39obMSJNyAJQ8+jx/LaTHyDOJB5r8u1tPTsMsWH9tGaDFwsV3PovHNCHDK5vwF1Yd3jBjcXeHaTPBw6fvZH6DkSl410c0uxH/lr92TZ/7OeL902p063Mcj4HGO/2CEZgF+wDCIPqPrfakfVSlrx5DvGbtIA/RNpL2J2VszeDi3NCh+K2hoP3OXrL3Ey9LFc= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) NZZ Management AG | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,152 @@ | ||
# Q Quiz | ||
# Q Quiz [![Build Status](https://travis-ci.com/nzzdev/Q-quiz.svg?token=bwR7zbPTTpEoDxbY2dJR&branch=dev)](https://travis-ci.com/nzzdev/Q-quiz) [![Greenkeeper badge](https://badges.greenkeeper.io/nzzdev/Q-quiz.svg?token=0092ccff54931fc37f0887dd73f1a0bd550f584c80482e40fde8768e26d885ac&ts=1551342745740)](https://greenkeeper.io/) | ||
|
||
**Maintainer**: [manuelroth](https://github.com/manuelroth) | ||
|
||
Q Quiz is one tool of the Q toolbox to render quizzes containing questions of type multiple choice, number guess and map point guess. It also includes the rendering of answer statistics for each question type. | ||
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](https://q-playground.st.nzz.ch/). | ||
|
||
## Table of contents | ||
|
||
- [Installation](#installation) | ||
- [Configuration](#configuration) | ||
- [Development](#development) | ||
- [Testing](#testing) | ||
- [Deployment](#deployment) | ||
- [Functionality](#functionality) | ||
- [License](#license) | ||
|
||
## Installation | ||
|
||
```bash | ||
$ npm install | ||
$ npm run build | ||
git clone [email protected]:nzzdev/Q-quiz.git | ||
cd ./Q-quiz | ||
nvm use | ||
npm install | ||
jspm install | ||
npm run build | ||
``` | ||
|
||
[to the top](#table-of-contents) | ||
|
||
## Configuration | ||
|
||
The following environment variables must be specified when starting the tool: | ||
|
||
- `COUCH_DB_USER` - couchdb user for accessing the answer-store database | ||
- `COUCH_DB_PASS` - couchdb password for accessing the answer-store database | ||
- `COUCH_DB_URL_Q_QUIZ` - url to the answer-store database | ||
- `COUCH_DB_URL_Q_ITEMS` - url to the q-items database (used for the statistics) | ||
- `ENRICO_API_URL` - url to enrico used to give article recommendations | ||
- `ENRICO_PRODUCTS` - array of publications which should be queried for article recommendations | ||
- `IMAGE_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](https://github.com/nzzdev/Q-server/blob/dev/plugins/file/index.js) | ||
`{width}` is replaced by the width the image should be loaded | ||
`{format}` will be `png` or `webp` (a `picture` element is used in the HTML with multiple `source` elements) | ||
Example: `https://q-images.nzz.ch/{key}?width={width}&format={format}` | ||
|
||
Please have a look at the test environment for examples on what this variables should look like. | ||
|
||
[to the top](#table-of-contents) | ||
|
||
## Development | ||
|
||
Install the [Q cli](https://github.com/nzzdev/Q-cli) and start the Q dev server: | ||
Start the Q dev server: | ||
|
||
``` | ||
$ Q server | ||
npx @nzz/q-cli server | ||
``` | ||
|
||
Run the Q tool: | ||
|
||
``` | ||
$ node index.js | ||
node dev.js | ||
``` | ||
|
||
## Implementation details | ||
[to the top](#table-of-contents) | ||
|
||
## Testing | ||
|
||
The testing framework used in this repository is [Code](https://github.com/hapijs/code). | ||
|
||
Run the tests: | ||
|
||
``` | ||
npm run test | ||
``` | ||
|
||
### Implementing a new test | ||
|
||
When changing or implementing... | ||
|
||
- A `route`, it needs to be tested in the `e2e-tests.js` file | ||
- Something on the frontend, it needs to be tested in the `dom-tests.js` file | ||
|
||
[to the top](#table-of-contents) | ||
|
||
## Deployment | ||
|
||
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 | ||
|
||
### Use the provided docker images | ||
|
||
1. Deploy `nzzonline/q-quiz` to a docker environment | ||
2. Set the ENV variables as described in the [configuration section](#configuration) | ||
|
||
[to the top](#table-of-contents) | ||
|
||
## Functionality | ||
|
||
The tool structure follows the general structure of each Q tool. Further information can be found in [Q server documentation - Developing tools](https://nzzdev.github.io/Q-server/developing-tools.html). | ||
|
||
### Question Types | ||
|
||
Q-Quiz supports three different question types `multiple choice`, `number guess` and `map point guess`. Each question type takes a question, a correct answer and additional configuration parameters like wrong answers or min and max values. The questions types are implemented as ES6 classes and each follow the same structure. | ||
|
||
### `/rendering-info/html-js` | ||
|
||
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. | ||
|
||
### Answer-Service | ||
|
||
The frontend communicates with the answer-service to store all the entered answers, get statistics on a single question or get the total score. | ||
|
||
#### `/answer` | ||
|
||
This endpoint is responsible for saving an `answer` object in the quiz answer database. | ||
|
||
#### `/score` | ||
|
||
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. | ||
|
||
#### `/stats/answers/{type}/{itemId}/{questionId}/{answerId?}` | ||
|
||
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. | ||
|
||
#### `/map/{questionId}/heatmap/{width}/{height}/{bbox}` | ||
|
||
This endpoint takes the `questionId`, `width`, `height` and bounding box as parameter and returns a heatmap visualizing other map point guesses. | ||
|
||
#### `/number-guess/{itemId}/{questionId}/plot/{width}` | ||
|
||
This endpoint takes the `itemId`, `questionId` and width as parameter and stripplot svg visualizing other number guesses. | ||
|
||
[to the top](#table-of-contents) | ||
|
||
### Options | ||
|
||
There are on options for this tool. | ||
|
||
[to the top](#table-of-contents) | ||
|
||
## License | ||
Copyright (c) 2018 Neue Zürcher Zeitung. All rights reserved. | ||
|
||
This software is published under the MIT license. | ||
Copyright (c) 2019 Neue Zürcher Zeitung. All rights reserved. | ||
|
||
This software is published under the [MIT](LICENSE) license. | ||
|
||
[to the top](#table-of-contents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.