From 0232686d43ba99201038fccd23cd2d64be4dbbcb Mon Sep 17 00:00:00 2001 From: Gareth Lomax <6199423+gclomax@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:33:34 +0000 Subject: [PATCH] changed to use newly uploaded starter and exit quizzes in based on and rag generators, from generateMathsExitQuizPatch --- .../src/core/quiz/generators/AilaRagQuizGenerator.ts | 6 +++++- .../src/core/quiz/generators/BaseQuizGenerator.ts | 6 ++---- .../core/quiz/generators/BasedOnRagQuizGenerator.ts | 11 +++++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/aila/src/core/quiz/generators/AilaRagQuizGenerator.ts b/packages/aila/src/core/quiz/generators/AilaRagQuizGenerator.ts index c6b434b7e..d544e6b3c 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 9d748aa98..5d02e30e3 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 8dc5090af..fa75c1950 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"), + ]; } }