diff --git a/packages/aila/src/core/quiz/generators/AilaRagQuizGenerator.ts b/packages/aila/src/core/quiz/generators/AilaRagQuizGenerator.ts index c6b434b7..d544e6b3 100644 --- a/packages/aila/src/core/quiz/generators/AilaRagQuizGenerator.ts +++ b/packages/aila/src/core/quiz/generators/AilaRagQuizGenerator.ts @@ -2,6 +2,7 @@ import type { JsonPatchDocument } from "../../../protocol/jsonPatchProtocol"; import type { AilaRagRelevantLesson, Quiz, + QuizPath, QuizQuestion, } from "../../../protocol/schema"; import type { LooseLessonPlan } from "../../../protocol/schema"; @@ -14,10 +15,11 @@ export class AilaRagQuizGenerator extends BasedOnRagQuizGenerator { async mappedQuizFromAilaRagRelevantLessons( lessonPlan: LooseLessonPlan, ailaRagRelevantLessons: AilaRagRelevantLesson[], + quizType: QuizPath = "/starterQuiz", ): Promise { // TODO: MG - This is a load of DB queries and may make it spiky. const quizPromises = ailaRagRelevantLessons.map((relevantLesson) => - this.questionArrayFromPlanId(relevantLesson.lessonPlanId), + this.questionArrayFromPlanId(relevantLesson.lessonPlanId, quizType), ); const quizzes = await Promise.all(quizPromises); @@ -31,6 +33,7 @@ export class AilaRagQuizGenerator extends BasedOnRagQuizGenerator { return await this.mappedQuizFromAilaRagRelevantLessons( lessonPlan, ailaRagRelevantLessons, + "/starterQuiz", ); } @@ -42,6 +45,7 @@ export class AilaRagQuizGenerator extends BasedOnRagQuizGenerator { return await this.mappedQuizFromAilaRagRelevantLessons( lessonPlan, ailaRagRelevantLessons, + "/exitQuiz", ); } } diff --git a/packages/aila/src/core/quiz/generators/BaseQuizGenerator.ts b/packages/aila/src/core/quiz/generators/BaseQuizGenerator.ts index 9d748aa9..5d02e30e 100644 --- a/packages/aila/src/core/quiz/generators/BaseQuizGenerator.ts +++ b/packages/aila/src/core/quiz/generators/BaseQuizGenerator.ts @@ -192,16 +192,14 @@ export abstract class BaseQuizGenerator implements AilaQuizGeneratorService { public async questionArrayFromPlanId( planId: string, + quizType: QuizPath = "/starterQuiz", ): Promise { // const lessonSlug = await this.getLessonSlugFromPlanId(planId); // const lessonSlugList = lessonSlug ? [lessonSlug] : []; // const customIds = await this.lessonSlugToQuestionIdSearch(lessonSlugList); // const quizQuestions = await this.questionArrayFromCustomIds(customIds); // return quizQuestions; - return await this.questionArrayFromPlanIdLookUpTable( - planId, - "/starterQuiz", - ); + return await this.questionArrayFromPlanIdLookUpTable(planId, quizType); } public async searchQuestions( diff --git a/packages/aila/src/core/quiz/generators/BasedOnRagQuizGenerator.ts b/packages/aila/src/core/quiz/generators/BasedOnRagQuizGenerator.ts index 8dc5090a..fa75c195 100644 --- a/packages/aila/src/core/quiz/generators/BasedOnRagQuizGenerator.ts +++ b/packages/aila/src/core/quiz/generators/BasedOnRagQuizGenerator.ts @@ -25,7 +25,12 @@ export class BasedOnRagQuizGenerator extends BaseQuizGenerator { if (!lessonPlan.basedOn?.id) { throw new Error("Lesson plan basedOn is undefined"); } - return [await this.questionArrayFromPlanId(lessonPlan.basedOn?.id)]; + return [ + await this.questionArrayFromPlanId( + lessonPlan.basedOn?.id, + "/starterQuiz", + ), + ]; } async generateMathsExitQuizPatch( @@ -40,6 +45,8 @@ export class BasedOnRagQuizGenerator extends BaseQuizGenerator { if (!lessonPlan.basedOn?.id) { throw new Error("Lesson plan basedOn is undefined"); } - return [await this.questionArrayFromPlanId(lessonPlan.basedOn?.id)]; + return [ + await this.questionArrayFromPlanId(lessonPlan.basedOn?.id, "/exitQuiz"), + ]; } }