analytica-frontend-lib 1.0.83 → 1.0.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordation/index.js +163 -74
- package/dist/Accordation/index.js.map +1 -1
- package/dist/Accordation/index.mjs +163 -74
- package/dist/Accordation/index.mjs.map +1 -1
- package/dist/Alert/index.js +32 -32
- package/dist/Alert/index.js.map +1 -1
- package/dist/Alert/index.mjs +32 -32
- package/dist/Alert/index.mjs.map +1 -1
- package/dist/AlertDialog/index.js +13 -2
- package/dist/AlertDialog/index.js.map +1 -1
- package/dist/AlertDialog/index.mjs +13 -2
- package/dist/AlertDialog/index.mjs.map +1 -1
- package/dist/Alternative/index.js +86 -25
- package/dist/Alternative/index.js.map +1 -1
- package/dist/Alternative/index.mjs +86 -25
- package/dist/Alternative/index.mjs.map +1 -1
- package/dist/Badge/index.js +13 -4
- package/dist/Badge/index.js.map +1 -1
- package/dist/Badge/index.mjs +13 -4
- package/dist/Badge/index.mjs.map +1 -1
- package/dist/Button/index.js +10 -1
- package/dist/Button/index.js.map +1 -1
- package/dist/Button/index.mjs +8 -1
- package/dist/Button/index.mjs.map +1 -1
- package/dist/Calendar/index.js +11 -2
- package/dist/Calendar/index.js.map +1 -1
- package/dist/Calendar/index.mjs +11 -2
- package/dist/Calendar/index.mjs.map +1 -1
- package/dist/Card/index.js +154 -71
- package/dist/Card/index.js.map +1 -1
- package/dist/Card/index.mjs +154 -71
- package/dist/Card/index.mjs.map +1 -1
- package/dist/CheckBox/index.js +28 -5
- package/dist/CheckBox/index.js.map +1 -1
- package/dist/CheckBox/index.mjs +28 -5
- package/dist/CheckBox/index.mjs.map +1 -1
- package/dist/Chips/index.js +10 -1
- package/dist/Chips/index.js.map +1 -1
- package/dist/Chips/index.mjs +10 -1
- package/dist/Chips/index.mjs.map +1 -1
- package/dist/Divider/index.js +10 -1
- package/dist/Divider/index.js.map +1 -1
- package/dist/Divider/index.mjs +8 -1
- package/dist/Divider/index.mjs.map +1 -1
- package/dist/DropdownMenu/index.js +18 -22
- package/dist/DropdownMenu/index.js.map +1 -1
- package/dist/DropdownMenu/index.mjs +18 -22
- package/dist/DropdownMenu/index.mjs.map +1 -1
- package/dist/IconButton/index.js +10 -1
- package/dist/IconButton/index.js.map +1 -1
- package/dist/IconButton/index.mjs +10 -1
- package/dist/IconButton/index.mjs.map +1 -1
- package/dist/IconRoundedButton/index.js +10 -1
- package/dist/IconRoundedButton/index.js.map +1 -1
- package/dist/IconRoundedButton/index.mjs +8 -1
- package/dist/IconRoundedButton/index.mjs.map +1 -1
- package/dist/Menu/index.js +22 -10
- package/dist/Menu/index.js.map +1 -1
- package/dist/Menu/index.mjs +22 -10
- package/dist/Menu/index.mjs.map +1 -1
- package/dist/Modal/index.js +15 -1
- package/dist/Modal/index.js.map +1 -1
- package/dist/Modal/index.mjs +15 -1
- package/dist/Modal/index.mjs.map +1 -1
- package/dist/NavButton/index.js +10 -1
- package/dist/NavButton/index.js.map +1 -1
- package/dist/NavButton/index.mjs +10 -1
- package/dist/NavButton/index.mjs.map +1 -1
- package/dist/NotFound/index.js +13 -3
- package/dist/NotFound/index.js.map +1 -1
- package/dist/NotFound/index.mjs +13 -3
- package/dist/NotFound/index.mjs.map +1 -1
- package/dist/ProgressBar/index.js +63 -15
- package/dist/ProgressBar/index.js.map +1 -1
- package/dist/ProgressBar/index.mjs +63 -15
- package/dist/ProgressBar/index.mjs.map +1 -1
- package/dist/ProgressCircle/index.js +34 -7
- package/dist/ProgressCircle/index.js.map +1 -1
- package/dist/ProgressCircle/index.mjs +34 -7
- package/dist/ProgressCircle/index.mjs.map +1 -1
- package/dist/Quiz/index.d.mts +25 -2
- package/dist/Quiz/index.d.ts +25 -2
- package/dist/Quiz/index.js +972 -260
- package/dist/Quiz/index.js.map +1 -1
- package/dist/Quiz/index.mjs +968 -261
- package/dist/Quiz/index.mjs.map +1 -1
- package/dist/Quiz/useQuizStore/index.d.mts +44 -12
- package/dist/Quiz/useQuizStore/index.d.ts +44 -12
- package/dist/Quiz/useQuizStore/index.js +206 -85
- package/dist/Quiz/useQuizStore/index.js.map +1 -1
- package/dist/Quiz/useQuizStore/index.mjs +203 -85
- package/dist/Quiz/useQuizStore/index.mjs.map +1 -1
- package/dist/Radio/index.js +36 -6
- package/dist/Radio/index.js.map +1 -1
- package/dist/Radio/index.mjs +36 -6
- package/dist/Radio/index.mjs.map +1 -1
- package/dist/Select/index.js +20 -4
- package/dist/Select/index.js.map +1 -1
- package/dist/Select/index.mjs +20 -4
- package/dist/Select/index.mjs.map +1 -1
- package/dist/SelectionButton/index.js +10 -1
- package/dist/SelectionButton/index.js.map +1 -1
- package/dist/SelectionButton/index.mjs +10 -1
- package/dist/SelectionButton/index.mjs.map +1 -1
- package/dist/Skeleton/index.js +18 -6
- package/dist/Skeleton/index.js.map +1 -1
- package/dist/Skeleton/index.mjs +18 -6
- package/dist/Skeleton/index.mjs.map +1 -1
- package/dist/Stepper/index.js +27 -18
- package/dist/Stepper/index.js.map +1 -1
- package/dist/Stepper/index.mjs +27 -18
- package/dist/Stepper/index.mjs.map +1 -1
- package/dist/Table/index.js +37 -13
- package/dist/Table/index.js.map +1 -1
- package/dist/Table/index.mjs +37 -13
- package/dist/Table/index.mjs.map +1 -1
- package/dist/Text/index.js +10 -1
- package/dist/Text/index.js.map +1 -1
- package/dist/Text/index.mjs +8 -1
- package/dist/Text/index.mjs.map +1 -1
- package/dist/TextArea/index.js +17 -3
- package/dist/TextArea/index.js.map +1 -1
- package/dist/TextArea/index.mjs +17 -3
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Toast/Toaster/index.js +15 -1
- package/dist/Toast/Toaster/index.js.map +1 -1
- package/dist/Toast/Toaster/index.mjs +15 -1
- package/dist/Toast/Toaster/index.mjs.map +1 -1
- package/dist/Toast/index.js +15 -1
- package/dist/Toast/index.js.map +1 -1
- package/dist/Toast/index.mjs +15 -1
- package/dist/Toast/index.mjs.map +1 -1
- package/dist/index.css +8 -9
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +903 -325
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +901 -326
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +8 -9
- package/dist/styles.css.map +1 -1
- package/package.json +3 -1
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
2
|
|
|
3
|
+
declare enum QUESTION_DIFFICULTY {
|
|
4
|
+
FACIL = "FACIL",
|
|
5
|
+
MEDIO = "MEDIO",
|
|
6
|
+
DIFICIL = "DIFICIL"
|
|
7
|
+
}
|
|
8
|
+
declare enum QUESTION_TYPE {
|
|
9
|
+
ALTERNATIVA = "ALTERNATIVA",
|
|
10
|
+
DISSERTATIVA = "DISSERTATIVA",
|
|
11
|
+
MULTIPLA_CHOICE = "MULTIPLA_CHOICE"
|
|
12
|
+
}
|
|
13
|
+
declare enum QUESTION_STATUS {
|
|
14
|
+
APROVADO = "APROVADO",
|
|
15
|
+
REPROVADO = "REPROVADO"
|
|
16
|
+
}
|
|
3
17
|
interface Question {
|
|
4
18
|
id: string;
|
|
5
19
|
questionText: string;
|
|
6
20
|
correctOptionId: string;
|
|
7
21
|
description: string;
|
|
8
|
-
type:
|
|
9
|
-
status:
|
|
10
|
-
difficulty:
|
|
22
|
+
type: QUESTION_TYPE;
|
|
23
|
+
status: QUESTION_STATUS;
|
|
24
|
+
difficulty: QUESTION_DIFFICULTY;
|
|
11
25
|
examBoard: string | null;
|
|
12
26
|
examYear: string | null;
|
|
13
27
|
answerKey: string | null;
|
|
@@ -29,6 +43,7 @@ interface Question {
|
|
|
29
43
|
interface Simulado {
|
|
30
44
|
id: string;
|
|
31
45
|
title: string;
|
|
46
|
+
category: string;
|
|
32
47
|
questions: Question[];
|
|
33
48
|
}
|
|
34
49
|
interface Atividade {
|
|
@@ -41,26 +56,38 @@ interface Aula {
|
|
|
41
56
|
title: string;
|
|
42
57
|
questions: Question[];
|
|
43
58
|
}
|
|
59
|
+
interface UserAnswerItem {
|
|
60
|
+
questionId: string;
|
|
61
|
+
activityId: string;
|
|
62
|
+
userId: string;
|
|
63
|
+
answer: string | null;
|
|
64
|
+
optionId: string | null;
|
|
65
|
+
}
|
|
44
66
|
interface UserAnswer extends Question {
|
|
45
67
|
isSkipped: boolean;
|
|
46
68
|
}
|
|
47
69
|
interface QuizState {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
bySimulated?: Simulado;
|
|
71
|
+
byActivity?: Atividade;
|
|
72
|
+
byQuestionary?: Aula;
|
|
51
73
|
currentQuestionIndex: number;
|
|
52
74
|
selectedAnswers: Record<string, string>;
|
|
53
|
-
|
|
54
|
-
userAnswers: UserAnswer[];
|
|
75
|
+
userAnswers: UserAnswerItem[];
|
|
55
76
|
timeElapsed: number;
|
|
56
77
|
isStarted: boolean;
|
|
57
78
|
isFinished: boolean;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
79
|
+
userId: string;
|
|
80
|
+
setBySimulated: (simulado: Simulado) => void;
|
|
81
|
+
setByActivity: (atividade: Atividade) => void;
|
|
82
|
+
setByQuestionary: (aula: Aula) => void;
|
|
83
|
+
setUserId: (userId: string) => void;
|
|
61
84
|
goToNextQuestion: () => void;
|
|
62
85
|
goToPreviousQuestion: () => void;
|
|
63
86
|
goToQuestion: (index: number) => void;
|
|
87
|
+
getActiveQuiz: () => {
|
|
88
|
+
quiz: Simulado | Atividade | Aula;
|
|
89
|
+
type: 'bySimulated' | 'byActivity' | 'byQuestionary';
|
|
90
|
+
} | null;
|
|
64
91
|
selectAnswer: (questionId: string, answerId: string) => void;
|
|
65
92
|
skipQuestion: () => void;
|
|
66
93
|
addUserAnswer: (questionId: string, answerId?: string) => void;
|
|
@@ -86,6 +113,11 @@ interface QuizState {
|
|
|
86
113
|
getQuestionsGroupedBySubject: () => {
|
|
87
114
|
[key: string]: Question[];
|
|
88
115
|
};
|
|
116
|
+
getUserId: () => string;
|
|
117
|
+
getUserAnswerByQuestionId: (questionId: string) => UserAnswerItem | null;
|
|
118
|
+
isQuestionAnsweredByUserAnswers: (questionId: string) => boolean;
|
|
119
|
+
getQuestionStatusFromUserAnswers: (questionId: string) => 'answered' | 'unanswered' | 'skipped';
|
|
120
|
+
getUserAnswersForActivity: () => UserAnswerItem[];
|
|
89
121
|
}
|
|
90
122
|
declare const useQuizStore: zustand.UseBoundStore<Omit<zustand.StoreApi<QuizState>, "setState" | "devtools"> & {
|
|
91
123
|
setState(partial: QuizState | Partial<QuizState> | ((state: QuizState) => QuizState | Partial<QuizState>), replace?: false | undefined, action?: (string | {
|
|
@@ -105,4 +137,4 @@ declare const useQuizStore: zustand.UseBoundStore<Omit<zustand.StoreApi<QuizStat
|
|
|
105
137
|
};
|
|
106
138
|
}>;
|
|
107
139
|
|
|
108
|
-
export { useQuizStore };
|
|
140
|
+
export { QUESTION_DIFFICULTY, QUESTION_STATUS, QUESTION_TYPE, type Question, useQuizStore };
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
2
|
|
|
3
|
+
declare enum QUESTION_DIFFICULTY {
|
|
4
|
+
FACIL = "FACIL",
|
|
5
|
+
MEDIO = "MEDIO",
|
|
6
|
+
DIFICIL = "DIFICIL"
|
|
7
|
+
}
|
|
8
|
+
declare enum QUESTION_TYPE {
|
|
9
|
+
ALTERNATIVA = "ALTERNATIVA",
|
|
10
|
+
DISSERTATIVA = "DISSERTATIVA",
|
|
11
|
+
MULTIPLA_CHOICE = "MULTIPLA_CHOICE"
|
|
12
|
+
}
|
|
13
|
+
declare enum QUESTION_STATUS {
|
|
14
|
+
APROVADO = "APROVADO",
|
|
15
|
+
REPROVADO = "REPROVADO"
|
|
16
|
+
}
|
|
3
17
|
interface Question {
|
|
4
18
|
id: string;
|
|
5
19
|
questionText: string;
|
|
6
20
|
correctOptionId: string;
|
|
7
21
|
description: string;
|
|
8
|
-
type:
|
|
9
|
-
status:
|
|
10
|
-
difficulty:
|
|
22
|
+
type: QUESTION_TYPE;
|
|
23
|
+
status: QUESTION_STATUS;
|
|
24
|
+
difficulty: QUESTION_DIFFICULTY;
|
|
11
25
|
examBoard: string | null;
|
|
12
26
|
examYear: string | null;
|
|
13
27
|
answerKey: string | null;
|
|
@@ -29,6 +43,7 @@ interface Question {
|
|
|
29
43
|
interface Simulado {
|
|
30
44
|
id: string;
|
|
31
45
|
title: string;
|
|
46
|
+
category: string;
|
|
32
47
|
questions: Question[];
|
|
33
48
|
}
|
|
34
49
|
interface Atividade {
|
|
@@ -41,26 +56,38 @@ interface Aula {
|
|
|
41
56
|
title: string;
|
|
42
57
|
questions: Question[];
|
|
43
58
|
}
|
|
59
|
+
interface UserAnswerItem {
|
|
60
|
+
questionId: string;
|
|
61
|
+
activityId: string;
|
|
62
|
+
userId: string;
|
|
63
|
+
answer: string | null;
|
|
64
|
+
optionId: string | null;
|
|
65
|
+
}
|
|
44
66
|
interface UserAnswer extends Question {
|
|
45
67
|
isSkipped: boolean;
|
|
46
68
|
}
|
|
47
69
|
interface QuizState {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
bySimulated?: Simulado;
|
|
71
|
+
byActivity?: Atividade;
|
|
72
|
+
byQuestionary?: Aula;
|
|
51
73
|
currentQuestionIndex: number;
|
|
52
74
|
selectedAnswers: Record<string, string>;
|
|
53
|
-
|
|
54
|
-
userAnswers: UserAnswer[];
|
|
75
|
+
userAnswers: UserAnswerItem[];
|
|
55
76
|
timeElapsed: number;
|
|
56
77
|
isStarted: boolean;
|
|
57
78
|
isFinished: boolean;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
79
|
+
userId: string;
|
|
80
|
+
setBySimulated: (simulado: Simulado) => void;
|
|
81
|
+
setByActivity: (atividade: Atividade) => void;
|
|
82
|
+
setByQuestionary: (aula: Aula) => void;
|
|
83
|
+
setUserId: (userId: string) => void;
|
|
61
84
|
goToNextQuestion: () => void;
|
|
62
85
|
goToPreviousQuestion: () => void;
|
|
63
86
|
goToQuestion: (index: number) => void;
|
|
87
|
+
getActiveQuiz: () => {
|
|
88
|
+
quiz: Simulado | Atividade | Aula;
|
|
89
|
+
type: 'bySimulated' | 'byActivity' | 'byQuestionary';
|
|
90
|
+
} | null;
|
|
64
91
|
selectAnswer: (questionId: string, answerId: string) => void;
|
|
65
92
|
skipQuestion: () => void;
|
|
66
93
|
addUserAnswer: (questionId: string, answerId?: string) => void;
|
|
@@ -86,6 +113,11 @@ interface QuizState {
|
|
|
86
113
|
getQuestionsGroupedBySubject: () => {
|
|
87
114
|
[key: string]: Question[];
|
|
88
115
|
};
|
|
116
|
+
getUserId: () => string;
|
|
117
|
+
getUserAnswerByQuestionId: (questionId: string) => UserAnswerItem | null;
|
|
118
|
+
isQuestionAnsweredByUserAnswers: (questionId: string) => boolean;
|
|
119
|
+
getQuestionStatusFromUserAnswers: (questionId: string) => 'answered' | 'unanswered' | 'skipped';
|
|
120
|
+
getUserAnswersForActivity: () => UserAnswerItem[];
|
|
89
121
|
}
|
|
90
122
|
declare const useQuizStore: zustand.UseBoundStore<Omit<zustand.StoreApi<QuizState>, "setState" | "devtools"> & {
|
|
91
123
|
setState(partial: QuizState | Partial<QuizState> | ((state: QuizState) => QuizState | Partial<QuizState>), replace?: false | undefined, action?: (string | {
|
|
@@ -105,4 +137,4 @@ declare const useQuizStore: zustand.UseBoundStore<Omit<zustand.StoreApi<QuizStat
|
|
|
105
137
|
};
|
|
106
138
|
}>;
|
|
107
139
|
|
|
108
|
-
export { useQuizStore };
|
|
140
|
+
export { QUESTION_DIFFICULTY, QUESTION_STATUS, QUESTION_TYPE, type Question, useQuizStore };
|
|
@@ -20,16 +20,39 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/components/Quiz/useQuizStore.ts
|
|
21
21
|
var useQuizStore_exports = {};
|
|
22
22
|
__export(useQuizStore_exports, {
|
|
23
|
+
QUESTION_DIFFICULTY: () => QUESTION_DIFFICULTY,
|
|
24
|
+
QUESTION_STATUS: () => QUESTION_STATUS,
|
|
25
|
+
QUESTION_TYPE: () => QUESTION_TYPE,
|
|
23
26
|
useQuizStore: () => useQuizStore
|
|
24
27
|
});
|
|
25
28
|
module.exports = __toCommonJS(useQuizStore_exports);
|
|
26
29
|
var import_zustand = require("zustand");
|
|
27
30
|
var import_middleware = require("zustand/middleware");
|
|
31
|
+
var QUESTION_DIFFICULTY = /* @__PURE__ */ ((QUESTION_DIFFICULTY2) => {
|
|
32
|
+
QUESTION_DIFFICULTY2["FACIL"] = "FACIL";
|
|
33
|
+
QUESTION_DIFFICULTY2["MEDIO"] = "MEDIO";
|
|
34
|
+
QUESTION_DIFFICULTY2["DIFICIL"] = "DIFICIL";
|
|
35
|
+
return QUESTION_DIFFICULTY2;
|
|
36
|
+
})(QUESTION_DIFFICULTY || {});
|
|
37
|
+
var QUESTION_TYPE = /* @__PURE__ */ ((QUESTION_TYPE2) => {
|
|
38
|
+
QUESTION_TYPE2["ALTERNATIVA"] = "ALTERNATIVA";
|
|
39
|
+
QUESTION_TYPE2["DISSERTATIVA"] = "DISSERTATIVA";
|
|
40
|
+
QUESTION_TYPE2["MULTIPLA_CHOICE"] = "MULTIPLA_CHOICE";
|
|
41
|
+
return QUESTION_TYPE2;
|
|
42
|
+
})(QUESTION_TYPE || {});
|
|
43
|
+
var QUESTION_STATUS = /* @__PURE__ */ ((QUESTION_STATUS2) => {
|
|
44
|
+
QUESTION_STATUS2["APROVADO"] = "APROVADO";
|
|
45
|
+
QUESTION_STATUS2["REPROVADO"] = "REPROVADO";
|
|
46
|
+
return QUESTION_STATUS2;
|
|
47
|
+
})(QUESTION_STATUS || {});
|
|
28
48
|
var useQuizStore = (0, import_zustand.create)()(
|
|
29
49
|
(0, import_middleware.devtools)(
|
|
30
50
|
(set, get) => {
|
|
31
51
|
let timerInterval = null;
|
|
32
52
|
const startTimer = () => {
|
|
53
|
+
if (get().isFinished) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
33
56
|
if (timerInterval) {
|
|
34
57
|
clearInterval(timerInterval);
|
|
35
58
|
}
|
|
@@ -48,15 +71,17 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
48
71
|
// Initial State
|
|
49
72
|
currentQuestionIndex: 0,
|
|
50
73
|
selectedAnswers: {},
|
|
51
|
-
skippedQuestions: [],
|
|
52
74
|
userAnswers: [],
|
|
53
75
|
timeElapsed: 0,
|
|
54
76
|
isStarted: false,
|
|
55
77
|
isFinished: false,
|
|
78
|
+
userId: "",
|
|
56
79
|
// Setters
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
80
|
+
setBySimulated: (simulado) => set({ bySimulated: simulado }),
|
|
81
|
+
setByActivity: (atividade) => set({ byActivity: atividade }),
|
|
82
|
+
setByQuestionary: (aula) => set({ byQuestionary: aula }),
|
|
83
|
+
setUserId: (userId) => set({ userId }),
|
|
84
|
+
getUserId: () => get().userId,
|
|
60
85
|
// Navigation
|
|
61
86
|
goToNextQuestion: () => {
|
|
62
87
|
const { currentQuestionIndex, getTotalQuestions } = get();
|
|
@@ -78,58 +103,107 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
78
103
|
set({ currentQuestionIndex: index });
|
|
79
104
|
}
|
|
80
105
|
},
|
|
81
|
-
|
|
106
|
+
getActiveQuiz: () => {
|
|
107
|
+
const { bySimulated, byActivity, byQuestionary } = get();
|
|
108
|
+
if (bySimulated)
|
|
109
|
+
return { quiz: bySimulated, type: "bySimulated" };
|
|
110
|
+
if (byActivity)
|
|
111
|
+
return { quiz: byActivity, type: "byActivity" };
|
|
112
|
+
if (byQuestionary)
|
|
113
|
+
return { quiz: byQuestionary, type: "byQuestionary" };
|
|
114
|
+
return null;
|
|
115
|
+
},
|
|
82
116
|
selectAnswer: (questionId, answerId) => {
|
|
83
|
-
const {
|
|
84
|
-
const
|
|
85
|
-
|
|
117
|
+
const { getActiveQuiz, userAnswers } = get();
|
|
118
|
+
const activeQuiz = getActiveQuiz();
|
|
119
|
+
if (!activeQuiz) return;
|
|
120
|
+
const updatedQuestions = activeQuiz.quiz.questions.map(
|
|
121
|
+
(question) => question.id === questionId ? { ...question, answerKey: answerId } : question
|
|
122
|
+
);
|
|
123
|
+
const updatedQuiz = {
|
|
124
|
+
...activeQuiz.quiz,
|
|
125
|
+
questions: updatedQuestions
|
|
126
|
+
};
|
|
127
|
+
const activityId = activeQuiz.quiz.id;
|
|
128
|
+
const userId = get().getUserId();
|
|
129
|
+
if (!userId) {
|
|
130
|
+
console.warn("selectAnswer called before userId is set");
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const existingAnswerIndex = userAnswers.findIndex(
|
|
134
|
+
(answer) => answer.questionId === questionId
|
|
86
135
|
);
|
|
136
|
+
const newUserAnswer = {
|
|
137
|
+
questionId,
|
|
138
|
+
activityId,
|
|
139
|
+
userId,
|
|
140
|
+
answer: answerId,
|
|
141
|
+
optionId: answerId
|
|
142
|
+
};
|
|
143
|
+
let updatedUserAnswers;
|
|
144
|
+
if (existingAnswerIndex !== -1) {
|
|
145
|
+
updatedUserAnswers = [...userAnswers];
|
|
146
|
+
updatedUserAnswers[existingAnswerIndex] = newUserAnswer;
|
|
147
|
+
} else {
|
|
148
|
+
updatedUserAnswers = [...userAnswers, newUserAnswer];
|
|
149
|
+
}
|
|
87
150
|
set({
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
[questionId]: answerId
|
|
91
|
-
},
|
|
92
|
-
skippedQuestions: newSkippedQuestions
|
|
151
|
+
[activeQuiz.type]: updatedQuiz,
|
|
152
|
+
userAnswers: updatedUserAnswers
|
|
93
153
|
});
|
|
94
|
-
addUserAnswer(questionId, answerId);
|
|
95
154
|
},
|
|
96
155
|
skipQuestion: () => {
|
|
97
|
-
const { getCurrentQuestion,
|
|
156
|
+
const { getCurrentQuestion, userAnswers, getActiveQuiz } = get();
|
|
98
157
|
const currentQuestion = getCurrentQuestion();
|
|
158
|
+
const activeQuiz = getActiveQuiz();
|
|
159
|
+
if (!activeQuiz) return;
|
|
99
160
|
if (currentQuestion) {
|
|
161
|
+
const activityId = activeQuiz.quiz.id;
|
|
162
|
+
const userId = get().getUserId();
|
|
163
|
+
const existingAnswerIndex = userAnswers.findIndex(
|
|
164
|
+
(answer) => answer.questionId === currentQuestion.id
|
|
165
|
+
);
|
|
166
|
+
const newUserAnswer = {
|
|
167
|
+
questionId: currentQuestion.id,
|
|
168
|
+
activityId,
|
|
169
|
+
userId,
|
|
170
|
+
answer: null,
|
|
171
|
+
optionId: null
|
|
172
|
+
};
|
|
173
|
+
let updatedUserAnswers;
|
|
174
|
+
if (existingAnswerIndex !== -1) {
|
|
175
|
+
updatedUserAnswers = [...userAnswers];
|
|
176
|
+
updatedUserAnswers[existingAnswerIndex] = newUserAnswer;
|
|
177
|
+
} else {
|
|
178
|
+
updatedUserAnswers = [...userAnswers, newUserAnswer];
|
|
179
|
+
}
|
|
100
180
|
set({
|
|
101
|
-
|
|
181
|
+
userAnswers: updatedUserAnswers
|
|
102
182
|
});
|
|
103
|
-
addUserAnswer(currentQuestion.id);
|
|
104
183
|
}
|
|
105
184
|
},
|
|
106
185
|
addUserAnswer: (questionId, answerId) => {
|
|
107
|
-
const {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
186
|
+
const { getActiveQuiz, userAnswers } = get();
|
|
187
|
+
const activeQuiz = getActiveQuiz();
|
|
188
|
+
if (!activeQuiz) return;
|
|
189
|
+
const activityId = activeQuiz.quiz.id;
|
|
190
|
+
const userId = get().getUserId();
|
|
111
191
|
const existingAnswerIndex = userAnswers.findIndex(
|
|
112
|
-
(answer) => answer.
|
|
192
|
+
(answer) => answer.questionId === questionId
|
|
113
193
|
);
|
|
194
|
+
const newUserAnswer = {
|
|
195
|
+
questionId,
|
|
196
|
+
activityId,
|
|
197
|
+
userId,
|
|
198
|
+
answer: answerId || null,
|
|
199
|
+
optionId: answerId || null
|
|
200
|
+
};
|
|
114
201
|
if (existingAnswerIndex !== -1) {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
answerKey: answerId || "",
|
|
119
|
-
isSkipped: !answerId
|
|
120
|
-
};
|
|
121
|
-
set({ userAnswers: updatedAnswers });
|
|
202
|
+
const updatedUserAnswers = [...userAnswers];
|
|
203
|
+
updatedUserAnswers[existingAnswerIndex] = newUserAnswer;
|
|
204
|
+
set({ userAnswers: updatedUserAnswers });
|
|
122
205
|
} else {
|
|
123
|
-
set({
|
|
124
|
-
userAnswers: [
|
|
125
|
-
...userAnswers,
|
|
126
|
-
{
|
|
127
|
-
...question,
|
|
128
|
-
answerKey: answerId || "",
|
|
129
|
-
isSkipped: !answerId
|
|
130
|
-
}
|
|
131
|
-
]
|
|
132
|
-
});
|
|
206
|
+
set({ userAnswers: [...userAnswers, newUserAnswer] });
|
|
133
207
|
}
|
|
134
208
|
},
|
|
135
209
|
startQuiz: () => {
|
|
@@ -145,11 +219,11 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
145
219
|
set({
|
|
146
220
|
currentQuestionIndex: 0,
|
|
147
221
|
selectedAnswers: {},
|
|
148
|
-
skippedQuestions: [],
|
|
149
222
|
userAnswers: [],
|
|
150
223
|
timeElapsed: 0,
|
|
151
224
|
isStarted: false,
|
|
152
|
-
isFinished: false
|
|
225
|
+
isFinished: false,
|
|
226
|
+
userId: ""
|
|
153
227
|
});
|
|
154
228
|
},
|
|
155
229
|
// Timer
|
|
@@ -158,36 +232,33 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
158
232
|
stopTimer,
|
|
159
233
|
// Getters
|
|
160
234
|
getCurrentQuestion: () => {
|
|
161
|
-
const {
|
|
162
|
-
const
|
|
163
|
-
if (!
|
|
235
|
+
const { currentQuestionIndex, getActiveQuiz } = get();
|
|
236
|
+
const activeQuiz = getActiveQuiz();
|
|
237
|
+
if (!activeQuiz) {
|
|
164
238
|
return null;
|
|
165
239
|
}
|
|
166
|
-
return quiz.questions[currentQuestionIndex];
|
|
240
|
+
return activeQuiz.quiz.questions[currentQuestionIndex];
|
|
167
241
|
},
|
|
168
242
|
getTotalQuestions: () => {
|
|
169
|
-
const {
|
|
170
|
-
const
|
|
171
|
-
return quiz?.questions?.length || 0;
|
|
243
|
+
const { getActiveQuiz } = get();
|
|
244
|
+
const activeQuiz = getActiveQuiz();
|
|
245
|
+
return activeQuiz?.quiz?.questions?.length || 0;
|
|
172
246
|
},
|
|
173
247
|
getAnsweredQuestions: () => {
|
|
174
|
-
const {
|
|
175
|
-
return
|
|
248
|
+
const { userAnswers } = get();
|
|
249
|
+
return userAnswers.filter((answer) => answer.answer !== null).length;
|
|
176
250
|
},
|
|
177
251
|
getUnansweredQuestions: () => {
|
|
178
|
-
const {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
byAula,
|
|
182
|
-
selectedAnswers,
|
|
183
|
-
skippedQuestions
|
|
184
|
-
} = get();
|
|
185
|
-
const quiz = bySimulado || byAtividade || byAula;
|
|
186
|
-
if (!quiz) return [];
|
|
252
|
+
const { getActiveQuiz, userAnswers } = get();
|
|
253
|
+
const activeQuiz = getActiveQuiz();
|
|
254
|
+
if (!activeQuiz) return [];
|
|
187
255
|
const unansweredQuestions = [];
|
|
188
|
-
quiz.questions.forEach((question, index) => {
|
|
189
|
-
const
|
|
190
|
-
|
|
256
|
+
activeQuiz.quiz.questions.forEach((question, index) => {
|
|
257
|
+
const userAnswer = userAnswers.find(
|
|
258
|
+
(answer) => answer.questionId === question.id
|
|
259
|
+
);
|
|
260
|
+
const isAnswered = userAnswer && userAnswer.answer !== null;
|
|
261
|
+
const isSkipped = userAnswer && userAnswer.answer === null;
|
|
191
262
|
if (!isAnswered && !isSkipped) {
|
|
192
263
|
unansweredQuestions.push(index + 1);
|
|
193
264
|
}
|
|
@@ -195,8 +266,8 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
195
266
|
return unansweredQuestions;
|
|
196
267
|
},
|
|
197
268
|
getSkippedQuestions: () => {
|
|
198
|
-
const {
|
|
199
|
-
return
|
|
269
|
+
const { userAnswers } = get();
|
|
270
|
+
return userAnswers.filter((answer) => answer.answer === null).length;
|
|
200
271
|
},
|
|
201
272
|
getProgress: () => {
|
|
202
273
|
const { getTotalQuestions, getAnsweredQuestions } = get();
|
|
@@ -205,22 +276,32 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
205
276
|
return total > 0 ? answered / total * 100 : 0;
|
|
206
277
|
},
|
|
207
278
|
isQuestionAnswered: (questionId) => {
|
|
208
|
-
const {
|
|
209
|
-
|
|
279
|
+
const { userAnswers } = get();
|
|
280
|
+
const userAnswer = userAnswers.find(
|
|
281
|
+
(answer) => answer.questionId === questionId
|
|
282
|
+
);
|
|
283
|
+
return userAnswer ? userAnswer.answer !== null : false;
|
|
210
284
|
},
|
|
211
285
|
isQuestionSkipped: (questionId) => {
|
|
212
|
-
const {
|
|
213
|
-
|
|
286
|
+
const { userAnswers } = get();
|
|
287
|
+
const userAnswer = userAnswers.find(
|
|
288
|
+
(answer) => answer.questionId === questionId
|
|
289
|
+
);
|
|
290
|
+
return userAnswer ? userAnswer.answer === null : false;
|
|
214
291
|
},
|
|
215
292
|
getCurrentAnswer: () => {
|
|
216
|
-
const { getCurrentQuestion,
|
|
293
|
+
const { getCurrentQuestion, userAnswers } = get();
|
|
217
294
|
const currentQuestion = getCurrentQuestion();
|
|
218
|
-
|
|
295
|
+
if (!currentQuestion) return void 0;
|
|
296
|
+
const userAnswer = userAnswers.find(
|
|
297
|
+
(answer) => answer.questionId === currentQuestion.id
|
|
298
|
+
);
|
|
299
|
+
return userAnswer?.answer;
|
|
219
300
|
},
|
|
220
301
|
getQuizTitle: () => {
|
|
221
|
-
const {
|
|
222
|
-
const
|
|
223
|
-
return quiz?.title || "Quiz";
|
|
302
|
+
const { getActiveQuiz } = get();
|
|
303
|
+
const activeQuiz = getActiveQuiz();
|
|
304
|
+
return activeQuiz?.quiz?.title || "Quiz";
|
|
224
305
|
},
|
|
225
306
|
formatTime: (seconds) => {
|
|
226
307
|
const minutes = Math.floor(seconds / 60);
|
|
@@ -228,30 +309,42 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
228
309
|
return `${minutes.toString().padStart(2, "0")}:${remainingSeconds.toString().padStart(2, "0")}`;
|
|
229
310
|
},
|
|
230
311
|
getUserAnswers: () => {
|
|
231
|
-
const { userAnswers } = get();
|
|
232
|
-
|
|
312
|
+
const { getActiveQuiz, userAnswers } = get();
|
|
313
|
+
const activeQuiz = getActiveQuiz();
|
|
314
|
+
if (!activeQuiz) return [];
|
|
315
|
+
return activeQuiz.quiz.questions.map((question) => {
|
|
316
|
+
const userAnswer = userAnswers.find(
|
|
317
|
+
(answer) => answer.questionId === question.id
|
|
318
|
+
);
|
|
319
|
+
return {
|
|
320
|
+
...question,
|
|
321
|
+
isSkipped: userAnswer ? userAnswer.answer === null : false
|
|
322
|
+
};
|
|
323
|
+
});
|
|
233
324
|
},
|
|
234
325
|
getUnansweredQuestionsFromUserAnswers: () => {
|
|
235
|
-
const {
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
326
|
+
const { getActiveQuiz, userAnswers } = get();
|
|
327
|
+
const activeQuiz = getActiveQuiz();
|
|
328
|
+
if (!activeQuiz) return [];
|
|
238
329
|
const unansweredQuestions = [];
|
|
239
|
-
quiz.questions.forEach((question, index) => {
|
|
330
|
+
activeQuiz.quiz.questions.forEach((question, index) => {
|
|
240
331
|
const userAnswer = userAnswers.find(
|
|
241
|
-
(answer) => answer.
|
|
332
|
+
(answer) => answer.questionId === question.id
|
|
242
333
|
);
|
|
243
|
-
|
|
334
|
+
const hasAnswer = userAnswer && userAnswer.answer !== null;
|
|
335
|
+
const isSkipped = userAnswer && userAnswer.answer === null;
|
|
336
|
+
if (!hasAnswer || isSkipped) {
|
|
244
337
|
unansweredQuestions.push(index + 1);
|
|
245
338
|
}
|
|
246
339
|
});
|
|
247
340
|
return unansweredQuestions;
|
|
248
341
|
},
|
|
249
342
|
getQuestionsGroupedBySubject: () => {
|
|
250
|
-
const {
|
|
251
|
-
const
|
|
252
|
-
if (!
|
|
343
|
+
const { getActiveQuiz } = get();
|
|
344
|
+
const activeQuiz = getActiveQuiz();
|
|
345
|
+
if (!activeQuiz) return {};
|
|
253
346
|
const groupedQuestions = {};
|
|
254
|
-
quiz.questions.forEach((question) => {
|
|
347
|
+
activeQuiz.quiz.questions.forEach((question) => {
|
|
255
348
|
const subjectId = question.knowledgeMatrix?.[0]?.subjectId || "Sem mat\xE9ria";
|
|
256
349
|
if (!groupedQuestions[subjectId]) {
|
|
257
350
|
groupedQuestions[subjectId] = [];
|
|
@@ -259,6 +352,31 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
259
352
|
groupedQuestions[subjectId].push(question);
|
|
260
353
|
});
|
|
261
354
|
return groupedQuestions;
|
|
355
|
+
},
|
|
356
|
+
// New methods for userAnswers
|
|
357
|
+
getUserAnswerByQuestionId: (questionId) => {
|
|
358
|
+
const { userAnswers } = get();
|
|
359
|
+
return userAnswers.find((answer) => answer.questionId === questionId) || null;
|
|
360
|
+
},
|
|
361
|
+
isQuestionAnsweredByUserAnswers: (questionId) => {
|
|
362
|
+
const { userAnswers } = get();
|
|
363
|
+
const answer = userAnswers.find(
|
|
364
|
+
(answer2) => answer2.questionId === questionId
|
|
365
|
+
);
|
|
366
|
+
return answer ? answer.answer !== null : false;
|
|
367
|
+
},
|
|
368
|
+
getQuestionStatusFromUserAnswers: (questionId) => {
|
|
369
|
+
const { userAnswers } = get();
|
|
370
|
+
const answer = userAnswers.find(
|
|
371
|
+
(answer2) => answer2.questionId === questionId
|
|
372
|
+
);
|
|
373
|
+
if (!answer) return "unanswered";
|
|
374
|
+
if (answer.answer === null) return "skipped";
|
|
375
|
+
return "answered";
|
|
376
|
+
},
|
|
377
|
+
getUserAnswersForActivity: () => {
|
|
378
|
+
const { userAnswers } = get();
|
|
379
|
+
return userAnswers;
|
|
262
380
|
}
|
|
263
381
|
};
|
|
264
382
|
},
|
|
@@ -269,6 +387,9 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
269
387
|
);
|
|
270
388
|
// Annotate the CommonJS export names for ESM import in node:
|
|
271
389
|
0 && (module.exports = {
|
|
390
|
+
QUESTION_DIFFICULTY,
|
|
391
|
+
QUESTION_STATUS,
|
|
392
|
+
QUESTION_TYPE,
|
|
272
393
|
useQuizStore
|
|
273
394
|
});
|
|
274
395
|
//# sourceMappingURL=index.js.map
|