analytica-frontend-lib 1.1.14 → 1.1.15
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 +9 -1
- package/dist/Quiz/index.d.ts +9 -1
- package/dist/Quiz/index.js +75 -63
- package/dist/Quiz/index.js.map +1 -1
- package/dist/Quiz/index.mjs +71 -62
- package/dist/Quiz/index.mjs.map +1 -1
- package/dist/Quiz/useQuizStore/index.d.mts +52 -14
- package/dist/Quiz/useQuizStore/index.d.ts +52 -14
- package/dist/Quiz/useQuizStore/index.js +30 -17
- package/dist/Quiz/useQuizStore/index.js.map +1 -1
- package/dist/Quiz/useQuizStore/index.mjs +30 -17
- package/dist/Quiz/useQuizStore/index.mjs.map +1 -1
- package/dist/index.css +6 -3
- package/dist/index.css.map +1 -1
- package/dist/index.js +67 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -61
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +6 -3
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8329,12 +8329,12 @@ var useQuizStore = create7()(
|
|
|
8329
8329
|
return unansweredQuestions;
|
|
8330
8330
|
},
|
|
8331
8331
|
getQuestionsGroupedBySubject: () => {
|
|
8332
|
-
const { getActiveQuiz } = get();
|
|
8333
|
-
const
|
|
8334
|
-
if (!
|
|
8332
|
+
const { getQuestionResult, getActiveQuiz, variant } = get();
|
|
8333
|
+
const questions = variant == "result" ? getQuestionResult()?.answers : getActiveQuiz()?.quiz.questions;
|
|
8334
|
+
if (!questions) return {};
|
|
8335
8335
|
const groupedQuestions = {};
|
|
8336
|
-
|
|
8337
|
-
const subjectId = question.knowledgeMatrix?.[0]?.
|
|
8336
|
+
questions.forEach((question) => {
|
|
8337
|
+
const subjectId = question.knowledgeMatrix?.[0]?.subject?.id || "Sem mat\xE9ria";
|
|
8338
8338
|
if (!groupedQuestions[subjectId]) {
|
|
8339
8339
|
groupedQuestions[subjectId] = [];
|
|
8340
8340
|
}
|
|
@@ -8368,12 +8368,22 @@ var useQuizStore = create7()(
|
|
|
8368
8368
|
return userAnswers;
|
|
8369
8369
|
},
|
|
8370
8370
|
setCurrentQuestion: (question) => {
|
|
8371
|
-
const { getActiveQuiz } = get();
|
|
8371
|
+
const { getActiveQuiz, variant, questionsResult } = get();
|
|
8372
8372
|
const activeQuiz = getActiveQuiz();
|
|
8373
8373
|
if (!activeQuiz) return;
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8374
|
+
let questionIndex = 0;
|
|
8375
|
+
if (variant == "result") {
|
|
8376
|
+
if (!questionsResult) return;
|
|
8377
|
+
const questionResult = questionsResult.answers.find((q) => q.id === question.id) ?? questionsResult.answers.find((q) => q.questionId === question.id);
|
|
8378
|
+
if (!questionResult) return;
|
|
8379
|
+
questionIndex = activeQuiz.quiz.questions.findIndex(
|
|
8380
|
+
(q) => q.id === questionResult.questionId
|
|
8381
|
+
);
|
|
8382
|
+
} else {
|
|
8383
|
+
questionIndex = activeQuiz.quiz.questions.findIndex(
|
|
8384
|
+
(q) => q.id === question.id
|
|
8385
|
+
);
|
|
8386
|
+
}
|
|
8377
8387
|
if (questionIndex === -1) {
|
|
8378
8388
|
console.warn(
|
|
8379
8389
|
`Question with id "${question.id}" not found in active quiz`
|
|
@@ -8404,20 +8414,23 @@ var useQuizStore = create7()(
|
|
|
8404
8414
|
return userAnswer ? userAnswer.answerStatus : null;
|
|
8405
8415
|
},
|
|
8406
8416
|
getQuestionIndex: (questionId) => {
|
|
8407
|
-
const {
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
(q) => q.id === questionId
|
|
8417
|
+
const { questionsResult } = get();
|
|
8418
|
+
if (!questionsResult) return 0;
|
|
8419
|
+
let idx = questionsResult.answers.findIndex(
|
|
8420
|
+
(q) => q.questionId === questionId
|
|
8412
8421
|
);
|
|
8413
|
-
|
|
8422
|
+
if (idx === -1) {
|
|
8423
|
+
idx = questionsResult.answers.findIndex((q) => q.id === questionId);
|
|
8424
|
+
}
|
|
8425
|
+
return idx !== -1 ? idx + 1 : 0;
|
|
8414
8426
|
},
|
|
8415
8427
|
// Question Result
|
|
8416
8428
|
getQuestionResultByQuestionId: (questionId) => {
|
|
8417
8429
|
const { questionsResult } = get();
|
|
8418
|
-
|
|
8430
|
+
const question = questionsResult?.answers.find(
|
|
8419
8431
|
(answer) => answer.questionId === questionId
|
|
8420
|
-
)
|
|
8432
|
+
);
|
|
8433
|
+
return question || null;
|
|
8421
8434
|
},
|
|
8422
8435
|
getQuestionResultStatistics: () => {
|
|
8423
8436
|
const { questionsResult } = get();
|
|
@@ -8568,8 +8581,8 @@ var QuizHeader = () => {
|
|
|
8568
8581
|
HeaderAlternative,
|
|
8569
8582
|
{
|
|
8570
8583
|
title: currentQuestion ? `Quest\xE3o ${currentQuestionIndex + 1}` : "Quest\xE3o",
|
|
8571
|
-
subTitle: currentQuestion?.knowledgeMatrix?.[0]?.
|
|
8572
|
-
content: currentQuestion?.
|
|
8584
|
+
subTitle: currentQuestion?.knowledgeMatrix?.[0]?.topic?.name ?? "",
|
|
8585
|
+
content: currentQuestion?.statement ?? ""
|
|
8573
8586
|
}
|
|
8574
8587
|
);
|
|
8575
8588
|
};
|
|
@@ -8618,10 +8631,10 @@ var QuizAlternative = ({ paddingBottom }) => {
|
|
|
8618
8631
|
const alternatives = currentQuestion?.options?.map((option) => {
|
|
8619
8632
|
let status = "neutral" /* NEUTRAL */;
|
|
8620
8633
|
if (variant === "result") {
|
|
8621
|
-
const isCorrectOption =
|
|
8622
|
-
|
|
8634
|
+
const isCorrectOption = currentQuestionResult?.options?.find((op) => op.id === option.id)?.isCorrect || false;
|
|
8635
|
+
const isSelected = currentQuestionResult?.selectedOptions.some(
|
|
8636
|
+
(selectedOption) => selectedOption.optionId === option.id
|
|
8623
8637
|
);
|
|
8624
|
-
const isSelected = currentQuestionResult?.optionId === option.id;
|
|
8625
8638
|
if (isCorrectOption) {
|
|
8626
8639
|
status = "correct" /* CORRECT */;
|
|
8627
8640
|
} else if (isSelected && !isCorrectOption) {
|
|
@@ -8647,8 +8660,8 @@ var QuizAlternative = ({ paddingBottom }) => {
|
|
|
8647
8660
|
name: `question-${currentQuestion?.id || "1"}`,
|
|
8648
8661
|
layout: "compact",
|
|
8649
8662
|
alternatives,
|
|
8650
|
-
value: variant === "result" ? currentQuestionResult?.optionId || "" : currentAnswer?.optionId || "",
|
|
8651
|
-
selectedValue: variant === "result" ? currentQuestionResult?.optionId || "" : currentAnswer?.optionId || "",
|
|
8663
|
+
value: variant === "result" ? currentQuestionResult?.selectedOptions[0]?.optionId || "" : currentAnswer?.optionId || "",
|
|
8664
|
+
selectedValue: variant === "result" ? currentQuestionResult?.selectedOptions[0]?.optionId || "" : currentAnswer?.optionId || "",
|
|
8652
8665
|
onValueChange: (value) => {
|
|
8653
8666
|
if (currentQuestion) {
|
|
8654
8667
|
selectAnswer(currentQuestion.id, value);
|
|
@@ -8693,15 +8706,16 @@ var QuizMultipleChoice = ({ paddingBottom }) => {
|
|
|
8693
8706
|
prevSelectedValuesRef.current = selectedValues;
|
|
8694
8707
|
return selectedValues;
|
|
8695
8708
|
}
|
|
8696
|
-
if (variant == "result"
|
|
8697
|
-
return currentQuestionResult?.
|
|
8709
|
+
if (variant == "result") {
|
|
8710
|
+
return currentQuestionResult?.selectedOptions.map((op) => op.optionId) || [];
|
|
8711
|
+
} else {
|
|
8712
|
+
return prevSelectedValuesRef.current;
|
|
8698
8713
|
}
|
|
8699
|
-
return prevSelectedValuesRef.current;
|
|
8700
8714
|
}, [
|
|
8701
8715
|
selectedValues,
|
|
8702
8716
|
currentQuestion?.id,
|
|
8703
8717
|
variant,
|
|
8704
|
-
currentQuestionResult?.
|
|
8718
|
+
currentQuestionResult?.selectedOptions
|
|
8705
8719
|
]);
|
|
8706
8720
|
const handleSelectedValues = useCallback4(
|
|
8707
8721
|
(values) => {
|
|
@@ -8718,11 +8732,9 @@ var QuizMultipleChoice = ({ paddingBottom }) => {
|
|
|
8718
8732
|
const choices = currentQuestion?.options?.map((option) => {
|
|
8719
8733
|
let status = "neutral" /* NEUTRAL */;
|
|
8720
8734
|
if (variant === "result") {
|
|
8721
|
-
const isCorrectOption =
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
const isSelected = currentQuestionResult?.options.find(
|
|
8725
|
-
(op) => op.id === option.id
|
|
8735
|
+
const isCorrectOption = currentQuestionResult?.options?.find((op) => op.id === option.id)?.isCorrect || false;
|
|
8736
|
+
const isSelected = currentQuestionResult?.selectedOptions?.some(
|
|
8737
|
+
(op) => op.optionId === option.id
|
|
8726
8738
|
);
|
|
8727
8739
|
if (isCorrectOption) {
|
|
8728
8740
|
status = "correct" /* CORRECT */;
|
|
@@ -8998,7 +9010,7 @@ var QuizConnectDots = ({ paddingBottom }) => {
|
|
|
8998
9010
|
}) }) })
|
|
8999
9011
|
] });
|
|
9000
9012
|
};
|
|
9001
|
-
var QuizFill = ({ paddingBottom
|
|
9013
|
+
var QuizFill = ({ paddingBottom }) => {
|
|
9002
9014
|
const { variant } = useQuizStore();
|
|
9003
9015
|
const options = [
|
|
9004
9016
|
"ci\xEAncia",
|
|
@@ -9356,7 +9368,7 @@ var QuizQuestionList = ({
|
|
|
9356
9368
|
([subjectId, questions]) => /* @__PURE__ */ jsxs32("section", { className: "flex flex-col gap-2", children: [
|
|
9357
9369
|
/* @__PURE__ */ jsxs32("span", { className: "pt-6 pb-4 flex flex-row gap-2", children: [
|
|
9358
9370
|
/* @__PURE__ */ jsx39("div", { className: "bg-primary-500 p-1 rounded-sm flex items-center justify-center", children: /* @__PURE__ */ jsx39(BookOpen, { size: 17, className: "text-white" }) }),
|
|
9359
|
-
/* @__PURE__ */ jsx39("p", { className: "text-text-800 font-bold text-lg", children:
|
|
9371
|
+
/* @__PURE__ */ jsx39("p", { className: "text-text-800 font-bold text-lg", children: questions?.[0]?.knowledgeMatrix?.[0]?.subject?.name ?? "Sem mat\xE9ria" })
|
|
9360
9372
|
] }),
|
|
9361
9373
|
/* @__PURE__ */ jsx39("ul", { className: "flex flex-col gap-2", children: questions.map((question) => {
|
|
9362
9374
|
const status = getQuestionStatus(question.id);
|
|
@@ -9787,28 +9799,24 @@ var QuizResultPerformance = forwardRef19(
|
|
|
9787
9799
|
}
|
|
9788
9800
|
);
|
|
9789
9801
|
var QuizListResult = forwardRef19(({ className, onSubjectClick, ...props }, ref) => {
|
|
9790
|
-
const {
|
|
9791
|
-
getQuestionsGroupedBySubject,
|
|
9792
|
-
isQuestionAnswered,
|
|
9793
|
-
getUserAnswerByQuestionId
|
|
9794
|
-
} = useQuizStore();
|
|
9802
|
+
const { getQuestionsGroupedBySubject } = useQuizStore();
|
|
9795
9803
|
const groupedQuestions = getQuestionsGroupedBySubject();
|
|
9796
9804
|
const subjectsStats = Object.entries(groupedQuestions).map(
|
|
9797
9805
|
([subjectId, questions]) => {
|
|
9798
9806
|
let correct = 0;
|
|
9799
9807
|
let incorrect = 0;
|
|
9800
9808
|
questions.forEach((question) => {
|
|
9801
|
-
if (
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
} else {
|
|
9806
|
-
incorrect++;
|
|
9807
|
-
}
|
|
9809
|
+
if (question.answerStatus == "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */) {
|
|
9810
|
+
correct++;
|
|
9811
|
+
} else {
|
|
9812
|
+
incorrect++;
|
|
9808
9813
|
}
|
|
9809
9814
|
});
|
|
9810
9815
|
return {
|
|
9811
|
-
subject:
|
|
9816
|
+
subject: {
|
|
9817
|
+
name: questions?.[0]?.knowledgeMatrix?.[0]?.subject?.name ?? "Sem mat\xE9ria",
|
|
9818
|
+
id: subjectId
|
|
9819
|
+
},
|
|
9812
9820
|
correct,
|
|
9813
9821
|
incorrect,
|
|
9814
9822
|
total: questions.length
|
|
@@ -9820,44 +9828,42 @@ var QuizListResult = forwardRef19(({ className, onSubjectClick, ...props }, ref)
|
|
|
9820
9828
|
/* @__PURE__ */ jsx39("ul", { className: "flex flex-col gap-2", children: subjectsStats.map((subject) => /* @__PURE__ */ jsx39("li", { children: /* @__PURE__ */ jsx39(
|
|
9821
9829
|
CardResults,
|
|
9822
9830
|
{
|
|
9823
|
-
onClick: () => onSubjectClick?.(subject.subject),
|
|
9831
|
+
onClick: () => onSubjectClick?.(subject.subject.id),
|
|
9824
9832
|
className: "max-w-full",
|
|
9825
|
-
header: subject.subject,
|
|
9833
|
+
header: subject.subject.name,
|
|
9826
9834
|
correct_answers: subject.correct,
|
|
9827
9835
|
incorrect_answers: subject.incorrect,
|
|
9828
9836
|
icon: /* @__PURE__ */ jsx39(Book, { size: 20 }),
|
|
9829
9837
|
direction: "row"
|
|
9830
9838
|
}
|
|
9831
|
-
) }, subject.subject)) })
|
|
9839
|
+
) }, subject.subject.id)) })
|
|
9832
9840
|
] });
|
|
9833
9841
|
});
|
|
9834
9842
|
var QuizListResultByMateria = ({
|
|
9835
9843
|
subject,
|
|
9836
9844
|
onQuestionClick
|
|
9837
9845
|
}) => {
|
|
9838
|
-
const {
|
|
9839
|
-
getQuestionsGroupedBySubject,
|
|
9840
|
-
getUserAnswerByQuestionId,
|
|
9841
|
-
getQuestionIndex
|
|
9842
|
-
} = useQuizStore();
|
|
9846
|
+
const { getQuestionsGroupedBySubject, getQuestionIndex } = useQuizStore();
|
|
9843
9847
|
const groupedQuestions = getQuestionsGroupedBySubject();
|
|
9844
9848
|
const answeredQuestions = groupedQuestions[subject] || [];
|
|
9845
9849
|
return /* @__PURE__ */ jsxs32("div", { className: "w-full max-w-[1000px] flex flex-col mx-auto h-full relative not-lg:px-6", children: [
|
|
9846
|
-
/* @__PURE__ */ jsx39("div", { className: "flex flex-row pt-4 justify-between", children: /* @__PURE__ */ jsx39("p", { className: "text-text-950 font-bold text-2xl", children: subject }) }),
|
|
9850
|
+
/* @__PURE__ */ jsx39("div", { className: "flex flex-row pt-4 justify-between", children: /* @__PURE__ */ jsx39("p", { className: "text-text-950 font-bold text-2xl", children: answeredQuestions?.[0]?.knowledgeMatrix?.[0]?.subject?.name ?? "Sem mat\xE9ria" }) }),
|
|
9847
9851
|
/* @__PURE__ */ jsxs32("section", { className: "flex flex-col ", children: [
|
|
9848
9852
|
/* @__PURE__ */ jsx39("p", { className: "pt-6 pb-4 text-text-950 font-bold text-lg", children: "Resultado das quest\xF5es" }),
|
|
9849
9853
|
/* @__PURE__ */ jsx39("ul", { className: "flex flex-col gap-2 pt-4", children: answeredQuestions.map((question) => {
|
|
9850
|
-
const questionIndex = getQuestionIndex(
|
|
9854
|
+
const questionIndex = getQuestionIndex(
|
|
9855
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9856
|
+
question.questionId ?? question.id
|
|
9857
|
+
);
|
|
9851
9858
|
return /* @__PURE__ */ jsx39("li", { children: /* @__PURE__ */ jsx39(
|
|
9852
9859
|
CardStatus,
|
|
9853
9860
|
{
|
|
9854
9861
|
className: "max-w-full",
|
|
9855
9862
|
header: `Quest\xE3o ${questionIndex.toString().padStart(2, "0")}`,
|
|
9856
9863
|
status: (() => {
|
|
9857
|
-
|
|
9858
|
-
if (userAnswer?.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */)
|
|
9864
|
+
if (question.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */)
|
|
9859
9865
|
return "correct";
|
|
9860
|
-
if (
|
|
9866
|
+
if (question.answerStatus === "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */)
|
|
9861
9867
|
return "incorrect";
|
|
9862
9868
|
return void 0;
|
|
9863
9869
|
})(),
|