Kaynağa Gözat

:recycle: Refactored survey stages as part of front end mutations

tabs-content
tomit4 3 yıl önce
ebeveyn
işleme
dcaae88b07

+ 0
- 19
backend/db/data-generator/mock.js Dosyayı Görüntüle

434
             response_key_description: 'first round draft scoring question',
434
             response_key_description: 'first round draft scoring question',
435
             aspect: 'visionary_vs_implementer',
435
             aspect: 'visionary_vs_implementer',
436
             category: 'aspect',
436
             category: 'aspect',
437
-            survey_stage: 'aspect-1',
438
             placeholder: null,
437
             placeholder: null,
439
             invalidInputPrompt: null,
438
             invalidInputPrompt: null,
440
         },
439
         },
445
             response_key_description: 'first round draft scoring question',
444
             response_key_description: 'first round draft scoring question',
446
             aspect: 'creative_vs_methodical',
445
             aspect: 'creative_vs_methodical',
447
             category: 'aspect',
446
             category: 'aspect',
448
-            survey_stage: 'aspect-2',
449
             placeholder: null,
447
             placeholder: null,
450
             invalidInputPrompt: null,
448
             invalidInputPrompt: null,
451
         },
449
         },
456
             response_key_description: 'first round draft scoring question',
454
             response_key_description: 'first round draft scoring question',
457
             aspect: 'dynamic_vs_ordered',
455
             aspect: 'dynamic_vs_ordered',
458
             category: 'aspect',
456
             category: 'aspect',
459
-            survey_stage: 'aspect-3',
460
             placeholder: null,
457
             placeholder: null,
461
             invalidInputPrompt: null,
458
             invalidInputPrompt: null,
462
         },
459
         },
467
             response_key_description: 'first round draft scoring question',
464
             response_key_description: 'first round draft scoring question',
468
             aspect: 'precise_vs_resourceful',
465
             aspect: 'precise_vs_resourceful',
469
             category: 'aspect',
466
             category: 'aspect',
470
-            survey_stage: 'aspect-4',
471
             placeholder: null,
467
             placeholder: null,
472
             invalidInputPrompt: null,
468
             invalidInputPrompt: null,
473
         },
469
         },
478
             response_key_description: 'first round draft scoring question',
474
             response_key_description: 'first round draft scoring question',
479
             aspect: 'big_Picture_vs_focused',
475
             aspect: 'big_Picture_vs_focused',
480
             category: 'aspect',
476
             category: 'aspect',
481
-            survey_stage: 'aspect-5',
482
             placeholder: null,
477
             placeholder: null,
483
             invalidInputPrompt: null,
478
             invalidInputPrompt: null,
484
         },
479
         },
489
             response_key_description: 'first round draft scoring question',
484
             response_key_description: 'first round draft scoring question',
490
             aspect: 'guided_vs_self-managed',
485
             aspect: 'guided_vs_self-managed',
491
             category: 'aspect',
486
             category: 'aspect',
492
-            survey_stage: 'aspect-6',
493
             placeholder: null,
487
             placeholder: null,
494
             invalidInputPrompt: null,
488
             invalidInputPrompt: null,
495
         },
489
         },
500
             response_key_description: 'required for profile creation',
494
             response_key_description: 'required for profile creation',
501
             aspect: null,
495
             aspect: null,
502
             category: 'input',
496
             category: 'input',
503
-            survey_stage: 'name',
504
             placeholder: 'Joe Doe',
497
             placeholder: 'Joe Doe',
505
             invalidInputPrompt: 'So sorry, but what is your name?',
498
             invalidInputPrompt: 'So sorry, but what is your name?',
506
         },
499
         },
511
             response_key_description: 'required for profile creation',
504
             response_key_description: 'required for profile creation',
512
             aspect: null,
505
             aspect: null,
513
             category: 'input',
506
             category: 'input',
514
-            survey_stage: 'email',
515
             placeholder: 'joe@mailme.com',
507
             placeholder: 'joe@mailme.com',
516
             invalidInputPrompt: 'It looks like that email is not valid, try en email that is formatted like so: joe@joe.com',
