Przeglądaj źródła

:recycle: Refactored flow of how aspects are created, removed tests

tags/0.0.3^2
tomit4 3 lat temu
rodzic
commit
60efd6f5d1

+ 9
- 24
backend/db/data-generator/mock.js Wyświetl plik

463
             response_key_prompt: 'Do you prefer to Guide your employees towards achieving the team goals, or do you prefer your employees to be Self-Managed?',
463
             response_key_prompt: 'Do you prefer to Guide your employees towards achieving the team goals, or do you prefer your employees to be Self-Managed?',
464
             response_key_description: 'first round draft scoring question',
464
             response_key_description: 'first round draft scoring question',
465
         },
465
         },
466
-        // TO ADD ASPECT: when creating new survey aspect step, add here, re-order response_key_id and run npm run reseed
467
         {
466
         {
468
             response_key_id: 7,
467
             response_key_id: 7,
469
-            response_key_category: 'love_vs_hate',
470
-            response_key_prompt: 'Do you prefer to be loved our hated?',
471
-            response_key_description: 'total test question, to be deleted',
472
-        },
473
-        {
474
-            response_key_id: 8,
475
             response_key_category: 'profile',
468
             response_key_category: 'profile',
476
             response_key_prompt: 'zipcode',
469
             response_key_prompt: 'zipcode',
477
             response_key_description: 'required for distance calculations',
470
             response_key_description: 'required for distance calculations',
478
         },
471
         },
479
         {
472
         {
480
-            response_key_id: 9,
473
+            response_key_id: 8,
481
             response_key_category: 'profile',
474
             response_key_category: 'profile',
482
             response_key_prompt: 'image',
475
             response_key_prompt: 'image',
483
             response_key_description: 'required for profile pictures',
476
             response_key_description: 'required for profile pictures',
484
         },
477
         },
485
         {
478
         {
486
-            response_key_id: 10,
479
+            response_key_id: 9,
487
             response_key_category: 'profile',
480
             response_key_category: 'profile',
488
             response_key_prompt: 'language',
481
             response_key_prompt: 'language',
489
             response_key_description:
482
             response_key_description:
490
                 'programming and spoken language preference',
483
                 'programming and spoken language preference',
491
         },
484
         },
492
         {
485
         {
493
-            response_key_id: 11,
486
+            response_key_id: 10,
494
             response_key_category: 'profile',
487
             response_key_category: 'profile',
495
             response_key_prompt: 'duration',
488
             response_key_prompt: 'duration',
496
             response_key_description:
489
             response_key_description:
497
                 'duration preference for hours able to dedicate to work',
490
                 'duration preference for hours able to dedicate to work',
498
         },
491
         },
499
         {
492
         {
500
-            response_key_id: 12,
493
+            response_key_id: 11,
501
             response_key_category: 'profile',
494
             response_key_category: 'profile',
502
             response_key_prompt: 'presence',
495
             response_key_prompt: 'presence',
503
             response_key_description:
496
             response_key_description:
504
                 'location preference for where work happens',
497
                 'location preference for where work happens',
505
         },
498
         },
506
         {
499
         {
507
-            response_key_id: 13,
500
+            response_key_id: 12,
508
             response_key_category: 'profile',
501
             response_key_category: 'profile',
509
             response_key_prompt: 'blurb',
502
             response_key_prompt: 'blurb',
510
             response_key_description: 'required for profile description',
503
             response_key_description: 'required for profile description',
511
         },
504
         },
512
         {
505
         {
513
-            response_key_id: 14,
506
+            response_key_id: 13,
514
             response_key_category: 'profile',
507
             response_key_category: 'profile',
515
             response_key_prompt: 'urgency',
508
             response_key_prompt: 'urgency',
516
             response_key_description: 'urgency for when work is required',
509
             response_key_description: 'urgency for when work is required',
517
         },
510
         },
