analytica-frontend-lib 1.0.83 → 1.0.84

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/index.mjs CHANGED
@@ -6253,7 +6253,8 @@ import {
6253
6253
  CaretRight as CaretRight4,
6254
6254
  Clock as Clock2,
6255
6255
  SquaresFour,
6256
- BookOpen
6256
+ BookOpen,
6257
+ Book
6257
6258
  } from "phosphor-react";
6258
6259
  import { forwardRef as forwardRef17, useState as useState12 } from "react";
6259
6260
 
@@ -6265,6 +6266,9 @@ var useQuizStore = create6()(
6265
6266
  (set, get) => {
6266
6267
  let timerInterval = null;
6267
6268
  const startTimer = () => {
6269
+ if (get().isFinished) {
6270
+ return;
6271
+ }
6268
6272
  if (timerInterval) {
6269
6273
  clearInterval(timerInterval);
6270
6274
  }
@@ -6283,15 +6287,17 @@ var useQuizStore = create6()(
6283
6287
  // Initial State
6284
6288
  currentQuestionIndex: 0,
6285
6289
  selectedAnswers: {},
6286
- skippedQuestions: [],
6287
6290
  userAnswers: [],
6288
6291
  timeElapsed: 0,
6289
6292
  isStarted: false,
6290
6293
  isFinished: false,
6294
+ userId: "",
6291
6295
  // Setters
6292
- setBySimulado: (simulado) => set({ bySimulado: simulado }),
6293
- setByAtividade: (atividade) => set({ byAtividade: atividade }),
6294
- setByAula: (aula) => set({ byAula: aula }),
6296
+ setBySimulated: (simulado) => set({ bySimulated: simulado }),
6297
+ setByActivity: (atividade) => set({ byActivity: atividade }),
6298
+ setByQuestionary: (aula) => set({ byQuestionary: aula }),
6299
+ setUserId: (userId) => set({ userId }),
6300
+ getUserId: () => get().userId,
6295
6301
  // Navigation
6296
6302
  goToNextQuestion: () => {
6297
6303
  const { currentQuestionIndex, getTotalQuestions } = get();
@@ -6313,58 +6319,107 @@ var useQuizStore = create6()(
6313
6319
  set({ currentQuestionIndex: index });
6314
6320
  }
6315
6321
  },
6316
- // Quiz Actions
6322
+ getActiveQuiz: () => {
6323
+ const { bySimulated, byActivity, byQuestionary } = get();
6324
+ if (bySimulated)
6325
+ return { quiz: bySimulated, type: "bySimulated" };
6326
+ if (byActivity)
6327
+ return { quiz: byActivity, type: "byActivity" };
6328
+ if (byQuestionary)
6329
+ return { quiz: byQuestionary, type: "byQuestionary" };
6330
+ return null;
6331
+ },
6317
6332
  selectAnswer: (questionId, answerId) => {
6318
- const { selectedAnswers, skippedQuestions, addUserAnswer } = get();
6319
- const newSkippedQuestions = skippedQuestions.filter(
6320
- (id) => id !== questionId
6333
+ const { getActiveQuiz, userAnswers } = get();
6334
+ const activeQuiz = getActiveQuiz();
6335
+ if (!activeQuiz) return;
6336
+ const updatedQuestions = activeQuiz.quiz.questions.map(
6337
+ (question) => question.id === questionId ? { ...question, answerKey: answerId } : question
6338
+ );
6339
+ const updatedQuiz = {
6340
+ ...activeQuiz.quiz,
6341
+ questions: updatedQuestions
6342
+ };
6343
+ const activityId = activeQuiz.quiz.id;
6344
+ const userId = get().getUserId();
6345
+ if (!userId) {
6346
+ console.warn("selectAnswer called before userId is set");
6347
+ return;
6348
+ }
6349
+ const existingAnswerIndex = userAnswers.findIndex(
6350
+ (answer) => answer.questionId === questionId
6321
6351
  );
6352
+ const newUserAnswer = {
6353
+ questionId,
6354
+ activityId,
6355
+ userId,
6356
+ answer: answerId,
6357
+ optionId: answerId
6358
+ };
6359
+ let updatedUserAnswers;
6360
+ if (existingAnswerIndex !== -1) {
6361
+ updatedUserAnswers = [...userAnswers];
6362
+ updatedUserAnswers[existingAnswerIndex] = newUserAnswer;
6363
+ } else {
6364
+ updatedUserAnswers = [...userAnswers, newUserAnswer];
6365
+ }
6322
6366
  set({
6323
- selectedAnswers: {
6324
- ...selectedAnswers,
6325
- [questionId]: answerId
6326
- },
6327
- skippedQuestions: newSkippedQuestions
6367
+ [activeQuiz.type]: updatedQuiz,
6368
+ userAnswers: updatedUserAnswers
6328
6369
  });
6329
- addUserAnswer(questionId, answerId);
6330
6370
  },
6331
6371
  skipQuestion: () => {
6332
- const { getCurrentQuestion, skippedQuestions, addUserAnswer } = get();
6372
+ const { getCurrentQuestion, userAnswers, getActiveQuiz } = get();
6333
6373
  const currentQuestion = getCurrentQuestion();
6374
+ const activeQuiz = getActiveQuiz();
6375
+ if (!activeQuiz) return;
6334
6376
  if (currentQuestion) {
6377
+ const activityId = activeQuiz.quiz.id;
6378
+ const userId = get().getUserId();
6379
+ const existingAnswerIndex = userAnswers.findIndex(
6380
+ (answer) => answer.questionId === currentQuestion.id
6381
+ );
6382
+ const newUserAnswer = {
6383
+ questionId: currentQuestion.id,
6384
+ activityId,
6385
+ userId,
6386
+ answer: null,
6387
+ optionId: null
6388
+ };
6389
+ let updatedUserAnswers;
6390
+ if (existingAnswerIndex !== -1) {
6391
+ updatedUserAnswers = [...userAnswers];
6392
+ updatedUserAnswers[existingAnswerIndex] = newUserAnswer;
6393
+ } else {
6394
+ updatedUserAnswers = [...userAnswers, newUserAnswer];
6395
+ }
6335
6396
  set({
6336
- skippedQuestions: [...skippedQuestions, currentQuestion.id]
6397
+ userAnswers: updatedUserAnswers
6337
6398
  });
6338
- addUserAnswer(currentQuestion.id);
6339
6399
  }
6340
6400
  },
6341
6401
  addUserAnswer: (questionId, answerId) => {
6342
- const { userAnswers, bySimulado, byAtividade, byAula } = get();
6343
- const quiz = bySimulado || byAtividade || byAula;
6344
- const question = quiz?.questions.find((q) => q.id === questionId);
6345
- if (!question) return;
6402
+ const { getActiveQuiz, userAnswers } = get();
6403
+ const activeQuiz = getActiveQuiz();
6404
+ if (!activeQuiz) return;
6405
+ const activityId = activeQuiz.quiz.id;
6406
+ const userId = get().getUserId();
6346
6407
  const existingAnswerIndex = userAnswers.findIndex(
6347
- (answer) => answer.id === questionId
6408
+ (answer) => answer.questionId === questionId
6348
6409
  );
6410
+ const newUserAnswer = {
6411
+ questionId,
6412
+ activityId,
6413
+ userId,
6414
+ answer: answerId || null,
6415
+ optionId: answerId || null
6416
+ };
6349
6417
  if (existingAnswerIndex !== -1) {
6350
- const updatedAnswers = [...userAnswers];
6351
- updatedAnswers[existingAnswerIndex] = {
6352
- ...question,
6353
- answerKey: answerId || "",
6354
- isSkipped: !answerId
6355
- };
6356
- set({ userAnswers: updatedAnswers });
6418
+ const updatedUserAnswers = [...userAnswers];
6419
+ updatedUserAnswers[existingAnswerIndex] = newUserAnswer;
6420
+ set({ userAnswers: updatedUserAnswers });
6357
6421
  } else {
6358
- set({
6359
- userAnswers: [
6360
- ...userAnswers,
6361
- {
6362
- ...question,
6363
- answerKey: answerId || "",
6364
- isSkipped: !answerId
6365
- }
6366
- ]
6367
- });
6422
+ set({ userAnswers: [...userAnswers, newUserAnswer] });
6368
6423
  }
6369
6424
  },
6370
6425
  startQuiz: () => {
@@ -6380,11 +6435,11 @@ var useQuizStore = create6()(
6380
6435
  set({
6381
6436
  currentQuestionIndex: 0,
6382
6437
  selectedAnswers: {},
6383
- skippedQuestions: [],
6384
6438
  userAnswers: [],
6385
6439
  timeElapsed: 0,
6386
6440
  isStarted: false,
6387
- isFinished: false
6441
+ isFinished: false,
6442
+ userId: ""
6388
6443
  });
6389
6444
  },
6390
6445
  // Timer
@@ -6393,36 +6448,33 @@ var useQuizStore = create6()(
6393
6448
  stopTimer,
6394
6449
  // Getters
6395
6450
  getCurrentQuestion: () => {
6396
- const { bySimulado, byAtividade, byAula, currentQuestionIndex } = get();
6397
- const quiz = bySimulado || byAtividade || byAula;
6398
- if (!quiz) {
6451
+ const { currentQuestionIndex, getActiveQuiz } = get();
6452
+ const activeQuiz = getActiveQuiz();
6453
+ if (!activeQuiz) {
6399
6454
  return null;
6400
6455
  }
6401
- return quiz.questions[currentQuestionIndex];
6456
+ return activeQuiz.quiz.questions[currentQuestionIndex];
6402
6457
  },
6403
6458
  getTotalQuestions: () => {
6404
- const { bySimulado, byAtividade, byAula } = get();
6405
- const quiz = bySimulado || byAtividade || byAula;
6406
- return quiz?.questions?.length || 0;
6459
+ const { getActiveQuiz } = get();
6460
+ const activeQuiz = getActiveQuiz();
6461
+ return activeQuiz?.quiz?.questions?.length || 0;
6407
6462
  },
6408
6463
  getAnsweredQuestions: () => {
6409
- const { selectedAnswers } = get();
6410
- return Object.keys(selectedAnswers).length;
6464
+ const { userAnswers } = get();
6465
+ return userAnswers.filter((answer) => answer.answer !== null).length;
6411
6466
  },
6412
6467
  getUnansweredQuestions: () => {
6413
- const {
6414
- bySimulado,
6415
- byAtividade,
6416
- byAula,
6417
- selectedAnswers,
6418
- skippedQuestions
6419
- } = get();
6420
- const quiz = bySimulado || byAtividade || byAula;
6421
- if (!quiz) return [];
6468
+ const { getActiveQuiz, userAnswers } = get();
6469
+ const activeQuiz = getActiveQuiz();
6470
+ if (!activeQuiz) return [];
6422
6471
  const unansweredQuestions = [];
6423
- quiz.questions.forEach((question, index) => {
6424
- const isAnswered = question.id in selectedAnswers;
6425
- const isSkipped = skippedQuestions.includes(question.id);
6472
+ activeQuiz.quiz.questions.forEach((question, index) => {
6473
+ const userAnswer = userAnswers.find(
6474
+ (answer) => answer.questionId === question.id
6475
+ );
6476
+ const isAnswered = userAnswer && userAnswer.answer !== null;
6477
+ const isSkipped = userAnswer && userAnswer.answer === null;
6426
6478
  if (!isAnswered && !isSkipped) {
6427
6479
  unansweredQuestions.push(index + 1);
6428
6480
  }
@@ -6430,8 +6482,8 @@ var useQuizStore = create6()(
6430
6482
  return unansweredQuestions;
6431
6483
  },
6432
6484
  getSkippedQuestions: () => {
6433
- const { skippedQuestions } = get();
6434
- return skippedQuestions.length;
6485
+ const { userAnswers } = get();
6486
+ return userAnswers.filter((answer) => answer.answer === null).length;
6435
6487
  },
6436
6488
  getProgress: () => {
6437
6489
  const { getTotalQuestions, getAnsweredQuestions } = get();
@@ -6440,22 +6492,32 @@ var useQuizStore = create6()(
6440
6492
  return total > 0 ? answered / total * 100 : 0;
6441
6493
  },
6442
6494
  isQuestionAnswered: (questionId) => {
6443
- const { selectedAnswers } = get();
6444
- return questionId in selectedAnswers;
6495
+ const { userAnswers } = get();
6496
+ const userAnswer = userAnswers.find(
6497
+ (answer) => answer.questionId === questionId
6498
+ );
6499
+ return userAnswer ? userAnswer.answer !== null : false;
6445
6500
  },
6446
6501
  isQuestionSkipped: (questionId) => {
6447
- const { skippedQuestions } = get();
6448
- return skippedQuestions.includes(questionId);
6502
+ const { userAnswers } = get();
6503
+ const userAnswer = userAnswers.find(
6504
+ (answer) => answer.questionId === questionId
6505
+ );
6506
+ return userAnswer ? userAnswer.answer === null : false;
6449
6507
  },
6450
6508
  getCurrentAnswer: () => {
6451
- const { getCurrentQuestion, selectedAnswers } = get();
6509
+ const { getCurrentQuestion, userAnswers } = get();
6452
6510
  const currentQuestion = getCurrentQuestion();
6453
- return selectedAnswers[currentQuestion?.id || ""];
6511
+ if (!currentQuestion) return void 0;
6512
+ const userAnswer = userAnswers.find(
6513
+ (answer) => answer.questionId === currentQuestion.id
6514
+ );
6515
+ return userAnswer?.answer;
6454
6516
  },
6455
6517
  getQuizTitle: () => {
6456
- const { bySimulado, byAtividade, byAula } = get();
6457
- const quiz = bySimulado || byAtividade || byAula;
6458
- return quiz?.title || "Quiz";
6518
+ const { getActiveQuiz } = get();
6519
+ const activeQuiz = getActiveQuiz();
6520
+ return activeQuiz?.quiz?.title || "Quiz";
6459
6521
  },
6460
6522
  formatTime: (seconds) => {
6461
6523
  const minutes = Math.floor(seconds / 60);
@@ -6463,30 +6525,42 @@ var useQuizStore = create6()(
6463
6525
  return `${minutes.toString().padStart(2, "0")}:${remainingSeconds.toString().padStart(2, "0")}`;
6464
6526
  },
6465
6527
  getUserAnswers: () => {
6466
- const { userAnswers } = get();
6467
- return userAnswers;
6528
+ const { getActiveQuiz, userAnswers } = get();
6529
+ const activeQuiz = getActiveQuiz();
6530
+ if (!activeQuiz) return [];
6531
+ return activeQuiz.quiz.questions.map((question) => {
6532
+ const userAnswer = userAnswers.find(
6533
+ (answer) => answer.questionId === question.id
6534
+ );
6535
+ return {
6536
+ ...question,
6537
+ isSkipped: userAnswer ? userAnswer.answer === null : false
6538
+ };
6539
+ });
6468
6540
  },
6469
6541
  getUnansweredQuestionsFromUserAnswers: () => {
6470
- const { bySimulado, byAtividade, byAula, userAnswers } = get();
6471
- const quiz = bySimulado || byAtividade || byAula;
6472
- if (!quiz) return [];
6542
+ const { getActiveQuiz, userAnswers } = get();
6543
+ const activeQuiz = getActiveQuiz();
6544
+ if (!activeQuiz) return [];
6473
6545
  const unansweredQuestions = [];
6474
- quiz.questions.forEach((question, index) => {
6546
+ activeQuiz.quiz.questions.forEach((question, index) => {
6475
6547
  const userAnswer = userAnswers.find(
6476
- (answer) => answer.id === question.id
6548
+ (answer) => answer.questionId === question.id
6477
6549
  );
6478
- if (!userAnswer || userAnswer.isSkipped) {
6550
+ const hasAnswer = userAnswer && userAnswer.answer !== null;
6551
+ const isSkipped = userAnswer && userAnswer.answer === null;
6552
+ if (!hasAnswer || isSkipped) {
6479
6553
  unansweredQuestions.push(index + 1);
6480
6554
  }
6481
6555
  });
6482
6556
  return unansweredQuestions;
6483
6557
  },
6484
6558
  getQuestionsGroupedBySubject: () => {
6485
- const { bySimulado, byAtividade, byAula } = get();
6486
- const quiz = bySimulado || byAtividade || byAula;
6487
- if (!quiz) return {};
6559
+ const { getActiveQuiz } = get();
6560
+ const activeQuiz = getActiveQuiz();
6561
+ if (!activeQuiz) return {};
6488
6562
  const groupedQuestions = {};
6489
- quiz.questions.forEach((question) => {
6563
+ activeQuiz.quiz.questions.forEach((question) => {
6490
6564
  const subjectId = question.knowledgeMatrix?.[0]?.subjectId || "Sem mat\xE9ria";
6491
6565
  if (!groupedQuestions[subjectId]) {
6492
6566
  groupedQuestions[subjectId] = [];
@@ -6494,6 +6568,31 @@ var useQuizStore = create6()(
6494
6568
  groupedQuestions[subjectId].push(question);
6495
6569
  });
6496
6570
  return groupedQuestions;
6571
+ },
6572
+ // New methods for userAnswers
6573
+ getUserAnswerByQuestionId: (questionId) => {
6574
+ const { userAnswers } = get();
6575
+ return userAnswers.find((answer) => answer.questionId === questionId) || null;
6576
+ },
6577
+ isQuestionAnsweredByUserAnswers: (questionId) => {
6578
+ const { userAnswers } = get();
6579
+ const answer = userAnswers.find(
6580
+ (answer2) => answer2.questionId === questionId
6581
+ );
6582
+ return answer ? answer.answer !== null : false;
6583
+ },
6584
+ getQuestionStatusFromUserAnswers: (questionId) => {
6585
+ const { userAnswers } = get();
6586
+ const answer = userAnswers.find(
6587
+ (answer2) => answer2.questionId === questionId
6588
+ );
6589
+ if (!answer) return "unanswered";
6590
+ if (answer.answer === null) return "skipped";
6591
+ return "answered";
6592
+ },
6593
+ getUserAnswersForActivity: () => {
6594
+ const { userAnswers } = get();
6595
+ return userAnswers;
6497
6596
  }
6498
6597
  };
6499
6598
  },
@@ -6519,6 +6618,26 @@ var Quiz = forwardRef17(({ children, className, ...props }, ref) => {
6519
6618
  }
6520
6619
  );
6521
6620
  });
6621
+ var QuizHeaderResult = forwardRef17(
6622
+ ({ className, ...props }, ref) => {
6623
+ const { getCurrentQuestion, getCurrentAnswer } = useQuizStore();
6624
+ const currentQuestion = getCurrentQuestion();
6625
+ const userAnswer = getCurrentAnswer();
6626
+ const isCorrect = userAnswer === currentQuestion?.correctOptionId;
6627
+ return /* @__PURE__ */ jsxs27(
6628
+ "div",
6629
+ {
6630
+ ref,
6631
+ className: `flex flex-row items-center gap-10 p-3.5 rounded-xl ${isCorrect ? "bg-success-background" : "bg-error-background"} ${className}`,
6632
+ ...props,
6633
+ children: [
6634
+ /* @__PURE__ */ jsx33("p", { className: "text-text-950 font-bold text-lg", children: "Resultado" }),
6635
+ /* @__PURE__ */ jsx33("p", { className: "text-text-700 text-md", children: isCorrect ? "\u{1F389} Parab\xE9ns!!" : "N\xE3o foi dessa vez..." })
6636
+ ]
6637
+ }
6638
+ );
6639
+ }
6640
+ );
6522
6641
  var QuizTitle = forwardRef17(
6523
6642
  ({ className, ...props }, ref) => {
6524
6643
  const {
@@ -6567,30 +6686,43 @@ var QuizContent = forwardRef17(({ type = "Alternativas", children, className, ..
6567
6686
  "div",
6568
6687
  {
6569
6688
  ref,
6570
- className: `rounded-t-xl bg-background px-4 pt-4 pb-[80px] h-full flex flex-col gap-4 mb-auto ${className}`,
6689
+ className: `rounded-t-xl px-4 pt-4 pb-[80px] h-full flex flex-col gap-4 mb-auto ${className}`,
6571
6690
  ...props,
6572
6691
  children
6573
6692
  }
6574
6693
  )
6575
6694
  ] });
6576
6695
  });
6577
- var QuizAlternative = () => {
6696
+ var QuizAlternative = ({ variant = "default" }) => {
6578
6697
  const { getCurrentQuestion, selectAnswer, getCurrentAnswer } = useQuizStore();
6579
6698
  const currentQuestion = getCurrentQuestion();
6580
6699
  const currentAnswer = getCurrentAnswer();
6581
- const alternatives = currentQuestion?.options?.map((option) => ({
6582
- label: option.option,
6583
- value: option.id
6584
- }));
6700
+ const alternatives = currentQuestion?.options?.map((option) => {
6701
+ let status = "neutral" /* NEUTRAL */;
6702
+ if (variant === "result") {
6703
+ if (option.id === currentQuestion.correctOptionId) {
6704
+ status = "correct" /* CORRECT */;
6705
+ } else if (currentAnswer === option.id && option.id !== currentQuestion.correctOptionId) {
6706
+ status = "incorrect" /* INCORRECT */;
6707
+ }
6708
+ }
6709
+ return {
6710
+ label: option.option,
6711
+ value: option.id,
6712
+ status
6713
+ };
6714
+ });
6585
6715
  if (!alternatives)
6586
6716
  return /* @__PURE__ */ jsx33("div", { children: /* @__PURE__ */ jsx33("p", { children: "N\xE3o h\xE1 Alternativas" }) });
6587
6717
  return /* @__PURE__ */ jsx33("div", { className: "space-y-4", children: /* @__PURE__ */ jsx33(
6588
6718
  AlternativesList,
6589
6719
  {
6720
+ mode: variant === "default" ? "interactive" : "readonly",
6590
6721
  name: `question-${currentQuestion?.id || "1"}`,
6591
- layout: "default",
6722
+ layout: "compact",
6592
6723
  alternatives,
6593
6724
  value: currentAnswer,
6725
+ selectedValue: currentAnswer,
6594
6726
  onValueChange: (value) => {
6595
6727
  if (currentQuestion) {
6596
6728
  selectAnswer(currentQuestion.id, value);
@@ -6607,18 +6739,11 @@ var QuizQuestionList = ({
6607
6739
  const {
6608
6740
  getQuestionsGroupedBySubject,
6609
6741
  goToQuestion,
6610
- isQuestionAnswered,
6611
- isQuestionSkipped
6742
+ getQuestionStatusFromUserAnswers
6612
6743
  } = useQuizStore();
6613
6744
  const groupedQuestions = getQuestionsGroupedBySubject();
6614
6745
  const getQuestionStatus = (questionId) => {
6615
- if (isQuestionSkipped(questionId)) {
6616
- return "skipped";
6617
- }
6618
- if (isQuestionAnswered(questionId)) {
6619
- return "answered";
6620
- }
6621
- return "unanswered";
6746
+ return getQuestionStatusFromUserAnswers(questionId);
6622
6747
  };
6623
6748
  const filteredGroupedQuestions = Object.entries(groupedQuestions).reduce(
6624
6749
  (acc, [subjectId, questions]) => {
@@ -6642,8 +6767,8 @@ var QuizQuestionList = ({
6642
6767
  {}
6643
6768
  );
6644
6769
  const getQuestionIndex = (questionId) => {
6645
- const { bySimulado, byAtividade, byAula } = useQuizStore.getState();
6646
- const quiz = bySimulado ?? byAtividade ?? byAula;
6770
+ const { bySimulated, byActivity, byQuestionary } = useQuizStore.getState();
6771
+ const quiz = bySimulated ?? byActivity ?? byQuestionary;
6647
6772
  if (!quiz) return 0;
6648
6773
  const index = quiz.questions.findIndex((q) => q.id === questionId);
6649
6774
  return index + 1;
@@ -6653,7 +6778,7 @@ var QuizQuestionList = ({
6653
6778
  case "answered":
6654
6779
  return "Respondida";
6655
6780
  case "skipped":
6656
- return "Pulada";
6781
+ return "N\xE3o respondida";
6657
6782
  default:
6658
6783
  return "Em branco";
6659
6784
  }
@@ -6694,14 +6819,14 @@ var QuizFooter = forwardRef17(({ className, onGoToSimulated, onDetailResult, ...
6694
6819
  getCurrentAnswer,
6695
6820
  skipQuestion,
6696
6821
  getCurrentQuestion,
6697
- isQuestionSkipped
6822
+ getQuestionStatusFromUserAnswers
6698
6823
  } = useQuizStore();
6699
6824
  const totalQuestions = getTotalQuestions();
6700
6825
  const isFirstQuestion = currentQuestionIndex === 0;
6701
6826
  const isLastQuestion = currentQuestionIndex === totalQuestions - 1;
6702
6827
  const currentAnswer = getCurrentAnswer();
6703
6828
  const currentQuestion = getCurrentQuestion();
6704
- const isCurrentQuestionSkipped = currentQuestion ? isQuestionSkipped(currentQuestion.id) : false;
6829
+ const isCurrentQuestionSkipped = currentQuestion ? getQuestionStatusFromUserAnswers(currentQuestion.id) === "skipped" : false;
6705
6830
  const [alertDialogOpen, setAlertDialogOpen] = useState12(false);
6706
6831
  const [modalResultOpen, setModalResultOpen] = useState12(false);
6707
6832
  const [modalNavigateOpen, setModalNavigateOpen] = useState12(false);
@@ -6891,6 +7016,223 @@ var QuizFooter = forwardRef17(({ className, onGoToSimulated, onDetailResult, ...
6891
7016
  )
6892
7017
  ] });
6893
7018
  });
7019
+ var QuizResultHeaderTitle = forwardRef17(({ className, ...props }, ref) => {
7020
+ const { bySimulated } = useQuizStore();
7021
+ return /* @__PURE__ */ jsxs27(
7022
+ "div",
7023
+ {
7024
+ ref,
7025
+ className: `flex flex-row pt-4 justify-between ${className}`,
7026
+ ...props,
7027
+ children: [
7028
+ /* @__PURE__ */ jsx33("p", { className: "text-text-950 font-bold text-2xl", children: "Resultado" }),
7029
+ bySimulated && /* @__PURE__ */ jsx33(Badge_default, { variant: "solid", action: "info", children: bySimulated.category })
7030
+ ]
7031
+ }
7032
+ );
7033
+ });
7034
+ var QuizResultTitle = forwardRef17(({ className, ...props }, ref) => {
7035
+ const { getQuizTitle } = useQuizStore();
7036
+ const quizTitle = getQuizTitle();
7037
+ return /* @__PURE__ */ jsx33(
7038
+ "p",
7039
+ {
7040
+ className: `pt-6 pb-4 text-text-950 font-bold text-lg ${className}`,
7041
+ ref,
7042
+ ...props,
7043
+ children: quizTitle
7044
+ }
7045
+ );
7046
+ });
7047
+ var QuizResultPerformance = forwardRef17(
7048
+ ({ ...props }, ref) => {
7049
+ const {
7050
+ getTotalQuestions,
7051
+ timeElapsed,
7052
+ formatTime,
7053
+ bySimulated,
7054
+ byActivity,
7055
+ byQuestionary
7056
+ } = useQuizStore();
7057
+ const totalQuestions = getTotalQuestions();
7058
+ const quiz = bySimulated || byActivity || byQuestionary;
7059
+ let correctAnswers = 0;
7060
+ let correctEasyAnswers = 0;
7061
+ let correctMediumAnswers = 0;
7062
+ let correctDifficultAnswers = 0;
7063
+ let totalEasyQuestions = 0;
7064
+ let totalMediumQuestions = 0;
7065
+ let totalDifficultQuestions = 0;
7066
+ if (quiz) {
7067
+ quiz.questions.forEach((question) => {
7068
+ const userAnswer = question.answerKey;
7069
+ const isCorrect = userAnswer && userAnswer === question.correctOptionId;
7070
+ if (isCorrect) {
7071
+ correctAnswers++;
7072
+ }
7073
+ if (question.difficulty === "FACIL" /* FACIL */) {
7074
+ totalEasyQuestions++;
7075
+ if (isCorrect) {
7076
+ correctEasyAnswers++;
7077
+ }
7078
+ } else if (question.difficulty === "MEDIO" /* MEDIO */) {
7079
+ totalMediumQuestions++;
7080
+ if (isCorrect) {
7081
+ correctMediumAnswers++;
7082
+ }
7083
+ } else if (question.difficulty === "DIFICIL" /* DIFICIL */) {
7084
+ totalDifficultQuestions++;
7085
+ if (isCorrect) {
7086
+ correctDifficultAnswers++;
7087
+ }
7088
+ }
7089
+ });
7090
+ }
7091
+ const percentage = totalQuestions > 0 ? Math.round(correctAnswers / totalQuestions * 100) : 0;
7092
+ return /* @__PURE__ */ jsxs27(
7093
+ "div",
7094
+ {
7095
+ className: "flex flex-row gap-6 p-6 rounded-xl bg-background justify-between",
7096
+ ref,
7097
+ ...props,
7098
+ children: [
7099
+ /* @__PURE__ */ jsxs27("div", { className: "relative", children: [
7100
+ /* @__PURE__ */ jsx33(
7101
+ ProgressCircle_default,
7102
+ {
7103
+ size: "medium",
7104
+ variant: "green",
7105
+ value: percentage,
7106
+ showPercentage: false,
7107
+ label: ""
7108
+ }
7109
+ ),
7110
+ /* @__PURE__ */ jsxs27("div", { className: "absolute inset-0 flex flex-col items-center justify-center", children: [
7111
+ /* @__PURE__ */ jsxs27("div", { className: "flex items-center gap-1 mb-1", children: [
7112
+ /* @__PURE__ */ jsx33(Clock2, { size: 12, weight: "regular", className: "text-text-800" }),
7113
+ /* @__PURE__ */ jsx33("span", { className: "text-2xs font-medium text-text-800", children: formatTime(timeElapsed) })
7114
+ ] }),
7115
+ /* @__PURE__ */ jsxs27("div", { className: "text-2xl font-medium text-text-800 leading-7", children: [
7116
+ correctAnswers,
7117
+ " de ",
7118
+ totalQuestions
7119
+ ] }),
7120
+ /* @__PURE__ */ jsx33("div", { className: "text-2xs font-medium text-text-600 mt-1", children: "Corretas" })
7121
+ ] })
7122
+ ] }),
7123
+ /* @__PURE__ */ jsxs27("div", { className: "flex flex-col gap-4 w-full", children: [
7124
+ /* @__PURE__ */ jsx33(
7125
+ ProgressBar_default,
7126
+ {
7127
+ className: "w-full",
7128
+ layout: "stacked",
7129
+ variant: "green",
7130
+ value: correctEasyAnswers,
7131
+ max: totalEasyQuestions,
7132
+ label: "F\xE1ceis",
7133
+ showHitCount: true,
7134
+ labelClassName: "text-base font-medium text-text-800 leading-none",
7135
+ percentageClassName: "text-xs font-medium leading-[14px] text-right"
7136
+ }
7137
+ ),
7138
+ /* @__PURE__ */ jsx33(
7139
+ ProgressBar_default,
7140
+ {
7141
+ className: "w-full",
7142
+ layout: "stacked",
7143
+ variant: "green",
7144
+ value: correctMediumAnswers,
7145
+ max: totalMediumQuestions,
7146
+ label: "M\xE9dias",
7147
+ showHitCount: true,
7148
+ labelClassName: "text-base font-medium text-text-800 leading-none",
7149
+ percentageClassName: "text-xs font-medium leading-[14px] text-right"
7150
+ }
7151
+ ),
7152
+ /* @__PURE__ */ jsx33(
7153
+ ProgressBar_default,
7154
+ {
7155
+ className: "w-full",
7156
+ layout: "stacked",
7157
+ variant: "green",
7158
+ value: correctDifficultAnswers,
7159
+ max: totalDifficultQuestions,
7160
+ label: "Dif\xEDceis",
7161
+ showHitCount: true,
7162
+ labelClassName: "text-base font-medium text-text-800 leading-none",
7163
+ percentageClassName: "text-xs font-medium leading-[14px] text-right"
7164
+ }
7165
+ )
7166
+ ] })
7167
+ ]
7168
+ }
7169
+ );
7170
+ }
7171
+ );
7172
+ var QuizListResult = forwardRef17(({ className, onSubjectClick, ...props }, ref) => {
7173
+ const { getQuestionsGroupedBySubject, isQuestionAnswered } = useQuizStore();
7174
+ const groupedQuestions = getQuestionsGroupedBySubject();
7175
+ const subjectsStats = Object.entries(groupedQuestions).map(
7176
+ ([subjectId, questions]) => {
7177
+ let correct = 0;
7178
+ let incorrect = 0;
7179
+ questions.forEach((question) => {
7180
+ if (isQuestionAnswered(question.id)) {
7181
+ const userAnswer = question.answerKey;
7182
+ if (userAnswer === question.correctOptionId) {
7183
+ correct++;
7184
+ } else {
7185
+ incorrect++;
7186
+ }
7187
+ }
7188
+ });
7189
+ return {
7190
+ subject: subjectId,
7191
+ correct,
7192
+ incorrect,
7193
+ total: questions.length
7194
+ };
7195
+ }
7196
+ );
7197
+ return /* @__PURE__ */ jsxs27("section", { ref, className, ...props, children: [
7198
+ /* @__PURE__ */ jsx33("p", { className: "pt-6 pb-4 text-text-950 font-bold text-lg", children: "Mat\xE9rias" }),
7199
+ /* @__PURE__ */ jsx33("ul", { className: "flex flex-col gap-2", children: subjectsStats.map((subject) => /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
7200
+ CardResults,
7201
+ {
7202
+ onClick: () => onSubjectClick?.(subject.subject),
7203
+ className: "max-w-full",
7204
+ header: subject.subject,
7205
+ correct_answers: subject.correct,
7206
+ incorrect_answers: subject.incorrect,
7207
+ icon: /* @__PURE__ */ jsx33(Book, { size: 20 }),
7208
+ direction: "row"
7209
+ }
7210
+ ) }, subject.subject)) })
7211
+ ] });
7212
+ });
7213
+ var QuizListResultByMateria = ({
7214
+ subject,
7215
+ onQuestionClick
7216
+ }) => {
7217
+ const { getQuestionsGroupedBySubject } = useQuizStore();
7218
+ const groupedQuestions = getQuestionsGroupedBySubject();
7219
+ const answeredQuestions = groupedQuestions[subject] || [];
7220
+ return /* @__PURE__ */ jsxs27("div", { className: "w-full max-w-[1000px] flex flex-col mx-auto h-full relative not-lg:px-6", children: [
7221
+ /* @__PURE__ */ jsx33("div", { className: "flex flex-row pt-4 justify-between", children: /* @__PURE__ */ jsx33("p", { className: "text-text-950 font-bold text-2xl", children: subject }) }),
7222
+ /* @__PURE__ */ jsxs27("section", { className: "flex flex-col ", children: [
7223
+ /* @__PURE__ */ jsx33("p", { className: "pt-6 pb-4 text-text-950 font-bold text-lg", children: "Resultado das quest\xF5es" }),
7224
+ /* @__PURE__ */ jsx33("ul", { className: "flex flex-col gap-2 pt-4", children: answeredQuestions.map((question) => /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
7225
+ CardStatus,
7226
+ {
7227
+ className: "max-w-full",
7228
+ header: `Quest\xE3o ${question.id}`,
7229
+ status: question.answerKey === question.correctOptionId ? "correct" : "incorrect",
7230
+ onClick: () => onQuestionClick?.(question)
7231
+ }
7232
+ ) }, question.id)) })
7233
+ ] })
7234
+ ] });
7235
+ };
6894
7236
  export {
6895
7237
  Alert_default as Alert,
6896
7238
  AlertDialog,
@@ -6942,7 +7284,11 @@ export {
6942
7284
  QuizContent,
6943
7285
  QuizFooter,
6944
7286
  QuizHeader,
7287
+ QuizListResultByMateria,
6945
7288
  QuizQuestionList,
7289
+ QuizResultHeaderTitle,
7290
+ QuizResultPerformance,
7291
+ QuizResultTitle,
6946
7292
  QuizTitle,
6947
7293
  Radio_default as Radio,
6948
7294
  RadioGroup,