Merge remote-tracking branch 'origin/dev' into fix/class-join-request

# Conflicts:
#	backend/src/controllers/classes.ts
#	backend/src/data/questions/question-repository.ts
#	backend/tests/controllers/students.test.ts
#	backend/tests/controllers/teachers.test.ts
This commit is contained in:
Gabriellvl 2025-04-09 12:13:42 +02:00
commit 0a0857deb9
58 changed files with 2058 additions and 277 deletions

View file

@ -4,6 +4,7 @@ import { LearningObjectIdentifier } from '../../entities/content/learning-object
import { Student } from '../../entities/users/student.entity.js';
import { LearningObject } from '../../entities/content/learning-object.entity.js';
import { Assignment } from '../../entities/assignments/assignment.entity.js';
import { Loaded } from '@mikro-orm/core';
export class QuestionRepository extends DwengoEntityRepository<Question> {
public async createQuestion(question: { loId: LearningObjectIdentifier; author: Student; content: string }): Promise<Question> {
@ -70,4 +71,19 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
orderBy: { timestamp: 'DESC' }, // New to old
});
}
public async findByLearningObjectAndSequenceNumber(loId: LearningObjectIdentifier, sequenceNumber: number): Promise<Loaded<Question> | null> {
return this.findOne({
learningObjectHruid: loId.hruid,
learningObjectLanguage: loId.language,
learningObjectVersion: loId.version,
sequenceNumber,
});
}
public async updateContent(question: Question, newContent: string): Promise<Question> {
question.content = newContent;
await this.save(question);
return question;
}
}