Renamed app store to results store.
This commit is contained in:
parent
3788f08679
commit
28732539de
@ -1,7 +1,7 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
export const useAppStore = defineStore({
|
export const useResultsStore = defineStore({
|
||||||
id: 'app',
|
id: 'results',
|
||||||
state: () => ({
|
state: () => ({
|
||||||
answers: [],
|
answers: [],
|
||||||
playbooks: {},
|
playbooks: {},
|
@ -1,5 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useAnswersStore } from '@/stores/answers.js'
|
||||||
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
import Content from '@/components/Content.vue'
|
import Content from '@/components/Content.vue'
|
||||||
import Header from '@/components/Header.vue'
|
import Header from '@/components/Header.vue'
|
||||||
import TextFrame from '@/components/TextFrame.vue'
|
import TextFrame from '@/components/TextFrame.vue'
|
||||||
@ -13,14 +14,21 @@
|
|||||||
TextFrame
|
TextFrame
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const appStore = useAppStore()
|
const answersStore = useAnswersStore()
|
||||||
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
appStore
|
answersStore,
|
||||||
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.appStore.$reset()
|
if (this.answersStore.quizCurrent !== null) {
|
||||||
|
this.$router.push(`/quiz/question/${this.answersStore.quizCurrent}`)
|
||||||
|
} else {
|
||||||
|
this.answersStore.$reset()
|
||||||
|
}
|
||||||
|
this.resultsStore.$reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,9 +1,28 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import { useAnswersStore } from '@/stores/answers.js'
|
||||||
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
import Sidebar from '@/components/sidebar/Index.vue'
|
import Sidebar from '@/components/sidebar/Index.vue'
|
||||||
export default {
|
export default {
|
||||||
name: 'AboutIndex',
|
name: 'AboutIndex',
|
||||||
components: {
|
components: {
|
||||||
Sidebar
|
Sidebar
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const answersStore = useAnswersStore()
|
||||||
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
|
return {
|
||||||
|
answersStore,
|
||||||
|
resultsStore
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.answersStore.quizCurrent !== null) {
|
||||||
|
this.$router.push(`/quiz/question/${this.answersStore.quizCurrent}`)
|
||||||
|
} else {
|
||||||
|
this.answersStore.$reset()
|
||||||
|
}
|
||||||
|
this.resultsStore.$reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
import Config from '@/config.js'
|
import Config from '@/config.js'
|
||||||
import { useQuestionStore } from '@/stores/questions.js'
|
import { useQuestionStore } from '@/stores/questions.js'
|
||||||
import { useAnswersStore } from '@/stores/answers.js'
|
import { useAnswersStore } from '@/stores/answers.js'
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const questionStore = useQuestionStore()
|
const questionStore = useQuestionStore()
|
||||||
const answersStore = useAnswersStore()
|
const answersStore = useAnswersStore()
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
questionStore,
|
questionStore,
|
||||||
answersStore,
|
answersStore,
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
name: 'QuestionIndex',
|
name: 'QuestionIndex',
|
||||||
@ -28,8 +28,8 @@
|
|||||||
this.$router.push(`/quiz/question/${this.answersStore.quizCurrent}`)
|
this.$router.push(`/quiz/question/${this.answersStore.quizCurrent}`)
|
||||||
} else {
|
} else {
|
||||||
this.answersStore.$reset()
|
this.answersStore.$reset()
|
||||||
this.appStore.$reset()
|
|
||||||
}
|
}
|
||||||
|
this.resultsStore.$reset()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getQuestions() {
|
getQuestions() {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
import Config from '@/config.js'
|
import Config from '@/config.js'
|
||||||
import { useQuestionStore } from '@/stores/questions.js'
|
import { useQuestionStore } from '@/stores/questions.js'
|
||||||
import { useAnswersStore } from '@/stores/answers.js'
|
import { useAnswersStore } from '@/stores/answers.js'
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
import Content from '@/components/Content.vue'
|
import Content from '@/components/Content.vue'
|
||||||
import Header from '@/components/Header.vue'
|
import Header from '@/components/Header.vue'
|
||||||
import TextFrame from '@/components/TextFrame.vue'
|
import TextFrame from '@/components/TextFrame.vue'
|
||||||
@ -15,12 +15,12 @@
|
|||||||
setup() {
|
setup() {
|
||||||
const questionStore = useQuestionStore()
|
const questionStore = useQuestionStore()
|
||||||
const answersStore = useAnswersStore()
|
const answersStore = useAnswersStore()
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
questionStore,
|
questionStore,
|
||||||
answersStore,
|
answersStore,
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
@ -69,8 +69,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
).then( (response) => {
|
).then( (response) => {
|
||||||
console.log('Submitted results.')
|
console.log('Submitted answers.')
|
||||||
this.appStore.store('results', response.data)
|
this.resultsStore.store('results', response.data)
|
||||||
console.log('Results fetched from the server.')
|
console.log('Results fetched from the server.')
|
||||||
this.answersStore.quizCurrent = null
|
this.answersStore.quizCurrent = null
|
||||||
this.$router.push('/results')
|
this.$router.push('/results')
|
||||||
|
@ -4,15 +4,15 @@
|
|||||||
import Content from '@/components/Content.vue'
|
import Content from '@/components/Content.vue'
|
||||||
import Header from '@/components/Header.vue'
|
import Header from '@/components/Header.vue'
|
||||||
import TextFrame from '@/components/TextFrame.vue'
|
import TextFrame from '@/components/TextFrame.vue'
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
import ChevronDoubleRight from '@/components/icons/ChevronDoubleRight.vue'
|
import ChevronDoubleRight from '@/components/icons/ChevronDoubleRight.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -30,7 +30,7 @@
|
|||||||
axios.get(`${Config.SERVER}api/playbooks/`)
|
axios.get(`${Config.SERVER}api/playbooks/`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log('Fetched playbook stats from the server.')
|
console.log('Fetched playbook stats from the server.')
|
||||||
this.appStore.store('playbooks', response.data)
|
this.resultsStore.store('playbooks', response.data)
|
||||||
})
|
})
|
||||||
.catch( error => {
|
.catch( error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -39,7 +39,7 @@
|
|||||||
axios.get(`${Config.SERVER}api/count/`)
|
axios.get(`${Config.SERVER}api/count/`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log('Fetched user count from the server.')
|
console.log('Fetched user count from the server.')
|
||||||
this.appStore.store('count', response.data)
|
this.resultsStore.store('count', response.data)
|
||||||
})
|
})
|
||||||
.catch( error => {
|
.catch( error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -76,8 +76,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(number, playbook, index) in this.appStore.playbooks" :key="playbook" class="hover:bg-yellow-50" :class="index % 2 == 0? `bg-lime-50 border-b dark:bg-gray-900 dark:border-gray-700` : `bg-lime-100 border-b dark:bg-gray-800 dark:border-gray-700`">
|
<tr v-for="(number, playbook, index) in this.resultsStore.playbooks" :key="playbook" class="hover:bg-yellow-50" :class="index % 2 == 0? `bg-lime-50 border-b dark:bg-gray-900 dark:border-gray-700` : `bg-lime-100 border-b dark:bg-gray-800 dark:border-gray-700`">
|
||||||
<td v-if="this.appStore.results.playbooks.some(obj => obj.hasOwnProperty(playbook))">
|
<td v-if="this.resultsStore.results.playbooks.some(obj => obj.hasOwnProperty(playbook))">
|
||||||
<ChevronDoubleRight/>
|
<ChevronDoubleRight/>
|
||||||
</td>
|
</td>
|
||||||
<td v-else>
|
<td v-else>
|
||||||
@ -90,11 +90,11 @@
|
|||||||
{{ number }}
|
{{ number }}
|
||||||
</td>
|
</td>
|
||||||
<td scope="col" class="py-1">
|
<td scope="col" class="py-1">
|
||||||
{{ Math.round(100*number/this.appStore.count) }} %
|
{{ Math.round(100*number/this.resultsStore.count) }} %
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" class="text-center text-lg text-gray-600">Out of {{ this.appStore.count }} users</td>
|
<td colspan="4" class="text-center text-lg text-gray-600">Out of {{ this.resultsStore.count }} users</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<script>
|
<script>
|
||||||
import Sidebar from '@/components/sidebar/Index.vue'
|
import Sidebar from '@/components/sidebar/Index.vue'
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
name: 'ResultsIndex',
|
name: 'ResultsIndex',
|
||||||
@ -15,7 +15,7 @@
|
|||||||
Sidebar
|
Sidebar
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.appStore.results.playbooks.length > 1) {
|
if (this.resultsStore.results.playbooks.length > 1) {
|
||||||
this.$router.options.routes[3].children[0].meta.title = 'Your Results'
|
this.$router.options.routes[3].children[0].meta.title = 'Your Results'
|
||||||
} else {
|
} else {
|
||||||
this.$router.options.routes[3].children[0].meta.title = 'Your Result'
|
this.$router.options.routes[3].children[0].meta.title = 'Your Result'
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
import Content from '@/components/Content.vue'
|
import Content from '@/components/Content.vue'
|
||||||
import Header from '@/components/Header.vue'
|
import Header from '@/components/Header.vue'
|
||||||
import TextFrame from '@/components/TextFrame.vue'
|
import TextFrame from '@/components/TextFrame.vue'
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
name: 'Results',
|
name: 'Results',
|
||||||
@ -41,12 +41,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<TextFrame>
|
<TextFrame>
|
||||||
<Header>
|
<Header>
|
||||||
<span v-if="this.appStore.results.playbooks.length > 1">Your Results</span>
|
<span v-if="this.resultsStore.results.playbooks.length > 1">Your Results</span>
|
||||||
<span v-else>Your Result</span>
|
<span v-else>Your Result</span>
|
||||||
</Header>
|
</Header>
|
||||||
<Content>
|
<Content>
|
||||||
<article class="prose">
|
<article class="prose">
|
||||||
<section v-for="playbook in this.appStore.results.playbooks" :key="Object.keys(playbook)[0]" class="border-solid border-b-2 border-lime-600 border-opacity-25">
|
<section v-for="playbook, index in this.resultsStore.results.playbooks" :key="Object.keys(playbook)[0]" :class="index < this.resultsStore.results.playbooks.length - 1 ? `border-solid border-b-2 border-lime-600 border-opacity-25` : ``">
|
||||||
<h2 class="flex justify-between">
|
<h2 class="flex justify-between">
|
||||||
<span class="uncial-antiqua align-bottom">
|
<span class="uncial-antiqua align-bottom">
|
||||||
<span class="text-xl">The</span> <span class="text-3xl capitalize">{{ Object.keys(playbook)[0] }}</span>
|
<span class="text-xl">The</span> <span class="text-3xl capitalize">{{ Object.keys(playbook)[0] }}</span>
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
import Content from '@/components/Content.vue'
|
import Content from '@/components/Content.vue'
|
||||||
import Header from '@/components/Header.vue'
|
import Header from '@/components/Header.vue'
|
||||||
import TextFrame from '@/components/TextFrame.vue'
|
import TextFrame from '@/components/TextFrame.vue'
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
name: 'Scores',
|
name: 'Scores',
|
||||||
@ -41,12 +41,12 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(score, playbook, index) in this.appStore.results.all_playbooks" :key="playbook" class="hover:bg-yellow-50" :class="index % 2 == 0? `bg-lime-50 border-b dark:bg-gray-900 dark:border-gray-700` : `bg-lime-100 border-b dark:bg-gray-800 dark:border-gray-700`">
|
<tr v-for="(score, playbook, index) in this.resultsStore.results.all_playbooks" :key="playbook" class="hover:bg-yellow-50" :class="index % 2 == 0? `bg-lime-50 border-b dark:bg-gray-900 dark:border-gray-700` : `bg-lime-100 border-b dark:bg-gray-800 dark:border-gray-700`">
|
||||||
<td scope="col" class="py-1 pl-10 capitalize">
|
<td scope="col" class="py-1 pl-10 capitalize">
|
||||||
The {{ playbook }}
|
The {{ playbook }}
|
||||||
</td>
|
</td>
|
||||||
<td scope="col" class="py-1">
|
<td scope="col" class="py-1">
|
||||||
{{ Math.round(100*score/this.appStore.results.max_score) }}
|
{{ Math.round(100*score/this.resultsStore.results.max_score) }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -4,15 +4,15 @@
|
|||||||
import Content from '@/components/Content.vue'
|
import Content from '@/components/Content.vue'
|
||||||
import Header from '@/components/Header.vue'
|
import Header from '@/components/Header.vue'
|
||||||
import TextFrame from '@/components/TextFrame.vue'
|
import TextFrame from '@/components/TextFrame.vue'
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
import ChevronDoubleRight from '@/components/icons/ChevronDoubleRight.vue'
|
import ChevronDoubleRight from '@/components/icons/ChevronDoubleRight.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -30,7 +30,7 @@
|
|||||||
axios.get(`${Config.SERVER}api/scores/`)
|
axios.get(`${Config.SERVER}api/scores/`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log('Fetched score stats from the server.')
|
console.log('Fetched score stats from the server.')
|
||||||
this.appStore.store('scores', response.data)
|
this.resultsStore.store('scores', response.data)
|
||||||
})
|
})
|
||||||
.catch( error => {
|
.catch( error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -39,7 +39,7 @@
|
|||||||
axios.get(`${Config.SERVER}api/count/`)
|
axios.get(`${Config.SERVER}api/count/`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log('Fetched user count from the server.')
|
console.log('Fetched user count from the server.')
|
||||||
this.appStore.store('count', response.data)
|
this.resultsStore.store('count', response.data)
|
||||||
})
|
})
|
||||||
.catch( error => {
|
.catch( error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -83,8 +83,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(stats, playbook, index) in this.appStore.scores" :key="playbook" class="hover:bg-yellow-50" :class="index % 2 == 0? `bg-lime-50 border-b dark:bg-gray-900 dark:border-gray-700` : `bg-lime-100 border-b dark:bg-gray-800 dark:border-gray-700`">
|
<tr v-for="(stats, playbook, index) in this.resultsStore.scores" :key="playbook" class="hover:bg-yellow-50" :class="index % 2 == 0? `bg-lime-50 border-b dark:bg-gray-900 dark:border-gray-700` : `bg-lime-100 border-b dark:bg-gray-800 dark:border-gray-700`">
|
||||||
<td v-if="this.appStore.results.playbooks.some(obj => obj.hasOwnProperty(playbook))">
|
<td v-if="this.resultsStore.results.playbooks.some(obj => obj.hasOwnProperty(playbook))">
|
||||||
<ChevronDoubleRight/>
|
<ChevronDoubleRight/>
|
||||||
</td>
|
</td>
|
||||||
<td v-else>
|
<td v-else>
|
||||||
@ -94,7 +94,7 @@
|
|||||||
The {{ playbook }}
|
The {{ playbook }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ Math.round(100*this.appStore.results.all_playbooks[playbook]/this.appStore.results.max_score) }}
|
{{ Math.round(100*this.resultsStore.results.all_playbooks[playbook]/this.resultsStore.results.max_score) }}
|
||||||
</td>
|
</td>
|
||||||
<td scope="col" class="py-1">
|
<td scope="col" class="py-1">
|
||||||
{{ Math.round(stats.mean * 100) / 100 }}
|
{{ Math.round(stats.mean * 100) / 100 }}
|
||||||
@ -107,7 +107,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-center text-lg text-gray-600">From {{ this.appStore.count }} users</td>
|
<td colspan="6" class="text-center text-lg text-gray-600">From {{ this.resultsStore.count }} users</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { useQuestionStore } from '@/stores/questions.js'
|
import { useQuestionStore } from '@/stores/questions.js'
|
||||||
import { useAnswersStore } from '@/stores/answers.js'
|
import { useAnswersStore } from '@/stores/answers.js'
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
import Content from '@/components/Content.vue'
|
import Content from '@/components/Content.vue'
|
||||||
import Header from '@/components/Header.vue'
|
import Header from '@/components/Header.vue'
|
||||||
import TextFrame from '@/components/TextFrame.vue'
|
import TextFrame from '@/components/TextFrame.vue'
|
||||||
@ -20,12 +20,12 @@
|
|||||||
setup() {
|
setup() {
|
||||||
const questionStore = useQuestionStore()
|
const questionStore = useQuestionStore()
|
||||||
const answersStore = useAnswersStore()
|
const answersStore = useAnswersStore()
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
questionStore,
|
questionStore,
|
||||||
answersStore,
|
answersStore,
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -37,14 +37,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.appStore.compareCurrent = this.id
|
this.resultsStore.compareCurrent = this.id
|
||||||
this.$watch(
|
this.$watch(
|
||||||
() => this.$route.params, (toParams, previousParams) => {
|
() => this.$route.params, (toParams, previousParams) => {
|
||||||
if (this.$route.name == 'CompareQuestion') {
|
if (this.$route.name == 'CompareQuestion') {
|
||||||
if (toParams.id >= this.questionStore.questions.length || this.id < 0) {
|
if (toParams.id >= this.questionStore.questions.length || this.id < 0) {
|
||||||
this.$router.push('/err_notfound')
|
this.$router.push('/err_notfound')
|
||||||
} else {
|
} else {
|
||||||
this.appStore.compareCurrent = toParams.id
|
this.resultsStore.compareCurrent = toParams.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,19 +64,19 @@
|
|||||||
Compare Answers
|
Compare Answers
|
||||||
</Header>
|
</Header>
|
||||||
<Content>
|
<Content>
|
||||||
<div v-if="questionStore.questions[this.id] && answersStore.answers[this.id] != null && appStore.answers[this.id]">
|
<div v-if="questionStore.questions[this.id] && answersStore.answers[this.id] != null && resultsStore.answers[this.id]">
|
||||||
<article class="prose">
|
<article class="prose">
|
||||||
<h3>Question {{ this.id + 1}}</h3>
|
<h3>Question {{ this.id + 1}}</h3>
|
||||||
<div v-html="questionStore.questions[this.id].question"></div>
|
<div v-html="questionStore.questions[this.id].question"></div>
|
||||||
</article>
|
</article>
|
||||||
<div class="grid grid-cols-1 content-evenly items-center gap-2 justify-between mt-12 mx-auto lg:grid-cols-2">
|
<div class="grid grid-cols-1 content-evenly items-center gap-2 justify-between mt-12 mx-auto lg:grid-cols-2">
|
||||||
<div v-for="(answer, index) in questionStore.questions[this.id].answers" :key="`q${this.id}-o${index}`" class="inline-flex justify-between rounded-md bg-lime-200" :style="`background: linear-gradient(to right, rgb(217 249 157) ${100*this.appStore.answers[this.id][index] / this.appStore.count}%, transparent ${100*this.appStore.answers[this.id][index] / this.appStore.count+3}%)`">
|
<div v-for="(answer, index) in questionStore.questions[this.id].answers" :key="`q${this.id}-o${index}`" class="inline-flex justify-between rounded-md bg-lime-200" :style="`background: linear-gradient(to right, rgb(217 249 157) ${100*this.resultsStore.answers[this.id][index] / this.resultsStore.count}%, transparent ${100*this.resultsStore.answers[this.id][index] / this.resultsStore.count+3}%)`">
|
||||||
<div v-html="answer" class="flex uncial-antiqua h-full p-2 select-none transition-all duration-100 ease-in-out" :class=" optionSelected(this.id, index) ? 'option-selected' : '' " :aria-label="answer" :title="answer"></div>
|
<div v-html="answer" class="flex uncial-antiqua h-full p-2 select-none transition-all duration-100 ease-in-out" :class=" optionSelected(this.id, index) ? 'option-selected' : '' " :aria-label="answer" :title="answer"></div>
|
||||||
<div class="flex p-2 w-fit items-center" style="white-space:nowrap;">{{ Math.round(100*this.appStore.answers[this.id][index] / this.appStore.count) }} %</div>
|
<div class="flex p-2 w-fit items-center" style="white-space:nowrap;">{{ Math.round(100*this.resultsStore.answers[this.id][index] / this.resultsStore.count) }} %</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center mt-6 mb-12 text-lg text-gray-600">
|
<div class="text-center mt-6 mb-12 text-lg text-gray-600">
|
||||||
From of {{ this.appStore.count }} users.
|
From of {{ this.resultsStore.count }} users.
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full flex mx-auto items-center justify-between max-w-sm">
|
<div class="w-full flex mx-auto items-center justify-between max-w-sm">
|
||||||
<router-link :to="`/results/answers/${this.id-1}`" v-if="this.id > 0">
|
<router-link :to="`/results/answers/${this.id-1}`" v-if="this.id > 0">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
import Content from '@/components/Content.vue'
|
import Content from '@/components/Content.vue'
|
||||||
import Header from '@/components/Header.vue'
|
import Header from '@/components/Header.vue'
|
||||||
import TextFrame from '@/components/TextFrame.vue'
|
import TextFrame from '@/components/TextFrame.vue'
|
||||||
@ -14,15 +14,15 @@
|
|||||||
TextFrame
|
TextFrame
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.appStore.compareCurrent !== null) {
|
if (this.resultsStore.compareCurrent !== null) {
|
||||||
this.$router.push(`/results/answers/${this.appStore.compareCurrent}`)
|
this.$router.push(`/results/answers/${this.resultsStore.compareCurrent}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
import Config from '@/config.js'
|
import Config from '@/config.js'
|
||||||
import { useQuestionStore } from '@/stores/questions.js'
|
import { useQuestionStore } from '@/stores/questions.js'
|
||||||
import { useAnswersStore } from '@/stores/answers.js'
|
import { useAnswersStore } from '@/stores/answers.js'
|
||||||
import { useAppStore } from '@/stores/app.js'
|
import { useResultsStore } from '@/stores/results.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const questionStore = useQuestionStore()
|
const questionStore = useQuestionStore()
|
||||||
const answersStore = useAnswersStore()
|
const answersStore = useAnswersStore()
|
||||||
const appStore = useAppStore()
|
const resultsStore = useResultsStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
questionStore,
|
questionStore,
|
||||||
answersStore,
|
answersStore,
|
||||||
appStore
|
resultsStore
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
name: 'CompareAnswersIndex',
|
name: 'CompareAnswersIndex',
|
||||||
@ -28,7 +28,7 @@
|
|||||||
axios.get(`${Config.SERVER}api/answers/`)
|
axios.get(`${Config.SERVER}api/answers/`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log('Fetched answer stats from the server.')
|
console.log('Fetched answer stats from the server.')
|
||||||
this.appStore.store('answers', response.data)
|
this.resultsStore.store('answers', response.data)
|
||||||
})
|
})
|
||||||
.catch( error => {
|
.catch( error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -37,7 +37,7 @@
|
|||||||
axios.get(`${Config.SERVER}api/count/`)
|
axios.get(`${Config.SERVER}api/count/`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log('Fetched user count from the server.')
|
console.log('Fetched user count from the server.')
|
||||||
this.appStore.store('count', response.data)
|
this.resultsStore.store('count', response.data)
|
||||||
})
|
})
|
||||||
.catch( error => {
|
.catch( error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
Loading…
Reference in New Issue
Block a user