fix: questionId map in teacher
This commit is contained in:
		
							parent
							
								
									38f423cb33
								
							
						
					
					
						commit
						e99df80ba0
					
				
					 3 changed files with 22 additions and 12 deletions
				
			
		|  | @ -10,15 +10,19 @@ export interface QuestionDTO { | |||
|     content: string; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Convert a Question entity to a DTO format. | ||||
|  */ | ||||
| export function mapToQuestionDTO(question: Question): QuestionDTO { | ||||
|     const learningObjectIdentifier = { | ||||
| function getLearningObjectIdentifier(question: Question): LearningObjectIdentifier { | ||||
|     return { | ||||
|         hruid: question.learningObjectHruid, | ||||
|         language: question.learningObjectLanguage, | ||||
|         version: question.learningObjectVersion, | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Convert a Question entity to a DTO format. | ||||
|  */ | ||||
| export function mapToQuestionDTO(question: Question): QuestionDTO { | ||||
|     const learningObjectIdentifier = getLearningObjectIdentifier(question); | ||||
| 
 | ||||
|     return { | ||||
|         learningObjectIdentifier, | ||||
|  | @ -34,9 +38,11 @@ export interface QuestionId { | |||
|     sequenceNumber: number; | ||||
| } | ||||
| 
 | ||||
| export function mapToQuestionId(question: QuestionDTO): QuestionId { | ||||
| export function mapToQuestionDTOId(question: Question): QuestionId { | ||||
|     const learningObjectIdentifier = getLearningObjectIdentifier(question); | ||||
| 
 | ||||
|     return { | ||||
|         learningObjectIdentifier: question.learningObjectIdentifier, | ||||
|         learningObjectIdentifier, | ||||
|         sequenceNumber: question.sequenceNumber!, | ||||
|     }; | ||||
| } | ||||
|  |  | |||
|  | @ -6,7 +6,12 @@ import { | |||
|     getTeacherRepository, | ||||
| } from '../data/repositories.js'; | ||||
| import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; | ||||
| import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from '../interfaces/question.js'; | ||||
| import { | ||||
|     mapToQuestionDTO, | ||||
|     mapToQuestionDTOId, | ||||
|     QuestionDTO, | ||||
|     QuestionId | ||||
| } from '../interfaces/question.js'; | ||||
| import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js'; | ||||
| import { Teacher } from '../entities/users/teacher.entity.js'; | ||||
| import { fetchStudent } from './students.js'; | ||||
|  | @ -115,13 +120,12 @@ export async function getTeacherQuestions(username: string, full: boolean): Prom | |||
|     // Fetch all questions related to these learning objects
 | ||||
|     const questionRepository: QuestionRepository = getQuestionRepository(); | ||||
|     const questions: Question[] = await questionRepository.findAllByLearningObjects(learningObjects); | ||||
|     const questionsDTO: QuestionDTO[] = questions.map(mapToQuestionDTO); | ||||
| 
 | ||||
|     if (full) { | ||||
|         return questionsDTO; | ||||
|         return questions.map(mapToQuestionDTO); | ||||
|     } | ||||
| 
 | ||||
|     return questionsDTO.map(mapToQuestionId); | ||||
|     return questions.map(mapToQuestionDTOId); | ||||
| } | ||||
| 
 | ||||
| export async function getJoinRequestsByClass(classId: string): Promise<StudentRequestDTO[]> { | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl