UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

366 lines 12.3 kB
import { QuizVariant } from '../Quiz.types/index'; export declare enum QUESTION_DIFFICULTY { FACIL = "FACIL", MEDIO = "MEDIO", DIFICIL = "DIFICIL" } export declare enum QUIZ_TYPE { SIMULADO = "SIMULADO", QUESTIONARIO = "QUESTIONARIO", ATIVIDADE = "ATIVIDADE", AULA_RECOMENDADA = "AULA_RECOMENDADA" } export declare enum QUESTION_TYPE { ALTERNATIVA = "ALTERNATIVA", DISSERTATIVA = "DISSERTATIVA", MULTIPLA_ESCOLHA = "MULTIPLA_ESCOLHA", VERDADEIRO_FALSO = "VERDADEIRO_FALSO", RELACIONAR = "RELACIONAR", PREENCHER_LACUNAS = "PREENCHER_LACUNAS", IMAGEM = "IMAGEM" } /** * Determines if a user answer has meaningful content. * For option-based questions: checks if optionId is not null * For multiple choice questions: checks if selectedOptionIds has items * For free-text questions (DISSERTATIVA): checks if answer is non-empty string * For structured questions (RELACIONAR, PREENCHER_LACUNAS): checks if answer is valid JSON with values * * @param answer - The user answer item to check (can be null/undefined) * @returns true if the answer has meaningful content, false otherwise */ export declare const hasMeaningfulAnswer: (answer: { optionId: string | null; answer: string | null; questionType: QUESTION_TYPE; selectedOptionIds?: string[] | null; } | null | undefined) => boolean; export declare enum QUESTION_STATUS { PENDENTE_AVALIACAO = "PENDENTE_AVALIACAO", RESPOSTA_CORRETA = "RESPOSTA_CORRETA", RESPOSTA_INCORRETA = "RESPOSTA_INCORRETA", NAO_RESPONDIDO = "NAO_RESPONDIDO" } export declare enum ANSWER_STATUS { RESPOSTA_CORRETA = "RESPOSTA_CORRETA", RESPOSTA_INCORRETA = "RESPOSTA_INCORRETA", PENDENTE_AVALIACAO = "PENDENTE_AVALIACAO", NAO_RESPONDIDO = "NAO_RESPONDIDO" } export declare enum SUBTYPE_ENUM { PROVA = "PROVA", ENEM_PROVA_1 = "ENEM_PROVA_1", ENEM_PROVA_2 = "ENEM_PROVA_2", VESTIBULAR = "VESTIBULAR", SIMULADO = "SIMULADO", SIMULADAO = "SIMULADAO" } export interface QuestionResult { answers: { id: string; questionId: string; answer: string | null; selectedOptions: { optionId: string; option?: string; isCorrect?: boolean; correctValue?: string | null; }[]; answerStatus: ANSWER_STATUS; statement: string; additionalContent: string | null; questionType: QUESTION_TYPE; difficultyLevel: QUESTION_DIFFICULTY; solutionExplanation: string | null; correctOption: string; createdAt: string; updatedAt: string; options?: { id: string; option: string; isCorrect: boolean; correctValue?: string | null; }[]; matchingAnswers?: { optionId: string; selectedValue: string; }[]; fillAnswers?: Record<string, string>; knowledgeMatrix: { areaKnowledge: { id: string; name: string; } | null; subject: { id: string; name: string; color: string; icon: string; } | null; topic: { id: string; name: string; } | null; subtopic: { id: string; name: string; } | null; content: { id: string; name: string; } | null; }[]; teacherFeedback: string | null; attachment: string | null; score: number | null; gradedAt: string | null; gradedBy: string | null; }[]; statistics: { totalAnswered: number; correctAnswers: number; incorrectAnswers: number; pendingAnswers: number; score: number; timeSpent: number; }; } export interface Question { id: string; statement: string; questionType: QUESTION_TYPE; difficultyLevel: QUESTION_DIFFICULTY; description: string; examBoard: string | null; examYear: string | null; solutionExplanation: string | null; additionalContent: string | null; answer: null; answerStatus: ANSWER_STATUS; options: { id: string; option: string; correctValue?: string | null; }[]; knowledgeMatrix: { areaKnowledge: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; content: { id: string; name: string; }; }[]; correctOptionIds?: string[]; } export interface QuizInterface { id: string; title: string; type: QUIZ_TYPE; subtype: SUBTYPE_ENUM | string; difficulty: string | null; notification: string | null; status: string; startDate: string | null; finalDate: string | null; canRetry: boolean; createdAt: string | null; updatedAt: string | null; questions: Question[]; } export interface UserAnswerItem { questionId: string; activityId: string; userId: string; answer: string | null; optionId: string | null; selectedOptionIds?: string[] | null; questionType: QUESTION_TYPE; answerStatus: ANSWER_STATUS; } /** * Draft answer item from the backend API * Used when loading saved drafts */ export interface DraftAnswerItem { questionId: string; answer: string | null; optionId: string | null; selectedOptionIds?: string[] | null; fillAnswers?: Record<string, string> | null; matchingAnswers?: Array<{ optionId: string; selectedValue: string; }> | null; imageAnswer?: { coordinateX: number; coordinateY: number; } | null; sequence?: number; timeSpent?: number; } /** * Payload for saving drafts to the backend */ export interface SaveDraftPayload { answers: Array<{ questionId: string; answer?: string | null; optionId?: string | null; selectedOptionIds?: string[] | null; fillAnswers?: Record<string, string> | null; matchingAnswers?: Array<{ optionId: string; selectedValue: string; }> | null; imageAnswer?: { coordinateX: number; coordinateY: number; } | null; }>; } /** * API client interface for draft operations * Pass this to the store to enable auto-save functionality */ export interface DraftApiClient { saveDraft: (activityId: string, payload: SaveDraftPayload) => Promise<{ success: boolean; }>; loadDraft: (activityId: string) => Promise<{ hasDraft: boolean; answers: DraftAnswerItem[]; } | null>; } export interface QuizState { quiz: QuizInterface | null; currentQuestionIndex: number; selectedAnswers: Record<string, string>; userAnswers: UserAnswerItem[]; timeElapsed: number; isStarted: boolean; isFinished: boolean; userId: string; variant: QuizVariant; minuteCallback: (() => void) | null; dissertativeCharLimit?: number; timeLimit: number | null; onTimeUp: (() => void) | null; setQuiz: (quiz: QuizInterface) => void; setQuestionResult: (questionResult: QuestionResult) => void; setUserId: (userId: string) => void; setUserAnswers: (userAnswers: UserAnswerItem[]) => void; setVariant: (variant: QuizVariant) => void; setDissertativeCharLimit: (limit?: number) => void; getDissertativeCharLimit: () => number | undefined; goToNextQuestion: () => void; goToPreviousQuestion: () => void; goToQuestion: (index: number) => void; selectAnswer: (questionId: string, answerId: string) => void; selectMultipleAnswer: (questionId: string, answerIds: string[]) => void; selectDissertativeAnswer: (questionId: string, answer: string) => void; skipQuestion: () => void; skipCurrentQuestionIfUnanswered: () => void; addUserAnswer: (questionId: string, answerId?: string) => void; startQuiz: () => void; finishQuiz: () => void; resetQuiz: () => void; updateTime: (time: number) => void; startTimer: () => void; stopTimer: () => void; setTimeLimit: (seconds: number | null) => void; setOnTimeUp: (callback: (() => void) | null) => void; getRemainingTime: () => number | null; setMinuteCallback: (callback: (() => void) | null) => void; startMinuteCallback: () => void; stopMinuteCallback: () => void; getCurrentQuestion: () => Question | null; getTotalQuestions: () => number; getAnsweredQuestions: () => number; getUnansweredQuestions: () => number[]; getSkippedQuestions: () => number; getProgress: () => number; isQuestionAnswered: (questionId: string) => boolean; isQuestionSkipped: (questionId: string) => boolean; getCurrentAnswer: () => UserAnswerItem | undefined; getAllCurrentAnswer: () => UserAnswerItem[] | undefined; getQuizTitle: () => string; formatTime: (seconds: number) => string; getUserAnswers: () => UserAnswerItem[]; getUnansweredQuestionsFromUserAnswers: () => number[]; getQuestionsGroupedBySubject: () => { [key: string]: (Question | QuestionResult['answers'][number])[]; }; getUserId: () => string; setCurrentQuestion: (question: Question) => void; getQuestionIndex: (questionId: string) => number; getUserAnswerByQuestionId: (questionId: string) => UserAnswerItem | null; isQuestionAnsweredByUserAnswers: (questionId: string) => boolean; getQuestionStatusFromUserAnswers: (questionId: string) => 'answered' | 'unanswered' | 'skipped'; getUserAnswersForActivity: () => UserAnswerItem[]; setAnswerStatus: (questionId: string, status: ANSWER_STATUS) => void; getAnswerStatus: (questionId: string) => ANSWER_STATUS | null; questionsResult: QuestionResult | null; currentQuestionResult: QuestionResult['answers'] | null; setQuestionsResult: (questionsResult: QuestionResult) => void; setCurrentQuestionResult: (currentQuestionResult: QuestionResult['answers']) => void; getQuestionResultByQuestionId: (questionId: string) => QuestionResult['answers'][number] | null; getQuestionResultStatistics: () => QuestionResult['statistics'] | null; getQuestionResult: () => QuestionResult | null; getCurrentQuestionResult: () => QuestionResult['answers'] | null; applyDraftAnswers: (draftAnswers: DraftAnswerItem[]) => void; prepareDraftPayload: () => SaveDraftPayload; hasDraftChanges: () => boolean; draftApiClient: DraftApiClient | null; setDraftApiClient: (client: DraftApiClient | null) => void; saveDraft: () => Promise<void>; loadAndApplyDraft: () => Promise<void>; lastSavedDraftPayload: string; isSavingDraft: boolean; activityFeedback: { teacherFeedback: string | null; attachment: string | null; } | null; setActivityFeedback: (feedback: { teacherFeedback: string | null; attachment: string | null; } | null) => void; getActivityFeedback: () => { teacherFeedback: string | null; attachment: string | null; } | null; } export declare const MINUTE_INTERVAL_MS = 60000; export declare const useQuizStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<QuizState>, "setState" | "devtools"> & { setState(partial: QuizState | Partial<QuizState> | ((state: QuizState) => QuizState | Partial<QuizState>), replace?: false | undefined, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; setState(state: QuizState | ((state: QuizState) => QuizState), replace: true, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; devtools: { cleanup: () => void; }; }>; //# sourceMappingURL=useQuizStore.d.ts.map