fix: strange merge conflict
This commit is contained in:
		
						commit
						aa1de9bfa3
					
				
					 12 changed files with 64 additions and 66 deletions
				
			
		|  | @ -1,5 +1,11 @@ | |||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | ||||
| import { getAssignmentRepository, getClassRepository, getGroupRepository, getQuestionRepository, getSubmissionRepository } from '../data/repositories.js'; | ||||
| import { | ||||
|     getAssignmentRepository, | ||||
|     getClassRepository, | ||||
|     getGroupRepository, | ||||
|     getQuestionRepository, | ||||
|     getSubmissionRepository, | ||||
| } from '../data/repositories.js'; | ||||
| import { Assignment } from '../entities/assignments/assignment.entity.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { mapToAssignment, mapToAssignmentDTO, mapToAssignmentDTOId } from '../interfaces/assignment.js'; | ||||
|  | @ -18,7 +24,7 @@ export async function fetchAssignment(classid: string, assignmentNumber: number) | |||
|     const cls = await classRepository.findById(classid); | ||||
| 
 | ||||
|     if (!cls) { | ||||
|         throw new NotFoundException('Could not find assignment\'s class'); | ||||
|         throw new NotFoundException("Could not find assignment's class"); | ||||
|     } | ||||
| 
 | ||||
