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.mjs CHANGED
@@ -9607,8 +9607,53 @@ var getQuestionStatusBadgeConfig = (status) => {
9607
9607
  };
9608
9608
  return configs[status] ?? defaultConfig;
9609
9609
  };
9610
+ var canAutoValidate = (questionData) => {
9611
+ const { result } = questionData;
9612
+ if (result.questionType === "DISSERTATIVA" /* DISSERTATIVA */) {
9613
+ return false;
9614
+ }
9615
+ return true;
9616
+ };
9617
+ var hasIsCorrect = (op) => {
9618
+ return op.isCorrect != null;
9619
+ };
9620
+ var validateAlternativa = (selected, options) => {
9621
+ if (selected.size !== 1) return "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */;
9622
+ const [selectedId] = selected;
9623
+ return options.find((o) => o.id === selectedId)?.isCorrect ? "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */ : "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */;
9624
+ };
9625
+ var validateMultiplaEscolha = (selected, options) => {
9626
+ const allMatch = options.every((op) => selected.has(op.id) === op.isCorrect);
9627
+ return allMatch ? "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */ : "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */;
9628
+ };
9629
+ var validateVerdadeiroFalso = validateMultiplaEscolha;
9630
+ var validators = {
9631
+ ["ALTERNATIVA" /* ALTERNATIVA */]: validateAlternativa,
9632
+ ["MULTIPLA_ESCOLHA" /* MULTIPLA_ESCOLHA */]: validateMultiplaEscolha,
9633
+ ["VERDADEIRO_FALSO" /* VERDADEIRO_FALSO */]: validateVerdadeiroFalso
9634
+ };
9635
+ var autoValidateQuestion = (questionData) => {
9636
+ const { result } = questionData;
9637
+ if (!canAutoValidate(questionData) || !result.options) return null;
9638
+ const validOptions = result.options.filter(hasIsCorrect);
9639
+ if (validOptions.length === 0) return null;
9640
+ const selected = new Set(
9641
+ result.selectedOptions?.map((o) => o.optionId) ?? []
9642
+ );
9643
+ if (selected.size === 0) return "NAO_RESPONDIDO" /* NAO_RESPONDIDO */;
9644
+ const validator = validators[result.questionType];
9645
+ if (!validator) return null;
9646
+ return validator(selected, validOptions);
9647
+ };
9610
9648
  var getQuestionStatusFromData = (questionData) => {
9611
- return mapAnswerStatusToQuestionStatus(questionData.result.answerStatus);
9649
+ const { result } = questionData;
9650
+ if (result.answerStatus === "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && canAutoValidate(questionData)) {
9651
+ const autoValidatedStatus = autoValidateQuestion(questionData);
9652
+ if (autoValidatedStatus !== null) {
9653
+ return mapAnswerStatusToQuestionStatus(autoValidatedStatus);
9654
+ }
9655
+ }
9656
+ return mapAnswerStatusToQuestionStatus(result.answerStatus);
9612
9657
  };
9613
9658
 
9614
9659
  // src/utils/studentActivityCorrection/converter.ts
@@ -9958,12 +10003,15 @@ var renderQuestionAlternative = ({
9958
10003
  question,
9959
10004
  result
9960
10005
  }) => {
10006
+ const hasAutoValidation = result?.options?.some(
10007
+ (op) => op.isCorrect !== void 0 && op.isCorrect !== null
10008
+ );
9961
10009
  const alternatives = question.options?.map((option) => {
9962
10010
  const isCorrectOption = result?.options?.find((op) => op.id === option.id)?.isCorrect || false;
9963
10011
  const isSelected = result?.selectedOptions?.some(
9964
10012
  (selectedOption) => selectedOption.optionId === option.id
9965
10013
  ) || false;
9966
- const shouldShowCorrectAnswers = result?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */;
10014
+ const shouldShowCorrectAnswers = result?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ || hasAutoValidation;
9967
10015
  let status;
9968
10016
  if (shouldShowCorrectAnswers) {
9969
10017
  if (isCorrectOption) {
@@ -10137,12 +10185,15 @@ var renderQuestionMultipleChoice = ({
10137
10185
  question,
10138
10186
  result
10139
10187
  }) => {
10188
+ const hasAutoValidation = result?.options?.some(
10189
+ (op) => op.isCorrect !== void 0 && op.isCorrect !== null
10190
+ );
10140
10191
  const choices = question.options?.map((option) => {
10141
10192
  const isCorrectOption = result?.options?.find((op) => op.id === option.id)?.isCorrect || false;
10142
10193
  const isSelected = result?.selectedOptions?.some(
10143
10194
  (op) => op.optionId === option.id
10144
10195
  );
10145
- const shouldShowCorrectAnswers = result?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && result?.answerStatus !== "NAO_RESPONDIDO" /* NAO_RESPONDIDO */;
10196
+ const shouldShowCorrectAnswers = result?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && result?.answerStatus !== "NAO_RESPONDIDO" /* NAO_RESPONDIDO */ || hasAutoValidation;
10146
10197
  let status;
10147
10198
  if (shouldShowCorrectAnswers) {
10148
10199
  if (isCorrectOption) {
@@ -14658,9 +14709,9 @@ var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
14658
14709
  ActivityType2["ATIVIDADE"] = "ATIVIDADE";
14659
14710
  return ActivityType2;
14660
14711
  })(ActivityType || {});
14661
- var ActivityStatus = /* @__PURE__ */ ((ActivityStatus2) => {
14662
- ActivityStatus2["A_VENCER"] = "A_VENCER";
14663
- return ActivityStatus2;
14712
+ var ActivityStatus = /* @__PURE__ */ ((ActivityStatus3) => {
14713
+ ActivityStatus3["A_VENCER"] = "A_VENCER";
14714
+ return ActivityStatus3;
14664
14715
  })(ActivityStatus || {});
14665
14716
 
14666
14717
  // src/components/ActivityCreate/ActivityCreate.utils.ts
@@ -27210,6 +27261,182 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27210
27261
  token
27211
27262
  };
27212
27263
  };
27264
+
27265
+ // src/types/activities.ts
27266
+ var ActivityStatus2 = /* @__PURE__ */ ((ActivityStatus3) => {
27267
+ ActivityStatus3["MODELO"] = "MODELO";
27268
+ ActivityStatus3["NAO_INICIADA"] = "NAO_INICIADA";
27269
+ ActivityStatus3["EM_ANDAMENTO"] = "EM_ANDAMENTO";
27270
+ ActivityStatus3["CONCLUIDA"] = "CONCLUIDA";
27271
+ return ActivityStatus3;
27272
+ })(ActivityStatus2 || {});
27273
+ var ActivityFilter = /* @__PURE__ */ ((ActivityFilter2) => {
27274
+ ActivityFilter2["NEAR"] = "NEAR";
27275
+ ActivityFilter2["CONCLUDED"] = "CONCLUDED";
27276
+ return ActivityFilter2;
27277
+ })(ActivityFilter || {});
27278
+ var CalendarActivityStatus = /* @__PURE__ */ ((CalendarActivityStatus2) => {
27279
+ CalendarActivityStatus2["NEAR_DEADLINE"] = "near-deadline";
27280
+ CalendarActivityStatus2["OVERDUE"] = "overdue";
27281
+ CalendarActivityStatus2["IN_DEADLINE"] = "in-deadline";
27282
+ return CalendarActivityStatus2;
27283
+ })(CalendarActivityStatus || {});
27284
+
27285
+ // src/hooks/useSendActivity.ts
27286
+ import { useState as useState54, useCallback as useCallback32, useMemo as useMemo30, useRef as useRef30 } from "react";
27287
+ import dayjs6 from "dayjs";
27288
+ function transformToCategoryConfig(data) {
27289
+ return [
27290
+ {
27291
+ key: "escola",
27292
+ label: "Escola",
27293
+ itens: data.schools,
27294
+ selectedIds: []
27295
+ },
27296
+ {
27297
+ key: "serie",
27298
+ label: "S\xE9rie",
27299
+ dependsOn: ["escola"],
27300
+ itens: data.schoolYears,
27301
+ filteredBy: [{ key: "escola", internalField: "escolaId" }],
27302
+ selectedIds: []
27303
+ },
27304
+ {
27305
+ key: "turma",
27306
+ label: "Turma",
27307
+ dependsOn: ["escola", "serie"],
27308
+ itens: data.classes,
27309
+ filteredBy: [
27310
+ { key: "escola", internalField: "escolaId" },
27311
+ { key: "serie", internalField: "serieId" }
27312
+ ],
27313
+ selectedIds: []
27314
+ },
27315
+ {
27316
+ key: "alunos",
27317
+ label: "Aluno",
27318
+ dependsOn: ["escola", "serie", "turma"],
27319
+ itens: data.students,
27320
+ filteredBy: [
27321
+ { key: "escola", internalField: "escolaId" },
27322
+ { key: "serie", internalField: "serieId" },
27323
+ { key: "turma", internalField: "turmaId" }
27324
+ ],
27325
+ selectedIds: []
27326
+ }
27327
+ ];
27328
+ }
27329
+ function toISODateTime(date, time) {
27330
+ return dayjs6(`${date}T${time}`).toISOString();
27331
+ }
27332
+ function useSendActivity(config) {
27333
+ const {
27334
+ fetchCategories,
27335
+ createActivity,
27336
+ sendToStudents,
27337
+ fetchQuestionIds,
27338
+ onSuccess,
27339
+ onError
27340
+ } = config;
27341
+ const [isOpen, setIsOpen] = useState54(false);
27342
+ const [selectedModel, setSelectedModel] = useState54(
27343
+ null
27344
+ );
27345
+ const [categories, setCategories] = useState54([]);
27346
+ const [isLoading, setIsLoading] = useState54(false);
27347
+ const [isCategoriesLoading, setIsCategoriesLoading] = useState54(false);
27348
+ const categoriesLoadedRef = useRef30(false);
27349
+ const initialData = useMemo30(() => {
27350
+ if (!selectedModel) return void 0;
27351
+ return {
27352
+ title: selectedModel.title
27353
+ };
27354
+ }, [selectedModel]);
27355
+ const loadCategories = useCallback32(async () => {
27356
+ if (categoriesLoadedRef.current) return;
27357
+ setIsCategoriesLoading(true);
27358
+ try {
27359
+ const data = await fetchCategories();
27360
+ const categoryConfig = transformToCategoryConfig(data);
27361
+ setCategories(categoryConfig);
27362
+ categoriesLoadedRef.current = true;
27363
+ } catch (error) {
27364
+ console.error("Error loading categories:", error);
27365
+ onError?.("Erro ao carregar destinat\xE1rios");
27366
+ } finally {
27367
+ setIsCategoriesLoading(false);
27368
+ }
27369
+ }, [fetchCategories, onError]);
27370
+ const openModal = useCallback32(
27371
+ (model) => {
27372
+ setSelectedModel(model);
27373
+ setIsOpen(true);
27374
+ void loadCategories();
27375
+ },
27376
+ [loadCategories]
27377
+ );
27378
+ const closeModal = useCallback32(() => {
27379
+ setIsOpen(false);
27380
+ setSelectedModel(null);
27381
+ }, []);
27382
+ const onCategoriesChange = useCallback32(
27383
+ (updatedCategories) => {
27384
+ setCategories(updatedCategories);
27385
+ },
27386
+ []
27387
+ );
27388
+ const handleSubmit = useCallback32(
27389
+ async (data) => {
27390
+ if (!selectedModel) return;
27391
+ setIsLoading(true);
27392
+ try {
27393
+ const questionIds = await fetchQuestionIds(selectedModel.id);
27394
+ if (!questionIds || questionIds.length === 0) {
27395
+ throw new Error("N\xE3o foi poss\xEDvel obter quest\xF5es do modelo");
27396
+ }
27397
+ const createResponse = await createActivity({
27398
+ title: data.title,
27399
+ subjectId: selectedModel.subjectId,
27400
+ questionIds,
27401
+ subtype: data.subtype,
27402
+ notification: data.notification,
27403
+ startDate: toISODateTime(data.startDate, data.startTime),
27404
+ finalDate: toISODateTime(data.finalDate, data.finalTime),
27405
+ canRetry: data.canRetry
27406
+ });
27407
+ await sendToStudents(createResponse.id, data.students);
27408
+ onSuccess?.(`Atividade enviada para ${data.students.length} aluno(s)`);
27409
+ closeModal();
27410
+ } catch (error) {
27411
+ console.error("Error sending activity:", error);
27412
+ onError?.("Erro ao enviar atividade");
27413
+ } finally {
27414
+ setIsLoading(false);
27415
+ }
27416
+ },
27417
+ [
27418
+ selectedModel,
27419
+ fetchQuestionIds,
27420
+ createActivity,
27421
+ sendToStudents,
27422
+ onSuccess,
27423
+ onError,
27424
+ closeModal
27425
+ ]
27426
+ );
27427
+ return {
27428
+ isOpen,
27429
+ openModal,
27430
+ closeModal,
27431
+ selectedModel,
27432
+ initialData,
27433
+ categories,
27434
+ onCategoriesChange,
27435
+ isLoading,
27436
+ isCategoriesLoading,
27437
+ handleSubmit
27438
+ };
27439
+ }
27213
27440
  export {
27214
27441
  ACTIVITY_AVAILABILITY,
27215
27442
  ACTIVITY_FILTER_STATUS_OPTIONS,
@@ -27223,6 +27450,7 @@ export {
27223
27450
  ActivityDetails,
27224
27451
  GenericDisplayStatus as ActivityDisplayStatus,
27225
27452
  ActivityDraftType,
27453
+ ActivityFilter,
27226
27454
  ActivityFilters,
27227
27455
  ActivityFiltersPopover,
27228
27456
  ActivityPreview,
@@ -27240,6 +27468,7 @@ export {
27240
27468
  CHAT_MESSAGE_TYPES,
27241
27469
  QUESTION_STATUS2 as CORRECTION_QUESTION_STATUS,
27242
27470
  Calendar_default as Calendar,
27471
+ CalendarActivityStatus,
27243
27472
  CardAccordation,
27244
27473
  CardActivitiesResults,
27245
27474
  CardAudio,
@@ -27278,6 +27507,7 @@ export {
27278
27507
  FilterModal,
27279
27508
  GOAL_FILTER_STATUS_OPTIONS,
27280
27509
  GOAL_STATUS_OPTIONS,
27510
+ ActivityStatus2 as GeneralActivityStatus,
27281
27511
  GenericApiStatus as GoalApiStatus,
27282
27512
  BadgeActionType as GoalBadgeActionType,
27283
27513
  GenericDisplayStatus as GoalDisplayStatus,
@@ -27490,6 +27720,7 @@ export {
27490
27720
  useQuestionsPdfPrint,
27491
27721
  useQuizStore,
27492
27722
  useRouteAuth,
27723
+ useSendActivity,
27493
27724
  useSendActivityModal,
27494
27725
  useTableFilter,
27495
27726
  useTableSort,