508
             invalidInputPrompt: 'It looks like that email is not valid, try en email that is formatted like so: joe@joe.com',
517
         },
509
         },
522
             response_key_description: 'required for profile creation',
514
             response_key_description: 'required for profile creation',
523
             aspect: null,
515
             aspect: null,
524
             category: 'input',
516
             category: 'input',
525
-            survey_stage: 'password',
526
             placeholder: 'supersecr3tp@ssword',
517
             placeholder: 'supersecr3tp@ssword',
527
             invalidInputPrompt: 'That password does not fit our requirements, please follow the above instructions to generate a secure password.',
518
             invalidInputPrompt: 'That password does not fit our requirements, please follow the above instructions to generate a secure password.',
528
         },
519
         },
533
             response_key_description: 'required for distance calculations',
524
             response_key_description: 'required for distance calculations',
534
             aspect: null,
525
             aspect: null,
535
             category: 'input',
526
             category: 'input',
536
-            survey_stage: 'zipcode',
537
             placeholder: '90012',
527
             placeholder: '90012',
538
             invalidInputPrompt: 'Oops! That is not a recognized zipcode, please enter a 5 digit zipcode like: 97869',
528
             invalidInputPrompt: 'Oops! That is not a recognized zipcode, please enter a 5 digit zipcode like: 97869',
539
         },
529
         },
544
             response_key_description: 'required for profile generation',
534
             response_key_description: 'required for profile generation',
545
             aspect: null,
535
             aspect: null,
546
             category: 'choice',
536
             category: 'choice',
547
-            survey_stage: 'seeking',
548
             placeholder: null,
537
             placeholder: null,
549
             invalidInputPrompt: 'In order to provide you with the best results, Siimee will need to know whether you are an employer looking to fill a position, or a candidate looking for an employment. Please take a look at our above options and choose one.',
538
             invalidInputPrompt: 'In order to provide you with the best results, Siimee will need to know whether you are an employer looking to fill a position, or a candidate looking for an employment. Please take a look at our above options and choose one.',
550
         },
539
         },
555
             response_key_description: 'required for profile pictures',
544
             response_key_description: 'required for profile pictures',
556
             aspect: null,
545
             aspect: null,
557
             category: 'input',
546
             category: 'input',
558
-            survey_stage: 'image',
559
             placeholder: null,
547
             placeholder: null,
560
             invalidInputPrompt: 'It appears you have yet to upload an image. Please provide Siimee with an image in case you want to show others what you look like.',
548
             invalidInputPrompt: 'It appears you have yet to upload an image. Please provide Siimee with an image in case you want to show others what you look like.',
561
         },
549
         },
566
             response_key_description: 'programming and spoken language preference',
554
             response_key_description: 'programming and spoken language preference',
567
             aspect: null,
555
             aspect: null,
568
             category: 'choice',
556
             category: 'choice',
569
-            survey_stage: 'language',
570
             placeholder: null,
557
             placeholder: null,
571
             invalidInputPrompt: '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?',
558
             invalidInputPrompt: '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?',
572
         },
559
         },
577
             response_key_description: 'duration preference for hours able to dedicate to work',
564
             response_key_description: 'duration preference for hours able to dedicate to work',
578
             aspect: null,
565
             aspect: null,
579
             category: 'choice',
566
             category: 'choice',
580
-            survey_stage: 'duration',
581
             placeholder: null,
567
             placeholder: null,
582
             invalidInputPrompt: 'Looks like you have yet to  fill out what kind of work you are 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!',
568
             invalidInputPrompt: 'Looks like you have yet to  fill out what kind of work you are 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!',
583
         },
569
         },
588
             response_key_description: 'location preference for where work happens',
574
             response_key_description: 'location preference for where work happens',
589
             aspect: null,
575
             aspect: null,
590
             category: 'choice',
576
             category: 'choice',
591
-            survey_stage: 'presence',
592
             placeholder: null,
577
             placeholder: null,
593
             invalidInputPrompt: 'Hold up! So sorry to put a pause here, but it looks like you have not chosen whether to work remotely or in person. No worries, if you are unsure, just choose the flexible option.',
