refactor(backend): Linting

This commit is contained in:
Tibo De Peuter 2025-04-02 18:20:09 +02:00
parent f537830b15
commit 2dbadc7eab
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
3 changed files with 20 additions and 9 deletions

View file

@ -66,12 +66,13 @@ async function fetchLearningObjects(learningPathId: LearningPathIdentifier, full
}
const objects = await Promise.all(
nodes.map(async (node) =>
dwengoApiLearningObjectProvider.getLearningObjectById({
nodes.map(async (node) => {
const learningObjectId: LearningObjectIdentifier = {
hruid: node.learningobject_hruid,
language: learningPathId.language,
})
)
language: learningPathId.language
};
return dwengoApiLearningObjectProvider.getLearningObjectById(learningObjectId);
})
);
return objects.filter((obj): obj is FilteredLearningObject => obj !== null);
} catch (error) {

View file

@ -75,9 +75,14 @@ export async function createQuestion(questionDTO: QuestionDTO): Promise<Question
const author = mapToStudent(questionDTO.author);
const loId: LearningObjectIdentifier = {
...questionDTO.learningObjectIdentifier,
version: questionDTO.learningObjectIdentifier.version ?? 1,
}
try {
await questionRepository.createQuestion({
loId: questionDTO.learningObjectIdentifier,
loId,
author,
content: questionDTO.content,
});
@ -97,8 +102,13 @@ export async function deleteQuestion(questionId: QuestionId): Promise<QuestionDT
return null;
}
const loId : LearningObjectIdentifier = {
...questionId.learningObjectIdentifier,
version: questionId.learningObjectIdentifier.version ?? 1
}
try {
await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(questionId.learningObjectIdentifier, questionId.sequenceNumber);
await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(loId, questionId.sequenceNumber);
} catch (_) {
return null;
}

View file

@ -37,7 +37,7 @@ describe('DatabaseLearningObjectProvider', () => {
it('should return the learning object when it is queried by its id', async () => {
const result: FilteredLearningObject | null = await databaseLearningObjectProvider.getLearningObjectById(exampleLearningObject);
expect(result).toBeTruthy();
expectToBeCorrectFilteredLearningObject(result!, exampleLearningObject);
expectToBeCorrectFilteredLearningObject(result, exampleLearningObject);
});
it('should return the learning object when it is queried by only hruid and language (but not version)', async () => {
@ -46,7 +46,7 @@ describe('DatabaseLearningObjectProvider', () => {
language: exampleLearningObject.language,
});
expect(result).toBeTruthy();
expectToBeCorrectFilteredLearningObject(result!, exampleLearningObject);
expectToBeCorrectFilteredLearningObject(result, exampleLearningObject);
});
it('should return null when queried with an id that does not exist', async () => {