Skip to content

Commit

Permalink
changed to use newly uploaded starter and exit quizzes in based on an…
Browse files Browse the repository at this point in the history
…d rag generators, from generateMathsExitQuizPatch
  • Loading branch information
gclomax committed Dec 16, 2024
1 parent 93199e9 commit 0232686
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -14,10 +15,11 @@ export class AilaRagQuizGenerator extends BasedOnRagQuizGenerator {
async mappedQuizFromAilaRagRelevantLessons(
lessonPlan: LooseLessonPlan,
ailaRagRelevantLessons: AilaRagRelevantLesson[],
quizType: QuizPath = "/starterQuiz",
): Promise<Quiz[]> {
// 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);
Expand All @@ -31,6 +33,7 @@ export class AilaRagQuizGenerator extends BasedOnRagQuizGenerator {
return await this.mappedQuizFromAilaRagRelevantLessons(
lessonPlan,
ailaRagRelevantLessons,
"/starterQuiz",
);
}

Expand All @@ -42,6 +45,7 @@ export class AilaRagQuizGenerator extends BasedOnRagQuizGenerator {
return await this.mappedQuizFromAilaRagRelevantLessons(
lessonPlan,
ailaRagRelevantLessons,
"/exitQuiz",
);
}
}
6 changes: 2 additions & 4 deletions packages/aila/src/core/quiz/generators/BaseQuizGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,14 @@ export abstract class BaseQuizGenerator implements AilaQuizGeneratorService {

public async questionArrayFromPlanId(
planId: string,
quizType: QuizPath = "/starterQuiz",
): Promise<QuizQuestion[]> {
// 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"),
];
}
}

0 comments on commit 0232686

Please sign in to comment.