Procházet zdrojové kódy

:recycle: Large refactor concentrating survey object in db

tabs-content
tomit4 před 3 roky
rodič
revize
63d6d4beeb

+ 21
- 22
backend/db/data-generator/index.js Zobrazit soubor

115
     // Generate responses first, before filling in details
115
     // Generate responses first, before filling in details
116
     let responses = generate(
116
     let responses = generate(
117
         classes.Response,
117
         classes.Response,
118
-        (config.batchSize + extraProfilesToGenerate) * mock.response_keys.length,
118
+        (config.batchSize + extraProfilesToGenerate) *
119
+            mock.response_keys.length,
119
         { starting: generatedResponseCount + config.batchSize },
120
         { starting: generatedResponseCount + config.batchSize },
120
     )
121
     )
121
     profiles.forEach((profile, i) => {
122
     profiles.forEach((profile, i) => {
125
             resToEdit.response_key_id = k + 1
126
             resToEdit.response_key_id = k + 1
126
             resToEdit.profile_id = profile.profile_id
127
             resToEdit.profile_id = profile.profile_id
127
 
128
 
128
-            if(resToEdit.response_key_id < config.zipcodeKey) {
129
+            if (resToEdit.response_key_id < config.zipcodeKey) {
129
                 resToEdit.val = random.valFrom(Object.values(possibleResponses))
130
                 resToEdit.val = random.valFrom(Object.values(possibleResponses))
130
-            }
131
-            else if(resToEdit.response_key_id == config.zipcodeKey) {
131
+            } else if (resToEdit.response_key_id == config.zipcodeKey) {
132
                 resToEdit.val = random.valFrom(config.possibleZipcodes)
132
                 resToEdit.val = random.valFrom(config.possibleZipcodes)
133
-            }
134
-            else {
133
+            } else {
135
                 switch (resToEdit.response_key_id) {
134
                 switch (resToEdit.response_key_id) {
136
-                case config.mediaKey:
137
-                    resToEdit.val = random.media()
138
-                    break
139
-                case config.langKey:
140
-                    resToEdit.val = random.language()
141
-                    break
142
-                case 10:
143
-                    resToEdit.val = random.duration()
144
-                    break
145
-                case 11:
146
-                    resToEdit.val = random.location()
147
-                    break
148
-                case config.blurbKey:
149
-                    resToEdit.val = random.blurb()
150
-                    break
135
+                    case config.mediaKey:
136
+                        resToEdit.val = random.media()
137
+                        break
138
+                    case config.langKey:
139
+                        resToEdit.val = random.language()
140
+                        break
141
+                    case 10:
142
+                        resToEdit.val = random.duration()
143
+                        break
144
+                    case 11:
145
+                        resToEdit.val = random.location()
146
+                        break
147
+                    case config.blurbKey:
148
+                        resToEdit.val = random.blurb()
149
+                        break
151
                 }
150
                 }
152
             }
151
             }
153
         }
152
         }
170
     let jobPosterIds = users
169
     let jobPosterIds = users
171
         .filter(user => user.is_poster > 0)
170
         .filter(user => user.is_poster > 0)
172
         .map(user => user.user_id)
171
         .map(user => user.user_id)
173
-    // Guarentee ONE job poster
172
+    // Guarantee ONE job poster
174
     if (!jobPosterIds.length) {
173
     if (!jobPosterIds.length) {
175
         random.valFrom(users).is_poster = 1
174
         random.valFrom(users).is_poster = 1
176
         jobPosterIds = users
175
         jobPosterIds = users

+ 176
- 33
backend/db/data-generator/mock.js Zobrazit soubor

426
             is_deleted: false,
426
             is_deleted: false,
427
         },
427
         },
428
     ],
428
     ],
