merge: merge fix/183-post-assignment into dev
This commit is contained in:
		
						commit
						5a593cb88f
					
				
					 67 changed files with 2205 additions and 2129 deletions
				
			
		|  | @ -1,17 +1,31 @@ | |||
| import { Group } from '../entities/assignments/group.entity.js'; | ||||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { mapToAssignment } from './assignment.js'; | ||||
| import { mapToStudent } from './student.js'; | ||||
| import { mapToAssignmentDTO } from './assignment.js'; | ||||
| import { mapToStudentDTO } from './student.js'; | ||||
| import { GroupDTO, GroupDTOId } from '@dwengo-1/common/interfaces/group'; | ||||
| import { getGroupRepository } from '../data/repositories.js'; | ||||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | ||||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | ||||
| import { mapToClassDTO } from './class.js'; | ||||
| 
 | ||||
| export function mapToGroupDTO(group: Group, cls: Class, options?: { expandStudents: boolean }): GroupDTO { | ||||
| export function mapToGroup(groupDto: GroupDTO, clazz: Class): Group { | ||||
|     const assignmentDto = groupDto.assignment as AssignmentDTO; | ||||
| 
 | ||||
|     return getGroupRepository().create({ | ||||
|         groupNumber: groupDto.groupNumber, | ||||
|         assignment: mapToAssignment(assignmentDto, clazz), | ||||
|         members: groupDto.members!.map((studentDto) => mapToStudent(studentDto as StudentDTO)), | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| export function mapToGroupDTO(group: Group, cls: Class): GroupDTO { | ||||
|     return { | ||||
|         class: cls.classId!, | ||||
|         assignment: group.assignment.id!, | ||||
|         groupNumber: group.groupNumber!, | ||||
|         members:  | ||||
|             options?.expandStudents  | ||||
|             ? group.members.map(mapToStudentDTO) | ||||
|             : group.members.map((student) => student.username) | ||||
|         members: group.members.map(mapToStudentDTO) | ||||
| 
 | ||||
|     }; | ||||
| } | ||||
|  | @ -23,3 +37,15 @@ export function mapToGroupDTOId(group: Group, cls: Class): GroupDTOId { | |||
|         groupNumber: group.groupNumber!, | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Map to group DTO where other objects are only referenced by their id. | ||||
|  */ | ||||
| export function mapToShallowGroupDTO(group: Group): GroupDTO { | ||||
|     return { | ||||
|         class: group.assignment.within.classId!, | ||||
|         assignment: group.assignment.id!, | ||||
|         groupNumber: group.groupNumber!, | ||||
|         members: group.members.map((member) => member.username), | ||||
|     }; | ||||
| } | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ import { mapToStudentDTO } from './student.js'; | |||
| import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; | ||||
| import { LearningObjectIdentifierDTO } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js'; | ||||
| import { mapToGroupDTOId } from './group.js'; | ||||
| 
 | ||||
| function getLearningObjectIdentifier(question: Question): LearningObjectIdentifierDTO { | ||||
|     return { | ||||
|  | @ -30,6 +31,7 @@ export function mapToQuestionDTO(question: Question): QuestionDTO { | |||
|         learningObjectIdentifier, | ||||
|         sequenceNumber: question.sequenceNumber!, | ||||
|         author: mapToStudentDTO(question.author), | ||||
|         inGroup: mapToGroupDTOId(question.inGroup), | ||||
|         timestamp: question.timestamp.toISOString(), | ||||
|         content: question.content, | ||||
|     }; | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import { getClassJoinRequestRepository } from '../data/repositories.js'; | |||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request'; | ||||
| import { ClassJoinRequestStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export function mapToStudentRequestDTO(request: ClassJoinRequest): ClassJoinRequestDTO { | ||||
|     return { | ||||
|  | @ -18,6 +18,6 @@ export function mapToStudentRequest(student: Student, cls: Class): ClassJoinRequ | |||
|     return getClassJoinRequestRepository().create({ | ||||
|         requester: student, | ||||
|         class: cls, | ||||
|         status: ClassJoinRequestStatus.Open, | ||||
|         status: ClassStatus.Open, | ||||
|     }); | ||||
| } | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| import { getSubmissionRepository } from '../data/repositories.js'; | ||||
| import { Group } from '../entities/assignments/group.entity.js'; | ||||
| import { Submission } from '../entities/assignments/submission.entity.js'; | ||||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { mapToGroupDTO } from './group.js'; | ||||
| import { mapToStudentDTO } from './student.js'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { getSubmissionRepository } from '../data/repositories.js'; | ||||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { Group } from '../entities/assignments/group.entity.js'; | ||||
| 
 | ||||
| export function mapToSubmissionDTO(submission: Submission): SubmissionDTO { | ||||
|     return { | ||||
|  | @ -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({ | ||||
|         learningObjectHruid: submissionDTO.learningObjectIdentifier.hruid, | ||||
|         learningObjectLanguage: submissionDTO.learningObjectIdentifier.language, | ||||
|  |  | |||
|  | @ -1,13 +1,17 @@ | |||
| import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity.js'; | ||||
| import { mapToClassDTO } from './class.js'; | ||||
| import { mapToUserDTO } from './user.js'; | ||||
| import { TeacherInvitationDTO } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import { getTeacherInvitationRepository } from '../data/repositories.js'; | ||||
| import { Teacher } from '../entities/users/teacher.entity.js'; | ||||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export function mapToTeacherInvitationDTO(invitation: TeacherInvitation): TeacherInvitationDTO { | ||||
|     return { | ||||
|         sender: mapToUserDTO(invitation.sender), | ||||
|         receiver: mapToUserDTO(invitation.receiver), | ||||
|         class: mapToClassDTO(invitation.class), | ||||
|         classId: invitation.class.classId!, | ||||
|         status: invitation.status, | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  | @ -15,6 +19,16 @@ export function mapToTeacherInvitationDTOIds(invitation: TeacherInvitation): Tea | |||
|     return { | ||||
|         sender: invitation.sender.username, | ||||
|         receiver: invitation.receiver.username, | ||||
|         class: invitation.class.classId!, | ||||
|         classId: invitation.class.classId!, | ||||
|         status: invitation.status, | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| export function mapToInvitation(sender: Teacher, receiver: Teacher, cls: Class): TeacherInvitation { | ||||
|     return getTeacherInvitationRepository().create({ | ||||
|         sender, | ||||
|         receiver, | ||||
|         class: cls, | ||||
|         status: ClassStatus.Open, | ||||
|     }); | ||||
| } | ||||
|  |  | |||
		Reference in a new issue
	
	 Adriaan Jacquet
						Adriaan Jacquet