refactor: delete endpoint back and frontend
This commit is contained in:
		
							parent
							
								
									a59417b8f5
								
							
						
					
					
						commit
						17620434f2
					
				
					 6 changed files with 0 additions and 69 deletions
				
			
		|  | @ -7,7 +7,6 @@ import { | |||
|     getJoinRequestsByClass, | ||||
|     getStudentsByTeacher, | ||||
|     getTeacher, | ||||
|     getTeacherQuestions, | ||||
|     updateClassJoinRequestStatus, | ||||
| } from '../services/teachers.js'; | ||||
| import { requireFields } from './error-helper.js'; | ||||
|  | @ -70,16 +69,6 @@ export async function getTeacherStudentHandler(req: Request, res: Response): Pro | |||
|     res.json({ students }); | ||||
| } | ||||
| 
 | ||||
| export async function getTeacherQuestionHandler(req: Request, res: Response): Promise<void> { | ||||
|     const username = req.params.username; | ||||
|     const full = req.query.full === 'true'; | ||||
|     requireFields({ username }); | ||||
| 
 | ||||
|     const questions = await getTeacherQuestions(username, full); | ||||
| 
 | ||||
|     res.json({ questions }); | ||||
| } | ||||
| 
 | ||||
| export async function getStudentJoinRequestHandler(req: Request, res: Response): Promise<void> { | ||||
|     const classId = req.params.classId; | ||||
|     requireFields({ classId }); | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; | |||
| import { LearningObject } from '../../entities/content/learning-object.entity.js'; | ||||
| import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { Teacher } from '../../entities/users/teacher.entity.js'; | ||||
| 
 | ||||
| export class LearningObjectRepository extends DwengoEntityRepository<LearningObject> { | ||||
|     public async findByIdentifier(identifier: LearningObjectIdentifier): Promise<LearningObject | null> { | ||||
|  | @ -32,11 +31,4 @@ export class LearningObjectRepository extends DwengoEntityRepository<LearningObj | |||
|             } | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     public async findAllByTeacher(teacher: Teacher): Promise<LearningObject[]> { | ||||
|         return this.find( | ||||
|             { admins: teacher }, | ||||
|             { populate: ['admins'] } // Make sure to load admin relations
 | ||||
|         ); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -6,7 +6,6 @@ import { | |||
|     getStudentJoinRequestHandler, | ||||
|     getTeacherClassHandler, | ||||
|     getTeacherHandler, | ||||
|     getTeacherQuestionHandler, | ||||
|     getTeacherStudentHandler, | ||||
|     updateStudentJoinRequestHandler, | ||||
| } from '../controllers/teachers.js'; | ||||
|  | @ -27,8 +26,6 @@ router.get('/:username/classes', getTeacherClassHandler); | |||
| 
 | ||||
| router.get('/:username/students', getTeacherStudentHandler); | ||||
| 
 | ||||
| router.get('/:username/questions', getTeacherQuestionHandler); | ||||
| 
 | ||||
| router.get('/:username/joinRequests/:classId', getStudentJoinRequestHandler); | ||||
| 
 | ||||
| router.put('/:username/joinRequests/:classId/:studentUsername', updateStudentJoinRequestHandler); | ||||
|  |  | |||
|  | @ -1,12 +1,9 @@ | |||
| import { | ||||
|     getClassJoinRequestRepository, | ||||
|     getClassRepository, | ||||
|     getLearningObjectRepository, | ||||
|     getQuestionRepository, | ||||
|     getTeacherRepository, | ||||
| } from '../data/repositories.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'; | ||||
|  | @ -15,10 +12,6 @@ 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 { 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'; | ||||
| 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'; | ||||
|  | @ -26,7 +19,6 @@ import { addClassStudent, fetchClass, 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'; | ||||
| import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; | ||||
| import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request'; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| import { ConflictException } from '../exceptions/conflict-exception.js'; | ||||
|  | @ -119,28 +111,6 @@ export async function getStudentsByTeacher(username: string, full: boolean): Pro | |||
|     return students.map((student) => student.username); | ||||
| } | ||||
| 
 | ||||
| export async function getTeacherQuestions(username: string, full: boolean): Promise<QuestionDTO[] | QuestionId[]> { | ||||
|     const teacher: Teacher = await fetchTeacher(username); | ||||
| 
 | ||||
|     // Find all learning objects that this teacher manages
 | ||||
|     const learningObjectRepository: LearningObjectRepository = getLearningObjectRepository(); | ||||
|     const learningObjects: LearningObject[] = await learningObjectRepository.findAllByTeacher(teacher); | ||||
| 
 | ||||
|     if (!learningObjects || learningObjects.length === 0) { | ||||
|         return []; | ||||
|     } | ||||
| 
 | ||||
|     // Fetch all questions related to these learning objects
 | ||||
|     const questionRepository: QuestionRepository = getQuestionRepository(); | ||||
|     const questions: Question[] = await questionRepository.findAllByLearningObjects(learningObjects); | ||||
| 
 | ||||
|     if (full) { | ||||
|         return questions.map(mapToQuestionDTO); | ||||
|     } | ||||
| 
 | ||||
|     return questions.map(mapToQuestionDTOId); | ||||
| } | ||||
| 
 | ||||
| export async function getJoinRequestsByClass(classId: string): Promise<ClassJoinRequestDTO[]> { | ||||
|     const classRepository: ClassRepository = getClassRepository(); | ||||
|     const cls: Class | null = await classRepository.findById(classId); | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl