analytica-frontend-lib 1.1.1 → 1.1.2

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.
@@ -1414,6 +1414,15 @@ var useQuizStore = create2()(
1414
1414
  (answer) => answer.questionId === questionId
1415
1415
  );
1416
1416
  return userAnswer ? userAnswer.answerStatus : null;
1417
+ },
1418
+ getQuestionIndex: (questionId) => {
1419
+ const { getActiveQuiz } = get();
1420
+ const activeQuiz = getActiveQuiz();
1421
+ if (!activeQuiz) return 0;
1422
+ const questionIndex = activeQuiz.quiz.questions.findIndex(
1423
+ (q) => q.id === questionId
1424
+ );
1425
+ return questionIndex + 1;
1417
1426
  }
1418
1427
  };
1419
1428
  },
@@ -5324,7 +5333,8 @@ var QuizQuestionList = ({
5324
5333
  const {
5325
5334
  getQuestionsGroupedBySubject,
5326
5335
  goToQuestion,
5327
- getQuestionStatusFromUserAnswers
5336
+ getQuestionStatusFromUserAnswers,
5337
+ getQuestionIndex
5328
5338
  } = useQuizStore();
5329
5339
  const groupedQuestions = getQuestionsGroupedBySubject();
5330
5340
  const getQuestionStatus = (questionId) => {
@@ -5351,13 +5361,6 @@ var QuizQuestionList = ({
5351
5361
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5352
5362
  {}
5353
5363
  );
5354
- const getQuestionIndex = (questionId) => {
5355
- const { bySimulated, byActivity, byQuestionary } = useQuizStore.getState();
5356
- const quiz = bySimulated ?? byActivity ?? byQuestionary;
5357
- if (!quiz) return 0;
5358
- const index = quiz.questions.findIndex((q) => q.id === questionId);
5359
- return index + 1;
5360
- };
5361
5364
  const getStatusLabel = (status) => {
5362
5365
  switch (status) {
5363
5366
  case "answered":
@@ -5695,9 +5698,7 @@ var QuizResultPerformance = forwardRef10(
5695
5698
  if (quiz) {
5696
5699
  quiz.questions.forEach((question) => {
5697
5700
  const userAnswerItem = getUserAnswerByQuestionId(question.id);
5698
- const userAnswer = userAnswerItem?.optionId;
5699
- const isCorrectOption = question?.options.find((op) => op.isCorrect);
5700
- const isCorrect = userAnswer && userAnswer === isCorrectOption?.id;
5701
+ const isCorrect = userAnswerItem?.answerStatus == "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */;
5701
5702
  if (isCorrect) {
5702
5703
  correctAnswers++;
5703
5704
  }
@@ -5814,9 +5815,7 @@ var QuizListResult = forwardRef10(({ className, onSubjectClick, ...props }, ref)
5814
5815
  questions.forEach((question) => {
5815
5816
  if (isQuestionAnswered(question.id)) {
5816
5817
  const userAnswerItem = getUserAnswerByQuestionId(question.id);
5817
- const userAnswer = userAnswerItem?.optionId;
5818
- const isCorrectOption = question?.options.find((op) => op.isCorrect);
5819
- if (userAnswer === isCorrectOption?.id) {
5818
+ if (userAnswerItem?.answerStatus == "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */) {
5820
5819
  correct++;
5821
5820
  } else {
5822
5821
  incorrect++;
@@ -5851,28 +5850,36 @@ var QuizListResultByMateria = ({
5851
5850
  subject,
5852
5851
  onQuestionClick
5853
5852
  }) => {
5854
- const { getQuestionsGroupedBySubject, getUserAnswerByQuestionId } = useQuizStore();
5853
+ const {
5854
+ getQuestionsGroupedBySubject,
5855
+ getUserAnswerByQuestionId,
5856
+ getQuestionIndex
5857
+ } = useQuizStore();
5855
5858
  const groupedQuestions = getQuestionsGroupedBySubject();
5856
5859
  const answeredQuestions = groupedQuestions[subject] || [];
5857
5860
  return /* @__PURE__ */ jsxs14("div", { className: "w-full max-w-[1000px] flex flex-col mx-auto h-full relative not-lg:px-6", children: [
5858
5861
  /* @__PURE__ */ jsx17("div", { className: "flex flex-row pt-4 justify-between", children: /* @__PURE__ */ jsx17("p", { className: "text-text-950 font-bold text-2xl", children: subject }) }),
5859
5862
  /* @__PURE__ */ jsxs14("section", { className: "flex flex-col ", children: [
5860
5863
  /* @__PURE__ */ jsx17("p", { className: "pt-6 pb-4 text-text-950 font-bold text-lg", children: "Resultado das quest\xF5es" }),
5861
- /* @__PURE__ */ jsx17("ul", { className: "flex flex-col gap-2 pt-4", children: answeredQuestions.map((question) => /* @__PURE__ */ jsx17("li", { children: /* @__PURE__ */ jsx17(
5862
- CardStatus,
5863
- {
5864
- className: "max-w-full",
5865
- header: `Quest\xE3o ${question.id}`,
5866
- status: (() => {
5867
- const userAnswer = getUserAnswerByQuestionId(question.id);
5868
- const isCorrectOption = question?.options.find(
5869
- (op) => op.isCorrect
5870
- );
5871
- return userAnswer && userAnswer.optionId === isCorrectOption?.id ? "correct" : "incorrect";
5872
- })(),
5873
- onClick: () => onQuestionClick?.(question)
5874
- }
5875
- ) }, question.id)) })
5864
+ /* @__PURE__ */ jsx17("ul", { className: "flex flex-col gap-2 pt-4", children: answeredQuestions.map((question) => {
5865
+ const questionIndex = getQuestionIndex(question.id);
5866
+ return /* @__PURE__ */ jsx17("li", { children: /* @__PURE__ */ jsx17(
5867
+ CardStatus,
5868
+ {
5869
+ className: "max-w-full",
5870
+ header: `Quest\xE3o ${questionIndex.toString().padStart(2, "0")}`,
5871
+ status: (() => {
5872
+ const userAnswer = getUserAnswerByQuestionId(question.id);
5873
+ if (userAnswer?.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */)
5874
+ return "correct";
5875
+ if (userAnswer?.answerStatus === "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */)
5876
+ return "incorrect";
5877
+ return void 0;
5878
+ })(),
5879
+ onClick: () => onQuestionClick?.(question)
5880
+ }
5881
+ ) }, question.id);
5882
+ }) })
5876
5883
  ] })
5877
5884
  ] });
5878
5885
  };