fix: merge + fixes
This commit is contained in:
		
							parent
							
								
									7d8a0fcbb2
								
							
						
					
					
						commit
						3c1eb82ce3
					
				
					 20 changed files with 52 additions and 41 deletions
				
			
		|  | @ -14,8 +14,8 @@ import { | |||
|     getStudentQuestions, | ||||
|     getStudentSubmissions, | ||||
| } from '../services/students.js'; | ||||
| import { StudentDTO } from '../interfaces/student.js'; | ||||
| import { requireFields } from './error-helper.js'; | ||||
| import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | ||||
| 
 | ||||
| export async function getAllStudentsHandler(req: Request, res: Response): Promise<void> { | ||||
|     const full = req.query.full === 'true'; | ||||
|  |  | |||
|  | @ -11,10 +11,7 @@ import { | |||
|     updateClassJoinRequestStatus, | ||||
| } from '../services/teachers.js'; | ||||
| import { requireFields } from './error-helper.js'; | ||||
| import { TeacherDTO } from 'dwengo-1-common/src/interfaces/teacher'; | ||||
| import { ClassDTO } from 'dwengo-1-common/src/interfaces/class'; | ||||
| import { StudentDTO } from 'dwengo-1-common/src/interfaces/student'; | ||||
| import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question'; | ||||
| import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; | ||||
| 
 | ||||
| export async function getAllTeachersHandler(req: Request, res: Response): Promise<void> { | ||||
|     const full = req.query.full === 'true'; | ||||
|  | @ -58,7 +55,7 @@ export async function getTeacherClassHandler(req: Request, res: Response): Promi | |||
|     const full = req.query.full === 'true'; | ||||
|     requireFields({ username }); | ||||
| 
 | ||||
|     const classes: ClassDTO[] | string[] = await getClassesByTeacher(username, full); | ||||
|     const classes = await getClassesByTeacher(username, full); | ||||
| 
 | ||||
|     res.json({ classes }); | ||||
| } | ||||
|  | @ -68,7 +65,7 @@ export async function getTeacherStudentHandler(req: Request, res: Response): Pro | |||
|     const full = req.query.full === 'true'; | ||||
|     requireFields({ username }); | ||||
| 
 | ||||
|     const students: StudentDTO[] | string[] = await getStudentsByTeacher(username, full); | ||||
|     const students = await getStudentsByTeacher(username, full); | ||||
| 
 | ||||
|     res.json({ students }); | ||||
| } | ||||
|  | @ -78,7 +75,7 @@ export async function getTeacherQuestionHandler(req: Request, res: Response): Pr | |||
|     const full = req.query.full === 'true'; | ||||
|     requireFields({ username }); | ||||
| 
 | ||||
|     const questions: QuestionDTO[] | QuestionId[] = await getTeacherQuestions(username, full); | ||||
|     const questions = await getTeacherQuestions(username, full); | ||||
| 
 | ||||
|     res.json({ questions }); | ||||
| } | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { Theme } from 'dwengo-1-common/src/interfaces/theme'; | ||||
| import { Theme } from 'common/src/interfaces/theme'; | ||||
| 
 | ||||
