Skip to content

Commit

Permalink
Merge pull request #22 from nzzdev/release-1.2.0
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
fuenkchen committed Sep 1, 2017
2 parents cb7d3da + 3fb1d87 commit 014ec7a
Show file tree
Hide file tree
Showing 15 changed files with 344 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
- docker
language: node_js
node_js:
- '7.6'
- '8.1'
install:
- npm install -g jspm
- npm install
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use following version of Node as the base image
FROM node:7.3
FROM node:8.1

# Set work directory for run/cmd
WORKDIR /app
Expand Down
148 changes: 74 additions & 74 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,118 +46,118 @@
<div id="container" class="widget widget--qembed entry">
<div id="quiz"></div>
</div>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.some other stuff </div>
<script src="node_modules/systemjs/dist/system-production.js"></script>
<script src="node_modules/systemjs/dist/system-production.js"></script>
<script>
let data = {
"item": {
"title": "Literatur-Quiz",
"title": "Ein tolles Quiz",
"elements": [
{
"title": "Wie gut kennen Sie die Weltliteratur?",
"type": "cover",
"id": "24e0125fe3583db8016ae44c2df47a64-1492782826375-7417"
"id": "86a6d3bc3be11a1cf51f7c12bd10858c-1503673199200-897399321",
"type": "cover"
},
{
"id": "24e0125fe3583db8016ae44c2df47a64-1492782862005-3923",
"question": "Wie heisst der Autor der \"Odyssee\"?",
"id": "86a6d3bc3be11a1cf51f7c12bd10858c-1503673205043-233776299",
"type": "multipleChoice",
"image": {},
"choices": [
"James Joyce",
"Friedrich Dürrenmatt",
"Ernst Jandl",
"Derek Walcott"
"vielleicht",
"falsch",
"absolut falsch"
],
"answer": "Homer",
"answerText": "Homer hatte die \"Odyssee\" gesungen, von <a href=\"https://www.nzz.ch/us-praesidentschaftswahl-liveblog-us-wahl-ld.125729\">James Joyce</a> stammte der \"Ulysses\", und Derek Walcott hatte das Epos \"Omeros\" geschrieben.",
"notes": "Ein paar Anmerkungen könnten hier stehen",
"articleRecommendations": [
{
"text": "Der karibische Dichter Derek Walcott hatte 1992 den Literaturnobelpreis erhalten und ist im letzten März 87-jährig gestorben:",
"articleId": "ld.152029"
}
]
"articleRecommendations": [],
"question": "Was ist die richtige Antwort?",
"answer": "richtig"
},
{
"id": "24e0125fe3583db8016ae44c2df47a64-1492783275801-3327",
"question": "Welchen Preis erzielte im Jahr 2000 die Auktion der ersten Manuskript-Seite von Marcel Prousts \"A la recherche du temps perdu\"?",
"id": "86a6d3bc3be11a1cf51f7c12bd10858c-1503673244888-827300797",
"type": "numberGuess",
"unit": "£",
"min": "100000",
"max": "1000000",
"step": "50",
"answer": "663750",
"answerText": "Die Manuskript-Seite wurde im Juli 2000 bei Christie's für 663'750 Pfund versteigert.",
"notes": "",
"image": {
"url": "http://www.famousauthors.org/famous-authors/marcel-proust.jpg"
},
"articleRecommendations": [
{
"text": "Marcel Proust war übrigens auch ein grandioser Briefschreiber:",
"articleId": "ld.144636"
}
]
"image": {},
"articleRecommendations": [],
"question": "Hausnummer der NZZ",
"answer": 11,
"min": 1,
"max": 30,
"step": 1
},
{
"id": "24e0125fe3583db8016ae44c2df47a64-1492786169038-1451",
"question": "Welches ist das meist verkaufte und in die meisten Sprachen übersetzte Buch der Schweizer Literaturgeschichte?",
"type": "multipleChoice",
"choices": [
"\"Der grüne Heinrich\" von Gottfried Keller",
"\"Anne Bäbi Jowäger\" von Jeremias Gotthelf",
"\"Stiller\" von Max Frisch"
],
"answer": "\"Heidi\" von Johanna Spyri",
"answerText": "Johanna Spyris 1880 erschienenes Jugendbuch \"Heidi\" wurde in mehr als fünfzig Sprachen übersetzt.",
"notes": "",
"articleRecommendations": []
"id": "86a6d3bc3be11a1cf51f7c12bd10858c-1503673375520-572013568",
"type": "numberGuess",
"image": {},
"articleRecommendations": [],
"question": "Temperatur",
"answer": 25,
"min": 1,
"max": 35,
"step": 1
},
{
"id": "24e0125fe3583db8016ae44c2df47a64-1492786574258-7503",
"question": "In welcher Stadt spielt James Joyces \"Ulysses\"?",
"id": "86a6d3bc3be11a1cf51f7c12bd10858c-1503673602641-999859280",
"type": "mapPointGuess",
"answer": {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-6.281314,
53.33928
8.548714,
47.3664
]
},
"properties": {
"pointLabel": "Dublin"
"pointLabel": "NZZ Red",
"label": "11 Falkenstrasse"
},
"bbox": [
-13.710937500000002,
42.42345651793833,
28.4765625,
57.51582286553883
8.50547790527344,
47.347779215247144,
8.591995239257814,
47.38498483918202
]
},
"answerText": "\"Ulysses\" von James Joyce spielt am 16. Juni 1904 in Dublin.",
"notes": "",
"image": {},
"articleRecommendations": [],
"question": "wo ist die nzz?"
},
{
"id": "24e0125fe3583db8016ae44c2df47a64-1492786574258-7504",
"id": "86a6d3bc3be11a1cf51f7c12bd10858c-1503673653497-139543834",
"type": "mapPointGuess",
"answer": {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
13.42632293701172,
51.456574106519724
]
},
"properties": {
"pointLabel": "Kuhkaff",
"label": "Röderland"
},
"bbox": [
2.4169921875000004,
46.830133640447414,
24.565429687500004,
55.60317816902704
]
},
"image": {},
"articleRecommendations": [],
"question": "wo kommt sharon her?"
},
{
"id": "86a6d3bc3be11a1cf51f7c12bd10858c-1503673750136-872919612",
"type": "lastCard",
"title": "The last one",
"text": "The very last.....",
"quizLink": "https://www.nzz.ch/feuilleton/nzz-quizz-twin-peaks-kehrt-zurueck-ld.1294313",
"quizTitle": "Was wissen Sie über Twin Peaks",
"articleRecommendations": [
{
"text": "Der karibische Dichter Derek Walcott hatte 1992 den Literaturnobelpreis erhalten und ist im letzten März 87-jährig gestorben:",
"articleId": "ld.152029"
}
]
"title": "Geschafft. Danke fürs Mitspielen.",
"isFinalScoreShown": true,
"articleRecommendations": [],
"text": "Ui so ein Spass"
}
]
],
},
toolRuntimeConfig: {
toolBaseUrl: `http://localhost:3000`,
isPure: false
isPure: true
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nzz/q-quiz",
"version": "1.1.6",
"version": "1.2.0",
"description": "Q quiz",
"keywords": [
"storytelling",
Expand Down
3 changes: 2 additions & 1 deletion resources/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"Grösse der Zwischenschritte": "step value",
"Ort schätzen": "map point guess",
"letzte Seite": "last card",
"Text": "text",
"Auswertung anzeigen": "show final score",
"Abmoderation": "closing text",
"Link zu Anschlussquiz": "URL of follow-up quiz",
"Titel Anschlussquiz": "title follow-up quiz",
"Artikelempfehlungen": "article recommendations",
Expand Down
17 changes: 13 additions & 4 deletions resources/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,30 @@
},
"title": {
"type": "string",
"title": "Titel"
"title": "Titel",
"default": "Geschafft. Danke fürs Mitspielen.",
"Q:options": {
"hideInEditor": true
}
},
"isFinalScoreShown": {
"type": "boolean",
"title": "Auswertung anzeigen",
"default": true
},
"text": {
"type": "string",
"title": "Text"
"title": "Abmoderation"
},
"articleRecommendations": {"$ref": "#/definitions/articleRecommendations"},
"quizLink": {
"type": "string",
"title": "Link zu Anschlussquiz"
},
"quizTitle": {
"type": "string",
"title": "Titel Anschlussquiz"
},
"articleRecommendations": {"$ref": "#/definitions/articleRecommendations"}
}
}
},
"elementId": {
Expand Down
5 changes: 3 additions & 2 deletions routes/rendering-info/html-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ module.exports = {

if (item.hasLastCard) {
scriptData.lastCardData = {
articleRecommendations: item.lastCard.articleRecommendations
articleRecommendations: item.lastCard.articleRecommendations,
}
scriptData.isFinalScoreShown = item.lastCard.isFinalScoreShown || false;
item.isFinalScoreShown = scriptData.isFinalScoreShown;
}

// elements are already split into cover, last card and questions
// so we don't need it here anymore
delete item.elements;
Expand Down
42 changes: 32 additions & 10 deletions script_src/MapPointGuessHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Leaflet from 'leaflet';
import iconPinSvg from './resources/icon-pin.svg!text';
import { getAnswerTextElement } from './answerHelpers.js';
import { getAnswerTextElement, getDistanceText } from './answerHelpers.js';

Leaflet.Icon.Default.imagePath = 'jspm_packages/github/Leaflet/[email protected]/dist/images';

Expand Down Expand Up @@ -46,6 +46,7 @@ export default class MapPointGuessHandler {
this.setMapSize(map);
window.addEventListener('resize', () => {
try {
this.mapBounds = map.getBounds();
this.setMapSize(map)
} catch (e) {

Expand All @@ -59,6 +60,8 @@ export default class MapPointGuessHandler {
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> &amp; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);

this.mapBounds = map.getBounds();

let markerPinIcon = Leaflet.divIcon({
className: 'q-quiz-map-pin',
html: iconPinSvg,
Expand Down Expand Up @@ -93,6 +96,27 @@ export default class MapPointGuessHandler {
}
}

getWorstAnswer() {
return this.worstAnswer;
}

setWorstAnswer() {
let mapBoundings = [
this.mapBounds['_southWest'].lng,
this.mapBounds['_southWest'].lat,
this.mapBounds['_northEast'].lng,
this.mapBounds['_northEast'].lat,
];

let correctLatLng = new L.latLng([this.data.correctAnswer.geometry.coordinates[1], this.data.correctAnswer.geometry.coordinates[0]]);
let upperLeft = new L.latLng([mapBoundings[3], mapBoundings[0]]);
let upperRight = new L.latLng([mapBoundings[3], mapBoundings[2]]);
let lowerLeft = new L.latLng([mapBoundings[1], mapBoundings[0]]);
let lowerRight = new L.latLng([mapBoundings[1], mapBoundings[2]]);

return Math.floor(Math.max(upperLeft.distanceTo(correctLatLng), upperRight.distanceTo(correctLatLng), lowerLeft.distanceTo(correctLatLng), lowerRight.distanceTo(correctLatLng)));
}

renderResult(answer) {
const correctAnswer = this.data.correctAnswer;
this.resultElement = this.questionElement.querySelector('.q-quiz-result');
Expand All @@ -110,11 +134,14 @@ export default class MapPointGuessHandler {
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> &amp; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);

this.bounds = map.getBounds();

this.worstAnswer = this.setWorstAnswer();

if (answer && answer.latLng) {
// add the correct point and the users input point
let bounds = map.getBounds();
let west = bounds.getWest();
let east = bounds.getEast();
let west = this.bounds.getWest();
let east = this.bounds.getEast();

let correctAnswerLabelPosition;
let answerLabelPosition;
Expand Down Expand Up @@ -174,12 +201,7 @@ export default class MapPointGuessHandler {
let textElement = getAnswerTextElement(answersStats, isCorrectAnswer, () => {
let text = '';
if (answer.distance !== undefined) {
let distanceText;
if (answer.distance > 1000) {
distanceText = `${(answer.distance / 1000).toFixed(1)} km`;
} else {
distanceText = `${answer.distance} m`;
}
let distanceText = getDistanceText(answer.distance);
text = ` Ihre Schätzung liegt um ${distanceText} daneben.`;
}
return text;
Expand Down
Loading

0 comments on commit 014ec7a

Please sign in to comment.