518
         {
511
         {
519
-            response_key_id: 15,
512
+            response_key_id: 14,
520
             response_key_category: 'profile',
513
             response_key_category: 'profile',
521
             response_key_prompt: 'role',
514
             response_key_prompt: 'role',
522
             response_key_description: 'current and desired role',
515
             response_key_description: 'current and desired role',
523
         },
516
         },
524
         {
517
         {
525
-            response_key_id: 16,
518
+            response_key_id: 15,
526
             response_key_category: 'profile',
519
             response_key_category: 'profile',
527
             response_key_prompt: 'pronouns',
520
             response_key_prompt: 'pronouns',
528
             response_key_description: 'required for profile pronouns',
521
             response_key_description: 'required for profile pronouns',
529
         },
522
         },
530
         {
523
         {
531
-            response_key_id: 17,
524
+            response_key_id: 16,
532
             response_key_category: 'profile',
525
             response_key_category: 'profile',
533
             response_key_prompt: 'distance',
526
             response_key_prompt: 'distance',
534
             response_key_description:
527
             response_key_description:
535
                 'preference for commuting distance cutoff',
528
                 'preference for commuting distance cutoff',
536
         },
529
         },
537
-        // TO ADD: when creating new survey step, add here and run npm run reseed
538
-        {
539
-            response_key_id: 18,
540
-            response_key_category: 'profile',
541
-            response_key_prompt: 'test',
542
-            response_key_description:
543
-                'this is just for testing stuff...',
544
-        },
545
     ],
530
     ],
546
     responses: [],
531
     responses: [],
547
     memberships: [
532
     memberships: [

+ 9
- 4
frontend/src/components/onboarding/Aspects.vue Wyświetl plik

12
 
12
 
13
 <script>
13
 <script>
14
 import QuestionResponse from './QuestionResponse.vue'
14
 import QuestionResponse from './QuestionResponse.vue'
15
-// TO ADD ASPECT: when creating new survey aspect step, increment additional null slots here
16
-const answered = [null, null, null, null, null, null, null]
15
+import { aspectsArr } from '../../utils/lang.js'
17
 
16
 
18
 export default {
17
 export default {
19
     name: 'Aspects',
18
     name: 'Aspects',
27
         },
26
         },
28
     },
27
     },
29
     emits: ['handle-submit', 'update-answers'],
28
     emits: ['handle-submit', 'update-answers'],
29
+    data: () => ({
30
+        answered: [],
31
+    }),
30
     async created() {
32
     async created() {
31
         this.aspectQuestions.forEach((q, i) => {
33
         this.aspectQuestions.forEach((q, i) => {
32
             console.log(`Aspect #${i}: ${JSON.stringify(q)}`)
34
             console.log(`Aspect #${i}: ${JSON.stringify(q)}`)
33
             q.isBeingAnswered = i === 0 ? true : false
35
             q.isBeingAnswered = i === 0 ? true : false
34
         })
36
         })
37
+        aspectsArr.forEach(() => {
38
+            this.answered.push(null)
39
+        })
35
     },
40
     },