429
+    // need to add responses? table to join to here... use json capability? OR
430
+    // use simplified association logic on front end that is already sort of
431
+    // present
429
     response_keys: [
432
     response_keys: [
430
         {
433
         {
431
             response_key_id: 1,
434
             response_key_id: 1,
435
+            response_key_category: 'splash',
436
+            response_key_prompt: 'splash page',
437
+            response_key_description: 'required for splash page rendering',
438
+            aspect: null,
439
+            category: 'splash',
440
+            component: 'Splash',
441
+            survey_stage: 'splash',
442
+            placeholder: null,
443
+            invalidInputPrompt: null,
444
+        },
445
+        {
446
+            response_key_id: 2,
432
             response_key_category: 'visionary_vs_implementer',
447
             response_key_category: 'visionary_vs_implementer',
433
             response_key_prompt: 'Do you prefer to work with those who are driven by their Visionary insights, or those who are driven more by their Implementation?',
448
             response_key_prompt: 'Do you prefer to work with those who are driven by their Visionary insights, or those who are driven more by their Implementation?',
434
             response_key_description: 'first round draft scoring question',
449
             response_key_description: 'first round draft scoring question',
450
+            aspect: 'visionary_vs_implementer',
451
+            category: 'aspect',
452
+            component: 'QuestionResponse',
453
+            survey_stage: 'aspect-1',
454
+            placeholder: null,
455
+            invalidInputPrompt: null,
435
         },
456
         },
436
         {
457
         {
437
-            response_key_id: 2,
458
+            response_key_id: 3,
438
             response_key_category: 'creative_vs_methodical',
459
             response_key_category: 'creative_vs_methodical',
439
             response_key_prompt: 'Have you found more success working with employees that are more Creative or those that are more Methodical?',
460
             response_key_prompt: 'Have you found more success working with employees that are more Creative or those that are more Methodical?',
440
             response_key_description: 'first round draft scoring question',
461
             response_key_description: 'first round draft scoring question',
462
+            aspect: 'creative_vs_methodical',
463
+            category: 'aspect',
464
+            component: 'QuestionResponse',
465
+            survey_stage: 'aspect-2',
466
+            placeholder: null,
467
+            invalidInputPrompt: null,
441
         },
468
         },
442
         {
469
         {
443
-            response_key_id: 3,
470
+            response_key_id: 4,
444
             response_key_category: 'dynamic_vs_ordered',
471
             response_key_category: 'dynamic_vs_ordered',
445
             response_key_prompt: 'Which do you find to be the ideal working environment, one that is more Collaborative or one that is more Independent?',
472
             response_key_prompt: 'Which do you find to be the ideal working environment, one that is more Collaborative or one that is more Independent?',
446
             response_key_description: 'first round draft scoring question',
473
             response_key_description: 'first round draft scoring question',
474
+            aspect: 'dynamic_vs_ordered',
475
+            category: 'aspect',
476
+            component: 'QuestionResponse',
477
+            survey_stage: 'aspect-3',
478
+            placeholder: null,
479
+            invalidInputPrompt: null,
447
         },
480
         },
448
         {
481
         {
449
-            response_key_id: 4,
482
+            response_key_id: 5,
450
             response_key_category: 'precise_vs_resourceful',
483
             response_key_category: 'precise_vs_resourceful',
451
             response_key_prompt: 'Is the success of your team more likely if it includes individuals who are more Innovative, or those that are more Conventional when fulfilling their job duties?',
484
             response_key_prompt: 'Is the success of your team more likely if it includes individuals who are more Innovative, or those that are more Conventional when fulfilling their job duties?',
452
             response_key_description: 'first round draft scoring question',
485
             response_key_description: 'first round draft scoring question',
486
+            aspect: 'precise_vs_resourceful',
487
+            category: 'aspect',
488
+            component: 'QuestionResponse',
489
+            survey_stage: 'aspect-4',
490
+            placeholder: null,
491
+            invalidInputPrompt: null,
453
         },
492
         },
454
         {
493
         {
455
-            response_key_id: 5,
494
+            response_key_id: 6,
456
             response_key_category: 'big_Picture_vs_focused',
495
             response_key_category: 'big_Picture_vs_focused',
457
             response_key_prompt: 'When fulfilling the role of the hiring leader, do you find yourself focusing more on the Big Picture or The Task At Hand?',
496
             response_key_prompt: 'When fulfilling the role of the hiring leader, do you find yourself focusing more on the Big Picture or The Task At Hand?',
458
             response_key_description: 'first round draft scoring question',
497
             response_key_description: 'first round draft scoring question',
498
+            aspect: 'big_Picture_vs_focused',
499
+            category: 'aspect',
500
+            component: 'QuestionResponse',
501
+            survey_stage: 'aspect-5',
502
+            placeholder: null,
503
+            invalidInputPrompt: null,
459
         },
504
         },
460
         {
505
         {
461
-            response_key_id: 6,
506
+            response_key_id: 7,
462
             response_key_category: 'guided_vs_self-managed',
507
             response_key_category: 'guided_vs_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?',
508
             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',
509
             response_key_description: 'first round draft scoring question',
465
-        },
466
-        {
467
-            response_key_id: 7,
468
-            response_key_category: 'profile',
469
-            response_key_prompt: 'zipcode',
470
-            response_key_description: 'required for distance calculations',
510
+            aspect: 'guided_vs_self-managed',
511
+            category: 'aspect',
512
+            component: 'QuestionResponse',
513
+            survey_stage: 'aspect-6',
514
+            placeholder: null,
515
+            invalidInputPrompt: null,
471
         },
516
         },
472
         {
517
         {
473
             response_key_id: 8,
518
             response_key_id: 8,
474
             response_key_category: 'profile',
519
             response_key_category: 'profile',
475
-            response_key_prompt: 'image',
476
-            response_key_description: 'required for profile pictures',
520
+            response_key_prompt: 'First things first, could you provide us with your name? [break] I am called [break] when others address me.',
521
+            response_key_description: 'required for profile creation',
522
+            aspect: null,
523
+            category: null,
524
+            component: 'FormInput',
525
+            survey_stage: 'name',
526
+            placeholder: 'Joe Doe',
527
+            invalidInputPrompt: 'So sorry, but what is your name?',
477
         },
528
         },
478
         {
529
         {
479
             response_key_id: 9,
530
             response_key_id: 9,
480
             response_key_category: 'profile',
531
             response_key_category: 'profile',
481
-            response_key_prompt: 'language',
482
-            response_key_description:
483
-                'programming and spoken language preference',
532
+            response_key_prompt: 'In order for others to reach out to you on Siimee, we will need you to provide your email address.[break]When reaching out to me, [break] is my preferred email.',
533
+            response_key_description: 'required for profile creation',
534
+            aspect: null,
535
+            category: null,
536
+            component: 'FormInput',
537
+            survey_stage: 'email',
538
+            placeholder: 'joe@mailme.com',
539
+            invalidInputPrompt: 'It looks like that email is not valid, try en email that is formatted like so: joe@joe.com',
484
         },
540
         },
485
         {
541
         {
486
             response_key_id: 10,
542
             response_key_id: 10,
487
             response_key_category: 'profile',
543
             response_key_category: 'profile',
488
-            response_key_prompt: 'duration',
489
-            response_key_description:
490
-                'duration preference for hours able to dedicate to work',
544
+            response_key_prompt: 'So far so good! Next we will need you to establish a super secret password. Your password should be at least 10 characters long and have at least 2 special characters.[break]My [break] is a very secure passcode that only I will have access to!',
545
+            response_key_description: 'required for profile creation',
546
+            aspect: null,
547
+            category: null,
548
+            component: 'FormInput',
549
+            survey_stage: 'password',
550
+            placeholder: 'supersecr3tp@ssword',
551
+            invalidInputPrompt: 'That password does not fit our requirements, please follow the above instructions to generate a secure password.',
491
         },
552
         },
492
         {
553
         {
493
             response_key_id: 11,
554
             response_key_id: 11,
494
             response_key_category: 'profile',
555
             response_key_category: 'profile',
495
-            response_key_prompt: 'presence',
496
-            response_key_description:
497
-                'location preference for where work happens',
556
+            response_key_prompt: 'Looking good! Doing great. The next piece of info needed is your zip code. That way we can be sure to only show you other people in your area.[break]My zip code, [break] is the general area where I wish to see results in.',
557
+            response_key_description: 'required for distance calculations',
558
+            aspect: null,
559
+            category: null,
560
+            component: 'FormInput',
561
+            survey_stage: 'zipcode',
562
+            placeholder: '90012',
563
+            invalidInputPrompt: 'Oops! That is not a recognized zipcode, please enter a 5 digit zipcode like: 97869',
498
         },
564
         },
499
         {
565
         {
500
             response_key_id: 12,
566
             response_key_id: 12,
501
             response_key_category: 'profile',
567
             response_key_category: 'profile',
502
-            response_key_prompt: 'blurb',
503
-            response_key_description: 'required for profile description',
568
+            response_key_prompt: 'What are you seeking? Are you looking to find a position to be employed in, or are you looking to employ a candidate?[break] I am a [break] seeking an employer/employee.',
569
+            response_key_description: 'required for profile generation',
570
+            aspect: null,
571
+            category: null,
572
+            component: 'FormDropdown',
573
+            survey_stage: 'seeking',
574
+            placeholder: null,
575
+            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.',
504
         },
576
         },
505
         {
577
         {
506
             response_key_id: 13,
578
             response_key_id: 13,
507
             response_key_category: 'profile',
579
             response_key_category: 'profile',
508
-            response_key_prompt: 'urgency',
509
-            response_key_description: 'urgency for when work is required',
580
+            response_key_prompt: 'Hey, you are almost done! Please provide an image of yourself so others can recognize you if you ever meet up IRL:',
581
+            response_key_description: 'required for profile pictures',
582
+            aspect: null,
583
+            category: null,
584
+            component: 'FormInput',
585
+            survey_stage: 'image',
586
+            placeholder: null,
587
+            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.',
510
         },
588
         },
511
         {
589
         {
512
             response_key_id: 14,
590
             response_key_id: 14,
513
             response_key_category: 'profile',
591
             response_key_category: 'profile',
514
-            response_key_prompt: 'role',
515
-            response_key_description: 'current and desired role',
592
+            response_key_prompt: 'What language is your native language?[break] I consider [break] language as my native language.',
593
+            response_key_description: 'programming and spoken language preference',
594
+            aspect: null,
595
+            category: null,
596
+            component: 'FormDropdown',
597
+            survey_stage: 'language',
598
+            placeholder: null,
599
+            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?',
516
         },
600
         },
517
         {
601
         {
518
             response_key_id: 15,
602
             response_key_id: 15,
519
             response_key_category: 'profile',
603
             response_key_category: 'profile',
520
-            response_key_prompt: 'pronouns',
521
-            response_key_description: 'required for profile pronouns',
604
+            response_key_prompt: 'What kind of duration would you prefer? Are you looking for part-time, full-time, other?[break] Currently, I am looking for a [break] job at this time.',
605
+            response_key_description: 'duration preference for hours able to dedicate to work',
606
+            aspect: null,
607
+            category: null,
608
+            component: 'FormDropdown',
609
+            survey_stage: 'duration',
610
+            placeholder: null,
611
+            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!',
522
         },
612
         },
523
         {
613
         {
524
             response_key_id: 16,
614
             response_key_id: 16,
525
             response_key_category: 'profile',
615
             response_key_category: 'profile',
526
-            response_key_prompt: 'distance',
527
-            response_key_description:
528
-                'preference for commuting distance cutoff',
616
+            response_key_prompt: 'Would you prefer remote, hybrid, in-person work?[break] Personally I would prefer a [break] job right now. It is just what works best for me.',
617
+            response_key_description: 'location preference for where work happens',
618
+            aspect: null,
619
+            category: null,
620
+            component: 'FormDropdown',
621
+            survey_stage: 'presence',
622
+            placeholder: null,
623
+            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.',
624
+        },
625
+        {
626
+            response_key_id: 17,
627
+            response_key_category: 'profile',
628
+            response_key_prompt: 'Please provide us with a short blurb about yourself. What is your backstory?[break] My origin story starts like this:[break]',
629
+            response_key_description: 'required for profile description',
630
+            aspect: null,
631
+            category: null,
632
+            component: 'FormInput',
633
+            survey_stage: 'blurb', 
634
+            placeholder: 'my backstory starts long long ago...',
635
+            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.',
636
+        },
637
+        {
638
+            response_key_id: 18,
639
+            response_key_category: 'profile',
640
+            response_key_prompt: 'How soon do you need the position filled or you need to be employed? [break]I am currently [break] when it comes to employment opportunities right now.',
641
+            response_key_description: 'urgency for when work is required',
642
+            aspect: null,
643
+            category: null,
644
+            component: 'FormDropdown',
645
+            survey_stage: 'urgency',
646
+            placeholder: null,
647
+            invalidInputPrompt: 'Looks like you left this field blank. Take a look at our provided options and tell us when you would like be employed.',
648
+        },
649
+        {
650
+            response_key_id: 19,
651
+            response_key_category: 'profile',
652
+            response_key_prompt: 'When others refer to you, what pronouns do you prefer they use?[break]I prefer to be called [break] when others refer to me.',
653
+            response_key_description: 'required for profile pronouns',
654
+            aspect: null,
655
+            category: null,
656
+            component: 'FormDropdown',
657
+            survey_stage: 'pronouns',
658
+            placeholder: null,
659
+            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.',
660
+        },
661
+        {
662
+            response_key_id: 20,
663
+            response_key_category: 'profile',
664
+            response_key_prompt: 'What distance from your home are you looking to work in?[break] Preferably, I would like to work [break] from my place of residence.',
665
+            response_key_description: 'preference for commuting distance cutoff',
666
+            aspect: null,
667
+            category: null,
668
+            component: 'FormInput',
669
+            survey_stage: 'distance',
670
+            placeholder: '5 mi',
671
+            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.',
529
         },
672
         },
530
     ],
673
     ],
