Create a first draft of the quiz that lets users order the elements
This commit is contained in:
commit
1ac81b7541
5 files changed
+12307
No files matched your search
+51
@@ -0,0 +1,51 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Ministranten-Quiz</title>
|
||||
<link rel="stylesheet" href="quiz.css">
|
||||
<script src="vue.js"></script>
|
||||
<script src="quiz.js" async></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="quiz">
|
||||
<div class="store">
|
||||
<div
|
||||
class="card"
|
||||
v-for="item_idx in store.items"
|
||||
v-bind:class="{selected: item_idx == store.selected}"
|
||||
v-bind:style="{visibility: store_card_visible(item_idx) ? 'visible' : 'hidden'}"
|
||||
v-on:click="store_select(item_idx)"
|
||||
>
|
||||
{{ store_text(item_idx) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="state">
|
||||
<div class="helptext" v-if="!all_inserted || order_revealed">{{ helptext }}</div>
|
||||
<button v-if="all_inserted && !order_revealed" v-on:click="reveal_order">Reihenfolge prüfen</button>
|
||||
</div>
|
||||
<div class="solution">
|
||||
<div class="arrow" v-bind:style="{visibility: arrows_visible ? 'visible' : 'hidden'}">
|
||||
<svg width="20" height="20" v-on:click="insert_front()">
|
||||
<path d="M20 0V20L0 10Z" fill="#2b8856" />
|
||||
</svg>
|
||||
</div>
|
||||
<template v-for="elem in solution">
|
||||
<div class="row">
|
||||
<div class="card" v-bind:class="{incorrect: incorrects[elem.main_idx]}">
|
||||
{{ solution_main_text(elem) }}
|
||||
<svg width=20 height=20 v-if="!order_correct" v-on:click="remove_solution(elem)">
|
||||
<path d="M2 2L18 18M18 2L2 18" stroke="#f00" stroke-width="2px" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="arrow" v-bind:style="{visibility: arrows_visible ? 'visible' : 'hidden'}">
|
||||
<svg width="20" height="20" v-on:click="insert_after(elem)">
|
||||
<path d="M20 0V20L0 10Z" fill="#2b8856" />
|
||||
</svg>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,88 @@
|
||||
body {
|
||||
background-color: #2b8856;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Roboto Slab';
|
||||
src: url(https://fonts.jimstatic.com/s/robotoslab/v11/BngbUXZYTXPIvIBgJJSb6s3BzlRRfKOFbvjojISmb2Rj.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
#quiz {
|
||||
background-color: #fff;
|
||||
font-family: "Roboto Slab";
|
||||
font-size: 16px;
|
||||
margin: 0 auto;
|
||||
width: 960px;
|
||||
}
|
||||
#quiz .store {
|
||||
border-bottom: 2px solid #000;
|
||||
padding: 5px;
|
||||
}
|
||||
#quiz .card {
|
||||
background-color: #eee;
|
||||
display: inline-block;
|
||||
margin: 5px;
|
||||
min-height: 50px;
|
||||
padding: 5px;
|
||||
vertical-align: top;
|
||||
width: 166px;
|
||||
}
|
||||
#quiz .store .card {
|
||||
cursor: pointer;
|
||||
}
|
||||
#quiz .store .card:hover {
|
||||
background-color: #c7dad0;
|
||||
}
|
||||
#quiz .card.selected {
|
||||
border: 3px solid #2b8856;
|
||||
padding: 2px;
|
||||
}
|
||||
#quiz .card.incorrect {
|
||||
background-color: #faa;
|
||||
}
|
||||
#quiz .state {
|
||||
border-bottom: 2px solid #000;
|
||||
padding: 5px;
|
||||
}
|
||||
#quiz .state .helptext {
|
||||
margin: 5px;
|
||||
}
|
||||
#quiz .state button {
|
||||
background-color: #e8912a;
|
||||
border-radius: 0;
|
||||
border-width: 0;
|
||||
cursor: pointer;
|
||||
font-family: "Roboto Slab";
|
||||
font-size: 16px;
|
||||
margin: 5px;
|
||||
padding: 5px;
|
||||
}
|
||||
#quiz .state button:hover {
|
||||
background-color: #facc99;
|
||||
}
|
||||
#quiz .solution {
|
||||
padding: 20px 5px;
|
||||
}
|
||||
#quiz .row .card {
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#quiz .row .card svg {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
visibility: hidden;
|
||||
}
|
||||
#quiz .row .card:hover svg {
|
||||
visibility: visible;
|
||||
}
|
||||
#quiz .arrow {
|
||||
height: 0;
|
||||
width: 0;
|
||||
}
|
||||
#quiz .arrow svg {
|
||||
cursor: pointer;
|
||||
left: 190px;
|
||||
position: relative;
|
||||
top: -10px;
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
let cards_content = [
|
||||
[
|
||||
"Einzug",
|
||||
"Kreuzzeichen und liturgischer Gruß",
|
||||
"Begrüßung und Einführung in die Feier",
|
||||
"Schuldbekenntnis und Vergebungsbitte (Bußakt)",
|
||||
"Kyrie",
|
||||
"Gloria",
|
||||
"Tagesgebet",
|
||||
"Lesung (Altes Testament)",
|
||||
"Zwischengesang / Antwortpsalm",
|
||||
"Lesung (Neues Testament)",
|
||||
"Hallelujaruf",
|
||||
"Evangelium",
|
||||
"Homilie / Predigt",
|
||||
"Credo / Glaubensbekenntnis",
|
||||
"Fürbitten",
|
||||
"Gabenbereitung mit Gabengebet",
|
||||
"Eucharistisches Hochgebet: Präfation",
|
||||
"Sanctus",
|
||||
"Einsetzungsbericht",
|
||||
"Vaterunser",
|
||||
"Friedensgruß",
|
||||
"Brechen des Brotes / Agnus Dei – Lamm Gottes",
|
||||
"Kommunion",
|
||||
"Dank- / Schlussgebet",
|
||||
"Segen",
|
||||
"Entlassung",
|
||||
],
|
||||
];
|
||||
|
||||
function shuffle(a) {
|
||||
for (let x = a.length-1; x>0; x--) {
|
||||
let y = Math.floor(Math.random() * (x + 1));
|
||||
let temp = a[x];
|
||||
a[x] = a[y];
|
||||
a[y] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
function shuffle_cards() {
|
||||
let a = [];
|
||||
for (let i=0; i<cards_content[0].length; i++) {
|
||||
a.push(i);
|
||||
}
|
||||
shuffle(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
function choose_incorrects(idx_vals) {
|
||||
let options = {
|
||||
0: [],
|
||||
};
|
||||
function find_longest_chain(maxkey) {
|
||||
let longest = null;
|
||||
for (let key in options) {
|
||||
if (
|
||||
(
|
||||
maxkey == null
|
||||
|| key <= maxkey
|
||||
)
|
||||
&& (
|
||||
longest == null
|
||||
|| options[key].length > options[longest].length
|
||||
|| (
|
||||
options[key].length == options[longest].length
|
||||
&& Number.parseInt(key) < Number.parseInt(longest)
|
||||
)
|
||||
)
|
||||
) {
|
||||
longest = key;
|
||||
}
|
||||
}
|
||||
return longest;
|
||||
}
|
||||
idx_vals.forEach((val) => {
|
||||
let longest = find_longest_chain(val);
|
||||
let mychain = options[longest].slice();
|
||||
mychain.push(val);
|
||||
options[val + 1] = mychain;
|
||||
});
|
||||
let result_chain = find_longest_chain(null);
|
||||
let a = [];
|
||||
for (let i=0; i<cards_content[0].length; i++) {
|
||||
a.push(true);
|
||||
}
|
||||
options[result_chain].forEach((elem) => {
|
||||
a[elem] = false;
|
||||
});
|
||||
return a;
|
||||
}
|
||||
|
||||
var app = new Vue({
|
||||
el: "#quiz",
|
||||
data: {
|
||||
cards_content,
|
||||
store: {
|
||||
section: 0,
|
||||
selected: null,
|
||||
items: shuffle_cards(),
|
||||
},
|
||||
solution: [],
|
||||
order_revealed: false,
|
||||
},
|
||||
computed: {
|
||||
helptext: function() {
|
||||
if (this.order_revealed) {
|
||||
if (this.order_correct) {
|
||||
return "Perfekt! Die Reihenfolge ist korrekt.";
|
||||
} else {
|
||||
return "Die Reihenfolge passt leider noch nicht ganz. Falsch eingeordnete Elemente sind rot markiert. Entferne diese mit einem Klick auf das rote X und füge sie neu ein, bis die Reihenfolge stimmt.";
|
||||
}
|
||||
} else {
|
||||
if (this.solution.length == 0) {
|
||||
return "Klicke oben auf ein Element des Gottesdienstablaufs, um es nach unten zu übernehmen.";
|
||||
} else if (this.solution.length == 1) {
|
||||
if (this.store.selected == null) {
|
||||
return "Wähle nun von oben das nächste Element aus.";
|
||||
} else {
|
||||
return "Klicke unten auf einen grünen Pfeil, um es an der richtigen Stelle in die Liste einzuordnen.";
|
||||
}
|
||||
} else {
|
||||
return "Bringe nun auch alle weiteren Elemente in die richtige Reihenfolge.";
|
||||
}
|
||||
}
|
||||
},
|
||||
all_inserted: function() {
|
||||
return this.solution.length == this.cards_content[0].length;
|
||||
},
|
||||
arrows_visible: function() {
|
||||
return this.store.selected != null;
|
||||
},
|
||||
incorrects: function() {
|
||||
if (this.order_revealed) {
|
||||
let idx_vals = this.solution.map(elem => elem.main_idx);
|
||||
return choose_incorrects(idx_vals);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
order_correct: function() {
|
||||
return this.order_revealed && this.all_inserted && !this.incorrects.includes(true);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
store_text: function(idx) {
|
||||
return this.cards_content[this.store.section][idx];
|
||||
},
|
||||
store_card_visible: function(idx) {
|
||||
for (let i=0; i<this.solution.length; i++) {
|
||||
if (this.solution[i].main_idx == idx) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
store_select: function(i) {
|
||||
if (this.solution.length == 0) {
|
||||
this.solution.push({
|
||||
main_idx: i,
|
||||
});
|
||||
} else if (i == this.store.selected) {
|
||||
this.store.selected = null;
|
||||
} else {
|
||||
this.store.selected = i;
|
||||
}
|
||||
},
|
||||
solution_main_text: function(elem) {
|
||||
return cards_content[0][elem.main_idx];
|
||||
},
|
||||
insert_front: function() {
|
||||
this.solution.splice(0, 0, {
|
||||
main_idx: this.store.selected,
|
||||
});
|
||||
this.store.selected = null;
|
||||
},
|
||||
find_solution: function(elem) {
|
||||
for (let i=0; i<this.solution.length; i++) {
|
||||
if (this.solution[i] == elem) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
},
|
||||
insert_after: function(elem) {
|
||||
this.solution.splice(this.find_solution(elem)+1, 0, {
|
||||
main_idx: this.store.selected,
|
||||
});
|
||||
this.store.selected = null;
|
||||
},
|
||||
remove_solution: function(elem) {
|
||||
this.solution.splice(this.find_solution(elem), 1);
|
||||
},
|
||||
reveal_order: function() {
|
||||
this.order_revealed = true;
|
||||
},
|
||||
},
|
||||
});
|
||||
+11965
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* Vue.js v2.6.11
|
||||
* (c) 2014-2019 Evan You
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Vue=t()}(this,function(){"use strict";var e=Object.freeze({});function t(e){return null==e}function n(e){return null!=e}function r(e){return!0===e}function i(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}function o(e){return null!==e&&"object"==typeof e}var a=Object.prototype.toString;function s(e){return"[object Object]"===a.call(e)}function c(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function u(e){return n(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function l(e){return null==e?"":Array.isArray(e)||s(e)&&e.toString===a?JSON.stringify(e,null,2):String(e)}function f(e){var t=parseFloat(e);return isNaN(t)?e:t}function p(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i<r.length;i++)n[r[i]]=!0;return t?function(e){return n[e.toLowerCase()]}:function(e){return n[e]}}var d=p("slot,component",!0),v=p("key,ref,slot,slot-scope,is");function h(e,t){if(e.length){var n=e.indexOf(t);if(n>-1)return e.splice(n,1)}}var m=Object.prototype.hasOwnProperty;function y(e,t){return m.call(e,t)}function g(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}var _=/-(\w)/g,b=g(function(e){return e.replace(_,function(e,t){return t?t.toUpperCase():""})}),$=g(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}),w=/\B([A-Z])/g,C=g(function(e){return e.replace(w,"-$1").toLowerCase()});var x=Function.prototype.bind?function(e,t){return e.bind(t)}:function(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n};function k(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function A(e,t){for(var n in t)e[n]=t[n];return e}function O(e){for(var t={},n=0;n<e.length;n++)e[n]&&A(t,e[n]);return t}function S(e,t,n){}var T=function(e,t,n){return!1},E=function(e){return e};function N(e,t){if(e===t)return!0;var n=o(e),r=o(t);if(!n||!r)return!n&&!r&&String(e)===String(t);try{var i=Array.isArray(e),a=Array.isArray(t);if(i&&a)return e.length===t.length&&e.every(function(e,n){return N(e,t[n])});if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(i||a)return!1;var s=Object.keys(e),c=Object.keys(t);return s.length===c.length&&s.every(function(n){return N(e[n],t[n])})}catch(e){return!1}}function j(e,t){for(var n=0;n<e.length;n++)if(N(e[n],t))return n;return-1}function D(e){var t=!1;return function(){t||(t=!0,e.apply(this,arguments))}}var L="data-server-rendered",M=["component","directive","filter"],I=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured","serverPrefetch"],F={optionMergeStrategies:Object.create(null),silent:!1,productionTip:!1,devtools:!1,performance:!1,errorHandler:null,warnHandler:null,ignoredElements:[],keyCodes:Object.create(null),isReservedTag:T,isReservedAttr:T,isUnknownElement:T,getTagNamespace:S,parsePlatformTagName:E,mustUseProp:T,async:!0,_lifecycleHooks:I},P=/a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;function R(e,t,n,r){Object.defineProperty(e,t,{value:n,enumerable:!!r,writable:!0,configurable:!0})}var H=new RegExp("[^"+P.source+".$_\\d]");var B,U="__proto__"in{},z="undefined"!=typeof window,V="undefined"!=typeof WXEnvironment&&!!WXEnvironment.platform,K=V&&WXEnvironment.platform.toLowerCase(),J=z&&window.navigator.userAgent.toLowerCase(),q=J&&/msie|trident/.test(J),W=J&&J.indexOf("msie 9.0")>0,Z=J&&J.indexOf("edge/")>0,G=(J&&J.indexOf("android"),J&&/iphone|ipad|ipod|ios/.test(J)||"ios"===K),X=(J&&/chrome\/\d+/.test(J),J&&/phantomjs/.test(J),J&&J.match(/firefox\/(\d+)/)),Y={}.watch,Q=!1;if(z)try{var ee={};Object.defineProperty(ee,"passive",{get:function(){Q=!0}}),window.addEventListener("test-passive",null,ee)}catch(e){}var te=function(){return void 0===B&&(B=!z&&!V&&"undefined"!=typeof global&&(global.process&&"server"===global.process.env.VUE_ENV)),B},ne=z&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function re(e){return"function"==typeof e&&/native code/.test(e.toString())}var ie,oe="undefined"!=typeof Symbol&&re(Symbol)&&"undefined"!=typeof Reflect&&re(Reflect.ownKeys);ie="undefined"!=typeof Set&&re(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return!0===this.set[e]},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var ae=S,se=0,ce=function(){this.id=se++,this.subs=[]};ce.prototype.addSub=function(e){this.subs.push(e)},ce.prototype.removeSub=function(e){h(this.subs,e)},ce.prototype.depend=function(){ce.target&&ce.target.addDep(this)},ce.prototype.notify=function(){for(var e=this.subs.slice(),t=0,n=e.length;t<n;t++)e[t].update()},ce.target=Line truncated
|
||||
Reference in new issue
Block a user