analytica-frontend-lib 1.1.63 → 1.1.64
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/Quiz/index.d.mts +26 -40
- package/dist/Quiz/index.d.ts +26 -40
- package/dist/Quiz/index.js +3411 -3790
- package/dist/Quiz/index.js.map +1 -1
- package/dist/Quiz/index.mjs +3425 -3792
- package/dist/Quiz/index.mjs.map +1 -1
- package/dist/Quiz/useQuizStore/index.d.mts +10 -25
- package/dist/Quiz/useQuizStore/index.d.ts +10 -25
- package/dist/Quiz/useQuizStore/index.js +52 -77
- package/dist/Quiz/useQuizStore/index.js.map +1 -1
- package/dist/Quiz/useQuizStore/index.mjs +51 -77
- package/dist/Quiz/useQuizStore/index.mjs.map +1 -1
- package/dist/index.d.mts +35 -4
- package/dist/index.d.ts +35 -4
- package/dist/index.js +585 -440
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +586 -440
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,11 @@ declare enum QUESTION_DIFFICULTY {
|
|
|
5
5
|
MEDIO = "MEDIO",
|
|
6
6
|
DIFICIL = "DIFICIL"
|
|
7
7
|
}
|
|
8
|
+
declare enum QUIZ_TYPE {
|
|
9
|
+
SIMULADO = "SIMULADO",
|
|
10
|
+
QUESTIONARIO = "QUESTIONARIO",
|
|
11
|
+
ATIVIDADE = "ATIVIDADE"
|
|
12
|
+
}
|
|
8
13
|
declare enum QUESTION_TYPE {
|
|
9
14
|
ALTERNATIVA = "ALTERNATIVA",
|
|
10
15
|
DISSERTATIVA = "DISSERTATIVA",
|
|
@@ -135,10 +140,10 @@ interface Question {
|
|
|
135
140
|
}[];
|
|
136
141
|
correctOptionIds?: string[];
|
|
137
142
|
}
|
|
138
|
-
interface
|
|
143
|
+
interface QuizInterface {
|
|
139
144
|
id: string;
|
|
140
145
|
title: string;
|
|
141
|
-
type:
|
|
146
|
+
type: QUIZ_TYPE;
|
|
142
147
|
subtype: SUBTYPE_ENUM | string;
|
|
143
148
|
difficulty: string | null;
|
|
144
149
|
notification: string | null;
|
|
@@ -150,18 +155,6 @@ interface Simulated {
|
|
|
150
155
|
updatedAt: string | null;
|
|
151
156
|
questions: Question[];
|
|
152
157
|
}
|
|
153
|
-
interface Activity {
|
|
154
|
-
id: string;
|
|
155
|
-
title: string;
|
|
156
|
-
subtype: string;
|
|
157
|
-
questions: Question[];
|
|
158
|
-
}
|
|
159
|
-
interface Lesson {
|
|
160
|
-
id: string;
|
|
161
|
-
title: string;
|
|
162
|
-
subtype: string;
|
|
163
|
-
questions: Question[];
|
|
164
|
-
}
|
|
165
158
|
interface UserAnswerItem {
|
|
166
159
|
questionId: string;
|
|
167
160
|
activityId: string;
|
|
@@ -172,9 +165,7 @@ interface UserAnswerItem {
|
|
|
172
165
|
answerStatus: ANSWER_STATUS;
|
|
173
166
|
}
|
|
174
167
|
interface QuizState {
|
|
175
|
-
|
|
176
|
-
byActivity?: Activity;
|
|
177
|
-
byQuestionary?: Lesson;
|
|
168
|
+
quiz: QuizInterface | null;
|
|
178
169
|
currentQuestionIndex: number;
|
|
179
170
|
selectedAnswers: Record<string, string>;
|
|
180
171
|
userAnswers: UserAnswerItem[];
|
|
@@ -184,9 +175,7 @@ interface QuizState {
|
|
|
184
175
|
userId: string;
|
|
185
176
|
variant: 'result' | 'default';
|
|
186
177
|
minuteCallback: (() => void) | null;
|
|
187
|
-
|
|
188
|
-
setByActivity: (activity: Activity) => void;
|
|
189
|
-
setByQuestionary: (lesson: Lesson) => void;
|
|
178
|
+
setQuiz: (quiz: QuizInterface) => void;
|
|
190
179
|
setQuestionResult: (questionResult: QuestionResult) => void;
|
|
191
180
|
setUserId: (userId: string) => void;
|
|
192
181
|
setUserAnswers: (userAnswers: UserAnswerItem[]) => void;
|
|
@@ -194,10 +183,6 @@ interface QuizState {
|
|
|
194
183
|
goToNextQuestion: () => void;
|
|
195
184
|
goToPreviousQuestion: () => void;
|
|
196
185
|
goToQuestion: (index: number) => void;
|
|
197
|
-
getActiveQuiz: () => {
|
|
198
|
-
quiz: Simulated | Activity | Lesson;
|
|
199
|
-
type: 'bySimulated' | 'byActivity' | 'byQuestionary';
|
|
200
|
-
} | null;
|
|
201
186
|
selectAnswer: (questionId: string, answerId: string) => void;
|
|
202
187
|
selectMultipleAnswer: (questionId: string, answerIds: string[]) => void;
|
|
203
188
|
selectDissertativeAnswer: (questionId: string, answer: string) => void;
|
|
@@ -266,4 +251,4 @@ declare const useQuizStore: zustand.UseBoundStore<Omit<zustand.StoreApi<QuizStat
|
|
|
266
251
|
};
|
|
267
252
|
}>;
|
|
268
253
|
|
|
269
|
-
export { ANSWER_STATUS,
|
|
254
|
+
export { ANSWER_STATUS, MINUTE_INTERVAL_MS, QUESTION_DIFFICULTY, QUESTION_STATUS, QUESTION_TYPE, QUIZ_TYPE, type Question, type QuestionResult, type QuizInterface, type QuizState, SUBTYPE_ENUM, type UserAnswerItem, useQuizStore };
|
|
@@ -5,6 +5,11 @@ declare enum QUESTION_DIFFICULTY {
|
|
|
5
5
|
MEDIO = "MEDIO",
|
|
6
6
|
DIFICIL = "DIFICIL"
|
|
7
7
|
}
|
|
8
|
+
declare enum QUIZ_TYPE {
|
|
9
|
+
SIMULADO = "SIMULADO",
|
|
10
|
+
QUESTIONARIO = "QUESTIONARIO",
|
|
11
|
+
ATIVIDADE = "ATIVIDADE"
|
|
12
|
+
}
|
|
8
13
|
declare enum QUESTION_TYPE {
|
|
9
14
|
ALTERNATIVA = "ALTERNATIVA",
|
|
10
15
|
DISSERTATIVA = "DISSERTATIVA",
|
|
@@ -135,10 +140,10 @@ interface Question {
|
|
|
135
140
|
}[];
|
|
136
141
|
correctOptionIds?: string[];
|
|
137
142
|
}
|
|
138
|
-
interface
|
|
143
|
+
interface QuizInterface {
|
|
139
144
|
id: string;
|
|
140
145
|
title: string;
|
|
141
|
-
type:
|
|
146
|
+
type: QUIZ_TYPE;
|
|
142
147
|
subtype: SUBTYPE_ENUM | string;
|
|
143
148
|
difficulty: string | null;
|
|
144
149
|
notification: string | null;
|
|
@@ -150,18 +155,6 @@ interface Simulated {
|
|
|
150
155
|
updatedAt: string | null;
|
|
151
156
|
questions: Question[];
|
|
152
157
|
}
|
|
153
|
-
interface Activity {
|
|
154
|
-
id: string;
|
|
155
|
-
title: string;
|
|
156
|
-
subtype: string;
|
|
157
|
-
questions: Question[];
|
|
158
|
-
}
|
|
159
|
-
interface Lesson {
|
|
160
|
-
id: string;
|
|
161
|
-
title: string;
|
|
162
|
-
subtype: string;
|
|
163
|
-
questions: Question[];
|
|
164
|
-
}
|
|
165
158
|
interface UserAnswerItem {
|
|
166
159
|
questionId: string;
|
|
167
160
|
activityId: string;
|
|
@@ -172,9 +165,7 @@ interface UserAnswerItem {
|
|
|
172
165
|
answerStatus: ANSWER_STATUS;
|
|
173
166
|
}
|
|
174
167
|
interface QuizState {
|
|
175
|
-
|
|
176
|
-
byActivity?: Activity;
|
|
177
|
-
byQuestionary?: Lesson;
|
|
168
|
+
quiz: QuizInterface | null;
|
|
178
169
|
currentQuestionIndex: number;
|
|
179
170
|
selectedAnswers: Record<string, string>;
|
|
180
171
|
userAnswers: UserAnswerItem[];
|
|
@@ -184,9 +175,7 @@ interface QuizState {
|
|
|
184
175
|
userId: string;
|
|
185
176
|
variant: 'result' | 'default';
|
|
186
177
|
minuteCallback: (() => void) | null;
|
|
187
|
-
|
|
188
|
-
setByActivity: (activity: Activity) => void;
|
|
189
|
-
setByQuestionary: (lesson: Lesson) => void;
|
|
178
|
+
setQuiz: (quiz: QuizInterface) => void;
|
|
190
179
|
setQuestionResult: (questionResult: QuestionResult) => void;
|
|
191
180
|
setUserId: (userId: string) => void;
|
|
192
181
|
setUserAnswers: (userAnswers: UserAnswerItem[]) => void;
|
|
@@ -194,10 +183,6 @@ interface QuizState {
|
|
|
194
183
|
goToNextQuestion: () => void;
|
|
195
184
|
goToPreviousQuestion: () => void;
|
|
196
185
|
goToQuestion: (index: number) => void;
|
|
197
|
-
getActiveQuiz: () => {
|
|
198
|
-
quiz: Simulated | Activity | Lesson;
|
|
199
|
-
type: 'bySimulated' | 'byActivity' | 'byQuestionary';
|
|
200
|
-
} | null;
|
|
201
186
|
selectAnswer: (questionId: string, answerId: string) => void;
|
|
202
187
|
selectMultipleAnswer: (questionId: string, answerIds: string[]) => void;
|
|
203
188
|
selectDissertativeAnswer: (questionId: string, answer: string) => void;
|
|
@@ -266,4 +251,4 @@ declare const useQuizStore: zustand.UseBoundStore<Omit<zustand.StoreApi<QuizStat
|
|
|
266
251
|
};
|
|
267
252
|
}>;
|
|
268
253
|
|
|
269
|
-
export { ANSWER_STATUS,
|
|
254
|
+
export { ANSWER_STATUS, MINUTE_INTERVAL_MS, QUESTION_DIFFICULTY, QUESTION_STATUS, QUESTION_TYPE, QUIZ_TYPE, type Question, type QuestionResult, type QuizInterface, type QuizState, SUBTYPE_ENUM, type UserAnswerItem, useQuizStore };
|
|
@@ -25,6 +25,7 @@ __export(useQuizStore_exports, {
|
|
|
25
25
|
QUESTION_DIFFICULTY: () => QUESTION_DIFFICULTY,
|
|
26
26
|
QUESTION_STATUS: () => QUESTION_STATUS,
|
|
27
27
|
QUESTION_TYPE: () => QUESTION_TYPE,
|
|
28
|
+
QUIZ_TYPE: () => QUIZ_TYPE,
|
|
28
29
|
SUBTYPE_ENUM: () => SUBTYPE_ENUM,
|
|
29
30
|
useQuizStore: () => useQuizStore
|
|
30
31
|
});
|
|
@@ -37,6 +38,12 @@ var QUESTION_DIFFICULTY = /* @__PURE__ */ ((QUESTION_DIFFICULTY2) => {
|
|
|
37
38
|
QUESTION_DIFFICULTY2["DIFICIL"] = "DIFICIL";
|
|
38
39
|
return QUESTION_DIFFICULTY2;
|
|
39
40
|
})(QUESTION_DIFFICULTY || {});
|
|
41
|
+
var QUIZ_TYPE = /* @__PURE__ */ ((QUIZ_TYPE2) => {
|
|
42
|
+
QUIZ_TYPE2["SIMULADO"] = "SIMULADO";
|
|
43
|
+
QUIZ_TYPE2["QUESTIONARIO"] = "QUESTIONARIO";
|
|
44
|
+
QUIZ_TYPE2["ATIVIDADE"] = "ATIVIDADE";
|
|
45
|
+
return QUIZ_TYPE2;
|
|
46
|
+
})(QUIZ_TYPE || {});
|
|
40
47
|
var QUESTION_TYPE = /* @__PURE__ */ ((QUESTION_TYPE2) => {
|
|
41
48
|
QUESTION_TYPE2["ALTERNATIVA"] = "ALTERNATIVA";
|
|
42
49
|
QUESTION_TYPE2["DISSERTATIVA"] = "DISSERTATIVA";
|
|
@@ -125,6 +132,7 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
125
132
|
};
|
|
126
133
|
return {
|
|
127
134
|
// Initial State
|
|
135
|
+
quiz: null,
|
|
128
136
|
currentQuestionIndex: 0,
|
|
129
137
|
selectedAnswers: {},
|
|
130
138
|
userAnswers: [],
|
|
@@ -137,9 +145,7 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
137
145
|
questionsResult: null,
|
|
138
146
|
currentQuestionResult: null,
|
|
139
147
|
// Setters
|
|
140
|
-
|
|
141
|
-
setByActivity: (activity) => set({ byActivity: activity }),
|
|
142
|
-
setByQuestionary: (lesson) => set({ byQuestionary: lesson }),
|
|
148
|
+
setQuiz: (quiz) => set({ quiz }),
|
|
143
149
|
setUserId: (userId) => set({ userId }),
|
|
144
150
|
setUserAnswers: (userAnswers) => set({ userAnswers }),
|
|
145
151
|
getUserId: () => get().userId,
|
|
@@ -166,29 +172,16 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
166
172
|
set({ currentQuestionIndex: index });
|
|
167
173
|
}
|
|
168
174
|
},
|
|
169
|
-
getActiveQuiz: () => {
|
|
170
|
-
const { bySimulated, byActivity, byQuestionary } = get();
|
|
171
|
-
if (bySimulated)
|
|
172
|
-
return { quiz: bySimulated, type: "bySimulated" };
|
|
173
|
-
if (byActivity)
|
|
174
|
-
return { quiz: byActivity, type: "byActivity" };
|
|
175
|
-
if (byQuestionary)
|
|
176
|
-
return { quiz: byQuestionary, type: "byQuestionary" };
|
|
177
|
-
return null;
|
|
178
|
-
},
|
|
179
175
|
selectAnswer: (questionId, answerId) => {
|
|
180
|
-
const {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const activityId = activeQuiz.quiz.id;
|
|
176
|
+
const { quiz, userAnswers } = get();
|
|
177
|
+
if (!quiz) return;
|
|
178
|
+
const activityId = quiz.id;
|
|
184
179
|
const userId = get().getUserId();
|
|
185
180
|
if (!userId || userId === "") {
|
|
186
181
|
console.warn("selectAnswer called before userId is set");
|
|
187
182
|
return;
|
|
188
183
|
}
|
|
189
|
-
const question =
|
|
190
|
-
(q) => q.id === questionId
|
|
191
|
-
);
|
|
184
|
+
const question = quiz.questions.find((q) => q.id === questionId);
|
|
192
185
|
if (!question) return;
|
|
193
186
|
const existingAnswerIndex = userAnswers.findIndex(
|
|
194
187
|
(answer) => answer.questionId === questionId
|
|
@@ -214,18 +207,15 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
214
207
|
});
|
|
215
208
|
},
|
|
216
209
|
selectMultipleAnswer: (questionId, answerIds) => {
|
|
217
|
-
const {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const activityId = activeQuiz.quiz.id;
|
|
210
|
+
const { quiz, userAnswers } = get();
|
|
211
|
+
if (!quiz) return;
|
|
212
|
+
const activityId = quiz.id;
|
|
221
213
|
const userId = get().getUserId();
|
|
222
214
|
if (!userId || userId === "") {
|
|
223
215
|
console.warn("selectMultipleAnswer called before userId is set");
|
|
224
216
|
return;
|
|
225
217
|
}
|
|
226
|
-
const question =
|
|
227
|
-
(q) => q.id === questionId
|
|
228
|
-
);
|
|
218
|
+
const question = quiz.questions.find((q) => q.id === questionId);
|
|
229
219
|
if (!question) return;
|
|
230
220
|
const filteredUserAnswers = userAnswers.filter(
|
|
231
221
|
(answer) => answer.questionId !== questionId
|
|
@@ -252,10 +242,9 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
252
242
|
});
|
|
253
243
|
},
|
|
254
244
|
selectDissertativeAnswer: (questionId, answer) => {
|
|
255
|
-
const {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const activityId = activeQuiz.quiz.id;
|
|
245
|
+
const { quiz, userAnswers } = get();
|
|
246
|
+
if (!quiz) return;
|
|
247
|
+
const activityId = quiz.id;
|
|
259
248
|
const userId = get().getUserId();
|
|
260
249
|
if (!userId || userId === "") {
|
|
261
250
|
console.warn(
|
|
@@ -263,9 +252,7 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
263
252
|
);
|
|
264
253
|
return;
|
|
265
254
|
}
|
|
266
|
-
const question =
|
|
267
|
-
(q) => q.id === questionId
|
|
268
|
-
);
|
|
255
|
+
const question = quiz.questions.find((q) => q.id === questionId);
|
|
269
256
|
if (!question || question.questionType !== "DISSERTATIVA" /* DISSERTATIVA */) {
|
|
270
257
|
console.warn(
|
|
271
258
|
"selectDissertativeAnswer called for non-dissertative question"
|
|
@@ -296,12 +283,11 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
296
283
|
});
|
|
297
284
|
},
|
|
298
285
|
skipQuestion: () => {
|
|
299
|
-
const { getCurrentQuestion, userAnswers,
|
|
286
|
+
const { getCurrentQuestion, userAnswers, quiz } = get();
|
|
300
287
|
const currentQuestion = getCurrentQuestion();
|
|
301
|
-
|
|
302
|
-
if (!activeQuiz) return;
|
|
288
|
+
if (!quiz) return;
|
|
303
289
|
if (currentQuestion) {
|
|
304
|
-
const activityId =
|
|
290
|
+
const activityId = quiz.id;
|
|
305
291
|
const userId = get().getUserId();
|
|
306
292
|
if (!userId || userId === "") {
|
|
307
293
|
console.warn("skipQuestion called before userId is set");
|
|
@@ -332,18 +318,15 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
332
318
|
}
|
|
333
319
|
},
|
|
334
320
|
addUserAnswer: (questionId, answerId) => {
|
|
335
|
-
const {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
const activityId = activeQuiz.quiz.id;
|
|
321
|
+
const { quiz, userAnswers } = get();
|
|
322
|
+
if (!quiz) return;
|
|
323
|
+
const activityId = quiz.id;
|
|
339
324
|
const userId = get().getUserId();
|
|
340
325
|
if (!userId || userId === "") {
|
|
341
326
|
console.warn("addUserAnswer called before userId is set");
|
|
342
327
|
return;
|
|
343
328
|
}
|
|
344
|
-
const question =
|
|
345
|
-
(q) => q.id === questionId
|
|
346
|
-
);
|
|
329
|
+
const question = quiz.questions.find((q) => q.id === questionId);
|
|
347
330
|
if (!question) return;
|
|
348
331
|
const existingAnswerIndex = userAnswers.findIndex(
|
|
349
332
|
(answer) => answer.questionId === questionId
|
|
@@ -379,6 +362,7 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
379
362
|
stopTimer();
|
|
380
363
|
stopMinuteCallback();
|
|
381
364
|
set({
|
|
365
|
+
quiz: null,
|
|
382
366
|
currentQuestionIndex: 0,
|
|
383
367
|
selectedAnswers: {},
|
|
384
368
|
userAnswers: [],
|
|
@@ -402,17 +386,15 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
402
386
|
stopMinuteCallback,
|
|
403
387
|
// Getters
|
|
404
388
|
getCurrentQuestion: () => {
|
|
405
|
-
const { currentQuestionIndex,
|
|
406
|
-
|
|
407
|
-
if (!activeQuiz) {
|
|
389
|
+
const { currentQuestionIndex, quiz } = get();
|
|
390
|
+
if (!quiz) {
|
|
408
391
|
return null;
|
|
409
392
|
}
|
|
410
|
-
return
|
|
393
|
+
return quiz.questions[currentQuestionIndex];
|
|
411
394
|
},
|
|
412
395
|
getTotalQuestions: () => {
|
|
413
|
-
const {
|
|
414
|
-
|
|
415
|
-
return activeQuiz?.quiz?.questions?.length || 0;
|
|
396
|
+
const { quiz } = get();
|
|
397
|
+
return quiz?.questions?.length || 0;
|
|
416
398
|
},
|
|
417
399
|
getAnsweredQuestions: () => {
|
|
418
400
|
const { userAnswers } = get();
|
|
@@ -421,11 +403,10 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
421
403
|
).length;
|
|
422
404
|
},
|
|
423
405
|
getUnansweredQuestions: () => {
|
|
424
|
-
const {
|
|
425
|
-
|
|
426
|
-
if (!activeQuiz) return [];
|
|
406
|
+
const { quiz, userAnswers } = get();
|
|
407
|
+
if (!quiz) return [];
|
|
427
408
|
const unansweredQuestions = [];
|
|
428
|
-
|
|
409
|
+
quiz.questions.forEach((question, index) => {
|
|
429
410
|
const userAnswer = userAnswers.find(
|
|
430
411
|
(answer) => answer.questionId === question.id
|
|
431
412
|
);
|
|
@@ -486,9 +467,8 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
486
467
|
return userAnswer;
|
|
487
468
|
},
|
|
488
469
|
getQuizTitle: () => {
|
|
489
|
-
const {
|
|
490
|
-
|
|
491
|
-
return activeQuiz?.quiz?.title || "Quiz";
|
|
470
|
+
const { quiz } = get();
|
|
471
|
+
return quiz?.title || "Quiz";
|
|
492
472
|
},
|
|
493
473
|
formatTime: (seconds) => {
|
|
494
474
|
const minutes = Math.floor(seconds / 60);
|
|
@@ -500,11 +480,10 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
500
480
|
return userAnswers;
|
|
501
481
|
},
|
|
502
482
|
getUnansweredQuestionsFromUserAnswers: () => {
|
|
503
|
-
const {
|
|
504
|
-
|
|
505
|
-
if (!activeQuiz) return [];
|
|
483
|
+
const { quiz, userAnswers } = get();
|
|
484
|
+
if (!quiz) return [];
|
|
506
485
|
const unansweredQuestions = [];
|
|
507
|
-
|
|
486
|
+
quiz.questions.forEach((question, index) => {
|
|
508
487
|
const userAnswer = userAnswers.find(
|
|
509
488
|
(answer) => answer.questionId === question.id
|
|
510
489
|
);
|
|
@@ -517,8 +496,8 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
517
496
|
return unansweredQuestions;
|
|
518
497
|
},
|
|
519
498
|
getQuestionsGroupedBySubject: () => {
|
|
520
|
-
const { getQuestionResult,
|
|
521
|
-
const questions = variant == "result" ? getQuestionResult()?.answers :
|
|
499
|
+
const { getQuestionResult, quiz, variant } = get();
|
|
500
|
+
const questions = variant == "result" ? getQuestionResult()?.answers : quiz?.questions;
|
|
522
501
|
if (!questions) return {};
|
|
523
502
|
const groupedQuestions = {};
|
|
524
503
|
questions.forEach((question) => {
|
|
@@ -556,19 +535,18 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
556
535
|
return userAnswers;
|
|
557
536
|
},
|
|
558
537
|
setCurrentQuestion: (question) => {
|
|
559
|
-
const {
|
|
560
|
-
|
|
561
|
-
if (!activeQuiz) return;
|
|
538
|
+
const { quiz, variant, questionsResult } = get();
|
|
539
|
+
if (!quiz) return;
|
|
562
540
|
let questionIndex = 0;
|
|
563
541
|
if (variant == "result") {
|
|
564
542
|
if (!questionsResult) return;
|
|
565
543
|
const questionResult = questionsResult.answers.find((q) => q.id === question.id) ?? questionsResult.answers.find((q) => q.questionId === question.id);
|
|
566
544
|
if (!questionResult) return;
|
|
567
|
-
questionIndex =
|
|
545
|
+
questionIndex = quiz.questions.findIndex(
|
|
568
546
|
(q) => q.id === questionResult.questionId
|
|
569
547
|
);
|
|
570
548
|
} else {
|
|
571
|
-
questionIndex =
|
|
549
|
+
questionIndex = quiz.questions.findIndex(
|
|
572
550
|
(q) => q.id === question.id
|
|
573
551
|
);
|
|
574
552
|
}
|
|
@@ -602,7 +580,7 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
602
580
|
return userAnswer ? userAnswer.answerStatus : null;
|
|
603
581
|
},
|
|
604
582
|
getQuestionIndex: (questionId) => {
|
|
605
|
-
const { questionsResult, variant } = get();
|
|
583
|
+
const { questionsResult, variant, quiz } = get();
|
|
606
584
|
if (variant == "result") {
|
|
607
585
|
if (!questionsResult) return 0;
|
|
608
586
|
let idx = questionsResult.answers.findIndex(
|
|
@@ -615,12 +593,8 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
615
593
|
}
|
|
616
594
|
return idx !== -1 ? idx + 1 : 0;
|
|
617
595
|
} else {
|
|
618
|
-
|
|
619
|
-
const
|
|
620
|
-
if (!activeQuiz) return 0;
|
|
621
|
-
const idx = activeQuiz.quiz.questions.findIndex(
|
|
622
|
-
(q) => q.id === questionId
|
|
623
|
-
);
|
|
596
|
+
if (!quiz) return 0;
|
|
597
|
+
const idx = quiz.questions.findIndex((q) => q.id === questionId);
|
|
624
598
|
return idx !== -1 ? idx + 1 : 0;
|
|
625
599
|
}
|
|
626
600
|
},
|
|
@@ -664,6 +638,7 @@ var useQuizStore = (0, import_zustand.create)()(
|
|
|
664
638
|
QUESTION_DIFFICULTY,
|
|
665
639
|
QUESTION_STATUS,
|
|
666
640
|
QUESTION_TYPE,
|
|
641
|
+
QUIZ_TYPE,
|
|
667
642
|
SUBTYPE_ENUM,
|
|
668
643
|
useQuizStore
|
|
669
644
|
});
|