Projet

Général

Profil

Task #793 » proposition_algorithm.txt

ahlem belgacem, 15/07/2025 16:01

 
1
Algorithm: Calculate Quiz Results for a Company
2
api => @Get  : /api/quiz
3

    
4
{
5
  "companyId": "your_company_id_here",
6
  "resultType": "quiz_market",  // or "current_sector"
7
  "questionCodes": ["q1", "q2", "q3", "q4", "q5"],
8
  "round": "round_number_here"
9
}
10

    
11
 
12
 
13
***************
14
Logic in nestJs: Calculated results for each questionCode in the quiz (json example output)
15

    
16
algorithm:
17
 *Validate Quiz Completion : fetch from "company_quiz" table using companyId and quizCode.
18
                           If quiz_status is not "COMPLETED"
19
						   Then return an message('please make sure  that quiz has already completed').
20
						   
21
*Calculate the Result
22
calcul:
23
Fetch Company Quiz Responses :
24
		*Retrieve all responses from the "company_quiz_response" table where
25
		(companyId  and quizCode).
26
		*Retrieve all responses for all comapanies exist
27
Process Each Question :
28
logic of calcul 
29
 *For each unique questionCode in the retrieved responses:
30
			*fetch Total Items =>GET from "solution_quiz_section_questions_items" 
31
			the complete list of itemCode associated with the current questionCode.
32
 *Return for each quizCode { list of itemCode with values grouped by questionCode).
33

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