531
     responses: [],
674
     responses: [],

+ 6
- 0
backend/db/migrations/20210527174416_create_response_keys_table.js Zobrazit soubor

4
         table.string('response_key_category').notNullable()
4
         table.string('response_key_category').notNullable()
5
         table.string('response_key_prompt')
5
         table.string('response_key_prompt')
6
         table.string('response_key_description')
6
         table.string('response_key_description')
7
+        table.string('aspect')
8
+        table.string('category')
9
+        table.string('component')
10
+        table.string('survey_stage')
11
+        table.string('placeholder')
12
+        table.string('invalidInputPrompt')
7
     })
13
     })
8
 }
14
 }
9
 
15
 

+ 7
- 0
backend/lib/schemas/responses.js Zobrazit soubor

14
     response_key_category: Joi.string().required(),
14
     response_key_category: Joi.string().required(),
15
     response_key_prompt: Joi.string().required(),
15
     response_key_prompt: Joi.string().required(),
16
     response_key_description: Joi.any(),
16
     response_key_description: Joi.any(),
17
+    aspect: Joi.string().allow(null, ''),
18
+    category: Joi.string().allow(null, ''),
19
+    component: Joi.string(),
20
+    survey_stage: Joi.string(),
21
+    placeholder: Joi.string().allow(null, ''),
22
+    invalidInputPrompt: Joi.string().allow(null, ''),
23
+
17
 }).label('question_single')