36
     methods: {
41
     methods: {
37
         updateAll() {
42
         updateAll() {
38
             this.$emit('handle-submit')
43
             this.$emit('handle-submit')
39
         },
44
         },
40
         updateRadio(onRadioSelect) {
45
         updateRadio(onRadioSelect) {
41
-            answered[onRadioSelect.id - 1] = onRadioSelect.answer
46
+            this.answered[onRadioSelect.id - 1] = onRadioSelect.answer
42
             this.$emit('update-answers', {
47
             this.$emit('update-answers', {
43
                 key: 'Aspects',
48
                 key: 'Aspects',
44
                 question: {
49
                 question: {
45
                     survey_stage: 'aspects',
50
                     survey_stage: 'aspects',
46
                 },
51
                 },
47
-                input: answered,
52
+                input: this.answered,
48
             })
53
             })
49
         },
54
         },
50
         updateIsAnswered(id) {
55
         updateIsAnswered(id) {

+ 4
- 2
frontend/src/components/onboarding/QuestionResponse.vue Wyświetl plik

4
     section.radio-buttons.w-flex.row.justify-space-between
4
     section.radio-buttons.w-flex.row.justify-space-between
5
         p(v-for="label in question.labels") {{label}}
5
         p(v-for="label in question.labels") {{label}}
6
     w-radios.w-flex.row.justify-space-between(@update:model-value="onUpdate" :items="radioItems" color="red")
6
     w-radios.w-flex.row.justify-space-between(@update:model-value="onUpdate" :items="radioItems" color="red")
7
-    // TO ADD ASPECT: when creating new survey aspect step, increment increment !== statement here
8
-    w-button.ma1.grow(v-if='question.id !== 7' @click="updateAnswers") NEXT
7
+    w-button.ma1.grow(v-if='question.id !== aspectsCount' @click="updateAnswers") NEXT
9
     w-button.ma1.grow(v-else @click="updateAll") SUBMIT ANSWERS
8
     w-button.ma1.grow(v-else @click="updateAll") SUBMIT ANSWERS
10
     p(v-if='noChoiceMade') Tough choices, we know! Just answer to the best of your ability. The team over at Siimee values the answers you provide us so that we can show you results catered to your specific needs.
9
     p(v-if='noChoiceMade') Tough choices, we know! Just answer to the best of your ability. The team over at Siimee values the answers you provide us so that we can show you results catered to your specific needs.
11
 </template>
10
 </template>
12
 
11
 
13
 <script>
12
 <script>
13
+import { aspectsArr } from '../../utils/lang.js'
14
+
14
 export default {
15
 export default {
15
     props: {
16
     props: {
16
         question: {
17
         question: {
29
         ],
30
         ],
30
         isAnswered: false,
31
         isAnswered: false,
31
         noChoiceMade: null,
32
         noChoiceMade: null,
33
+        aspectsCount: aspectsArr.length
32
     }),
34
     }),
33
     methods: {
35
     methods: {
34
         onUpdate(e) {
36
         onUpdate(e) {

+ 2
- 2
frontend/src/entities/card/card.js Wyświetl plik

1
 /** @module card/card */
1
 /** @module card/card */
2
+import { aspectsArr } from "../../utils/lang.js"
2
 
3
 
3
 const DEFAULT_ABOUT =
4
 const DEFAULT_ABOUT =
4
     'Hello! My name is L.L. and I am a nurse from New York. I have been in the healthcare industry for over 6 years.'
5
     'Hello! My name is L.L. and I am a nurse from New York. I have been in the healthcare industry for over 6 years.'
139
     c.locale = `${profile.city}, ${profile.state}`
140
     c.locale = `${profile.city}, ${profile.state}`
140
     c.email = profile.user_email
141
     c.email = profile.user_email
141
 
142
 
142
-    // TO ADD ASPECT: when creating new survey aspect step, increment array.indexOf here
143
-    let aspectResponses = profile?.responses.filter(r => [1,2,3,4,5,6,7].indexOf(r.response_key_id) !== -1)
143
+    let aspectResponses = profile?.responses.filter(r => aspectsArr.indexOf(r.response_key_id) !== -1)
144
     if(aspectResponses.length){ // if user has responses for aspects we overwrite default percentages
144
     if(aspectResponses.length){ // if user has responses for aspects we overwrite default percentages
145
         c.aspects.map(a => {
145
         c.aspects.map(a => {
146
             a.percentage = Number(aspectResponses.find(r => responseKeyIdToAspectName[r.response_key_id] == a.name).val )
146
             a.percentage = Number(aspectResponses.find(r => responseKeyIdToAspectName[r.response_key_id] == a.name).val )

+ 2
- 2
frontend/src/entities/survey/survey.js Wyświetl plik

2
 import { _baseRecord } from '../index.js'
2
 import { _baseRecord } from '../index.js'
3
 import { surveySchema } from './survey.schema.js'
3
 import { surveySchema } from './survey.schema.js'
4
 import { answersSchema } from './survey.answer.schema.js'
4
 import { answersSchema } from './survey.answer.schema.js'
5
+import { aspectsArr } from '../../utils/lang.js'
5
 
6
 
6
-// TO ADD ASPECT: when creating new survey aspect step, add additional number here
7
-const SCORED = [1, 2, 3, 4, 5, 6, 7]
7
+const SCORED = aspectsArr
8
 const _isScored = id => SCORED.includes(id)
8
 const _isScored = id => SCORED.includes(id)
9
 const _makeCategoryFriendly = responseCategory => {
9
 const _makeCategoryFriendly = responseCategory => {
10
     const labels = responseCategory.split('_vs_')
10
     const labels = responseCategory.split('_vs_')

+ 3
- 20
frontend/src/utils/lang.js Wyświetl plik

1
 const DELIMITER = '_'
1
 const DELIMITER = '_'
2
+// TO ADD ASPECT, increment aspectsArr here
3
+const aspectsArr = [1, 2, 3, 4, 5, 6]
2
 
4
 
3
 // TODO: Combine these two
5
 // TODO: Combine these two
4
 const allSteps = {
6
 const allSteps = {
17
         image: 'image',
19
         image: 'image',
18
         distance: 'distance',
20
         distance: 'distance',
19
         blurb: 'blurb',
21
         blurb: 'blurb',
20
-        // TO ADD: when creating a new step, place before aspects
21
-        test: 'test',
22
-        // TO ADD DROP DOWN: when creating a new step, place before aspects
23
-        testOptions: 'testOptions',
24
         aspects: 'aspects',
22
         aspects: 'aspects',
25
         // experience: 'experience',
23
         // experience: 'experience',
26
         // roles: 'role',
24
         // roles: 'role',
55
     presence: ['remote', 'in_person', 'hybrid', 'flexible'],
53
     presence: ['remote', 'in_person', 'hybrid', 'flexible'],
56
     // key 10
54
     // key 10
57
     duration: ['full-time', 'part-time', 'contract', 'flexible'],
55
     duration: ['full-time', 'part-time', 'contract', 'flexible'],
58
-    // TO ADD DROP DOWN: When adding new survey Form Drop Down step, add all
59
-    // options in array
60
-    testOptions: ['test-option-1', 'test-option-2', 'test-option-3'],
61
     // Experience and roles concat, key: 14
56
     // Experience and roles concat, key: 14
62
     experience: ['associate', 'junior', 'mid-level', 'senior', 'staff'],
57
     experience: ['associate', 'junior', 'mid-level', 'senior', 'staff'],
63
     roles: {
58
     roles: {
83
     image: [],
78
     image: [],
84
     zipcode: [],
79
     zipcode: [],
85
     blurb: [],
80
     blurb: [],
86
-    test: []
87
 }
81
 }
88
 
82
 
89
 // TODO: set up a separate object of similar prompts based off of
83
 // TODO: set up a separate object of similar prompts based off of
103
     duration: "What kind of duration would you prefer? Are you looking for part-time, full-time, other?[break] Currently, I'm looking for a [break] job at this time.",
97
     duration: "What kind of duration would you prefer? Are you looking for part-time, full-time, other?[break] Currently, I'm looking for a [break] job at this time.",
104
     language: "What language is your native language?[break] I consider [break] language as my native language.",
98
     language: "What language is your native language?[break] I consider [break] language as my native language.",
105
     distance: "What distance from your home are you looking to work in?[break] Preferably, I'd like to work [break] from my place of residence.",
99
     distance: "What distance from your home are you looking to work in?[break] Preferably, I'd like to work [break] from my place of residence.",
106
-    // TO ADD: add new prompt for new survey steps here
107
-    test: 'this[break]is just[break] a test.',
108
-    // TO ADD DROP DOWN: add new prompt for new survey steps here
109
-    testOptions: 'this[break]is another[break] test with options.'
110
 }
100
 }
111
 
101
 
112
 const inputPlaceholders = {
102
 const inputPlaceholders = {
116
     password: 'supersecr3tp@ssword',
106
     password: 'supersecr3tp@ssword',
117
     blurb: 'my backstory starts long long ago...',
107
     blurb: 'my backstory starts long long ago...',
118
     distance: '5 mi',
108
     distance: '5 mi',
119
-    // TO ADD: add new input place holder here
120
-    test: 'test',
121
-    // TO ADD DROP DOWN: add new input place holder here
122
-    testOptions: 'testOptions'
123
 }
109
 }
124
 
110
 
125
 const invalidInputPrompts = {
111
 const invalidInputPrompts = {
136
     duration: "Looks like you haven't filled out what kind of work you're most interested in. As in, part-time, full-time. Take a look at our above options and choose whatever feels right for you right now. You can always edit them later!",
122
     duration: "Looks like you haven't filled out what kind of work you're most interested in. As in, part-time, full-time. Take a look at our above options and choose whatever feels right for you right now. You can always edit them later!",
137
     language: "We try our best to provide results in the language of your choosing. ¿Prefieres ver resultados en español? Or would you prefer to see results in english?",
123
     language: "We try our best to provide results in the language of your choosing. ¿Prefieres ver resultados en español? Or would you prefer to see results in english?",
138
     distance: "Whoa! You either left this field blank or tried to input an astronomically large distance you'd like to see results from. Please input a distance you'd like to see results in.",
124
     distance: "Whoa! You either left this field blank or tried to input an astronomically large distance you'd like to see results from. Please input a distance you'd like to see results in.",
139
-    // TO ADD: add new input invalid message here
140
-    test: 'oh goodness, why test this!',
141
-    // TO ADD DROP DOWN: add new input invalid message here
142
-    testOptions: 'oh goodness, why test this with Options!'
143
 }
125
 }
144
 
126
 
145
 export {
127
 export {
148
     invalidInputPrompts,
130
     invalidInputPrompts,
149
     allSteps,
131
     allSteps,
150
     aspectResponses,
132
     aspectResponses,
133
+    aspectsArr,
151
     possible,
134
     possible,
152
     DELIMITER,
135
     DELIMITER,
153
 }
136
 }

+ 4
- 3
frontend/src/utils/survey.js Wyświetl plik

1
 import { Survey } from '../entities/index.js'
1
 import { Survey } from '../entities/index.js'
2
 import { fetchQuestions } from '../services/index.js'
2
 import { fetchQuestions } from '../services/index.js'
3
-import { promptOverrides, inputPlaceholders, invalidInputPrompts ,possible } from './lang.js'
3
+import { promptOverrides, inputPlaceholders, invalidInputPrompts ,possible, aspectsArr } from './lang.js'
4
 
4
 
5
 const promptToComponent = {
5
 const promptToComponent = {
6
     splash: 'Splash',
6
     splash: 'Splash',
56
 class SurveyFactory {
56
 class SurveyFactory {
57
     constructor() {
57
     constructor() {
58
         this.questionsFromDb = []
58
         this.questionsFromDb = []
59
+        // consider moving this into something like lang.js to be imported
60
+        // wherever aspects needs to be incremented, ie TO ADD ASPECTS
59
     }
61
     }
60
     _setSteps(langFile) {
62
     _setSteps(langFile) {
61
         const stepsToProcess = [...Object.values(langFile)]
63
         const stepsToProcess = [...Object.values(langFile)]
84
         let unseen = this.questionsFromDb.filter(
86
         let unseen = this.questionsFromDb.filter(
85
             q =>
87
             q =>
86
                 !seenIds.includes(q.response_key_id) &&
88
                 !seenIds.includes(q.response_key_id) &&
87
-                // TO ADD ASPECTS: increment array here
88
-                [1, 2, 3, 4, 5, 6, 7].includes(q.response_key_id),
89
+                aspectsArr.includes(q.response_key_id)
89
         )
90
         )
90
         return [...stepsInCommon, ...unseen]
91
         return [...stepsInCommon, ...unseen]
91
     }
92
     }

Ładowanie…
Anuluj
Zapisz