| export const themes: Theme[] = [ | ||||
|     { | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| import { Question } from '../entities/questions/question.entity.js'; | ||||
| import { mapToStudentDTO } from './student.js'; | ||||
| import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; | ||||
| import { LearningObjectIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| function getLearningObjectIdentifier(question: Question): LearningObjectIdentifier { | ||||
|     return { | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import { ClassJoinRequest, ClassJoinRequestStatus } from '../entities/classes/cl | |||
| 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/src/interfaces/class-join-request'; | ||||
| import { ClassJoinRequestDTO } from 'common/src/interfaces/class-join-request'; | ||||
| 
 | ||||
| export function mapToStudentRequestDTO(request: ClassJoinRequest): ClassJoinRequestDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -6,17 +6,23 @@ import { | |||
|     getStudentRepository, | ||||
|     getSubmissionRepository, | ||||
| } from '../data/repositories.js'; | ||||
| import { AssignmentDTO } from '../interfaces/assignment.js'; | ||||
| import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; | ||||
| import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; | ||||
| import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student.js'; | ||||
| import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js'; | ||||
| import { mapToClassDTO } from '../interfaces/class.js'; | ||||
| import { mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; | ||||
| import { mapToStudent, mapToStudentDTO } from '../interfaces/student.js'; | ||||
| import { mapToSubmissionDTO, mapToSubmissionDTOId } from '../interfaces/submission.js'; | ||||
| import { getAllAssignments } from './assignments.js'; | ||||
| import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; | ||||
| import { mapToStudentRequest, mapToStudentRequestDTO, StudentRequestDTO } from '../interfaces/student-request.js'; | ||||
| import { mapToQuestionDTO, mapToQuestionDTOId } from '../interfaces/question.js'; | ||||
| import { mapToStudentRequest, mapToStudentRequestDTO } from '../interfaces/student-request.js'; | ||||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { fetchClass } from './classes.js'; | ||||
| import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | ||||
| import { ClassDTO } from '@dwengo-1/common/interfaces/class'; | ||||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | ||||
| import { GroupDTO } from '@dwengo-1/common/interfaces/group'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; | ||||
| import {ClassJoinRequestDTO} from '@dwengo-1/common/interfaces/class-join-request'; | ||||
| 
 | ||||
| export async function getAllStudents(full: boolean): Promise<StudentDTO[] | string[]> { | ||||
|     const studentRepository = getStudentRepository(); | ||||
|  | @ -123,7 +129,7 @@ export async function getStudentQuestions(username: string, full: boolean): Prom | |||
|     return questions.map(mapToQuestionDTOId); | ||||
| } | ||||
| 
 | ||||
| export async function createClassJoinRequest(username: string, classId: string): Promise<StudentRequestDTO> { | ||||
| export async function createClassJoinRequest(username: string, classId: string): Promise<ClassJoinRequestDTO> { | ||||
|     const requestRepo = getClassJoinRequestRepository(); | ||||
| 
 | ||||
|     const student = await fetchStudent(username); // Throws error if student not found
 | ||||
|  | @ -134,7 +140,7 @@ export async function createClassJoinRequest(username: string, classId: string): | |||
|     return mapToStudentRequestDTO(request); | ||||
| } | ||||
| 
 | ||||
| export async function getJoinRequestsByStudent(username: string): Promise<StudentRequestDTO[]> { | ||||
| export async function getJoinRequestsByStudent(username: string): Promise<ClassJoinRequestDTO[]> { | ||||
|     const requestRepo = getClassJoinRequestRepository(); | ||||
| 
 | ||||
|     const student = await fetchStudent(username); | ||||
|  | @ -143,7 +149,7 @@ export async function getJoinRequestsByStudent(username: string): Promise<Studen | |||
|     return requests.map(mapToStudentRequestDTO); | ||||
| } | ||||
| 
 | ||||
| export async function getJoinRequestByStudentClass(username: string, classId: string): Promise<StudentRequestDTO> { | ||||
| export async function getJoinRequestByStudentClass(username: string, classId: string): Promise<ClassJoinRequestDTO> { | ||||
|     const requestRepo = getClassJoinRequestRepository(); | ||||
| 
 | ||||
|     const student = await fetchStudent(username); | ||||
|  | @ -157,7 +163,7 @@ export async function getJoinRequestByStudentClass(username: string, classId: st | |||
|     return mapToStudentRequestDTO(request); | ||||
| } | ||||
| 
 | ||||
| export async function deleteClassJoinRequest(username: string, classId: string): Promise<StudentRequestDTO> { | ||||
| export async function deleteClassJoinRequest(username: string, classId: string): Promise<ClassJoinRequestDTO> { | ||||
|     const requestRepo = getClassJoinRequestRepository(); | ||||
| 
 | ||||
|     const student = await fetchStudent(username); | ||||
|  |  | |||
|  | @ -5,17 +5,16 @@ import { | |||
|     getQuestionRepository, | ||||
|     getTeacherRepository, | ||||
| } from '../data/repositories.js'; | ||||
| import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; | ||||
| import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; | ||||
| import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js'; | ||||
| import { mapToClassDTO } from '../interfaces/class.js'; | ||||
| import { mapToQuestionDTO, mapToQuestionDTOId } from '../interfaces/question.js'; | ||||
| import { mapToTeacher, mapToTeacherDTO } from '../interfaces/teacher.js'; | ||||
| import { Teacher } from '../entities/users/teacher.entity.js'; | ||||
| import { fetchStudent } from './students.js'; | ||||
| import { ClassJoinRequest, ClassJoinRequestStatus } from '../entities/classes/class-join-request.entity.js'; | ||||
| import { mapToStudentRequestDTO, StudentRequestDTO } from '../interfaces/student-request.js'; | ||||
| import { ClassJoinRequest } from '../entities/classes/class-join-request.entity.js'; | ||||
| import { mapToStudentRequestDTO } from '../interfaces/student-request.js'; | ||||
| import { TeacherRepository } from '../data/users/teacher-repository.js'; | ||||
| import { ClassRepository } from '../data/classes/class-repository.js'; | ||||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { StudentDTO } from '../interfaces/student.js'; | ||||
| import { LearningObjectRepository } from '../data/content/learning-object-repository.js'; | ||||
| import { LearningObject } from '../entities/content/learning-object.entity.js'; | ||||
| import { QuestionRepository } from '../data/questions/question-repository.js'; | ||||
|  | @ -24,6 +23,12 @@ import { ClassJoinRequestRepository } from '../data/classes/class-join-request-r | |||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { getClassStudents } 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'; | ||||
| import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; | ||||
| import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request'; | ||||
| import { ClassJoinRequestStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export async function getAllTeachers(full: boolean): Promise<TeacherDTO[] | string[]> { | ||||
|     const teacherRepository: TeacherRepository = getTeacherRepository(); | ||||
|  | @ -123,7 +128,7 @@ export async function getTeacherQuestions(username: string, full: boolean): Prom | |||
|     return questions.map(mapToQuestionDTOId); | ||||
| } | ||||
| 
 | ||||
| export async function getJoinRequestsByClass(classId: string): Promise<StudentRequestDTO[]> { | ||||
| export async function getJoinRequestsByClass(classId: string): Promise<ClassJoinRequestDTO[]> { | ||||
|     const classRepository: ClassRepository = getClassRepository(); | ||||
|     const cls: Class | null = await classRepository.findById(classId); | ||||
| 
 | ||||
|  | @ -136,7 +141,7 @@ export async function getJoinRequestsByClass(classId: string): Promise<StudentRe | |||
|     return requests.map(mapToStudentRequestDTO); | ||||
| } | ||||
| 
 | ||||
| export async function updateClassJoinRequestStatus(studentUsername: string, classId: string, accepted = true): Promise<StudentRequestDTO> { | ||||
| export async function updateClassJoinRequestStatus(studentUsername: string, classId: string, accepted = true): Promise<ClassJoinRequestDTO> { | ||||
|     const requestRepo: ClassJoinRequestRepository = getClassJoinRequestRepository(); | ||||
|     const classRepo: ClassRepository = getClassRepository(); | ||||
| 
 | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl