analytica-frontend-lib 1.2.68 → 1.2.70

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.
Files changed (55) hide show
  1. package/dist/ActivityCardQuestionBanks/index.js +8 -2
  2. package/dist/ActivityCardQuestionBanks/index.js.map +1 -1
  3. package/dist/ActivityCardQuestionBanks/index.mjs +8 -2
  4. package/dist/ActivityCardQuestionBanks/index.mjs.map +1 -1
  5. package/dist/ActivityCardQuestionPreview/index.js +8 -2
  6. package/dist/ActivityCardQuestionPreview/index.js.map +1 -1
  7. package/dist/ActivityCardQuestionPreview/index.mjs +8 -2
  8. package/dist/ActivityCardQuestionPreview/index.mjs.map +1 -1
  9. package/dist/ActivityDetails/index.js +54 -3
  10. package/dist/ActivityDetails/index.js.map +1 -1
  11. package/dist/ActivityDetails/index.mjs +54 -3
  12. package/dist/ActivityDetails/index.mjs.map +1 -1
  13. package/dist/ActivityPreview/index.js +8 -2
  14. package/dist/ActivityPreview/index.js.map +1 -1
  15. package/dist/ActivityPreview/index.mjs +8 -2
  16. package/dist/ActivityPreview/index.mjs.map +1 -1
  17. package/dist/CorrectActivityModal/index.js +54 -3
  18. package/dist/CorrectActivityModal/index.js.map +1 -1
  19. package/dist/CorrectActivityModal/index.mjs +54 -3
  20. package/dist/CorrectActivityModal/index.mjs.map +1 -1
  21. package/dist/hooks/useSendActivity/index.d.ts +47 -0
  22. package/dist/hooks/useSendActivity/index.d.ts.map +1 -0
  23. package/dist/hooks/useSendActivity/index.js +194 -0
  24. package/dist/hooks/useSendActivity/index.js.map +1 -0
  25. package/dist/hooks/useSendActivity/index.mjs +159 -0
  26. package/dist/hooks/useSendActivity/index.mjs.map +1 -0
  27. package/dist/hooks/useSendActivity.d.ts +47 -0
  28. package/dist/hooks/useSendActivity.d.ts.map +1 -0
  29. package/dist/index.d.ts +4 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +241 -6
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +237 -6
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/types/activities/index.d.ts +81 -0
  36. package/dist/types/activities/index.d.ts.map +1 -0
  37. package/dist/types/activities/index.js +52 -0
  38. package/dist/types/activities/index.js.map +1 -0
  39. package/dist/types/activities/index.mjs +25 -0
  40. package/dist/types/activities/index.mjs.map +1 -0
  41. package/dist/types/activities.d.ts +81 -0
  42. package/dist/types/activities.d.ts.map +1 -0
  43. package/dist/types/sendActivity/index.d.ts +127 -0
  44. package/dist/types/sendActivity/index.d.ts.map +1 -0
  45. package/dist/types/sendActivity/index.js +19 -0
  46. package/dist/types/sendActivity/index.js.map +1 -0
  47. package/dist/types/sendActivity/index.mjs +1 -0
  48. package/dist/types/sendActivity/index.mjs.map +1 -0
  49. package/dist/types/sendActivity.d.ts +127 -0
  50. package/dist/types/sendActivity.d.ts.map +1 -0
  51. package/dist/utils/questionRenderer/alternative/index.d.ts.map +1 -1
  52. package/dist/utils/questionRenderer/multipleChoice/index.d.ts.map +1 -1
  53. package/dist/utils/studentActivityCorrection/utils.d.ts +14 -0
  54. package/dist/utils/studentActivityCorrection/utils.d.ts.map +1 -1
  55. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ __export(src_exports, {
42
42
  ActivityDetails: () => ActivityDetails,
43
43
  ActivityDisplayStatus: () => GenericDisplayStatus,
44
44
  ActivityDraftType: () => ActivityDraftType,
45
+ ActivityFilter: () => ActivityFilter,
45
46
  ActivityFilters: () => ActivityFilters,
46
47
  ActivityFiltersPopover: () => ActivityFiltersPopover,
47
48
  ActivityPreview: () => ActivityPreview,
@@ -59,6 +60,7 @@ __export(src_exports, {
59
60
  CHAT_MESSAGE_TYPES: () => CHAT_MESSAGE_TYPES,
60
61
  CORRECTION_QUESTION_STATUS: () => QUESTION_STATUS2,
61
62
  Calendar: () => Calendar_default,
63
+ CalendarActivityStatus: () => CalendarActivityStatus,
62
64
  CardAccordation: () => CardAccordation,
63
65
  CardActivitiesResults: () => CardActivitiesResults,
64
66
  CardAudio: () => CardAudio,
@@ -97,6 +99,7 @@ __export(src_exports, {
97
99
  FilterModal: () => FilterModal,
98
100
  GOAL_FILTER_STATUS_OPTIONS: () => GOAL_FILTER_STATUS_OPTIONS,
99
101
  GOAL_STATUS_OPTIONS: () => GOAL_STATUS_OPTIONS,
102
+ GeneralActivityStatus: () => ActivityStatus2,
100
103
  GoalApiStatus: () => GenericApiStatus,
101
104
  GoalBadgeActionType: () => BadgeActionType,
102
105
  GoalDisplayStatus: () => GenericDisplayStatus,
@@ -309,6 +312,7 @@ __export(src_exports, {
309
312
  useQuestionsPdfPrint: () => useQuestionsPdfPrint,
310
313
  useQuizStore: () => useQuizStore,
311
314
  useRouteAuth: () => useRouteAuth,
315
+ useSendActivity: () => useSendActivity,
312
316
  useSendActivityModal: () => useSendActivityModal,
313
317
  useTableFilter: () => useTableFilter,
314
318
  useTableSort: () => useTableSort,
@@ -9826,8 +9830,53 @@ var getQuestionStatusBadgeConfig = (status) => {
9826
9830
  };
9827
9831
  return configs[status] ?? defaultConfig;
9828
9832
  };
9833
+ var canAutoValidate = (questionData) => {
9834
+ const { result } = questionData;
9835
+ if (result.questionType === "DISSERTATIVA" /* DISSERTATIVA */) {
9836
+ return false;
9837
+ }
9838
+ return true;
9839
+ };
9840
+ var hasIsCorrect = (op) => {
9841
+ return op.isCorrect != null;
9842
+ };
9843
+ var validateAlternativa = (selected, options) => {
9844
+ if (selected.size !== 1) return "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */;
9845
+ const [selectedId] = selected;
9846
+ return options.find((o) => o.id === selectedId)?.isCorrect ? "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */ : "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */;
9847
+ };
9848
+ var validateMultiplaEscolha = (selected, options) => {
9849
+ const allMatch = options.every((op) => selected.has(op.id) === op.isCorrect);
9850
+ return allMatch ? "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */ : "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */;
9851
+ };
9852
+ var validateVerdadeiroFalso = validateMultiplaEscolha;
9853
+ var validators = {
9854
+ ["ALTERNATIVA" /* ALTERNATIVA */]: validateAlternativa,
9855
+ ["MULTIPLA_ESCOLHA" /* MULTIPLA_ESCOLHA */]: validateMultiplaEscolha,
9856
+ ["VERDADEIRO_FALSO" /* VERDADEIRO_FALSO */]: validateVerdadeiroFalso
9857
+ };
9858
+ var autoValidateQuestion = (questionData) => {
9859
+ const { result } = questionData;
9860
+ if (!canAutoValidate(questionData) || !result.options) return null;
9861
+ const validOptions = result.options.filter(hasIsCorrect);
9862
+ if (validOptions.length === 0) return null;
9863
+ const selected = new Set(
9864
+ result.selectedOptions?.map((o) => o.optionId) ?? []
9865
+ );
9866
+ if (selected.size === 0) return "NAO_RESPONDIDO" /* NAO_RESPONDIDO */;
9867
+ const validator = validators[result.questionType];
9868
+ if (!validator) return null;
9869
+ return validator(selected, validOptions);
9870
+ };
9829
9871
  var getQuestionStatusFromData = (questionData) => {
9830
- return mapAnswerStatusToQuestionStatus(questionData.result.answerStatus);
9872
+ const { result } = questionData;
9873
+ if (result.answerStatus === "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && canAutoValidate(questionData)) {
9874
+ const autoValidatedStatus = autoValidateQuestion(questionData);
9875
+ if (autoValidatedStatus !== null) {
9876
+ return mapAnswerStatusToQuestionStatus(autoValidatedStatus);
9877
+ }
9878
+ }
9879
+ return mapAnswerStatusToQuestionStatus(result.answerStatus);
9831
9880
  };
9832
9881
 
9833
9882
  // src/utils/studentActivityCorrection/converter.ts
@@ -10177,12 +10226,15 @@ var renderQuestionAlternative = ({
10177
10226
  question,
10178
10227
  result
10179
10228
  }) => {
10229
+ const hasAutoValidation = result?.options?.some(
10230
+ (op) => op.isCorrect !== void 0 && op.isCorrect !== null
10231
+ );
10180
10232
  const alternatives = question.options?.map((option) => {
10181
10233
  const isCorrectOption = result?.options?.find((op) => op.id === option.id)?.isCorrect || false;
10182
10234
  const isSelected = result?.selectedOptions?.some(
10183
10235
  (selectedOption) => selectedOption.optionId === option.id
10184
10236
  ) || false;
10185
- const shouldShowCorrectAnswers = result?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */;
10237
+ const shouldShowCorrectAnswers = result?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ || hasAutoValidation;
10186
10238
  let status;
10187
10239
  if (shouldShowCorrectAnswers) {
10188
10240
  if (isCorrectOption) {
@@ -10356,12 +10408,15 @@ var renderQuestionMultipleChoice = ({
10356
10408
  question,
10357
10409
  result
10358
10410
  }) => {
10411
+ const hasAutoValidation = result?.options?.some(
10412
+ (op) => op.isCorrect !== void 0 && op.isCorrect !== null
10413
+ );
10359
10414
  const choices = question.options?.map((option) => {
10360
10415
  const isCorrectOption = result?.options?.find((op) => op.id === option.id)?.isCorrect || false;
10361
10416
  const isSelected = result?.selectedOptions?.some(
10362
10417
  (op) => op.optionId === option.id
10363
10418
  );
10364
- const shouldShowCorrectAnswers = result?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && result?.answerStatus !== "NAO_RESPONDIDO" /* NAO_RESPONDIDO */;
10419
+ const shouldShowCorrectAnswers = result?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && result?.answerStatus !== "NAO_RESPONDIDO" /* NAO_RESPONDIDO */ || hasAutoValidation;
10365
10420
  let status;
10366
10421
  if (shouldShowCorrectAnswers) {
10367
10422
  if (isCorrectOption) {
@@ -14846,9 +14901,9 @@ var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
14846
14901
  ActivityType2["ATIVIDADE"] = "ATIVIDADE";
14847
14902
  return ActivityType2;
14848
14903
  })(ActivityType || {});
14849
- var ActivityStatus = /* @__PURE__ */ ((ActivityStatus2) => {
14850
- ActivityStatus2["A_VENCER"] = "A_VENCER";
14851
- return ActivityStatus2;
14904
+ var ActivityStatus = /* @__PURE__ */ ((ActivityStatus3) => {
14905
+ ActivityStatus3["A_VENCER"] = "A_VENCER";
14906
+ return ActivityStatus3;
14852
14907
  })(ActivityStatus || {});
14853
14908
 
14854
14909
  // src/components/ActivityCreate/ActivityCreate.utils.ts
@@ -27338,6 +27393,182 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27338
27393
  token
27339
27394
  };
27340
27395
  };
27396
+
27397
+ // src/types/activities.ts
27398
+ var ActivityStatus2 = /* @__PURE__ */ ((ActivityStatus3) => {
27399
+ ActivityStatus3["MODELO"] = "MODELO";
27400
+ ActivityStatus3["NAO_INICIADA"] = "NAO_INICIADA";
27401
+ ActivityStatus3["EM_ANDAMENTO"] = "EM_ANDAMENTO";
27402
+ ActivityStatus3["CONCLUIDA"] = "CONCLUIDA";
27403
+ return ActivityStatus3;
27404
+ })(ActivityStatus2 || {});
27405
+ var ActivityFilter = /* @__PURE__ */ ((ActivityFilter2) => {
27406
+ ActivityFilter2["NEAR"] = "NEAR";
27407
+ ActivityFilter2["CONCLUDED"] = "CONCLUDED";
27408
+ return ActivityFilter2;
27409
+ })(ActivityFilter || {});
27410
+ var CalendarActivityStatus = /* @__PURE__ */ ((CalendarActivityStatus2) => {
27411
+ CalendarActivityStatus2["NEAR_DEADLINE"] = "near-deadline";
27412
+ CalendarActivityStatus2["OVERDUE"] = "overdue";
27413
+ CalendarActivityStatus2["IN_DEADLINE"] = "in-deadline";
27414
+ return CalendarActivityStatus2;
27415
+ })(CalendarActivityStatus || {});
27416
+
27417
+ // src/hooks/useSendActivity.ts
27418
+ var import_react91 = require("react");
27419
+ var import_dayjs6 = __toESM(require("dayjs"));
27420
+ function transformToCategoryConfig(data) {
27421
+ return [
27422
+ {
27423
+ key: "escola",
27424
+ label: "Escola",
27425
+ itens: data.schools,
27426
+ selectedIds: []
27427
+ },
27428
+ {
27429
+ key: "serie",
27430
+ label: "S\xE9rie",
27431
+ dependsOn: ["escola"],
27432
+ itens: data.schoolYears,
27433
+ filteredBy: [{ key: "escola", internalField: "escolaId" }],
27434
+ selectedIds: []
27435
+ },
27436
+ {
27437
+ key: "turma",
27438
+ label: "Turma",
27439
+ dependsOn: ["escola", "serie"],
27440
+ itens: data.classes,
27441
+ filteredBy: [
27442
+ { key: "escola", internalField: "escolaId" },
27443
+ { key: "serie", internalField: "serieId" }
27444
+ ],
27445
+ selectedIds: []
27446
+ },
27447
+ {
27448
+ key: "alunos",
27449
+ label: "Aluno",
27450
+ dependsOn: ["escola", "serie", "turma"],
27451
+ itens: data.students,
27452
+ filteredBy: [
27453
+ { key: "escola", internalField: "escolaId" },
27454
+ { key: "serie", internalField: "serieId" },
27455
+ { key: "turma", internalField: "turmaId" }
27456
+ ],
27457
+ selectedIds: []
27458
+ }
27459
+ ];
27460
+ }
27461
+ function toISODateTime(date, time) {
27462
+ return (0, import_dayjs6.default)(`${date}T${time}`).toISOString();
27463
+ }
27464
+ function useSendActivity(config) {
27465
+ const {
27466
+ fetchCategories,
27467
+ createActivity,
27468
+ sendToStudents,
27469
+ fetchQuestionIds,
27470
+ onSuccess,
27471
+ onError
27472
+ } = config;
27473
+ const [isOpen, setIsOpen] = (0, import_react91.useState)(false);
27474
+ const [selectedModel, setSelectedModel] = (0, import_react91.useState)(
27475
+ null
27476
+ );
27477
+ const [categories, setCategories] = (0, import_react91.useState)([]);
27478
+ const [isLoading, setIsLoading] = (0, import_react91.useState)(false);
27479
+ const [isCategoriesLoading, setIsCategoriesLoading] = (0, import_react91.useState)(false);
27480
+ const categoriesLoadedRef = (0, import_react91.useRef)(false);
27481
+ const initialData = (0, import_react91.useMemo)(() => {
27482
+ if (!selectedModel) return void 0;
27483
+ return {
27484
+ title: selectedModel.title
27485
+ };
27486
+ }, [selectedModel]);
27487
+ const loadCategories = (0, import_react91.useCallback)(async () => {
27488
+ if (categoriesLoadedRef.current) return;
27489
+ setIsCategoriesLoading(true);
27490
+ try {
27491
+ const data = await fetchCategories();
27492
+ const categoryConfig = transformToCategoryConfig(data);
27493
+ setCategories(categoryConfig);
27494
+ categoriesLoadedRef.current = true;
27495
+ } catch (error) {
27496
+ console.error("Error loading categories:", error);
27497
+ onError?.("Erro ao carregar destinat\xE1rios");
27498
+ } finally {
27499
+ setIsCategoriesLoading(false);
27500
+ }
27501
+ }, [fetchCategories, onError]);
27502
+ const openModal = (0, import_react91.useCallback)(
27503
+ (model) => {
27504
+ setSelectedModel(model);
27505
+ setIsOpen(true);
27506
+ void loadCategories();
27507
+ },
27508
+ [loadCategories]
27509
+ );
27510
+ const closeModal = (0, import_react91.useCallback)(() => {
27511
+ setIsOpen(false);
27512
+ setSelectedModel(null);
27513
+ }, []);
27514
+ const onCategoriesChange = (0, import_react91.useCallback)(
27515
+ (updatedCategories) => {
27516
+ setCategories(updatedCategories);
27517
+ },
27518
+ []
27519
+ );
27520
+ const handleSubmit = (0, import_react91.useCallback)(
27521
+ async (data) => {
27522
+ if (!selectedModel) return;
27523
+ setIsLoading(true);
27524
+ try {
27525
+ const questionIds = await fetchQuestionIds(selectedModel.id);
27526
+ if (!questionIds || questionIds.length === 0) {
27527
+ throw new Error("N\xE3o foi poss\xEDvel obter quest\xF5es do modelo");
27528
+ }
27529
+ const createResponse = await createActivity({
27530
+ title: data.title,
27531
+ subjectId: selectedModel.subjectId,
27532
+ questionIds,
27533
+ subtype: data.subtype,
27534
+ notification: data.notification,
27535
+ startDate: toISODateTime(data.startDate, data.startTime),
27536
+ finalDate: toISODateTime(data.finalDate, data.finalTime),
27537
+ canRetry: data.canRetry
27538
+ });
27539
+ await sendToStudents(createResponse.id, data.students);
27540
+ onSuccess?.(`Atividade enviada para ${data.students.length} aluno(s)`);
27541
+ closeModal();
27542
+ } catch (error) {
27543
+ console.error("Error sending activity:", error);
27544
+ onError?.("Erro ao enviar atividade");
27545
+ } finally {
27546
+ setIsLoading(false);
27547
+ }
27548
+ },
27549
+ [
27550
+ selectedModel,
27551
+ fetchQuestionIds,
27552
+ createActivity,
27553
+ sendToStudents,
27554
+ onSuccess,
27555
+ onError,
27556
+ closeModal
27557
+ ]
27558
+ );
27559
+ return {
27560
+ isOpen,
27561
+ openModal,
27562
+ closeModal,
27563
+ selectedModel,
27564
+ initialData,
27565
+ categories,
27566
+ onCategoriesChange,
27567
+ isLoading,
27568
+ isCategoriesLoading,
27569
+ handleSubmit
27570
+ };
27571
+ }
27341
27572
  // Annotate the CommonJS export names for ESM import in node:
27342
27573
  0 && (module.exports = {
27343
27574
  ACTIVITY_AVAILABILITY,
@@ -27352,6 +27583,7 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27352
27583
  ActivityDetails,
27353
27584
  ActivityDisplayStatus,
27354
27585
  ActivityDraftType,
27586
+ ActivityFilter,
27355
27587
  ActivityFilters,
27356
27588
  ActivityFiltersPopover,
27357
27589
  ActivityPreview,
@@ -27369,6 +27601,7 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27369
27601
  CHAT_MESSAGE_TYPES,
27370
27602
  CORRECTION_QUESTION_STATUS,
27371
27603
  Calendar,
27604
+ CalendarActivityStatus,
27372
27605
  CardAccordation,
27373
27606
  CardActivitiesResults,
27374
27607
  CardAudio,
@@ -27407,6 +27640,7 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27407
27640
  FilterModal,
27408
27641
  GOAL_FILTER_STATUS_OPTIONS,
27409
27642
  GOAL_STATUS_OPTIONS,
27643
+ GeneralActivityStatus,
27410
27644
  GoalApiStatus,
27411
27645
  GoalBadgeActionType,
27412
27646
  GoalDisplayStatus,
@@ -27619,6 +27853,7 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27619
27853
  useQuestionsPdfPrint,
27620
27854
  useQuizStore,
27621
27855
  useRouteAuth,
27856
+ useSendActivity,
27622
27857
  useSendActivityModal,
27623
27858
  useTableFilter,
27624
27859
  useTableSort,