style: fix linting issues met ESLint
This commit is contained in:
		
							parent
							
								
									b5390258e3
								
							
						
					
					
						commit
						e78849f568
					
				
					 21 changed files with 64 additions and 116 deletions
				
			
		|  | @ -83,7 +83,7 @@ export async function getGroupSubmissionsHandler( | ||||||
|     res: Response, |     res: Response, | ||||||
| ): Promise<void> { | ): Promise<void> { | ||||||
|     const classId = req.params.classid; |     const classId = req.params.classid; | ||||||
|     // const full = req.query.full === 'true';
 |     // Const full = req.query.full === 'true';
 | ||||||
| 
 | 
 | ||||||
|     const assignmentId = +req.params.assignmentid; |     const assignmentId = +req.params.assignmentid; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ function getQuestionId(req: Request, res: Response): QuestionId | null { | ||||||
|     const learningObjectIdentifier = getObjectId(req,res); |     const learningObjectIdentifier = getObjectId(req,res); | ||||||
| 
 | 
 | ||||||
|     if (!learningObjectIdentifier) |     if (!learningObjectIdentifier) | ||||||
|         return null |         {return null} | ||||||
| 
 | 
 | ||||||
|     return { |     return { | ||||||
|         learningObjectIdentifier, |         learningObjectIdentifier, | ||||||
|  | @ -48,28 +48,28 @@ export async function getAllQuestionsHandler( | ||||||
|     const full = req.query.full === 'true'; |     const full = req.query.full === 'true'; | ||||||
| 
 | 
 | ||||||
|     if (!objectId) |     if (!objectId) | ||||||
|         return |         {return} | ||||||
| 
 | 
 | ||||||
|     const questions = await getAllQuestions(objectId, full); |     const questions = await getAllQuestions(objectId, full); | ||||||
| 
 | 
 | ||||||
|     if (!questions) |     if (!questions) | ||||||
|         res.status(404).json({ error: `Questions not found.` }); |         {res.status(404).json({ error: `Questions not found.` });} | ||||||
|     else |     else | ||||||
|         res.json(questions); |         {res.json(questions);} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function getQuestionHandler(req: Request, res: Response): Promise<void> { | export async function getQuestionHandler(req: Request, res: Response): Promise<void> { | ||||||
|     const questionId = getQuestionId(req, res); |     const questionId = getQuestionId(req, res); | ||||||
| 
 | 
 | ||||||
|     if (!questionId) |     if (!questionId) | ||||||
|         return |         {return} | ||||||
| 
 | 
 | ||||||
|     const question = await getQuestion(questionId); |     const question = await getQuestion(questionId); | ||||||
| 
 | 
 | ||||||
|     if (!question) |     if (!question) | ||||||
|         res.status(404).json({ error: `Question not found.` }); |         {res.status(404).json({ error: `Question not found.` });} | ||||||
|     else |     else | ||||||
|         res.json(question) |         {res.json(question)} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function getQuestionAnswersHandler(req: Request, res: Response): Promise<void> { | export async function getQuestionAnswersHandler(req: Request, res: Response): Promise<void> { | ||||||
|  | @ -77,14 +77,14 @@ export async function getQuestionAnswersHandler(req: Request, res: Response): Pr | ||||||
|     const full = req.query.full === 'true'; |     const full = req.query.full === 'true'; | ||||||
| 
 | 
 | ||||||
|     if (!questionId) |     if (!questionId) | ||||||
|         return |         {return} | ||||||
| 
 | 
 | ||||||
|     const answers = getAnswersByQuestion(questionId, full); |     const answers = getAnswersByQuestion(questionId, full); | ||||||
| 
 | 
 | ||||||
|     if (!answers) |     if (!answers) | ||||||
|         res.status(404).json({ error: `Questions not found.` }); |         {res.status(404).json({ error: `Questions not found.` });} | ||||||
|     else |     else | ||||||
|         res.json(answers) |         {res.json(answers)} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function createQuestionHandler(req: Request, res: Response): Promise<void> { | export async function createQuestionHandler(req: Request, res: Response): Promise<void> { | ||||||
|  | @ -98,23 +98,23 @@ export async function createQuestionHandler(req: Request, res: Response): Promis | ||||||
|     const question = await createQuestion(questionDTO); |     const question = await createQuestion(questionDTO); | ||||||
| 
 | 
 | ||||||
|     if (!question) |     if (!question) | ||||||
|         res.status(400).json({error: 'Could not add question'}); |         {res.status(400).json({error: 'Could not add question'});} | ||||||
|     else |     else | ||||||
|         res.json(question) |         {res.json(question)} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function deleteQuestionHandler(req: Request, res: Response): Promise<void> { | export async function deleteQuestionHandler(req: Request, res: Response): Promise<void> { | ||||||
|     const questionId = getQuestionId(req, res); |     const questionId = getQuestionId(req, res); | ||||||
| 
 | 
 | ||||||
|     if (!questionId) |     if (!questionId) | ||||||
|         return |         {return} | ||||||
| 
 | 
 | ||||||
|     const question = await deleteQuestion(questionId); |     const question = await deleteQuestion(questionId); | ||||||
| 
 | 
 | ||||||
|     if (!question) |     if (!question) | ||||||
|         res.status(400).json({error: 'Could not find nor delete question'}); |         {res.status(400).json({error: 'Could not find nor delete question'});} | ||||||
|     else |     else | ||||||
|         res.json(question) |         {res.json(question)} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -20,8 +20,8 @@ export async function getSubmissionHandler( | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     let lang = languageMap[req.query.language as string] || Language.Dutch; |     const lang = languageMap[req.query.language as string] || Language.Dutch; | ||||||
|     let version = (req.query.version || 1) as number; |     const version = (req.query.version || 1) as number; | ||||||
| 
 | 
 | ||||||
|     const submission = await getSubmission(lohruid, lang, version, submissionNumber); |     const submission = await getSubmission(lohruid, lang, version, submissionNumber); | ||||||
| 
 | 
 | ||||||
|  | @ -39,22 +39,22 @@ export async function createSubmissionHandler(req: Request, res: Response){ | ||||||
|     const submission = await createSubmission(submissionDTO); |     const submission = await createSubmission(submissionDTO); | ||||||
| 
 | 
 | ||||||
|     if (!submission) |     if (!submission) | ||||||
|         res.status(404).json({ error: 'Submission not added' }); |         {res.status(404).json({ error: 'Submission not added' });} | ||||||
|     else |     else | ||||||
|         res.json(submission) |         {res.json(submission)} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function deleteSubmissionHandler(req: Request, res: Response){ | export async function deleteSubmissionHandler(req: Request, res: Response){ | ||||||
|     const hruid = req.params.hruid; |     const hruid = req.params.hruid; | ||||||
|     const submissionNumber = +req.params.id; |     const submissionNumber = +req.params.id; | ||||||
| 
 | 
 | ||||||
|     let lang = languageMap[req.query.language as string] || Language.Dutch; |     const lang = languageMap[req.query.language as string] || Language.Dutch; | ||||||
|     let version = (req.query.version || 1) as number; |     const version = (req.query.version || 1) as number; | ||||||
| 
 | 
 | ||||||
|     const submission = await deleteSubmission(hruid, lang, version, submissionNumber); |     const submission = await deleteSubmission(hruid, lang, version, submissionNumber); | ||||||
| 
 | 
 | ||||||
|     if (!submission) |     if (!submission) | ||||||
|         res.status(404).json({ error: 'Submission not found' }); |         {res.status(404).json({ error: 'Submission not found' });} | ||||||
|     else |     else | ||||||
|         res.json(submission) |         {res.json(submission)} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -50,13 +50,11 @@ export class QuestionRepository extends DwengoEntityRepository<Question> { | ||||||
|     public async findAllByLearningObjects( |     public async findAllByLearningObjects( | ||||||
|         learningObjects: LearningObject[] |         learningObjects: LearningObject[] | ||||||
|     ): Promise<Question[]> { |     ): Promise<Question[]> { | ||||||
|         const objectIdentifiers = learningObjects.map((lo) => { |         const objectIdentifiers = learningObjects.map((lo) => ({ | ||||||
|             return { |  | ||||||
|                 learningObjectHruid: lo.hruid, |                 learningObjectHruid: lo.hruid, | ||||||
|                 learningObjectLanguage: lo.language, |                 learningObjectLanguage: lo.language, | ||||||
|                 learningObjectVersion: lo.version, |                 learningObjectVersion: lo.version, | ||||||
|             }; |             })); | ||||||
|         }); |  | ||||||
| 
 | 
 | ||||||
|         return this.findAll({ |         return this.findAll({ | ||||||
|             where: { $or: objectIdentifiers }, |             where: { $or: objectIdentifiers }, | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| import { Student } from '../../entities/users/student.entity.js'; | import { Student } from '../../entities/users/student.entity.js'; | ||||||
| import { User } from '../../entities/users/user.entity.js'; | import { User } from '../../entities/users/user.entity.js'; | ||||||
| import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; | import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; | ||||||
| // import { UserRepository } from './user-repository.js';
 | // Import { UserRepository } from './user-repository.js';
 | ||||||
| 
 | 
 | ||||||
| // export class StudentRepository extends UserRepository<Student> {}
 | // Export class StudentRepository extends UserRepository<Student> {}
 | ||||||
| 
 | 
 | ||||||
| export class StudentRepository extends DwengoEntityRepository<Student> { | export class StudentRepository extends DwengoEntityRepository<Student> { | ||||||
|     public findByUsername(username: string): Promise<Student | null> { |     public findByUsername(username: string): Promise<Student | null> { | ||||||
|  |  | ||||||
|  | @ -13,15 +13,11 @@ import { Language } from '../content/language.js'; | ||||||
| import { AssignmentRepository } from '../../data/assignments/assignment-repository.js'; | import { AssignmentRepository } from '../../data/assignments/assignment-repository.js'; | ||||||
| 
 | 
 | ||||||
| @Entity({ | @Entity({ | ||||||
|     repository: () => { |     repository: () => AssignmentRepository, | ||||||
|         return AssignmentRepository; |  | ||||||
|     }, |  | ||||||
| }) | }) | ||||||
| export class Assignment { | export class Assignment { | ||||||
|     @ManyToOne({ |     @ManyToOne({ | ||||||
|         entity: () => { |         entity: () => Class, | ||||||
|             return Class; |  | ||||||
|         }, |  | ||||||
|         primary: true, |         primary: true, | ||||||
|     }) |     }) | ||||||
|     within!: Class; |     within!: Class; | ||||||
|  | @ -39,16 +35,12 @@ export class Assignment { | ||||||
|     learningPathHruid!: string; |     learningPathHruid!: string; | ||||||
| 
 | 
 | ||||||
|     @Enum({ |     @Enum({ | ||||||
|         items: () => { |         items: () => Language, | ||||||
|             return Language; |  | ||||||
|         }, |  | ||||||
|     }) |     }) | ||||||
|     learningPathLanguage!: Language; |     learningPathLanguage!: Language; | ||||||
| 
 | 
 | ||||||
|     @OneToMany({ |     @OneToMany({ | ||||||
|         entity: () => { |         entity: () => Group, | ||||||
|             return Group; |  | ||||||
|         }, |  | ||||||
|         mappedBy: 'assignment', |         mappedBy: 'assignment', | ||||||
|     }) |     }) | ||||||
|     groups!: Group[]; |     groups!: Group[]; | ||||||
|  |  | ||||||
|  | @ -4,9 +4,7 @@ import { Student } from '../users/student.entity.js'; | ||||||
| import { GroupRepository } from '../../data/assignments/group-repository.js'; | import { GroupRepository } from '../../data/assignments/group-repository.js'; | ||||||
| 
 | 
 | ||||||
| @Entity({ | @Entity({ | ||||||
|     repository: () => { |     repository: () => GroupRepository, | ||||||
|         return GroupRepository; |  | ||||||
|     }, |  | ||||||
| }) | }) | ||||||
| export class Group { | export class Group { | ||||||
|     @ManyToOne({ |     @ManyToOne({ | ||||||
|  |  | ||||||
|  | @ -4,9 +4,7 @@ import { Class } from './class.entity.js'; | ||||||
| import { ClassJoinRequestRepository } from '../../data/classes/class-join-request-repository.js'; | import { ClassJoinRequestRepository } from '../../data/classes/class-join-request-repository.js'; | ||||||
| 
 | 
 | ||||||
| @Entity({ | @Entity({ | ||||||
|     repository: () => { |     repository: () => ClassJoinRequestRepository, | ||||||
|         return ClassJoinRequestRepository; |  | ||||||
|     }, |  | ||||||
| }) | }) | ||||||
| export class ClassJoinRequest { | export class ClassJoinRequest { | ||||||
|     @ManyToOne({ |     @ManyToOne({ | ||||||
|  |  | ||||||
|  | @ -11,9 +11,7 @@ import { Student } from '../users/student.entity.js'; | ||||||
| import { ClassRepository } from '../../data/classes/class-repository.js'; | import { ClassRepository } from '../../data/classes/class-repository.js'; | ||||||
| 
 | 
 | ||||||
| @Entity({ | @Entity({ | ||||||
|     repository: () => { |     repository: () => ClassRepository, | ||||||
|         return ClassRepository; |  | ||||||
|     }, |  | ||||||
| }) | }) | ||||||
| export class Class { | export class Class { | ||||||
|     @PrimaryKey() |     @PrimaryKey() | ||||||
|  |  | ||||||
|  | @ -3,15 +3,11 @@ import { LearningObject } from './learning-object.entity.js'; | ||||||
| import { AttachmentRepository } from '../../data/content/attachment-repository.js'; | import { AttachmentRepository } from '../../data/content/attachment-repository.js'; | ||||||
| 
 | 
 | ||||||
| @Entity({ | @Entity({ | ||||||
|     repository: () => { |     repository: () => AttachmentRepository, | ||||||
|         return AttachmentRepository; |  | ||||||
|     }, |  | ||||||
| }) | }) | ||||||
| export class Attachment { | export class Attachment { | ||||||
|     @ManyToOne({ |     @ManyToOne({ | ||||||
|         entity: () => { |         entity: () => LearningObject, | ||||||
|             return LearningObject; |  | ||||||
|         }, |  | ||||||
|         primary: true, |         primary: true, | ||||||
|     }) |     }) | ||||||
|     learningObject!: LearningObject; |     learningObject!: LearningObject; | ||||||
|  |  | ||||||
|  | @ -21,12 +21,8 @@ export function mapToClassDTO(cls: Class): ClassDTO { | ||||||
|     return { |     return { | ||||||
|         id: cls.classId!, |         id: cls.classId!, | ||||||
|         displayName: cls.displayName, |         displayName: cls.displayName, | ||||||
|         teachers: cls.teachers.map((teacher) => { |         teachers: cls.teachers.map((teacher) => teacher.username), | ||||||
|             return teacher.username; |         students: cls.students.map((student) => student.username), | ||||||
|         }), |  | ||||||
|         students: cls.students.map((student) => { |  | ||||||
|             return student.username; |  | ||||||
|         }), |  | ||||||
|         joinRequests: [], // TODO
 |         joinRequests: [], // TODO
 | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -20,8 +20,6 @@ export function mapToGroupDTOId(group: Group): GroupDTO { | ||||||
|     return { |     return { | ||||||
|         assignment: group.assignment.id!, |         assignment: group.assignment.id!, | ||||||
|         groupNumber: group.groupNumber!, |         groupNumber: group.groupNumber!, | ||||||
|         members: group.members.map((member) => { |         members: group.members.map((member) => member.username), | ||||||
|             return member.username; |  | ||||||
|         }), |  | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -36,10 +36,10 @@ export function mapToSubmission(submissionDTO: SubmissionDTO): Submission { | ||||||
|     submission.learningObjectHruid = submissionDTO.learningObjectHruid; |     submission.learningObjectHruid = submissionDTO.learningObjectHruid; | ||||||
|     submission.learningObjectLanguage = submissionDTO.learningObjectLanguage; |     submission.learningObjectLanguage = submissionDTO.learningObjectLanguage; | ||||||
|     submission.learningObjectVersion = submissionDTO.learningObjectVersion; |     submission.learningObjectVersion = submissionDTO.learningObjectVersion; | ||||||
|     // submission.submissionNumber = submissionDTO.submissionNumber;
 |     // Submission.submissionNumber = submissionDTO.submissionNumber;
 | ||||||
|     submission.submitter = mapToStudent(submissionDTO.submitter) ; |     submission.submitter = mapToStudent(submissionDTO.submitter) ; | ||||||
|     // submission.submissionTime = submissionDTO.time;
 |     // Submission.submissionTime = submissionDTO.time;
 | ||||||
|     // submission.onBehalfOf =  submissionDTO.group!;
 |     // Submission.onBehalfOf =  submissionDTO.group!;
 | ||||||
|     // TODO fix group
 |     // TODO fix group
 | ||||||
|     submission.content = submissionDTO.content; |     submission.content = submissionDTO.content; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ import { | ||||||
| } from "../controllers/questions.js"; | } from "../controllers/questions.js"; | ||||||
| const router = express.Router({ mergeParams: true }); | const router = express.Router({ mergeParams: true }); | ||||||
| 
 | 
 | ||||||
| // query language
 | // Query language
 | ||||||
| 
 | 
 | ||||||
| // Root endpoint used to search objects
 | // Root endpoint used to search objects
 | ||||||
| router.get('/', getAllQuestionsHandler); | router.get('/', getAllQuestionsHandler); | ||||||
|  |  | ||||||
|  | @ -29,9 +29,7 @@ export async function getAllClasses( | ||||||
|     if (full) { |     if (full) { | ||||||
|         return classes.map(mapToClassDTO); |         return classes.map(mapToClassDTO); | ||||||
|     } |     } | ||||||
|     return classes.map((cls) => { |     return classes.map((cls) => cls.classId!); | ||||||
|         return cls.classId!; |  | ||||||
|     }); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function createClass(classData: ClassDTO): Promise<Class | null> { | export async function createClass(classData: ClassDTO): Promise<Class | null> { | ||||||
|  | @ -45,7 +43,7 @@ export async function createClass(classData: ClassDTO): Promise<Class | null> { | ||||||
|     const students = (await Promise.all(studentUsernames.map(id => studentRepository.findByUsername(id)))) |     const students = (await Promise.all(studentUsernames.map(id => studentRepository.findByUsername(id)))) | ||||||
|         .filter(student => student != null); |         .filter(student => student != null); | ||||||
| 
 | 
 | ||||||
|     //const cls = mapToClass(classData, teachers, students);
 |     //Const cls = mapToClass(classData, teachers, students);
 | ||||||
| 
 | 
 | ||||||
|     const classRepository = getClassRepository(); |     const classRepository = getClassRepository(); | ||||||
| 
 | 
 | ||||||
|  | @ -91,9 +89,7 @@ export async function getClassStudents(classId: string): Promise<StudentDTO[]> { | ||||||
| 
 | 
 | ||||||
| export async function getClassStudentsIds(classId: string): Promise<string[]> { | export async function getClassStudentsIds(classId: string): Promise<string[]> { | ||||||
|     const students: StudentDTO[] = await fetchClassStudents(classId); |     const students: StudentDTO[] = await fetchClassStudents(classId); | ||||||
|     return students.map((student) => { |     return students.map((student) => student.username); | ||||||
|         return student.username; |  | ||||||
|     }); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function getClassTeacherInvitations( | export async function getClassTeacherInvitations( | ||||||
|  |  | ||||||
|  | @ -85,23 +85,15 @@ async function fetchLearningObjects( | ||||||
|         const nodes: LearningObjectNode[] = learningPathResponse.data[0].nodes; |         const nodes: LearningObjectNode[] = learningPathResponse.data[0].nodes; | ||||||
| 
 | 
 | ||||||
|         if (!full) { |         if (!full) { | ||||||
|             return nodes.map((node) => { |             return nodes.map((node) => node.learningobject_hruid); | ||||||
|                 return node.learningobject_hruid; |  | ||||||
|             }); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return await Promise.all( |         return await Promise.all( | ||||||
|             nodes.map(async (node) => { |             nodes.map(async (node) => getLearningObjectById( | ||||||
|                 return getLearningObjectById( |  | ||||||
|                     node.learningobject_hruid, |                     node.learningobject_hruid, | ||||||
|                     language |                     language | ||||||
|                 ); |                 )) | ||||||
|             }) |         ).then((objects) => objects.filter((obj): obj is FilteredLearningObject => obj !== null)); | ||||||
|         ).then((objects) => { |  | ||||||
|             return objects.filter((obj): obj is FilteredLearningObject => { |  | ||||||
|                 return obj !== null; |  | ||||||
|             }); |  | ||||||
|         }); |  | ||||||
|     } catch (error) { |     } catch (error) { | ||||||
|         console.error('❌ Error fetching learning objects:', error); |         console.error('❌ Error fetching learning objects:', error); | ||||||
|         return []; |         return []; | ||||||
|  |  | ||||||
|  | @ -45,7 +45,7 @@ export async function getQuestion(questionId: QuestionId): Promise<QuestionDTO | | ||||||
|     const question = await fetchQuestion(questionId); |     const question = await fetchQuestion(questionId); | ||||||
| 
 | 
 | ||||||
|     if (!question) |     if (!question) | ||||||
|         return null |         {return null} | ||||||
| 
 | 
 | ||||||
|     return mapToQuestionDTO(question); |     return mapToQuestionDTO(question); | ||||||
| } | } | ||||||
|  | @ -55,17 +55,17 @@ export async function getAnswersByQuestion(questionId: QuestionId, full: boolean | ||||||
|     const question = await fetchQuestion(questionId); |     const question = await fetchQuestion(questionId); | ||||||
| 
 | 
 | ||||||
|     if (!question) |     if (!question) | ||||||
|         return []; |         {return [];} | ||||||
| 
 | 
 | ||||||
|     const answers: Answer[] = await answerRepository.findAllAnswersToQuestion(question); |     const answers: Answer[] = await answerRepository.findAllAnswersToQuestion(question); | ||||||
| 
 | 
 | ||||||
|     if (!answers) |     if (!answers) | ||||||
|         return [] |         {return []} | ||||||
| 
 | 
 | ||||||
|     const answersDTO = answers.map(mapToAnswerDTO); |     const answersDTO = answers.map(mapToAnswerDTO); | ||||||
| 
 | 
 | ||||||
|     if (full) |     if (full) | ||||||
|         return answersDTO |         {return answersDTO} | ||||||
| 
 | 
 | ||||||
|     return answersDTO.map(mapToAnswerId); |     return answersDTO.map(mapToAnswerId); | ||||||
| } | } | ||||||
|  | @ -94,7 +94,7 @@ export async function deleteQuestion(questionId: QuestionId) { | ||||||
|     const question = await fetchQuestion(questionId); |     const question = await fetchQuestion(questionId); | ||||||
| 
 | 
 | ||||||
|     if (!question) |     if (!question) | ||||||
|         return null |         {return null} | ||||||
| 
 | 
 | ||||||
|     try { |     try { | ||||||
|         await questionRepository.removeQuestionByLearningObjectAndSequenceNumber( |         await questionRepository.removeQuestionByLearningObjectAndSequenceNumber( | ||||||
|  |  | ||||||
|  | @ -23,9 +23,7 @@ export async function getAllStudents(): Promise<StudentDTO[]> { | ||||||
| 
 | 
 | ||||||
| export async function getAllStudentIds(): Promise<string[]> { | export async function getAllStudentIds(): Promise<string[]> { | ||||||
|     const users = await getAllStudents(); |     const users = await getAllStudents(); | ||||||
|     return users.map((user) => { |     return users.map((user) => user.username); | ||||||
|         return user.username; |  | ||||||
|     }); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function getStudent(username: string): Promise<StudentDTO | null> { | export async function getStudent(username: string): Promise<StudentDTO | null> { | ||||||
|  | @ -98,9 +96,7 @@ export async function getStudentAssignments(username: string, full: boolean): Pr | ||||||
| 
 | 
 | ||||||
|     const assignments = ( |     const assignments = ( | ||||||
|         await Promise.all( |         await Promise.all( | ||||||
|             classes.map(async (cls) => { |             classes.map(async (cls) => await getAllAssignments(cls.classId!, full)) | ||||||
|                 return await getAllAssignments(cls.classId!, full); |  | ||||||
|             }) |  | ||||||
|         ) |         ) | ||||||
|     ).flat(); |     ).flat(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -46,7 +46,7 @@ export async function deleteSubmission( | ||||||
|     const submission = getSubmission(learningObjectHruid, language, version, submissionNumber); |     const submission = getSubmission(learningObjectHruid, language, version, submissionNumber); | ||||||
| 
 | 
 | ||||||
|     if (!submission) |     if (!submission) | ||||||
|         return null |         {return null} | ||||||
| 
 | 
 | ||||||
|     const loId = new LearningObjectIdentifier(learningObjectHruid, language, version); |     const loId = new LearningObjectIdentifier(learningObjectHruid, language, version); | ||||||
|     await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(loId, submissionNumber); |     await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(loId, submissionNumber); | ||||||
|  |  | ||||||
|  | @ -27,9 +27,7 @@ export async function getAllTeachers(): Promise<TeacherDTO[]> { | ||||||
| 
 | 
 | ||||||
| export async function getAllTeacherIds(): Promise<string[]> { | export async function getAllTeacherIds(): Promise<string[]> { | ||||||
|     const users = await getAllTeachers(); |     const users = await getAllTeachers(); | ||||||
|     return users.map((user) => { |     return users.map((user) => user.username); | ||||||
|         return user.username; |  | ||||||
|     }); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function getTeacher(username: string): Promise<TeacherDTO | null> { | export async function getTeacher(username: string): Promise<TeacherDTO | null> { | ||||||
|  | @ -89,9 +87,7 @@ export async function getClassesByTeacher(username: string): Promise<ClassDTO[]> | ||||||
| 
 | 
 | ||||||
| export async function getClassIdsByTeacher(username: string): Promise<string[]> { | export async function getClassIdsByTeacher(username: string): Promise<string[]> { | ||||||
|     const classes = await fetchClassesByTeacher(username); |     const classes = await fetchClassesByTeacher(username); | ||||||
|     return classes.map((cls) => { |     return classes.map((cls) => cls.id); | ||||||
|         return cls.id; |  | ||||||
|     }); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function fetchStudentsByTeacher(username: string) { | export async function fetchStudentsByTeacher(username: string) { | ||||||
|  | @ -99,9 +95,7 @@ export async function fetchStudentsByTeacher(username: string) { | ||||||
| 
 | 
 | ||||||
|     return ( |     return ( | ||||||
|         await Promise.all( |         await Promise.all( | ||||||
|             classes.map(async (id) => { |             classes.map(async (id) => getClassStudents(id)) | ||||||
|                 return getClassStudents(id); |  | ||||||
|             }) |  | ||||||
|         ) |         ) | ||||||
|     ).flat(); |     ).flat(); | ||||||
| } | } | ||||||
|  | @ -112,9 +106,7 @@ export async function getStudentsByTeacher(username: string): Promise<StudentDTO | ||||||
| 
 | 
 | ||||||
| export async function getStudentIdsByTeacher(username: string): Promise<string[]> { | export async function getStudentIdsByTeacher(username: string): Promise<string[]> { | ||||||
|     const students = await fetchStudentsByTeacher(username); |     const students = await fetchStudentsByTeacher(username); | ||||||
|     return students.map((student) => { |     return students.map((student) => student.username); | ||||||
|         return student.username; |  | ||||||
|     }); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function fetchTeacherQuestions(username: string): Promise<QuestionDTO[]> { | export async function fetchTeacherQuestions(username: string): Promise<QuestionDTO[]> { | ||||||
|  |  | ||||||
|  | @ -16,9 +16,7 @@ export class UserService<T extends User> { | ||||||
| 
 | 
 | ||||||
|     async getAllUserIds(): Promise<string[]> { |     async getAllUserIds(): Promise<string[]> { | ||||||
|         const users = await this.getAllUsers(); |         const users = await this.getAllUsers(); | ||||||
|         return users.map((user) => { |         return users.map((user) => user.username); | ||||||
|             return user.username; |  | ||||||
|         }); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async getUserByUsername(username: string): Promise<UserDTO | null> { |     async getUserByUsername(username: string): Promise<UserDTO | null> { | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Lint Action
						Lint Action