|
|
@@ -3,60 +3,109 @@ main.view--surveycomplete
|
|
3
|
3
|
article(style='display: flex; flex-direction: column; align-items: center; text-align: center;')
|
|
4
|
4
|
h2 Thanks for Completing Our Survey!!
|
|
5
|
5
|
h1 Please review your answers and let us know if you need to change anything.
|
|
|
6
|
+ div(v-for='response in responses')
|
|
|
7
|
+ p Your {{ response.stage }}:
|
|
|
8
|
+ p {{ response.val }}
|
|
|
9
|
+ br
|
|
|
10
|
+ div.survey-spacer
|
|
|
11
|
+ div(v-for='aspectResponse in aspectResponses')
|
|
|
12
|
+ p {{ aspectResponse.question }} :
|
|
|
13
|
+ br
|
|
|
14
|
+ p {{ aspectResponse.response }}
|
|
|
15
|
+ br
|
|
6
|
16
|
br
|
|
7
|
|
- p(v-for='input in formInputs')
|
|
8
|
|
- p(v-for='(value, key) in answers')
|
|
9
|
|
- p(v-if='input.survey_stage == key && key !== "password"')
|
|
10
|
|
- p Your {{ key }}: {{ value }}
|
|
11
|
|
- br
|
|
12
|
|
- p(v-for='input in formDropdowns')
|
|
13
|
|
- p(v-for='(value, key) in answers')
|
|
14
|
|
- p(v-if='input.survey_stage == key')
|
|
15
|
|
- p Your {{ key }}: {{ value }}
|
|
16
|
|
- br
|
|
17
|
|
- p(v-for='(response, responseIndex) in questionResponses')
|
|
18
|
|
- p(v-for='(value, key) in answers')
|
|
19
|
|
- p(v-if='response.survey_stage == key')
|
|
20
|
|
- p Survey Question {{ responseIndex + 1 }}:
|
|
21
|
|
- p {{ response.response_key_prompt }}
|
|
22
|
|
- p You Answered: {{ value }}
|
|
23
|
|
- br
|
|
24
|
17
|
w-button.ma1(@click="changeAnswers") Change Answers
|
|
25
|
|
- w-button.ma1(@click="finalSubmit") Submit Answers
|
|
26
|
18
|
</template>
|
|
27
|
19
|
|
|
28
|
20
|
<script>
|
|
|
21
|
+import { currentProfile } from '../services'
|
|
29
|
22
|
export default {
|
|
30
|
23
|
props: {
|
|
31
|
|
- answers: {
|
|
32
|
|
- type: Object,
|
|
33
|
|
- default: () => ({}),
|
|
34
|
|
- },
|
|
35
|
24
|
surveySteps: {
|
|
36
|
25
|
type: Array,
|
|
37
|
26
|
default: () => [],
|
|
38
|
27
|
},
|
|
39
|
28
|
},
|
|
40
|
29
|
data: () => ({
|
|
41
|
|
- surveyObjects: [],
|
|
42
|
|
- formInputs: [],
|
|
43
|
|
- questionResponses: [],
|
|
44
|
|
- formDropdowns: [],
|
|
|
30
|
+ responses: {},
|
|
|
31
|
+ aspectQuestions: {},
|
|
|
32
|
+ surveyStages: {},
|
|
|
33
|
+ aspectResponses: [],
|
|
45
|
34
|
}),
|
|
46
|
35
|
created() {
|
|
47
|
|
- this.surveySteps.forEach((step) => {
|
|
48
|
|
- switch (step.component) {
|
|
49
|
|
- case 'FormInput':
|
|
50
|
|
- this.formInputs.push(step)
|
|
51
|
|
- break
|
|
52
|
|
- case 'FormDropdown':
|
|
53
|
|
- this.formDropdowns.push(step)
|
|
54
|
|
- break
|
|
55
|
|
- case 'QuestionResponse':
|
|
56
|
|
- this.questionResponses.push(step)
|
|
57
|
|
- break
|
|
58
|
|
- }
|
|
59
|
|
- })
|
|
|
36
|
+ // TODO: Troubleshoot bug where not all responses are returned
|
|
|
37
|
+ console.log('currentProfile :=>', currentProfile)
|
|
|
38
|
+ this.aspectQuestions = this.parseSurvey(this.surveySteps, false)
|
|
|
39
|
+ this.surveyStages = this.parseSurvey(this.surveySteps, true)
|
|
|
40
|
+ this.aspectResponses = this.grabAspectResponses(
|
|
|
41
|
+ currentProfile._profile.responses,
|
|
|
42
|
+ this.aspectQuestions,
|
|
|
43
|
+ )
|
|
|
44
|
+ const responses = this.grabResponsesFromProfile(this.aspectQuestions)
|
|
|
45
|
+ this.responses = this.appendStagesToResponses(
|
|
|
46
|
+ responses,
|
|
|
47
|
+ this.surveyStages,
|
|
|
48
|
+ )
|
|
|
49
|
+ },
|
|
|
50
|
+ methods: {
|
|
|
51
|
+ parseSurvey(surveySteps, isStage) {
|
|
|
52
|
+ const parsedAspects = {}
|
|
|
53
|
+ const parsedStages = {}
|
|
|
54
|
+ surveySteps.forEach(step => {
|
|
|
55
|
+ const isAspect = step.category === 'aspect'
|
|
|
56
|
+ if (isAspect) {
|
|
|
57
|
+ parsedAspects[`${step.response_key_id}`] =
|
|
|
58
|
+ step.response_key_prompt
|
|
|
59
|
+ } else {
|
|
|
60
|
+ parsedStages[`${step.response_key_id}`] = step.survey_stage
|
|
|
61
|
+ }
|
|
|
62
|
+ })
|
|
|
63
|
+ return isStage ? parsedStages : parsedAspects
|
|
|
64
|
+ },
|
|
|
65
|
+ grabResponsesFromProfile(aspectQuestions) {
|
|
|
66
|
+ const aspectQuestionsKeys = Object.keys(aspectQuestions).map(Number)
|
|
|
67
|
+ const responses = currentProfile._profile.responses
|
|
|
68
|
+ .map(response => {
|
|
|
69
|
+ if (
|
|
|
70
|
+ !aspectQuestionsKeys.includes(response.response_key_id)
|
|
|
71
|
+ ) {
|
|
|
72
|
+ return response
|
|
|
73
|
+ }
|
|
|
74
|
+ })
|
|
|
75
|
+ .filter(res => {
|
|
|
76
|
+ return typeof res === 'object'
|
|
|
77
|
+ })
|
|
|
78
|
+ return responses
|
|
|
79
|
+ },
|
|
|
80
|
+ appendStagesToResponses(responses, surveyStages) {
|
|
|
81
|
+ const responsesWithStages = responses.map(response => {
|
|
|
82
|
+ return {
|
|
|
83
|
+ ...response,
|
|
|
84
|
+ stage: surveyStages[`${response.response_key_id}`],
|
|
|
85
|
+ }
|
|
|
86
|
+ })
|
|
|
87
|
+ return responsesWithStages
|
|
|
88
|
+ },
|
|
|
89
|
+ grabAspectResponses(responses, questions) {
|
|
|
90
|
+ return responses
|
|
|
91
|
+ .map(response => {
|
|
|
92
|
+ const prompt = questions[`${response.response_key_id}`]
|
|
|
93
|
+ if (prompt) {
|
|
|
94
|
+ return {
|
|
|
95
|
+ question: questions[`${response.response_key_id}`],
|
|
|
96
|
+ response: response.val,
|
|
|
97
|
+ }
|
|
|
98
|
+ }
|
|
|
99
|
+ })
|
|
|
100
|
+ .filter(res => {
|
|
|
101
|
+ return typeof res === 'object'
|
|
|
102
|
+ })
|
|
|
103
|
+ },
|
|
60
|
104
|
},
|
|
61
|
105
|
}
|
|
62
|
106
|
</script>
|
|
|
107
|
+<style>
|
|
|
108
|
+.survey-spacer {
|
|
|
109
|
+ height: 1.25rem;
|
|
|
110
|
+}
|
|
|
111
|
+</style>
|