Merge remote-tracking branch 'origin/dev' into feat/endpoints-beschermen-met-authenticatie-#105

# Conflicts:
#	backend/src/controllers/assignments.ts
#	backend/src/controllers/questions.ts
#	backend/src/data/questions/question-repository.ts
#	backend/src/interfaces/question.ts
#	backend/src/routes/assignments.ts
#	backend/src/routes/classes.ts
#	backend/src/routes/groups.ts
#	backend/src/routes/teachers.ts
#	backend/src/services/questions.ts
#	common/src/interfaces/question.ts
This commit is contained in:
Gabriellvl 2025-04-18 21:55:01 +02:00
commit ac399153b6
71 changed files with 2075 additions and 2603 deletions

View file

@ -3,8 +3,8 @@ 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.js';
import { Group } from '../../entities/assignments/group.entity';
import { Assignment } from '../../entities/assignments/assignment.entity';
import { Group } from '../../entities/assignments/group.entity.js';
import { Assignment } from '../../entities/assignments/assignment.entity.js';
import { Loaded } from '@mikro-orm/core';
export class QuestionRepository extends DwengoEntityRepository<Question> {
@ -60,6 +60,16 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
});
}
public async findAllByAssignment(assignment: Assignment): Promise<Question[]> {
return this.find({
inGroup: {
$contained: assignment.groups,
},
learningObjectHruid: assignment.learningPathHruid,
learningObjectLanguage: assignment.learningPathLanguage,
});
}
public async findAllByAuthor(author: Student): Promise<Question[]> {
return this.findAll({
where: { author },
@ -67,21 +77,6 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
});
}
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;
}
/**
* Looks up all questions for the given learning object which were asked as part of the given assignment.
* When forStudentUsername is set, only the questions within the given user's group are shown.
@ -113,4 +108,19 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
},
});
}
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;
}
}