generated from muhtadeetaron/nextjs-template
fix(exam): fix startexam function (not finding examdata)
This commit is contained in:
@ -86,18 +86,21 @@ export const ExamProvider: React.FC<{ children: ReactNode }> = ({
|
||||
setCurrentAttemptState(null);
|
||||
};
|
||||
|
||||
const startExam = () => {
|
||||
if (!currentExam) {
|
||||
const startExam = (exam?: Exam) => {
|
||||
const examToUse = exam || currentExam;
|
||||
|
||||
if (!examToUse) {
|
||||
console.warn("No exam selected, redirecting to /unit");
|
||||
router.push("/unit");
|
||||
return;
|
||||
}
|
||||
|
||||
const attempt: ExamAttempt = {
|
||||
examId: currentExam.id,
|
||||
exam: currentExam,
|
||||
examId: examToUse.id,
|
||||
exam: examToUse,
|
||||
answers: [],
|
||||
startTime: new Date(),
|
||||
totalQuestions: 0,
|
||||
};
|
||||
|
||||
setCurrentAttemptState(attempt);
|
||||
|
||||
Reference in New Issue
Block a user