24
 }).label('question_single')
18
 
25
 
19
 module.exports = {
26
 module.exports = {

+ 1
- 1
frontend/src/components/onboarding/QuestionResponse.vue Zobrazit soubor

1
 <template lang="pug">
1
 <template lang="pug">
2
 w-card.question
2
 w-card.question
3
-    p {{ question.survey_stage }}
3
+    p {{ question.response_key_prompt }}
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(
6
     w-radios.w-flex.row.justify-space-between(

+ 24
- 113
frontend/src/utils/lang.js Zobrazit soubor

1
-const DELIMITER = '_'
2
-// TO ADD ASPECT, increment aspectsArr here
3
 const aspectsArr = [1, 2, 3, 4, 5, 6]
1
 const aspectsArr = [1, 2, 3, 4, 5, 6]
4
-
5
-// TODO: Combine these two
6
 const allSteps = {
2
 const allSteps = {
7
     usa: {
3
     usa: {
8
         splash: 'splash',
4
         splash: 'splash',
30
     },
26
     },
31
 }
27
 }
32
 
28
 
33
-const promptToComponent = {
34
-    splash: 'Splash',
35
-    aspect: 'QuestionResponse', // Special hacky case
36
-    name: 'FormInput',
37
-    email: 'FormInput',
38
-    password: 'FormInput',
39
-    zipcode: 'FormInput',
40
-    seeking: 'FormDropdown',
41
-    urgency: 'FormDropdown',
42
-    presence: 'FormDropdown',
43
-    duration: 'FormDropdown',
44
-    pronouns: 'FormDropdown',
45
-    language: 'FormDropdown',
46
-    image: 'FormInput',
47
-    distance: 'FormInput',
48
-    blurb: 'FormInput',
49
-    // experience: 'FormTags',
50
-    // role: 'FormDropdown',
51
-}
52
-
53
 const aspectResponses = {
29
 const aspectResponses = {
54
     usa: {
30
     usa: {
55
         never: 'never',
31
         never: 'never',
79
     // key 10
55
     // key 10
80
     duration: ['full-time', 'part-time', 'contract', 'flexible'],
56
     duration: ['full-time', 'part-time', 'contract', 'flexible'],
81
     // Experience and roles concat, key: 14
57
     // Experience and roles concat, key: 14
82
-    experience: ['associate', 'junior', 'mid-level', 'senior', 'staff'],
83
-    roles: {
84
-        type: [
85
-            'back-end',
86
-            'database',
87
-            'front-end',
88
-            'full-stack',
89
-            'qa',
90
-            'security',
91
-            'system',
92
-            'test',
93
-        ],
94
-        position: [
95
-            'administrator',
96
-            'analyst',
97
-            'architect',
98
-            'developer',
99
-            'engineer',
100
-            'manager',
101
-            'technician',
102
-        ],
103
-        candidate: ['hiring_manager', 'recruiter'],
104
-    },
58
+//     experience: ['associate', 'junior', 'mid-level', 'senior', 'staff'],
59
+    // roles: {
60
+        // type: [
61
+            // 'back-end',
62
+            // 'database',
63
+            // 'front-end',
64
+            // 'full-stack',
65
+            // 'qa',
66
+            // 'security',
67
+            // 'system',
68
+            // 'test',
69
+        // ],
70
+        // position: [
71
+            // 'administrator',
72
+            // 'analyst',
73
+            // 'architect',
74
+            // 'developer',
75
+            // 'engineer',
76
+            // 'manager',
77
+            // 'technician',
78
+        // ],
79
+        // candidate: ['hiring_manager', 'recruiter'],
80
+    // },
105
     pronouns: ['she/her', 'she/they', 'he/him', 'he/they', 'they/them'],
81
     pronouns: ['she/her', 'she/they', 'he/him', 'he/they', 'they/them'],
82
+//    role: ['role1', 'role2'],
106
     image: [],
83
     image: [],
107
     zipcode: [],
84
     zipcode: [],
108
     blurb: [],
85
     blurb: [],
109
 }
86
 }
110
 
87
 
111
-// TODO: set up a separate object of similar prompts based off of
112
-// employer/employee, right now is generic
113
-const promptOverrides = {
114
-    name: 'First things first, could you provide us with your name? [break] I am called [break] when others address me.',
115
-    email: "In order for others to reach out to you on Siimee, you'll need to provide your email address.[break]When reaching out to me, [break] is my preferred email.",
116
-    password:
117
-        "So far so good! Next we'll need you to establish a super secret password. Your password should be at least 10 characters long and have at least 2 special characters.[break]My [break] is a very secure passcode that only I will have access to!",
118
-    zipcode:
119
-        "Looking good! You're doing great. The next piece of info we'll need is your zip code. That way we can be sure to only show you other people in your area.[break]My zip code, [break] is the general area where I wish to see results in.",
120
-    seeking:
121
-        "Alright, let's continue! What are you seeking? Are you looking to find a position to be employed in, or are you looking to employ a candidate?[break] I am a [break] seeking an employer/employee.",
122
-    blurb: "Please provide us with a short blurb about yourself. What's your backstory?[break] My origin story starts like this:[break]",
123
-    image: "Hey, you're almost done! Please provide an image of yourself so others can recognize you if you ever meet up IRL:",
124
-    pronouns:
125
-        'When others refer to you, what pronouns do you prefer they use?[break]I prefer to be called [break] when others refer to me.',
126
-    urgency:
127
-        'How soon do you need the position filled or you need to be employed? [break]I am currently [break] when it comes to employment opportunities right now.',
128
-    presence:
129
-        "Would you prefer remote, hybrid, in-person work?[break] Personally I'd prefer a [break] job right now. It's just what works best for me.",
130
-    duration:
131
-        "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.",
132
-    language:
133
-        'What language is your native language?[break] I consider [break] language as my native language.',
134
-    distance:
135
-        "What distance from your home are you looking to work in?[break] Preferably, I'd like to work [break] from my place of residence.",
136
-}
137
-
138
-const inputPlaceholders = {
139
-    name: 'Joe Doe',
140
-    email: 'Joe@mailme.com',
141
-    zipcode: '90012',
142
-    password: 'supersecr3tp@ssword',
143
-    blurb: 'my backstory starts long long ago...',
144
-    distance: '5 mi',
145
-}
146
-
147
-const invalidInputPrompts = {
148
-    name: "So sorry, but what's your name?",
149
-    email: "It looks like that email isn't valid, try en email that is formatted like so: joe@joe.com",
150
-    password:
151
-        "That password doesn't fit our requirements, please follow the above instructions to generate a secure password.",
152
-    zipcode:
153
-        "Oops! That isn't a recognized zipcode, please enter a 5 digit zipcode like: 97869",
154
-    blurb: '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.',
155
-    image: "It appears you didn't upload an image. Please provide Siimee with an image in case you want to show others what you look like.",
156
-    seeking:
157
-        "In order to provide you with the best results, Siimee will need to know whether you're 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.",
158
-    pronouns:
159
-        '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.',
160
-    urgency:
161
-        "Looks like you left this field blank. Take a look at our provided options and tell us when you'd like be employed.",
162
-    presence:
163
-        "Hold up! So sorry to put a pause here, but it looks like you haven't chosen whether to work remotely or in person. No worries, if you're unsure, just choose the 'flexible' option.",
164
-    duration:
165
-        "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!",
166
-    language:
167
-        '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?',
168
-    distance:
169
-        "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.",
170
-}
171
-
172
 export {
88
 export {
173
-    promptOverrides,
174
-    promptToComponent,
175
-    inputPlaceholders,
176
-    invalidInputPrompts,
177
     allSteps,
89
     allSteps,
178
     aspectResponses,
90
     aspectResponses,
179
     aspectsArr,
91
     aspectsArr,
180
     possible,
92
     possible,
181
-    DELIMITER,
182
 }
93
 }

+ 13
- 91
frontend/src/utils/survey.js Zobrazit soubor

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 {
4
-    allSteps,
5
-    promptOverrides,
6
-    promptToComponent,
7
-    inputPlaceholders,
8
-    invalidInputPrompts,
9
-    possible,
10
-    aspectsArr,
11
-} from './lang.js'
12
-
13
-/**
14
- * Make a step from match or step information
15
- * @param {object} match
16
- * @param {object} step
17
- * @returns something like a response_key with possible responses
18
- */
19
-const formatStep = (match, step) => {
20
-    const responsesByCategory = possible['usa']
21
-    const responseKey = {
22
-        response_key_id: match ? match.response_key_id : null,
23
-        response_key_category: match ? match.response_key_category : 'profile',
24
-        response_key_prompt: match ? match.response_key_prompt : step,
25
-        response_key_description: match ? match.response_key_description : null,
26
-    }
27
-    // Embarassing hack
28
-    const uglyMatch = step.split('-')
29
-    if (uglyMatch.length > 1 && uglyMatch[0] == 'aspect') {
30
-        responseKey.aspect = match.response_key_category
31
-        responseKey.category = 'aspect'
32
-    }
33
-    return {
34
-        ...responseKey,
35
-        responses: responsesByCategory[step] ? responsesByCategory[step] : [],
36
-    }
37
-}
38
-const associateWithComponent = responseKeyLike => {
39
-    let component = promptToComponent[responseKeyLike.response_key_prompt]
40
-    // Embarassing hack
41
-    if (responseKeyLike.category == 'aspect') {
42
-        component = promptToComponent[responseKeyLike.category]
43
-    }
44
-    return { ...responseKeyLike, component }
45
-}
46
-
47
-const hasMatch = (step, inArray) => {
48
-    const uglyMatch = step.split('-')
49
-    // Embarassing hack
50
-    if (uglyMatch.length > 1 && uglyMatch[0] == 'aspect') {
51
-        return inArray.find(q => q.response_key_id == uglyMatch[1])
52
-    } else {
53
-        return inArray.find(q => q.response_key_prompt == step)
54
-    }
55
-}
3
+import { possible } from './lang.js'
56
 
4
 
57
 class SurveyFactory {
5
 class SurveyFactory {
58
     constructor() {
6
     constructor() {
59
         this.questionsFromDb = []
7
         this.questionsFromDb = []
60
     }
8
     }
61
-    _setSteps(langFile) {
62
-        const stepsToProcess = [...Object.values(langFile)]
63
-        const seenIds = []
64
-        const stepsInCommon = stepsToProcess.map(step => {
65
-            // Match question to step
66
-            const match = hasMatch(step, this.questionsFromDb)
67
-            if (match) {
68
-                seenIds.push(match.response_key_id)
69
-            }
70
-            // Reformat something from the db into something the gui likes
71
-            const responseKeyLike = formatStep(match, step)
72
-
73
-            // Lookup a matching component
74
-            const withComponent = associateWithComponent(responseKeyLike)
75
-
76
-            // Mutate the object with extra stuff
77
-            const langStub = responseKeyLike.response_key_prompt
78
-            withComponent.survey_stage = langStub
79
-            if (promptOverrides[responseKeyLike.response_key_prompt]) {
80
-                withComponent.response_key_prompt = promptOverrides[langStub]
81
-                withComponent.placeholder = inputPlaceholders[langStub]
82
-                withComponent.invalidInputPrompt = invalidInputPrompts[langStub]
83
-            } else {
84
-                console.warn(
85
-                    `WARN: ${withComponent.survey_stage} must have promptOverride`,
86
-                )
87
-            }
88
-
89
-            return withComponent
9
+    _setSteps() {
10
+        const responseKeys = this.questionsFromDb
11
+        const responsesByCategory = possible['usa']
12
+        Object.keys(responsesByCategory).forEach((k) => {
13
+            responseKeys.forEach((key) => {
14
+                if (key.survey_stage === k) {
15
+                    key.responses = responsesByCategory[k]
16
+                }
17
+            })
90
         })
18
         })
91
-        // temporary extra condition in filter
92
-        let unseen = this.questionsFromDb.filter(
93
-            q =>
94
-                !seenIds.includes(q.response_key_id) &&
95
-                aspectsArr.includes(q.response_key_id),
96
-        )
97
-        return [...stepsInCommon, ...unseen]
19
+        return responseKeys
98
     }
20
     }
99
     async getQuestions() {
21
     async getQuestions() {
100
         try {
22
         try {
104
             console.error(err)
26
             console.error(err)
105
         }
27
         }
106
     }
28
     }
107
-    async createSurvey(langFile = allSteps['usa'], roleTree) {
29
+    async createSurvey(roleTree) {
108
         if (!this.questionsFromDb.length) {
30
         if (!this.questionsFromDb.length) {
109
             const res = await this.getQuestions()
31
             const res = await this.getQuestions()
110
             console.warn(
32
             console.warn(
111
                 `Attempted to create a survey before getting questions: retrieved ${res.length} questions`,
33
                 `Attempted to create a survey before getting questions: retrieved ${res.length} questions`,
112
             )
34
             )
113
         }
35
         }
114
-        const steps = this._setSteps(langFile)
36
+        const steps = this._setSteps()
115
         return new Survey(steps, roleTree)
37
         return new Survey(steps, roleTree)
116
     }
38
     }
117
 }
39
 }

+ 1
- 1
frontend/src/views/SurveyCompleteView.vue Zobrazit soubor

18
             p(v-for='(value, key) in answers')
18
             p(v-for='(value, key) in answers')
19
                 p(v-if='response.survey_stage == key') 
19
                 p(v-if='response.survey_stage == key') 
20
                     p Survey Question {{ responseIndex + 1 }}: 
20
                     p Survey Question {{ responseIndex + 1 }}: 
21
-                    p {{ key }} 
21
+                    p {{ response.response_key_prompt }}
22
                     p You Answered: {{ value }}
22
                     p You Answered: {{ value }}
23
                     br
23
                     br
24
         w-button.ma1(@click="changeAnswers") Change Answers
24
         w-button.ma1(@click="changeAnswers") Change Answers

Načítá se…
Zrušit
Uložit