|     const assignmentRepository = getAssignmentRepository(); | ||||
|  | @ -48,10 +54,10 @@ export async function createAssignment(classid: string, assignmentData: Assignme | |||
|     const cls = await fetchClass(classid); | ||||
| 
 | ||||
|     const assignment = mapToAssignment(assignmentData, cls); | ||||
|      | ||||
| 
 | ||||
|     const assignmentRepository = getAssignmentRepository(); | ||||
|     const newAssignment = assignmentRepository.create(assignment); | ||||
|     await assignmentRepository.save(newAssignment, {preventOverwrite: true}); | ||||
|     await assignmentRepository.save(newAssignment, { preventOverwrite: true }); | ||||
| 
 | ||||
|     return mapToAssignmentDTO(newAssignment); | ||||
| } | ||||
|  | @ -90,9 +96,7 @@ export async function getAssignmentsSubmissions( | |||
|     const groups = await groupRepository.findAllGroupsForAssignment(assignment); | ||||
| 
 | ||||
|     const submissionRepository = getSubmissionRepository(); | ||||
|     const submissions = (await Promise.all( | ||||
|         groups.map(async (group) => submissionRepository.findAllSubmissionsForGroup(group)) | ||||
|     )).flat(); | ||||
|     const submissions = (await Promise.all(groups.map(async (group) => submissionRepository.findAllSubmissionsForGroup(group)))).flat(); | ||||
| 
 | ||||
|     if (full) { | ||||
|         return submissions.map(mapToSubmissionDTO); | ||||
|  | @ -101,11 +105,7 @@ export async function getAssignmentsSubmissions( | |||
|     return submissions.map(mapToSubmissionDTOId); | ||||
| } | ||||
| 
 | ||||
| export async function getAssignmentsQuestions( | ||||
|     classid: string, | ||||
|     assignmentNumber: number, | ||||
|     full: boolean | ||||
| ): Promise<QuestionDTO[] | QuestionId[]> { | ||||
| export async function getAssignmentsQuestions(classid: string, assignmentNumber: number, full: boolean): Promise<QuestionDTO[] | QuestionId[]> { | ||||
|     const assignment = await fetchAssignment(classid, assignmentNumber); | ||||
| 
 | ||||
|     const questionRepository = getQuestionRepository(); | ||||
|  | @ -116,4 +116,4 @@ export async function getAssignmentsQuestions( | |||
|     } | ||||
| 
 | ||||
|     return questions.map(mapToQuestionDTO); | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -8,10 +8,10 @@ import { Class } from '../entities/classes/class.entity.js'; | |||
| import { ClassDTO } from '@dwengo-1/common/interfaces/class'; | ||||
| import { TeacherInvitationDTO } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | ||||
| import {fetchTeacher} from "./teachers"; | ||||
| import {fetchStudent, getStudent} from "./students"; | ||||
| import {TeacherDTO} from "@dwengo-1/common/interfaces/teacher"; | ||||
| import {mapToTeacherDTO} from "../interfaces/teacher"; | ||||
| import { fetchTeacher } from './teachers'; | ||||
| import { fetchStudent, getStudent } from './students'; | ||||
| import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; | ||||
| import { mapToTeacherDTO } from '../interfaces/teacher'; | ||||
| import { EntityDTO } from '@mikro-orm/core'; | ||||
| import { putObject } from './service-helper.js'; | ||||
| 
 | ||||
|  | @ -20,7 +20,7 @@ export async function fetchClass(classid: string): Promise<Class> { | |||
|     const cls = await classRepository.findById(classid); | ||||
| 
 | ||||
|     if (!cls) { | ||||
|         throw new NotFoundException("Class not found"); | ||||
|         throw new NotFoundException('Class not found'); | ||||
|     } | ||||
| 
 | ||||
|     return cls; | ||||
|  | @ -43,10 +43,10 @@ export async function getClass(classId: string): Promise<ClassDTO> { | |||
| 
 | ||||
| export async function createClass(classData: ClassDTO): Promise<ClassDTO> { | ||||
|     const teacherUsernames = classData.teachers || []; | ||||
|     const teachers = (await Promise.all(teacherUsernames.map(async (id) => fetchTeacher(id) ))); | ||||
|     const teachers = await Promise.all(teacherUsernames.map(async (id) => fetchTeacher(id))); | ||||
| 
 | ||||
|     const studentUsernames = classData.students || []; | ||||
|     const students = (await Promise.all(studentUsernames.map(async (id) => fetchStudent(id) ))); | ||||
|     const students = await Promise.all(studentUsernames.map(async (id) => fetchStudent(id))); | ||||
| 
 | ||||
|     const classRepository = getClassRepository(); | ||||
|     const newClass = classRepository.create({ | ||||
|  | @ -54,7 +54,7 @@ export async function createClass(classData: ClassDTO): Promise<ClassDTO> { | |||
|         teachers: teachers, | ||||
|         students: students, | ||||
|     }); | ||||
|     await classRepository.save(newClass, {preventOverwrite: true}); | ||||
|     await classRepository.save(newClass, { preventOverwrite: true }); | ||||
| 
 | ||||
|     return mapToClassDTO(newClass); | ||||
| } | ||||
|  | @ -93,7 +93,7 @@ export async function getClassStudentsDTO(classId: string): Promise<StudentDTO[] | |||
| export async function getClassTeachers(classId: string, full: boolean): Promise<TeacherDTO[] | string[]> { | ||||
|     const cls = await fetchClass(classId); | ||||
| 
 | ||||
|     if (full){ | ||||
|     if (full) { | ||||
|         return cls.teachers.map(mapToTeacherDTO); | ||||
|     } | ||||
|     return cls.teachers.map((student) => student.username); | ||||
|  | @ -114,7 +114,7 @@ export async function getClassTeacherInvitations(classId: string, full: boolean) | |||
| 
 | ||||
| export async function deleteClassStudent(classId: string, username: string): Promise<ClassDTO> { | ||||
|     const cls = await fetchClass(classId); | ||||
|      | ||||
| 
 | ||||
|     const newStudents = { students: cls.students.filter((student) => student.username !== username) }; | ||||
|     await putObject<Class>(cls, newStudents, getClassRepository()); | ||||
| 
 | ||||
|  | @ -123,7 +123,7 @@ export async function deleteClassStudent(classId: string, username: string): Pro | |||
| 
 | ||||
| export async function deleteClassTeacher(classId: string, username: string): Promise<ClassDTO> { | ||||
|     const cls = await fetchClass(classId); | ||||
|      | ||||
| 
 | ||||
|     const newTeachers = { teachers: cls.teachers.filter((teacher) => teacher.username !== username) }; | ||||
|     await putObject<Class>(cls, newTeachers, getClassRepository()); | ||||
| 
 | ||||
|  |  | |||
|  | @ -28,7 +28,7 @@ export async function fetchGroup(classId: string, assignmentNumber: number, grou | |||
|         throw new NotFoundException('Could not find group'); | ||||
|     } | ||||
| 
 | ||||
|     return group;  | ||||
|     return group; | ||||
| } | ||||
| 
 | ||||
| export async function getGroup(classId: string, assignmentNumber: number, groupNumber: number): Promise<GroupDTO> { | ||||
|  | @ -52,7 +52,7 @@ export async function putGroup( | |||
| export async function deleteGroup(classId: string, assignmentNumber: number, groupNumber: number): Promise<GroupDTO> { | ||||
|     const group = await fetchGroup(classId, assignmentNumber, groupNumber); | ||||
|     const assignment = await fetchAssignment(classId, assignmentNumber); | ||||
|      | ||||
| 
 | ||||
|     const groupRepository = getGroupRepository(); | ||||
|     await groupRepository.deleteByAssignmentAndGroupNumber(assignment, groupNumber); | ||||
| 
 | ||||
|  | @ -60,8 +60,8 @@ export async function deleteGroup(classId: string, assignmentNumber: number, gro | |||
| } | ||||
| 
 | ||||
| export async function getExistingGroupFromGroupDTO(groupData: GroupDTO) { | ||||
|     const classId = typeof(groupData.class) === 'string' ? groupData.class : groupData.class.id; | ||||
|     const assignmentNumber = typeof(groupData.assignment) === 'number' ? groupData.assignment : groupData.assignment.id; | ||||
|     const classId = typeof groupData.class === 'string' ? groupData.class : groupData.class.id; | ||||
|     const assignmentNumber = typeof groupData.assignment === 'number' ? groupData.assignment : groupData.assignment.id; | ||||
|     const groupNumber = groupData.groupNumber; | ||||
| 
 | ||||
|     return await fetchGroup(classId, assignmentNumber, groupNumber); | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { EntityDTO, FromEntityType } from "@mikro-orm/core"; | ||||
| import { DwengoEntityRepository } from "../data/dwengo-entity-repository"; | ||||
| import { EntityDTO, FromEntityType } from '@mikro-orm/core'; | ||||
| import { DwengoEntityRepository } from '../data/dwengo-entity-repository'; | ||||
| 
 | ||||
| /** | ||||
|  * Utility function to perform an PUT on an object. | ||||
|  | @ -7,7 +7,7 @@ import { DwengoEntityRepository } from "../data/dwengo-entity-repository"; | |||
|  * @param object The object that needs to be changed | ||||
|  * @param data The datafields and their values that will be updated | ||||
|  * @param repo The repository on which this action needs to be performed | ||||
|  *  | ||||
|  * | ||||
|  * @returns Nothing. | ||||
|  */ | ||||
| export async function putObject<T extends object>( | ||||
|  | @ -17,4 +17,4 @@ export async function putObject<T extends object>( | |||
| ): Promise<void> { | ||||
|     repo.assign(object, data); | ||||
|     await repo.getEntityManager().flush(); | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -8,10 +8,7 @@ import { fetchStudent } from './students.js'; | |||
| import { fetchGroup, getExistingGroupFromGroupDTO } from './groups.js'; | ||||
| import { Submission } from '../entities/assignments/submission.entity.js'; | ||||
| 
 | ||||
| export async function fetchSubmission( | ||||
|     loId: LearningObjectIdentifier, | ||||
|     submissionNumber: number, | ||||
| ): Promise<Submission> { | ||||
| export async function fetchSubmission(loId: LearningObjectIdentifier, submissionNumber: number): Promise<Submission> { | ||||
|     const submissionRepository = getSubmissionRepository(); | ||||
|     const submission = await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(loId, submissionNumber); | ||||
| 
 | ||||
|  | @ -22,17 +19,12 @@ export async function fetchSubmission( | |||
|     return submission; | ||||
| } | ||||
| 
 | ||||
| export async function getSubmission( | ||||
|     loId: LearningObjectIdentifier, | ||||
|     submissionNumber: number | ||||
| ): Promise<SubmissionDTO> { | ||||
| export async function getSubmission(loId: LearningObjectIdentifier, submissionNumber: number): Promise<SubmissionDTO> { | ||||
|     const submission = await fetchSubmission(loId, submissionNumber); | ||||
|     return mapToSubmissionDTO(submission); | ||||
| } | ||||
| 
 | ||||
| export async function getAllSubmissions( | ||||
|     loId: LearningObjectIdentifier, | ||||
| ): Promise<SubmissionDTO[]> { | ||||
| export async function getAllSubmissions(loId: LearningObjectIdentifier): Promise<SubmissionDTO[]> { | ||||
|     const submissionRepository = getSubmissionRepository(); | ||||
|     const submissions = await submissionRepository.findByLearningObject(loId); | ||||
| 
 | ||||
|  | @ -52,7 +44,7 @@ export async function createSubmission(submissionDTO: SubmissionDTO): Promise<Su | |||
| 
 | ||||
| export async function deleteSubmission(loId: LearningObjectIdentifier, submissionNumber: number): Promise<SubmissionDTO> { | ||||
|     const submission = await fetchSubmission(loId, submissionNumber); | ||||
|      | ||||
| 
 | ||||
|     const submissionRepository = getSubmissionRepository(); | ||||
|     await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(loId, submissionNumber); | ||||
| 
 | ||||
|  |  | |||
|  | @ -22,7 +22,7 @@ import { Question } from '../entities/questions/question.entity.js'; | |||
| import { ClassJoinRequestRepository } from '../data/classes/class-join-request-repository.js'; | ||||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import {getClassStudents, getClassStudentsDTO} from './classes.js'; | ||||
| import { getClassStudents, getClassStudentsDTO } from './classes.js'; | ||||
| import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; | ||||
| import { ClassDTO } from '@dwengo-1/common/interfaces/class'; | ||||
| import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | ||||
|  | @ -102,9 +102,9 @@ export async function getStudentsByTeacher(username: string, full: boolean): Pro | |||
|     const students: StudentDTO[] = (await Promise.all(classIds.map(async (username) => await getClassStudentsDTO(username)))).flat(); | ||||
| 
 | ||||
|     if (full) { | ||||
|         return students | ||||
|         return students; | ||||
|     } | ||||
|      | ||||
| 
 | ||||
|     return students.map((student) => student.username); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Reference in a new issue
	
	 Adriaan Jacquet
						Adriaan Jacquet