feat: question-teacher route

This commit is contained in:
Gabriellvl 2025-03-08 10:19:22 +01:00
parent 4968d7cb07
commit 16b73b9e18
6 changed files with 138 additions and 22 deletions

View file

@ -2,6 +2,7 @@ import { DwengoEntityRepository } from '../dwengo-entity-repository.js';
import { Question } from '../../entities/questions/question.entity.js';
import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier.js';
import { Student } from '../../entities/users/student.entity.js';
import {LearningObject} from "../../entities/content/learning-object.entity";
export class QuestionRepository extends DwengoEntityRepository<Question> {
public createQuestion(question: {
@ -42,4 +43,17 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
sequenceNumber: sequenceNumber,
});
}
public async findAllByLearningObjects(learningObjects: LearningObject[]): Promise<Question[]> {
const objectIdentifiers = learningObjects.map(lo => ({
learningObjectHruid: lo.hruid,
learningObjectLanguage: lo.language,
learningObjectVersion: lo.version
}));
return this.findAll({
where: { $or: objectIdentifiers },
orderBy: { timestamp: 'ASC' },
});
}
}