Projet

Général

Profil

US #941 » proposition_algorithm.txt

ahlem belgacem, 07/04/2025 18:31

 
1
Algorithm: Calculate Quiz Results for a Company
2

    
3
Input:(companyId ,quizCode)
4
  Api: GET /questionnaire/:quizCode/company/:companyId/echarts
5
Output: Calculated results for each questionCode in the quiz (json example output)
6

    
7
algorithm:
8

    
9
 *Validate Quiz Completion : fetch from "company_quiz" table using companyId and quizCode.
10
                           If quiz_status is not "COMPLETED"
11
						   Then return an message('please make sure  that quiz has already completed').
12

    
13

    
14

    
15
 *Calculate the Result
16
calcul:
17
Fetch Company Quiz Responses :
18
		*Retrieve all responses from the "company_quiz_response" table where
19
		(companyId  and quizCode).
20
		*Retrieve all responses for all comapanies exist
21

    
22
Process Each Question :
23
logic of calcul 
24
 *For each unique questionCode in the retrieved responses:
25
			*fetch Total Items =>GET from "solution_quiz_section_questions_items" 
26
			the complete list of itemCode associated with the current questionCode.
27
 *Return for each quizCode { list of itemCode with values ).
28

    
29

    
30
example output .json
31

    
32
{
33
  "quizCode": "Salary_Revision_Quiz",
34
  "companyId": "1",
35
  "results": [
36
    {
37
      "questionCode": "Q2-PRS-1",
38
      "items": [
39
        { "itemCode": "yes", "value": 40 },
40
        { "itemCode": "no", "value": 60 }
41
      ]
42
    },
43
    {
44
      "questionCode": "Q2-PRS-2",
45
      "items": [
46
        { "itemCode": "less-than-1-year", "value": 20 },
47
        { "itemCode": "1-3-years", "value": 30 },
48
        { "itemCode": "3-5-years", "value": 25 },
49
        { "itemCode": "more-than-5-years", "value": 25 }
50
      ]
51
    },
52
    {
53
      "questionCode": "Q2-PRS-3",
54
      "items": [
55
        { "itemCode": "annually", "value": 35 },
56
        { "itemCode": "semi-annually", "value": 35 },
57
        { "itemCode": "quarterly", "value": 20 },
58
        { "itemCode": "other-please-specify", "value": 10 }
59
      ]
60
    },
61
    {
62
      "questionCode": "Q2-PRS-4",
63
      "items": [
64
        { "itemCode": "employee-motivation-retention", "value": 45 },
65
        { "itemCode": "alignment-of-wages", "value": 20 },
66
        { "itemCode": "reward-for-performance", "value": 15 },
67
        { "itemCode": "internal-equity", "value": 10 },
68
        { "itemCode": "other-please-specify", "value": 10 }
69
      ]
70
    },
71
    {
72
      "questionCode": "Q2-PRS-5",
73
      "items": [
74
        { "itemCode": "individual-performance", "value": 25 },
75
        { "itemCode": "team-performance", "value": 25 },
76
        { "itemCode": "company-performance", "value": 20 },
77
        { "itemCode": "seniority", "value": 15 },
78
        { "itemCode": "specific-skills", "value": 5 },
79
        { "itemCode": "market-salary-comparison", "value": 5 },
80
        { "itemCode": "achieving-personal-goals", "value": 3 },
81
        { "itemCode": "other-please-specify", "value": 2 }
82
      ]
83
    },
84
    {
85
      "questionCode": "Q2-PRS-6",
86
      "items": [
87
        { "itemCode": "merit-increases", "value": 30 },
88
        { "itemCode": "cost-of-living-adjustments", "value": 25 },
89
        { "itemCode": "promotion-increases", "value": 20 },
90
        { "itemCode": "one-time-bonuses", "value": 15 },
91
        { "itemCode": "market-comparisons", "value": 5 },
92
        { "itemCode": "other-please-specify", "value": 5 }
93
      ]
94
    },
95
    {
96
      "questionCode": "Q2-PRS-7",
97
      "items": [
98
        { "itemCode": "less-than-3-percent", "value": 40 },
99
        { "itemCode": "between-3-and-5-percent", "value": 30 },
100
        { "itemCode": "between-5-and-7-percent", "value": 20 },
101
        { "itemCode": "more-than-7-percent", "value": 10 }
102
      ]
103
    },
104
    {
105
      "questionCode": "Q2-PRS-8",
106
      "items": [
107
        { "itemCode": "less-than-3-percent", "value": 25 },
108
        { "itemCode": "between-3-and-5-percent", "value": 35 },
109
        { "itemCode": "between-5-and-7-percent", "value": 25 },
110
        { "itemCode": "more-than-7-percent", "value": 15 }
111
      ]
112
    },
113
    {
114
      "questionCode": "Q2-PRS-9",
115
      "items": [
116
        { "itemCode": "less-than-1-percent", "value": 15 },
117
        { "itemCode": "between-1-and-3-percent", "value": 35 },
118
        { "itemCode": "between-3-and-5-percent", "value": 30 },
119
        { "itemCode": "more-than-5-percent", "value": 20 }
120
      ]
121
    }
122
  ]
123
}
124

    
125

    
126
 question : for  the type of question (Bar, table,pie)is that have an impact for values of results ? 
(4-4/4)