updated questionmaire
This commit is contained in:
parent
de12ea3f4b
commit
577ae5722d
3 changed files with 88 additions and 27 deletions
|
@ -1,7 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="question">
|
<div class="question">
|
||||||
<p>{{ question }}</p>
|
<p>{{ question }}</p>
|
||||||
|
<div v-if="type === 'choice'" class="question-choice">
|
||||||
|
<button>Ja</button>
|
||||||
|
<button>Nein</button>
|
||||||
|
</div>
|
||||||
|
<div v-if="type === 'slider'" class="question-slider">
|
||||||
|
<p>{{ selection }}</p>
|
||||||
|
<input v-model="selection" type="range" min="0" max="150" value="18" class="slider">
|
||||||
|
</div>
|
||||||
|
<div v-if="type === 'options'" class="question-options">
|
||||||
<button v-bind:key="answer" v-for="answer in answers">{{ answer }}</button>
|
<button v-bind:key="answer" v-for="answer in answers">{{ answer }}</button>
|
||||||
|
</div>
|
||||||
<router-link to="/questionmaire"><button class="alert">Ich brauche Hilfe zu dieser Frage</button></router-link>
|
<router-link to="/questionmaire"><button class="alert">Ich brauche Hilfe zu dieser Frage</button></router-link>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -10,12 +20,49 @@
|
||||||
export default {
|
export default {
|
||||||
name: "Question",
|
name: "Question",
|
||||||
props: {
|
props: {
|
||||||
|
type: String,
|
||||||
question: String,
|
question: String,
|
||||||
answers: Array
|
answers: Array
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
selection: 0
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.slider {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 1em;
|
||||||
|
background: #d3d3d3;
|
||||||
|
outline: none;
|
||||||
|
opacity: 0.7;
|
||||||
|
-webkit-transition: .2s;
|
||||||
|
transition: opacity .2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider::-webkit-slider-thumb {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
width: 2.5em;
|
||||||
|
height: 2.5em;
|
||||||
|
background: #e94a47;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider::-moz-range-thumb {
|
||||||
|
width: 2.5em;
|
||||||
|
height: 2.5em;
|
||||||
|
background: #e94a47;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -3,29 +3,41 @@ import Vuex from 'vuex'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
|
const preQuestions = [
|
||||||
|
{
|
||||||
|
type: "slider",
|
||||||
|
question: "Wie alt sind Sie?"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
illustration: "",
|
||||||
|
type: "choice",
|
||||||
|
question: "Haben Sie sich in letzter Zeit in einem Risikogebiet aufgehalten?"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
illustration: "",
|
||||||
|
type: "choice",
|
||||||
|
question: "Hatten Sie Kontakt zu Personen, die positiv auf COVID-19 getestet wurden?"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
currentQuestion: 0,
|
currentQuestion: 0,
|
||||||
answers: [],
|
answers: [],
|
||||||
questions: [{
|
questions: preQuestions
|
||||||
question: "Test",
|
|
||||||
answers: ["Answer 1", "Answer 2", "Answer 3"]
|
|
||||||
}]
|
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
nextQuestion() {
|
nextQuestion() {
|
||||||
if(this.state.currentQuestion <=
|
if (this.state.currentQuestion <=
|
||||||
this.state.questions.length - 1)
|
this.state.questions.length - 1)
|
||||||
this.state.currentQuestion += 1
|
this.state.currentQuestion += 1
|
||||||
},
|
},
|
||||||
previousQuestion() {
|
previousQuestion() {
|
||||||
if(this.state.currentQuestion > 0) {
|
if (this.state.currentQuestion > 0) {
|
||||||
this.state.currentQuestion -= 1
|
this.state.currentQuestion -= 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {},
|
||||||
},
|
modules: {}
|
||||||
modules: {
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="questionmaire">
|
<div class="questionmaire">
|
||||||
<Question v-bind:question="$store.state.questions[$store.state.currentQuestion].question"
|
<Question
|
||||||
|
v-bind:type="$store.state.questions[$store.state.currentQuestion].type"
|
||||||
|
v-bind:question="$store.state.questions[$store.state.currentQuestion].question"
|
||||||
v-bind:answers="$store.state.questions[$store.state.currentQuestion].answers"></Question>
|
v-bind:answers="$store.state.questions[$store.state.currentQuestion].answers"></Question>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in a new issue