diff --git a/src/components/AIQuiz/AIMCQQuestion.tsx b/src/components/AIQuiz/AIMCQQuestion.tsx
index a4819e026..9ce07461b 100644
--- a/src/components/AIQuiz/AIMCQQuestion.tsx
+++ b/src/components/AIQuiz/AIMCQQuestion.tsx
@@ -14,11 +14,20 @@ type AIMCQQuestionProps = {
setSelectedOptions: (options: number[]) => void;
onSubmit: (status: QuestionState['status']) => void;
onNext: () => void;
+ isLastQuestion: boolean;
+ onComplete: () => void;
};
export function AIMCQQuestion(props: AIMCQQuestionProps) {
- const { question, questionState, setSelectedOptions, onSubmit, onNext } =
- props;
+ const {
+ question,
+ questionState,
+ setSelectedOptions,
+ onSubmit,
+ onNext,
+ isLastQuestion,
+ onComplete,
+ } = props;
const { title: questionText, options, answerExplanation } = question;
const { isSubmitted, selectedOptions = [] } = questionState;
@@ -45,7 +54,11 @@ export function AIMCQQuestion(props: AIMCQQuestionProps) {
const handleSubmit = () => {
if (isSubmitted) {
- onNext?.();
+ if (isLastQuestion) {
+ onComplete();
+ } else {
+ onNext();
+ }
return;
}
@@ -143,7 +156,11 @@ export function AIMCQQuestion(props: AIMCQQuestionProps) {
onClick={handleSubmit}
disabled={!canSubmit}
>
- {isSubmitted ? 'Next Question' : 'Submit Answer'}
+ {isSubmitted
+ ? isLastQuestion
+ ? 'Finish Quiz'
+ : 'Next Question'
+ : 'Submit Answer'}
);
diff --git a/src/components/AIQuiz/AIOpenEndedQuestion.tsx b/src/components/AIQuiz/AIOpenEndedQuestion.tsx
index 293d734a9..c3d797e71 100644
--- a/src/components/AIQuiz/AIOpenEndedQuestion.tsx
+++ b/src/components/AIQuiz/AIOpenEndedQuestion.tsx
@@ -20,6 +20,9 @@ type AIOpenEndedQuestionProps = {
setUserAnswer: (answer: string) => void;
setCorrectAnswer: (answer: string) => void;
+
+ isLastQuestion: boolean;
+ onComplete: () => void;
};
export function AIOpenEndedQuestion(props: AIOpenEndedQuestionProps) {
@@ -31,6 +34,8 @@ export function AIOpenEndedQuestion(props: AIOpenEndedQuestionProps) {
onNext,
setUserAnswer,
setCorrectAnswer,
+ isLastQuestion,
+ onComplete,
} = props;
const { title: questionText } = question;
@@ -63,7 +68,11 @@ export function AIOpenEndedQuestion(props: AIOpenEndedQuestionProps) {
const handleSubmit = async () => {
if (isSubmitted) {
- onNext?.();
+ if (isLastQuestion) {
+ onComplete();
+ } else {
+ onNext();
+ }
return;
}
@@ -126,7 +135,11 @@ export function AIOpenEndedQuestion(props: AIOpenEndedQuestionProps) {
{isVerifying ? (