generated from muhtadeetaron/nextjs-template
fix(exam): fix pretest screen start exam button
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user