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.
package/dist/index.mjs CHANGED
@@ -7591,6 +7591,15 @@ var useQuizStore = create7()(
7591
7591
  (answer) => answer.questionId === questionId
7592
7592
  );
7593
7593
  return userAnswer ? userAnswer.answerStatus : null;
7594
+ },
7595
+ getQuestionIndex: (questionId) => {
7596
+ const { getActiveQuiz } = get();
7597
+ const activeQuiz = getActiveQuiz();
7598
+ if (!activeQuiz) return 0;
7599
+ const questionIndex = activeQuiz.quiz.questions.findIndex(
7600
+ (q) => q.id === questionId
7601
+ );
7602
+ return questionIndex + 1;
7594
7603
  }
7595
7604
  };
7596
7605
  },
@@ -8433,7 +8442,8 @@ var QuizQuestionList = ({
8433
8442
  const {
8434
8443
  getQuestionsGroupedBySubject,
8435
8444
  goToQuestion,
8436
- getQuestionStatusFromUserAnswers
8445
+ getQuestionStatusFromUserAnswers,
8446
+ getQuestionIndex
8437
8447
  } = useQuizStore();
8438
8448
  const groupedQuestions = getQuestionsGroupedBySubject();
8439
8449
  const getQuestionStatus = (questionId) => {
@@ -8460,13 +8470,6 @@ var QuizQuestionList = ({
8460
8470
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8461
8471
  {}
8462
8472
  );
8463
- const getQuestionIndex = (questionId) => {
8464
- const { bySimulated, byActivity, byQuestionary } = useQuizStore.getState();
8465
- const quiz = bySimulated ?? byActivity ?? byQuestionary;
8466
- if (!quiz) return 0;
8467
- const index = quiz.questions.findIndex((q) => q.id === questionId);
8468
- return index + 1;
8469
- };
8470
8473
  const getStatusLabel = (status) => {
8471
8474
  switch (status) {
8472
8475
  case "answered":
@@ -8804,9 +8807,7 @@ var QuizResultPerformance = forwardRef19(
8804
8807
  if (quiz) {
8805
8808
  quiz.questions.forEach((question) => {
8806
8809
  const userAnswerItem = getUserAnswerByQuestionId(question.id);
8807
- const userAnswer = userAnswerItem?.optionId;
8808
- const isCorrectOption = question?.options.find((op) => op.isCorrect);
8809
- const isCorrect = userAnswer && userAnswer === isCorrectOption?.id;
8810
+ const isCorrect = userAnswerItem?.answerStatus == "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */;
8810
8811
  if (isCorrect) {
8811
8812
  correctAnswers++;
8812
8813
  }
@@ -8923,9 +8924,7 @@ var QuizListResult = forwardRef19(({ className, onSubjectClick, ...props }, ref)
8923
8924
  questions.forEach((question) => {
8924
8925
  if (isQuestionAnswered(question.id)) {
8925
8926
  const userAnswerItem = getUserAnswerByQuestionId(question.id);
8926
- const userAnswer = userAnswerItem?.optionId;
8927
- const isCorrectOption = question?.options.find((op) => op.isCorrect);
8928
- if (userAnswer === isCorrectOption?.id) {
8927
+ if (userAnswerItem?.answerStatus == "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */) {
8929
8928
  correct++;
8930
8929
  } else {
8931
8930
  incorrect++;
@@ -8960,28 +8959,36 @@ var QuizListResultByMateria = ({
8960
8959
  subject,
8961
8960
  onQuestionClick
8962
8961
  }) => {
8963
- const { getQuestionsGroupedBySubject, getUserAnswerByQuestionId } = useQuizStore();
8962
+ const {
8963
+ getQuestionsGroupedBySubject,
8964
+ getUserAnswerByQuestionId,
8965
+ getQuestionIndex
8966
+ } = useQuizStore();
8964
8967
  const groupedQuestions = getQuestionsGroupedBySubject();
8965
8968
  const answeredQuestions = groupedQuestions[subject] || [];
8966
8969
  return /* @__PURE__ */ jsxs30("div", { className: "w-full max-w-[1000px] flex flex-col mx-auto h-full relative not-lg:px-6", children: [
8967
8970
  /* @__PURE__ */ jsx37("div", { className: "flex flex-row pt-4 justify-between", children: /* @__PURE__ */ jsx37("p", { className: "text-text-950 font-bold text-2xl", children: subject }) }),
8968
8971
  /* @__PURE__ */ jsxs30("section", { className: "flex flex-col ", children: [
8969
8972
  /* @__PURE__ */ jsx37("p", { className: "pt-6 pb-4 text-text-950 font-bold text-lg", children: "Resultado das quest\xF5es" }),
8970
- /* @__PURE__ */ jsx37("ul", { className: "flex flex-col gap-2 pt-4", children: answeredQuestions.map((question) => /* @__PURE__ */ jsx37("li", { children: /* @__PURE__ */ jsx37(
8971
- CardStatus,
8972
- {
8973
- className: "max-w-full",
8974
- header: `Quest\xE3o ${question.id}`,
8975
- status: (() => {
8976
- const userAnswer = getUserAnswerByQuestionId(question.id);
8977
- const isCorrectOption = question?.options.find(
8978
- (op) => op.isCorrect
8979
- );
8980
- return userAnswer && userAnswer.optionId === isCorrectOption?.id ? "correct" : "incorrect";
8981
- })(),
8982
- onClick: () => onQuestionClick?.(question)
8983
- }
8984
- ) }, question.id)) })
8973
+ /* @__PURE__ */ jsx37("ul", { className: "flex flex-col gap-2 pt-4", children: answeredQuestions.map((question) => {
8974
+ const questionIndex = getQuestionIndex(question.id);
8975
+ return /* @__PURE__ */ jsx37("li", { children: /* @__PURE__ */ jsx37(
8976
+ CardStatus,
8977
+ {
8978
+ className: "max-w-full",
8979
+ header: `Quest\xE3o ${questionIndex.toString().padStart(2, "0")}`,
8980
+ status: (() => {
8981
+ const userAnswer = getUserAnswerByQuestionId(question.id);
8982
+ if (userAnswer?.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */)
8983
+ return "correct";
8984
+ if (userAnswer?.answerStatus === "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */)
8985
+ return "incorrect";
8986
+ return void 0;
8987
+ })(),
8988
+ onClick: () => onQuestionClick?.(question)
8989
+ }
8990
+ ) }, question.id);
8991
+ }) })
8985
8992
  ] })
8986
8993
  ] });
8987
8994
  };