578
             invalidInputPrompt: 'Hold up! So sorry to put a pause here, but it looks like you have not chosen whether to work remotely or in person. No worries, if you are unsure, just choose the flexible option.',
594
         },
579
         },
599
             response_key_description: 'required for profile description',
584
             response_key_description: 'required for profile description',
600
             aspect: null,
585
             aspect: null,
601
             category: 'input',
586
             category: 'input',
602
-            survey_stage: 'blurb', 
603
             placeholder: 'my backstory starts long long ago...',
587
             placeholder: 'my backstory starts long long ago...',
604
             invalidInputPrompt: 'Whoa! Cool story. Unfortunately your backstory is either too long or too short. Please tell us a bit about yourself between 1 and 100 characters.',
588
             invalidInputPrompt: 'Whoa! Cool story. Unfortunately your backstory is either too long or too short. Please tell us a bit about yourself between 1 and 100 characters.',
605
         },
589
         },
610
             response_key_description: 'urgency for when work is required',
594
             response_key_description: 'urgency for when work is required',
611
             aspect: null,
595
             aspect: null,
612
             category: 'choice',
596
             category: 'choice',
613
-            survey_stage: 'urgency',
614
             placeholder: null,
597
             placeholder: null,
615
             invalidInputPrompt: 'Looks like you left this field blank. Take a look at our provided options and tell us when you would like be employed.',
598
             invalidInputPrompt: 'Looks like you left this field blank. Take a look at our provided options and tell us when you would like be employed.',
616
         },
599
         },
621
             response_key_description: 'required for profile pronouns',
604
             response_key_description: 'required for profile pronouns',
622
             aspect: null,
605
             aspect: null,
623
             category: 'choice',
606
             category: 'choice',
624
-            survey_stage: 'pronouns',
625
             placeholder: null,
607
             placeholder: null,
626
             invalidInputPrompt: 'Ensuring that others on our platform are aware of what your preferred pronouns are is important to us. Please choose from one of the above options.',
608
             invalidInputPrompt: 'Ensuring that others on our platform are aware of what your preferred pronouns are is important to us. Please choose from one of the above options.',
627
         },
609
         },
632
             response_key_description: 'preference for commuting distance cutoff',
614
             response_key_description: 'preference for commuting distance cutoff',
633
             aspect: null,
615
             aspect: null,
634
             category: 'input',
616
             category: 'input',
635
-            survey_stage: 'distance',
636
             placeholder: '5 mi',
617
             placeholder: '5 mi',
637
             invalidInputPrompt: 'Whoa! You either left this field blank or tried to input an astronomically large distance you would like to see results from. Please input a distance you would like to see results in.',
618
             invalidInputPrompt: 'Whoa! You either left this field blank or tried to input an astronomically large distance you would like to see results from. Please input a distance you would like to see results in.',
638
         },
619
         },

+ 0
- 1
backend/db/migrations/20210527174416_create_response_keys_table.js Dosyayı Görüntüle

6
         table.string('response_key_description')
6
         table.string('response_key_description')
7
         table.string('aspect')
7
         table.string('aspect')
8
         table.string('category')
8
         table.string('category')
9
-        table.string('survey_stage')
10
         table.string('placeholder')
9
         table.string('placeholder')
11
         table.string('invalidInputPrompt')
10
         table.string('invalidInputPrompt')
12
     })
11
     })

+ 0
- 1
backend/lib/schemas/responses.js Dosyayı Görüntüle

16
     response_key_description: Joi.any(),
16
     response_key_description: Joi.any(),
17
     aspect: Joi.string().allow(null, ''),
17
     aspect: Joi.string().allow(null, ''),
18
     category: Joi.string().allow(null, ''),
18
     category: Joi.string().allow(null, ''),
19
-    survey_stage: Joi.string(),
20
     placeholder: Joi.string().allow(null, ''),
19
     placeholder: Joi.string().allow(null, ''),
21
     invalidInputPrompt: Joi.string().allow(null, ''),
20
     invalidInputPrompt: Joi.string().allow(null, ''),
