fix(backend): Merge-conflicten opgelost & testen gerepareerd.
This commit is contained in:
parent
d6dd7fb3bf
commit
620a988c6b
8 changed files with 23 additions and 9 deletions
|
@ -15,9 +15,15 @@ import { LearningObjectIdentifier } from '../entities/content/learning-object-id
|
||||||
export async function getSubmissionsHandler(req: Request, res: Response): Promise<void> {
|
export async function getSubmissionsHandler(req: Request, res: Response): Promise<void> {
|
||||||
const loHruid = req.params.hruid;
|
const loHruid = req.params.hruid;
|
||||||
const lang = languageMap[req.query.language as string] || Language.Dutch;
|
const lang = languageMap[req.query.language as string] || Language.Dutch;
|
||||||
const version = req.query.version || 1;
|
const version = parseInt(req.query.version as string) ?? 1;
|
||||||
|
|
||||||
const submissions = await getSubmissionsForLearningObjectAndAssignment(loHruid, lang, version, req.query.classId, req.query.assignmentId);
|
const submissions = await getSubmissionsForLearningObjectAndAssignment(
|
||||||
|
loHruid,
|
||||||
|
lang,
|
||||||
|
version,
|
||||||
|
req.query.classId as string,
|
||||||
|
parseInt(req.query.assignmentId as string)
|
||||||
|
);
|
||||||
|
|
||||||
res.json(submissions);
|
res.json(submissions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,9 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
|
||||||
|
|
||||||
public async findAllByAssignment(assignment: Assignment): Promise<Question[]> {
|
public async findAllByAssignment(assignment: Assignment): Promise<Question[]> {
|
||||||
return this.find({
|
return this.find({
|
||||||
author: assignment.groups.flatMap((group) => group.members),
|
inGroup: {
|
||||||
|
$contained: assignment.groups
|
||||||
|
},
|
||||||
learningObjectHruid: assignment.learningPathHruid,
|
learningObjectHruid: assignment.learningPathHruid,
|
||||||
learningObjectLanguage: assignment.learningPathLanguage,
|
learningObjectLanguage: assignment.learningPathLanguage,
|
||||||
});
|
});
|
||||||
|
|
|
@ -32,7 +32,7 @@ export function mapToSubmissionDTOId(submission: Submission): SubmissionDTOId {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mapToSubmission(submissionDTO: SubmissionDTO, submitter: Student, onBehalfOf: Group | undefined): Submission {
|
export function mapToSubmission(submissionDTO: SubmissionDTO, submitter: Student, onBehalfOf: Group): Submission {
|
||||||
return getSubmissionRepository().create({
|
return getSubmissionRepository().create({
|
||||||
learningObjectHruid: submissionDTO.learningObjectIdentifier.hruid,
|
learningObjectHruid: submissionDTO.learningObjectIdentifier.hruid,
|
||||||
learningObjectLanguage: submissionDTO.learningObjectIdentifier.language,
|
learningObjectLanguage: submissionDTO.learningObjectIdentifier.language,
|
||||||
|
|
|
@ -33,7 +33,7 @@ export async function getAllSubmissions(loId: LearningObjectIdentifier): Promise
|
||||||
|
|
||||||
export async function createSubmission(submissionDTO: SubmissionDTO): Promise<SubmissionDTO> {
|
export async function createSubmission(submissionDTO: SubmissionDTO): Promise<SubmissionDTO> {
|
||||||
const submitter = await fetchStudent(submissionDTO.submitter.username);
|
const submitter = await fetchStudent(submissionDTO.submitter.username);
|
||||||
const group = submissionDTO.group ? await getExistingGroupFromGroupDTO(submissionDTO.group) : undefined;
|
const group = await getExistingGroupFromGroupDTO(submissionDTO.group!);
|
||||||
|
|
||||||
const submissionRepository = getSubmissionRepository();
|
const submissionRepository = getSubmissionRepository();
|
||||||
const submission = mapToSubmission(submissionDTO, submitter, group);
|
const submission = mapToSubmission(submissionDTO, submitter, group);
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe('AssignmentRepository', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should find all by username of the responsible teacher', async () => {
|
it('should find all by username of the responsible teacher', async () => {
|
||||||
const result = await assignmentRepository.findAllByResponsibleTeacher('FooFighters');
|
const result = await assignmentRepository.findAllByResponsibleTeacher('testleerkracht1');
|
||||||
const resultIds = result.map((it) => it.id).sort((a, b) => (a ?? 0) - (b ?? 0));
|
const resultIds = result.map((it) => it.id).sort((a, b) => (a ?? 0) - (b ?? 0));
|
||||||
|
|
||||||
expect(resultIds).toEqual([1, 3, 4]);
|
expect(resultIds).toEqual([1, 3, 4]);
|
||||||
|
|
|
@ -66,7 +66,7 @@ describe('SubmissionRepository', () => {
|
||||||
let assignment: Assignment | null;
|
let assignment: Assignment | null;
|
||||||
let loId: LearningObjectIdentifier;
|
let loId: LearningObjectIdentifier;
|
||||||
it('should find all submissions for a certain learning object and assignment', async () => {
|
it('should find all submissions for a certain learning object and assignment', async () => {
|
||||||
clazz = await classRepository.findById('id01');
|
clazz = await classRepository.findById('8764b861-90a6-42e5-9732-c0d9eb2f55f9');
|
||||||
assignment = await assignmentRepository.findByClassAndId(clazz!, 1);
|
assignment = await assignmentRepository.findByClassAndId(clazz!, 1);
|
||||||
loId = {
|
loId = {
|
||||||
hruid: 'id02',
|
hruid: 'id02',
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe('QuestionRepository', () => {
|
||||||
const id = new LearningObjectIdentifier('id03', Language.English, 1);
|
const id = new LearningObjectIdentifier('id03', Language.English, 1);
|
||||||
const student = await studentRepository.findByUsername('Noordkaap');
|
const student = await studentRepository.findByUsername('Noordkaap');
|
||||||
|
|
||||||
const clazz = await getClassRepository().findById('id01');
|
const clazz = await getClassRepository().findById('8764b861-90a6-42e5-9732-c0d9eb2f55f9');
|
||||||
const assignment = await getAssignmentRepository().findByClassAndId(clazz!, 1);
|
const assignment = await getAssignmentRepository().findByClassAndId(clazz!, 1);
|
||||||
const group = await getGroupRepository().findByAssignmentAndGroupNumber(assignment!, 1);
|
const group = await getGroupRepository().findByAssignmentAndGroupNumber(assignment!, 1);
|
||||||
await questionRepository.createQuestion({
|
await questionRepository.createQuestion({
|
||||||
|
@ -56,7 +56,7 @@ describe('QuestionRepository', () => {
|
||||||
let assignment: Assignment | null;
|
let assignment: Assignment | null;
|
||||||
let loId: LearningObjectIdentifier;
|
let loId: LearningObjectIdentifier;
|
||||||
it('should find all questions for a certain learning object and assignment', async () => {
|
it('should find all questions for a certain learning object and assignment', async () => {
|
||||||
clazz = await getClassRepository().findById('id01');
|
clazz = await getClassRepository().findById('8764b861-90a6-42e5-9732-c0d9eb2f55f9');
|
||||||
assignment = await getAssignmentRepository().findByClassAndId(clazz!, 1);
|
assignment = await getAssignmentRepository().findByClassAndId(clazz!, 1);
|
||||||
loId = {
|
loId = {
|
||||||
hruid: 'id05',
|
hruid: 'id05',
|
||||||
|
|
|
@ -11,6 +11,12 @@ export interface QuestionDTO {
|
||||||
content: string;
|
content: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface QuestionData {
|
||||||
|
author?: string;
|
||||||
|
content: string;
|
||||||
|
inGroup: GroupDTO;
|
||||||
|
}
|
||||||
|
|
||||||
export interface QuestionId {
|
export interface QuestionId {
|
||||||
learningObjectIdentifier: LearningObjectIdentifierDTO;
|
learningObjectIdentifier: LearningObjectIdentifierDTO;
|
||||||
sequenceNumber: number;
|
sequenceNumber: number;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue