|
|
@@ -1,94 +1,101 @@
|
|
1
|
1
|
<template lang="pug">
|
|
|
2
|
+article
|
|
|
3
|
+ form(@submit.prevent="onSubmit")
|
|
|
4
|
+ .questionnaire
|
|
|
5
|
+ .question(
|
|
|
6
|
+ v-for="q in questionnaireQuestions"
|
|
|
7
|
+ )
|
|
|
8
|
+ label {{q.question}}
|
|
|
9
|
+ .question--response
|
|
|
10
|
+ .question--answers
|
|
|
11
|
+ h3 {{q.answers[0].charAt(0).toUpperCase() + q.answers[0].slice(1)}}
|
|
|
12
|
+ h3 {{q.answers[1].charAt(0).toUpperCase() + q.answers[1].slice(1)}}
|
|
|
13
|
+ .question--radio-buttons
|
|
|
14
|
+ input(type='radio' :id="'q'+(q.id)+'_a1'" :name="'q'+(q.id)" value="a1" v-model="questionnaireAnswers[q.id-1]")
|
|
|
15
|
+ input(type='radio' :id="'q'+(q.id)+'_a2'" :name="'q'+(q.id)" value="a2" v-model="questionnaireAnswers[q.id-1]")
|
|
|
16
|
+ input(type='radio' :id="'q'+(q.id)+'_a3'" :name="'q'+(q.id)" value="a3" v-model="questionnaireAnswers[q.id-1]")
|
|
|
17
|
+ input(type='radio' :id="'q'+(q.id)+'_a4'" :name="'q'+(q.id)" value="a4" v-model="questionnaireAnswers[q.id-1]")
|
|
|
18
|
+ input(type='radio' :id="'q'+(q.id)+'_a5'" :name="'q'+(q.id)" value="a5" v-model="questionnaireAnswers[q.id-1]")
|
|
|
19
|
+ br
|
|
|
20
|
+ w-flex
|
|
|
21
|
+ w-button.ma1.grow(type="submit" bg-color="success")
|
|
|
22
|
+ w-icon.mr1 wi-check
|
|
|
23
|
+ | SUBMIT ANSWERS
|
|
|
24
|
+//- br
|
|
|
25
|
+//- h3 Current Step: {{currentStep}}
|
|
|
26
|
+//- br
|
|
|
27
|
+//- ul
|
|
|
28
|
+//- li(v-for="question in onboardingStep")
|
|
|
29
|
+//- p {{question}}
|
|
|
30
|
+//- br
|
|
|
31
|
+//- button(@click="goToStep(currentStep - 1)") previous
|
|
|
32
|
+//- br
|
|
|
33
|
+//- button(@click="goToStep(currentStep + 1)") next
|
|
2
|
34
|
//- br
|
|
3
|
35
|
//- br
|
|
4
|
|
-//- article
|
|
5
|
|
-//- form(@submit.prevent="onSubmit")
|
|
6
|
|
-//- .aspects
|
|
7
|
|
-//- .aspect(
|
|
8
|
|
-//- v-for="(aspect, i) in aspects"
|
|
9
|
|
-//- )
|
|
10
|
|
-//- label {{aspect.seeker_question}}
|
|
11
|
|
-//- //- label {{aspect.employer_question}}
|
|
12
|
|
-//- br
|
|
13
|
|
-//- br
|
|
14
|
|
-//- .aspect--response
|
|
15
|
|
-//- .aspect--answers
|
|
16
|
|
-//- h3 {{aspect.answers[0]}}
|
|
17
|
|
-//- h3 {{aspect.answers[1]}}
|
|
18
|
|
-//- .aspect--radio-buttons
|
|
19
|
|
-//- input(type="radio" :id="'q'+(i+1)+'_a1'" :name="'q'+(i+1)" value="a1" v-model="questionnaireAnswers[i]")
|
|
20
|
|
-//- input(type="radio" :id="'q'+(i+1)+'_a2'" :name="'q'+(i+1)" value="a2" v-model="questionnaireAnswers[i]")
|
|
21
|
|
-//- input(type="radio" :id="'q'+(i+1)+'_a3'" :name="'q'+(i+1)" value="a3" v-model="questionnaireAnswers[i]")
|
|
22
|
|
-//- input(type="radio" :id="'q'+(i+1)+'_a4'" :name="'q'+(i+1)" value="a4" v-model="questionnaireAnswers[i]")
|
|
23
|
|
-//- input(type="radio" :id="'q'+(i+1)+'_a5'" :name="'q'+(i+1)" value="a5" v-model="questionnaireAnswers[i]")
|
|
24
|
|
-//- br
|
|
25
|
|
-//- br
|
|
26
|
|
-//- br
|
|
27
|
|
-//- w-flex
|
|
28
|
|
-//- w-button.ma1.grow(type="submit" bg-color="success")
|
|
29
|
|
-//- w-icon.mr1 wi-check
|
|
30
|
|
-//- | SUBMIT ANSWERS
|
|
31
|
|
-br
|
|
32
|
|
-h3 Current Step: {{currentStep}}
|
|
33
|
|
-br
|
|
34
|
|
-ul
|
|
35
|
|
- li(v-for="question in onboardingStep")
|
|
36
|
|
- p {{question}}
|
|
37
|
|
-br
|
|
38
|
|
-button(@click="goToStep(currentStep - 1)") previous
|
|
39
|
|
-br
|
|
40
|
|
-button(@click="goToStep(currentStep + 1)") next
|
|
41
|
36
|
</template>
|
|
42
|
37
|
<script>
|
|
43
|
|
-import aspects from '../utils/aspects'
|
|
44
|
38
|
import { surveyFactory } from '@/utils'
|
|
45
|
39
|
import { allSteps, possible } from '@/utils/lang'
|
|
46
|
40
|
|
|
47
|
41
|
|
|
48
|
42
|
export default {
|
|
49
|
43
|
name:'OnboardingView',
|
|
50
|
|
- props: {
|
|
51
|
|
- pid: {
|
|
52
|
|
- type: Number,
|
|
53
|
|
- default: () => 45,
|
|
54
|
|
- },
|
|
55
|
|
- },
|
|
56
|
44
|
data: () => {
|
|
57
|
|
- let num_of_ans = aspects.length // need 1 answer for every aspect question
|
|
58
|
45
|
return {
|
|
59
|
|
- onboardingQuestions: [],
|
|
60
|
|
- currentStep: 0,
|
|
61
|
|
- onboardingAnswers: [],
|
|
|
46
|
+ // onboardingQuestions: [],
|
|
|
47
|
+ // currentStep: 0,
|
|
|
48
|
+ // onboardingAnswers: [],
|
|
62
|
49
|
validSurvey: null,
|
|
63
|
|
- questionnaireAnswers: Array(num_of_ans).join(".").split(".")
|
|
|
50
|
+ questionnaireQuestions:[],
|
|
|
51
|
+ questionnaireAnswers: Array(6).join(".").split(".")
|
|
64
|
52
|
}
|
|
65
|
53
|
},
|
|
66
|
54
|
computed:{
|
|
67
|
|
- aspects() {
|
|
68
|
|
- return aspects
|
|
69
|
|
- },
|
|
70
|
|
- onboardingStep(){
|
|
71
|
|
- if(!this.onboardingQuestions.length) return []
|
|
72
|
|
- return this.onboardingQuestions[this.currentStep]
|
|
73
|
|
- }
|
|
|
55
|
+ // onboardingStep(){
|
|
|
56
|
+ // if(!this.onboardingQuestions.length) return []
|
|
|
57
|
+ // return this.onboardingQuestions[this.currentStep]
|
|
|
58
|
+ // },
|
|
|
59
|
+ // questionnaireAnswers(){
|
|
|
60
|
+ // let num_of_ans = 6 // TODO make dynamic once we know which questions we will be asking
|
|
|
61
|
+ // return Array(num_of_ans).join(".").split(".")
|
|
|
62
|
+ // }
|
|
74
|
63
|
},
|
|
75
|
64
|
async created(){
|
|
76
|
65
|
this.validSurvey = await surveyFactory.createSurvey(
|
|
77
|
66
|
allSteps['usa'],
|
|
78
|
67
|
possible['usa']['roles'],
|
|
79
|
68
|
)
|
|
80
|
|
- var step = []
|
|
81
|
|
- var fooSteps = [...this.validSurvey.steps]
|
|
82
|
|
- while(fooSteps.length > (this.validSurvey.steps.length % 3)){
|
|
83
|
|
- var q = fooSteps.shift()
|
|
84
|
|
- step.push(q)
|
|
85
|
|
- if(step.length == 3){
|
|
86
|
|
- this.onboardingQuestions.push(step)
|
|
87
|
|
- step = []
|
|
|
69
|
+ // gather questionnaire questions
|
|
|
70
|
+ this.validSurvey.steps.forEach(q => {
|
|
|
71
|
+ if(q.response_key_id && q.response_key_id < 7) {
|
|
|
72
|
+ let id = q.response_key_id
|
|
|
73
|
+ let question = q.response_key_prompt
|
|
|
74
|
+ let answers = q.response_key_category.split('_vs_')
|
|
|
75
|
+ answers.forEach((a,i) => {
|
|
|
76
|
+ if(a.indexOf('_') !== -1){
|
|
|
77
|
+ answers[i] = a.split('_').join(' ')
|
|
|
78
|
+ }
|
|
|
79
|
+ })
|
|
|
80
|
+ this.questionnaireQuestions.push({
|
|
|
81
|
+ id,
|
|
|
82
|
+ question,
|
|
|
83
|
+ answers
|
|
|
84
|
+ })
|
|
88
|
85
|
}
|
|
89
|
|
- }
|
|
90
|
|
- var last_step = [...fooSteps]
|
|
91
|
|
- this.onboardingQuestions.push(last_step)
|
|
|
86
|
+ })
|
|
|
87
|
+ // var step = []
|
|
|
88
|
+ // var fooSteps = [...this.validSurvey.steps]
|
|
|
89
|
+ // while(fooSteps.length > (this.validSurvey.steps.length % 3)){
|
|
|
90
|
+ // var q = fooSteps.shift()
|
|
|
91
|
+ // step.push(q)
|
|
|
92
|
+ // if(step.length == 3){
|
|
|
93
|
+ // this.onboardingQuestions.push(step)
|
|
|
94
|
+ // step = []
|
|
|
95
|
+ // }
|
|
|
96
|
+ // }
|
|
|
97
|
+ // var last_step = [...fooSteps]
|
|
|
98
|
+ // this.onboardingQuestions.push(last_step)
|
|
92
|
99
|
},
|
|
93
|
100
|
methods: {
|
|
94
|
101
|
onSubmit() {
|
|
|
@@ -96,38 +103,55 @@ export default {
|
|
96
|
103
|
console.log(`Question ${ind+1} was ${ans==''? 'left blank.' : `answered ${ans}`}`)
|
|
97
|
104
|
})
|
|
98
|
105
|
},
|
|
99
|
|
- goToStep(num){
|
|
100
|
|
- if(num < 0){
|
|
101
|
|
- this.currentStep = this.onboardingQuestions.length-1
|
|
102
|
|
- }
|
|
103
|
|
- else if(num >= this.onboardingQuestions.length) {
|
|
104
|
|
- this.currentStep = 0
|
|
105
|
|
- }
|
|
106
|
|
- else
|
|
107
|
|
- this.currentStep = num
|
|
108
|
|
- },
|
|
|
106
|
+ // goToStep(num){
|
|
|
107
|
+ // if(num < 0){
|
|
|
108
|
+ // this.currentStep = this.onboardingQuestions.length-1
|
|
|
109
|
+ // }
|
|
|
110
|
+ // else if(num >= this.onboardingQuestions.length) {
|
|
|
111
|
+ // this.currentStep = 0
|
|
|
112
|
+ // }
|
|
|
113
|
+ // else
|
|
|
114
|
+ // this.currentStep = num
|
|
|
115
|
+ // },
|
|
109
|
116
|
},
|
|
110
|
117
|
}
|
|
111
|
118
|
</script>
|
|
112
|
119
|
<style>
|
|
113
|
|
-.aspects{
|
|
|
120
|
+body{
|
|
|
121
|
+ background-color: #1F2024;
|
|
|
122
|
+}
|
|
|
123
|
+article{
|
|
|
124
|
+ color: #FFFFFF;
|
|
|
125
|
+}
|
|
|
126
|
+.questionnaire{
|
|
114
|
127
|
display: flex;
|
|
115
|
128
|
flex-direction:column;
|
|
116
|
129
|
}
|
|
117
|
|
-.aspect--response{
|
|
118
|
|
- display: flex;
|
|
119
|
|
- flex-direction: column;
|
|
|
130
|
+.question{
|
|
|
131
|
+ margin-top: 44px;
|
|
|
132
|
+}
|
|
|
133
|
+.question > label{
|
|
|
134
|
+ font-size: 18px;
|
|
|
135
|
+ line-height: 23px;
|
|
120
|
136
|
}
|
|
121
|
|
-.aspect--answers{
|
|
|
137
|
+.question--response{
|
|
|
138
|
+ margin-top: 22px;
|
|
|
139
|
+ margin-inline: 19px;
|
|
|
140
|
+}
|
|
|
141
|
+.question--answers{
|
|
122
|
142
|
display: flex;
|
|
123
|
143
|
flex-direction: row;
|
|
124
|
144
|
justify-content: space-between;
|
|
125
|
145
|
}
|
|
126
|
|
-.aspect--radio-buttons{
|
|
127
|
|
- width: 90%;
|
|
128
|
|
- margin: auto;
|
|
|
146
|
+.question--radio-buttons{
|
|
|
147
|
+ padding: 0 25px;
|
|
|
148
|
+ margin: 16px auto auto auto;
|
|
129
|
149
|
display: flex;
|
|
130
|
150
|
flex-direction: row;
|
|
131
|
151
|
justify-content: space-between;
|
|
132
|
152
|
}
|
|
|
153
|
+.question--radio-buttons > input {
|
|
|
154
|
+ width: 24px;
|
|
|
155
|
+ height: 24px;
|
|
|
156
|
+}
|
|
133
|
157
|
</style>
|