22
 
21
 

+ 26
- 1
frontend/src/utils/lang.js Dosyayı Görüntüle

3
 // Splash page is unique in survey steps and therefore is simply spliced in
3
 // Splash page is unique in survey steps and therefore is simply spliced in
4
 // during survey generation
4
 // during survey generation
5
 const splash = {
5
 const splash = {
6
-    response_key_id: 1,
6
+    response_key_id: 20,
7
     response_key_category: 'splash',
7
     response_key_category: 'splash',
8
     response_key_prompt: 'splash page',
8
     response_key_prompt: 'splash page',
9
     response_key_description: 'required for splash page rendering',
9
     response_key_description: 'required for splash page rendering',
15
     invalidInputPrompt: null,
15
     invalidInputPrompt: null,
16
 }
16
 }
17
 
17
 
18
+// Order of surveyStages is strongly correlated with order of response_keys 
19
+// in backend's mock.js
20
+const surveyStages = [
21
+    'aspect-1',
22
+    'aspect-2',
23
+    'aspect-3',
24
+    'aspect-4',
25
+    'aspect-5',
26
+    'aspect-6',
27
+    'name',
28
+    'email',
29
+    'password',
30
+    'zipcode',
31
+    'seeking',
32
+    'image',
33
+    'language',
34
+    'duration',
35
+    'presence',
36
+    'blurb',
37
+    'urgency',
38
+    'pronouns',
39
+    'distance'
40
+]
41
+
18
 // TODO: in utils/survey.js modify _setSteps() to reorder survey steps from here
42
 // TODO: in utils/survey.js modify _setSteps() to reorder survey steps from here
19
 const allSteps = {
43
 const allSteps = {
20
     usa: {
44
     usa: {
105
 export {
129
 export {
106
     allSteps,
130
     allSteps,
107
     splash,
131
     splash,
132
+    surveyStages,
108
     aspectResponses,
133
     aspectResponses,
109
     aspectsArr,
134
     aspectsArr,
110
     possible,
135
     possible,

+ 10
- 4
frontend/src/utils/survey.js Dosyayı Görüntüle

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 { splash, possible } from './lang.js'
3
+import { splash, possible, surveyStages } from './lang.js'
4
 
4
 
5
 class SurveyFactory {
5
 class SurveyFactory {
6
     constructor() {
6
     constructor() {
7
         this.questionsFromDb = []
7
         this.questionsFromDb = []
8
     }
8
     }
9
+    _addSurveyStages(responseKeys, surveyStages) {
10
+        responseKeys.forEach((key, i) => {
11
+            key.survey_stage = surveyStages[i]
12
+        })
13
+    }
9
     _addResponses(responseKeys, responsesByCategory) {
14
     _addResponses(responseKeys, responsesByCategory) {
10
         Object.keys(responsesByCategory).forEach(k => {
15
         Object.keys(responsesByCategory).forEach(k => {
11
             responseKeys.forEach(key => {
16
             responseKeys.forEach(key => {
36
     _setSteps() {
41
     _setSteps() {
37
         const responseKeys = this.questionsFromDb
42
         const responseKeys = this.questionsFromDb
38
         const responsesByCategory = possible['usa']
43
         const responsesByCategory = possible['usa']
39
-        let mutatedResponseKeys = this._addResponses(responseKeys, responsesByCategory)
44
+        let mutatedResponseKeys = this._addSurveyStages(responseKeys, surveyStages)
45
+        mutatedResponseKeys = this._addResponses(responseKeys, responsesByCategory)
40
         mutatedResponseKeys = this._addComponents(responseKeys)
46
         mutatedResponseKeys = this._addComponents(responseKeys)
41
-        // Splash page is spliced into first step of survey
42
-        mutatedResponseKeys.splice(0, 1, splash)
47
+        // Splash page is placed at beginning of survey
48
+        mutatedResponseKeys.unshift(splash)
43
         return mutatedResponseKeys
49
         return mutatedResponseKeys
44
     }
50
     }
45
     async getQuestions() {
51
     async getQuestions() {

Loading…
İptal
Kaydet