Bladeren bron

:file_folder: new questionnaire endpoint with aspects json import and basic form submission logic

tags/0.0.1^2
juancarbajal98 3 jaren geleden
bovenliggende
commit
bec18458fa
3 gewijzigde bestanden met toevoegingen van 108 en 0 verwijderingen
  1. 7
    0
      frontend/src/router/index.js
  2. 28
    0
      frontend/src/utils/aspects.js
  3. 73
    0
      frontend/src/views/QuestionnaireView.vue

+ 7
- 0
frontend/src/router/index.js Bestand weergeven

@@ -6,6 +6,7 @@ import ChatView from '../views/ChatView.vue'
6 6
 import MatchesView from '../views/MatchesView.vue'
7 7
 import LoginView from '../views/LoginView.vue'
8 8
 import SurveyView from '../views/SurveyView.vue'
9
+import QuestionnaireView from '../views/QuestionnaireView.vue'
9 10
 
10 11
 const routes = [
11 12
     {
@@ -46,6 +47,12 @@ const routes = [
46 47
         name: `SurveyView`,
47 48
         meta: { requiresAuth: true, requiresCompleteProfile: false },
48 49
     },
50
+    {
51
+        path: `/questionnaire`,
52
+        component: QuestionnaireView,
53
+        name: `QuestionnaireView`,
54
+        meta: { requiresAuth: true, requiresCompleteProfile: false },
55
+    },
49 56
     {
50 57
         path: `/login`,
51 58
         component: LoginView,

+ 28
- 0
frontend/src/utils/aspects.js Bestand weergeven

@@ -0,0 +1,28 @@
1
+const Aspects = [
2
+    {
3
+        question: 'While operating in your professional role, do you identify yourself to be a Visionary or Implementer?',
4
+        answers: ['Visionary', 'Implementer']
5
+    },
6
+    {
7
+        question: 'As a professional, do you consider yourself to be Creative or Methodical in your execution of job duties?',
8
+        answers: ['Creative', 'Methodical']
9
+    },
10
+    {
11
+        question: 'Do you prefer to work in a Collaborative or Independent environment?',
12
+        answers: ['Collaborative', 'Independent']
13
+    },
14
+    {
15
+        question: 'Are you Innovative or Convetional?',
16
+        answers: ['Innovative', 'Conventional']
17
+    },
18
+    {
19
+        question: 'As a professional, are you a Big Picture thinker or Focused thinker when it comes to how you operate in your job duties?',
20
+        answers: ['Big Picture', 'Focused']
21
+    },
22
+    {
23
+        question: 'While working on job related tasks, do you prefer to be Guided or Self-managed in achieveing completion of your responsibilities?',
24
+        answers: ['Guided', 'Self-managed']
25
+    },
26
+]
27
+
28
+export default Aspects

+ 73
- 0
frontend/src/views/QuestionnaireView.vue Bestand weergeven

@@ -0,0 +1,73 @@
1
+<template lang="pug">
2
+br
3
+br
4
+article
5
+    form(@submit.prevent="onSubmit")
6
+        .aspects
7
+            .aspect(
8
+                v-for="(aspect, i) in aspects"
9
+            )
10
+                label {{aspect.question}}
11
+                br
12
+                br
13
+                .aspect--response
14
+                    .aspect--answers
15
+                        h3 {{aspect.answers[0]}}
16
+                        h3 {{aspect.answers[1]}}
17
+                    .aspect--radio-buttons
18
+                        input(type="radio" :id="'q'+(i+1)+'_a1'"  :name="'q'+(i+1)" value="a1" v-model="questionnaireAnswers[i]")
19
+                        input(type="radio" :id="'q'+(i+1)+'_a2'"  :name="'q'+(i+1)" value="a2" v-model="questionnaireAnswers[i]")
20
+                        input(type="radio" :id="'q'+(i+1)+'_a3'"  :name="'q'+(i+1)" value="a3" v-model="questionnaireAnswers[i]")
21
+                        input(type="radio" :id="'q'+(i+1)+'_a4'"  :name="'q'+(i+1)" value="a4" v-model="questionnaireAnswers[i]")
22
+                        input(type="radio" :id="'q'+(i+1)+'_a5'"  :name="'q'+(i+1)" value="a5" v-model="questionnaireAnswers[i]")
23
+                br
24
+                br
25
+        br
26
+        w-flex
27
+            w-button.ma1.grow(type="submit" bg-color="primary") Submit Rating
28
+</template>
29
+<script>
30
+import aspects from '../utils/aspects'
31
+
32
+export default {
33
+    name:'QuestionnaireView',
34
+    data: () => {
35
+        let num_of_ans = aspects.length // need 1 answer for every aspect question
36
+        return {
37
+            questionnaireAnswers: Array(num_of_ans).join(".").split(".") 
38
+        }
39
+    },
40
+    computed:{
41
+        aspects() { return aspects }
42
+    },
43
+    methods: {
44
+        onSubmit() {
45
+            this.questionnaireAnswers.forEach((ans,ind)=>{
46
+                console.log(`Question ${ind+1} was ${ans==''? 'left blank.' : `answered ${ans}`}`)
47
+            })
48
+        }
49
+    },
50
+}
51
+</script>
52
+<style>
53
+.aspects{
54
+    display: flex;
55
+    flex-direction:column;
56
+}
57
+.aspect--response{
58
+    display: flex;
59
+    flex-direction: column;
60
+}
61
+.aspect--answers{
62
+    display: flex;
63
+    flex-direction: row;
64
+    justify-content: space-between;
65
+}
66
+.aspect--radio-buttons{
67
+    width: 90%;
68
+    margin: auto;
69
+    display: flex;
70
+    flex-direction: row;
71
+    justify-content: space-between;
72
+}
73
+</style>

Laden…
Annuleren
Opslaan