# Conflicts:
#	backend/src/controllers/questions.ts
#	backend/src/controllers/submissions.ts
#	backend/src/data/questions/question-repository.ts
#	backend/src/interfaces/group.ts
#	backend/src/interfaces/question.ts
#	backend/src/interfaces/submission.ts
#	backend/src/routes/submissions.ts
#	backend/src/services/groups.ts
#	backend/src/services/questions.ts
#	backend/src/services/students.ts
#	backend/src/services/submissions.ts
#	common/src/interfaces/question.ts
This commit is contained in:
Gerald Schmittinger 2025-04-09 20:25:30 +02:00
commit d6dd7fb3bf
90 changed files with 2934 additions and 792 deletions

View file

@ -3,8 +3,9 @@ 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 { Assignment } from '../../entities/assignments/assignment.entity.js';
import { Loaded } from '@mikro-orm/core';
import { Group } from '../../entities/assignments/group.entity';
import { Assignment } from '../../entities/assignments/assignment.entity';
export class QuestionRepository extends DwengoEntityRepository<Question> {
public async createQuestion(question: { loId: LearningObjectIdentifier; author: Student; inGroup: Group; content: string }): Promise<Question> {
@ -59,6 +60,14 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
});
}
public async findAllByAssignment(assignment: Assignment): Promise<Question[]> {
return this.find({
author: assignment.groups.flatMap((group) => group.members),
learningObjectHruid: assignment.learningPathHruid,
learningObjectLanguage: assignment.learningPathLanguage,
});
}
public async findAllByAuthor(author: Student): Promise<Question[]> {
return this.findAll({
where: { author },
@ -97,4 +106,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;
}
}