fix(exam): fix pretest screen start exam button

This commit is contained in:
shafin-r
2025-07-07 21:01:11 +06:00
parent 22eb8285ec
commit d42a42a8d1
10 changed files with 122 additions and 128 deletions

View File

@ -81,7 +81,7 @@ export const ExamProvider: React.FC<{ children: ReactNode }> = ({
const setCurrentExam = (exam: Exam) => {
setCurrentExamState(exam);
// Clear any existing attempt when setting a new exam
setCurrentAttemptState(null);
};
@ -167,6 +167,7 @@ export const ExamProvider: React.FC<{ children: ReactNode }> = ({
...currentAttempt,
endTime: new Date(),
score,
totalQuestions,
passed: currentAttempt.exam.passingScore
? score >= currentAttempt.exam.passingScore
: undefined,
@ -176,7 +177,7 @@ export const ExamProvider: React.FC<{ children: ReactNode }> = ({
return completedAttempt;
};
const clearExam = () => {
const clearExam = (): void => {
setCurrentExamState(null);
setCurrentAttemptState(null);
};
@ -205,10 +206,7 @@ export const ExamProvider: React.FC<{ children: ReactNode }> = ({
return totalQuestions > 0 ? (answeredQuestions / totalQuestions) * 100 : 0;
};
const isExamStarted = (): boolean => {
if (!isHydrated) return false; // ⛔ wait for hydration
return currentAttempt !== null && !currentAttempt.endTime;
};
const isExamStarted = () => !!currentExam && !!currentAttempt;
const isExamCompleted = (): boolean => {
if (!isHydrated) return false; // ⛔ wait for hydration