Merge remote-tracking branch 'origin/dev' into feat/user-routes
# Conflicts: # backend/src/controllers/students.ts # backend/src/controllers/teachers.ts # backend/src/data/classes/class-join-request-repository.ts # backend/src/routes/students.ts # backend/src/services/students.ts # backend/src/services/teachers.ts # backend/tests/test_assets/users/students.testdata.ts # frontend/src/controllers/controllers.ts # frontend/src/queries/themes.ts
This commit is contained in:
		
						commit
						7f189188e8
					
				
					 139 changed files with 3594 additions and 3063 deletions
				
			
		|  | @ -3,9 +3,7 @@ import { setupTestApp } from '../../setup-tests'; | |||
| import { ClassJoinRequestRepository } from '../../../src/data/classes/class-join-request-repository'; | ||||
| import { getClassJoinRequestRepository, getClassRepository, getStudentRepository } from '../../../src/data/repositories'; | ||||
| import { StudentRepository } from '../../../src/data/users/student-repository'; | ||||
| import { Class } from '../../../src/entities/classes/class.entity'; | ||||
| import { ClassRepository } from '../../../src/data/classes/class-repository'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| 
 | ||||
| describe('ClassJoinRequestRepository', () => { | ||||
|     let classJoinRequestRepository: ClassJoinRequestRepository; | ||||
|  |  | |||
|  | @ -10,9 +10,12 @@ import { LearningObjectIdentifier } from '../../../src/entities/content/learning | |||
| 
 | ||||
| const NEWER_TEST_SUFFIX = 'nEweR'; | ||||
| 
 | ||||
| function createTestLearningObjects(learningObjectRepo: LearningObjectRepository): { older: LearningObject; newer: LearningObject } { | ||||
| async function createTestLearningObjects(learningObjectRepo: LearningObjectRepository): Promise<{ | ||||
|     older: LearningObject; | ||||
|     newer: LearningObject; | ||||
| }> { | ||||
|     const olderExample = example.createLearningObject(); | ||||
|     learningObjectRepo.save(olderExample); | ||||
|     await learningObjectRepo.save(olderExample); | ||||
| 
 | ||||
|     const newerExample = example.createLearningObject(); | ||||
|     newerExample.title = 'Newer example'; | ||||
|  | @ -32,23 +35,21 @@ describe('AttachmentRepository', () => { | |||
|     beforeAll(async () => { | ||||
|         await setupTestApp(); | ||||
|         attachmentRepo = getAttachmentRepository(); | ||||
|         exampleLearningObjects = createTestLearningObjects(getLearningObjectRepository()); | ||||
|         exampleLearningObjects = await createTestLearningObjects(getLearningObjectRepository()); | ||||
|     }); | ||||
| 
 | ||||
|     it('can add attachments to learning objects without throwing an error', () => { | ||||
|     it('can add attachments to learning objects without throwing an error', async () => { | ||||
|         attachmentsOlderLearningObject = Object.values(example.createAttachment).map((fn) => fn(exampleLearningObjects.older)); | ||||
| 
 | ||||
|         for (const attachment of attachmentsOlderLearningObject) { | ||||
|             attachmentRepo.save(attachment); | ||||
|         } | ||||
|         await Promise.all(attachmentsOlderLearningObject.map(async (attachment) => attachmentRepo.save(attachment))); | ||||
|     }); | ||||
| 
 | ||||
|     let attachmentOnlyNewer: Attachment; | ||||
|     it('allows us to add attachments with the same name to a different learning object without throwing an error', () => { | ||||
|     it('allows us to add attachments with the same name to a different learning object without throwing an error', async () => { | ||||
|         attachmentOnlyNewer = Object.values(example.createAttachment)[0](exampleLearningObjects.newer); | ||||
|         attachmentOnlyNewer.content.write(NEWER_TEST_SUFFIX); | ||||
| 
 | ||||
|         attachmentRepo.save(attachmentOnlyNewer); | ||||
|         await attachmentRepo.save(attachmentOnlyNewer); | ||||
|     }); | ||||
| 
 | ||||
|     let olderLearningObjectId: LearningObjectIdentifier; | ||||
|  |  | |||
|  | @ -10,7 +10,7 @@ import { Language } from '../../../src/entities/content/language.js'; | |||
| function expectToHaveFoundPrecisely(expected: LearningPath, result: LearningPath[]): void { | ||||
|     expect(result).toHaveProperty('length'); | ||||
|     expect(result.length).toBe(1); | ||||
|     expectToBeCorrectEntity({ entity: result[0]! }, { entity: expected }); | ||||
|     expectToBeCorrectEntity({ entity: result[0] }, { entity: expected }); | ||||
| } | ||||
| 
 | ||||
| function expectToHaveFoundNothing(result: LearningPath[]): void { | ||||
|  |  | |||
|  | @ -23,9 +23,9 @@ describe('AnswerRepository', () => { | |||
|         const id = new LearningObjectIdentifier('id05', Language.English, 1); | ||||
|         const questions = await questionRepository.findAllQuestionsAboutLearningObject(id); | ||||
| 
 | ||||
|         const question = questions.filter((it) => it.sequenceNumber == 2)[0]; | ||||
|         const question = questions.find((it) => it.sequenceNumber === 2); | ||||
| 
 | ||||
|         const answers = await answerRepository.findAllAnswersToQuestion(question); | ||||
|         const answers = await answerRepository.findAllAnswersToQuestion(question!); | ||||
| 
 | ||||
|         expect(answers).toBeTruthy(); | ||||
|         expect(answers).toHaveLength(2); | ||||
|  |  | |||
|  | @ -1,22 +1,19 @@ | |||
| import { beforeAll, describe, expect, it } from 'vitest'; | ||||
| import { setupTestApp } from '../../setup-tests'; | ||||
| import { QuestionRepository } from '../../../src/data/questions/question-repository'; | ||||
| import { getLearningObjectRepository, getQuestionRepository, getStudentRepository } from '../../../src/data/repositories'; | ||||
| import { getQuestionRepository, getStudentRepository } from '../../../src/data/repositories'; | ||||
| import { StudentRepository } from '../../../src/data/users/student-repository'; | ||||
| import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository'; | ||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| 
 | ||||
| describe('QuestionRepository', () => { | ||||
|     let questionRepository: QuestionRepository; | ||||
|     let studentRepository: StudentRepository; | ||||
|     let learningObjectRepository: LearningObjectRepository; | ||||
| 
 | ||||
|     beforeAll(async () => { | ||||
|         await setupTestApp(); | ||||
|         questionRepository = getQuestionRepository(); | ||||
|         studentRepository = getStudentRepository(); | ||||
|         learningObjectRepository = getLearningObjectRepository(); | ||||
|     }); | ||||
| 
 | ||||
|     it('should return all questions part of the given learning object', async () => { | ||||
|  |  | |||
|  | @ -78,7 +78,7 @@ describe('DatabaseLearningObjectProvider', () => { | |||
|         }); | ||||
|         it('should throw an error if queried with a path identifier for which there is no learning path', async () => { | ||||
|             await expect( | ||||
|                 (async () => { | ||||
|                 (async (): Promise<void> => { | ||||
|                     await databaseLearningObjectProvider.getLearningObjectIdsFromPath({ | ||||
|                         hruid: 'non_existing_hruid', | ||||
|                         language: Language.Dutch, | ||||
|  | @ -97,7 +97,7 @@ describe('DatabaseLearningObjectProvider', () => { | |||
|         }); | ||||
|         it('should throw an error if queried with a path identifier for which there is no learning path', async () => { | ||||
|             await expect( | ||||
|                 (async () => { | ||||
|                 (async (): Promise<void> => { | ||||
|                     await databaseLearningObjectProvider.getLearningObjectsFromPath({ | ||||
|                         hruid: 'non_existing_hruid', | ||||
|                         language: Language.Dutch, | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import learningObjectExample from '../../test-assets/learning-objects/pn-werking | |||
| import learningObjectService from '../../../src/services/learning-objects/learning-object-service'; | ||||
| import { LearningObjectIdentifier, LearningPathIdentifier } from '../../../src/interfaces/learning-content'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { EnvVars, getEnvVar } from '../../../src/util/envvars'; | ||||
| import { envVars, getEnvVar } from '../../../src/util/envVars'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import learningPathExample from '../../test-assets/learning-paths/pn-werking-example'; | ||||
| 
 | ||||
|  | @ -79,7 +79,7 @@ describe('LearningObjectService', () => { | |||
|                 expect(result).not.toBeNull(); | ||||
| 
 | ||||
|                 const responseFromDwengoApi = await fetch( | ||||
|                     getEnvVar(EnvVars.LearningContentRepoApiBaseUrl) + | ||||
|                     getEnvVar(envVars.LearningContentRepoApiBaseUrl) + | ||||
|                         `/learningObject/getRaw?hruid=${DWENGO_TEST_LEARNING_OBJECT_ID.hruid}&language=${DWENGO_TEST_LEARNING_OBJECT_ID.language}&version=${DWENGO_TEST_LEARNING_OBJECT_ID.version}` | ||||
|                 ); | ||||
|                 const responseHtml = await responseFromDwengoApi.text(); | ||||
|  |  | |||
|  | @ -46,8 +46,6 @@ async function initPersonalizationTestData(): Promise<{ | |||
|     await learningObjectRepo.save(learningContent.extraExerciseObject); | ||||
|     await learningPathRepo.save(learningContent.learningPath); | ||||
| 
 | ||||
|     console.log(await getSubmissionRepository().findAll({})); | ||||
| 
 | ||||
|     const studentA = studentRepo.create({ | ||||
|         username: 'student_a', | ||||
|         firstName: 'Aron', | ||||
|  | @ -124,7 +122,7 @@ describe('DatabaseLearningPathProvider', () => { | |||
| 
 | ||||
|             const learningObjectsOnPath = ( | ||||
|                 await Promise.all( | ||||
|                     example.learningPath.nodes.map((node) => | ||||
|                     example.learningPath.nodes.map(async (node) => | ||||
|                         learningObjectService.getLearningObjectById({ | ||||
|                             hruid: node.learningObjectHruid, | ||||
|                             version: node.version, | ||||
|  |  | |||
|  | @ -39,8 +39,8 @@ describe('LearningPathService', () => { | |||
|             expect(result.success).toBeTruthy(); | ||||
|             expect(result.data?.filter((it) => it.hruid === TEST_DWENGO_LEARNING_PATH_HRUID).length).not.toBe(0); | ||||
|             expect(result.data?.filter((it) => it.hruid === example.learningPath.hruid).length).not.toBe(0); | ||||
|             expect(result.data?.filter((it) => it.hruid === TEST_DWENGO_LEARNING_PATH_HRUID)[0].title).toEqual(TEST_DWENGO_LEARNING_PATH_TITLE); | ||||
|             expect(result.data?.filter((it) => it.hruid === example.learningPath.hruid)[0].title).toEqual(example.learningPath.title); | ||||
|             expect(result.data?.find((it) => it.hruid === TEST_DWENGO_LEARNING_PATH_HRUID)?.title).toEqual(TEST_DWENGO_LEARNING_PATH_TITLE); | ||||
|             expect(result.data?.find((it) => it.hruid === example.learningPath.hruid)?.title).toEqual(example.learningPath.title); | ||||
|         }); | ||||
|         it('should include both the learning objects from the Dwengo API and learning objects from the database in its response', async () => { | ||||
|             const result = await learningPathService.fetchLearningPaths([example.learningPath.hruid], example.learningPath.language, 'the source'); | ||||
|  |  | |||
|  | @ -14,7 +14,7 @@ import { makeTestQuestions } from './test_assets/questions/questions.testdata.js | |||
| import { makeTestAnswers } from './test_assets/questions/answers.testdata.js'; | ||||
| import { makeTestSubmissions } from './test_assets/assignments/submission.testdata.js'; | ||||
| 
 | ||||
| export async function setupTestApp() { | ||||
| export async function setupTestApp(): Promise<void> { | ||||
|     dotenv.config({ path: '.env.test' }); | ||||
|     await initORM(true); | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import { LearningObject } from '../../../../src/entities/content/learning-object | |||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { loadTestAsset } from '../../../test-utils/load-test-asset'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| import { EnvVars, getEnvVar } from '../../../../src/util/envvars'; | ||||
| import { envVars, getEnvVar } from '../../../../src/util/envVars'; | ||||
| 
 | ||||
| /** | ||||
|  * Create a dummy learning object to be used in tests where multiple learning objects are needed (for example for use | ||||
|  | @ -11,9 +11,9 @@ import { EnvVars, getEnvVar } from '../../../../src/util/envvars'; | |||
|  */ | ||||
| export function dummyLearningObject(hruid: string, language: Language, title: string): LearningObjectExample { | ||||
|     return { | ||||
|         createLearningObject: () => { | ||||
|         createLearningObject: (): LearningObject => { | ||||
|             const learningObject = new LearningObject(); | ||||
|             learningObject.hruid = getEnvVar(EnvVars.UserContentPrefix) + hruid; | ||||
|             learningObject.hruid = getEnvVar(envVars.UserContentPrefix) + hruid; | ||||
|             learningObject.language = language; | ||||
|             learningObject.version = 1; | ||||
|             learningObject.title = title; | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||
| import { Attachment } from '../../../src/entities/content/attachment.entity'; | ||||
| 
 | ||||
| type LearningObjectExample = { | ||||
| interface LearningObjectExample { | ||||
|     createLearningObject: () => LearningObject; | ||||
|     createAttachment: { [key: string]: (owner: LearningObject) => Attachment }; | ||||
|     createAttachment: Record<string, (owner: LearningObject) => Attachment>; | ||||
|     getHTMLRendering: () => string; | ||||
| }; | ||||
| } | ||||
|  |  | |||
|  | @ -2,16 +2,18 @@ import { LearningObjectExample } from '../learning-object-example'; | |||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| import { loadTestAsset } from '../../../test-utils/load-test-asset'; | ||||
| import { EducationalGoal, LearningObject, ReturnValue } from '../../../../src/entities/content/learning-object.entity'; | ||||
| import { LearningObject } from '../../../../src/entities/content/learning-object.entity'; | ||||
| import { Attachment } from '../../../../src/entities/content/attachment.entity'; | ||||
| import { EnvVars, getEnvVar } from '../../../../src/util/envvars'; | ||||
| import { envVars, getEnvVar } from '../../../../src/util/envVars'; | ||||
| import { EducationalGoal } from '../../../../src/entities/content/educational-goal.entity'; | ||||
| import { ReturnValue } from '../../../../src/entities/content/return-value.entity'; | ||||
| 
 | ||||
| const ASSETS_PREFIX = 'learning-objects/pn-werkingnotebooks/'; | ||||
| 
 | ||||
| const example: LearningObjectExample = { | ||||
|     createLearningObject: () => { | ||||
|         const learningObject = new LearningObject(); | ||||
|         learningObject.hruid = `${getEnvVar(EnvVars.UserContentPrefix)}pn_werkingnotebooks`; | ||||
|         learningObject.hruid = `${getEnvVar(envVars.UserContentPrefix)}pn_werkingnotebooks`; | ||||
|         learningObject.version = 3; | ||||
|         learningObject.language = Language.Dutch; | ||||
|         learningObject.title = 'Werken met notebooks'; | ||||
|  |  | |||
|  | @ -1,14 +1,14 @@ | |||
| import { LearningObjectExample } from '../learning-object-example'; | ||||
| import { LearningObject } from '../../../../src/entities/content/learning-object.entity'; | ||||
| import { loadTestAsset } from '../../../test-utils/load-test-asset'; | ||||
| import { EnvVars, getEnvVar } from '../../../../src/util/envvars'; | ||||
| import { envVars, getEnvVar } from '../../../../src/util/envVars'; | ||||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| 
 | ||||
| const example: LearningObjectExample = { | ||||
|     createLearningObject: () => { | ||||
|         const learningObject = new LearningObject(); | ||||
|         learningObject.hruid = `${getEnvVar(EnvVars.UserContentPrefix)}test_essay`; | ||||
|         learningObject.hruid = `${getEnvVar(envVars.UserContentPrefix)}test_essay`; | ||||
|         learningObject.language = Language.English; | ||||
|         learningObject.version = 1; | ||||
|         learningObject.title = 'Essay question for testing'; | ||||
|  |  | |||
|  | @ -1,14 +1,14 @@ | |||
| import { LearningObjectExample } from '../learning-object-example'; | ||||
| import { LearningObject } from '../../../../src/entities/content/learning-object.entity'; | ||||
| import { loadTestAsset } from '../../../test-utils/load-test-asset'; | ||||
| import { EnvVars, getEnvVar } from '../../../../src/util/envvars'; | ||||
| import { envVars, getEnvVar } from '../../../../src/util/envVars'; | ||||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| 
 | ||||
| const example: LearningObjectExample = { | ||||
|     createLearningObject: () => { | ||||
|         const learningObject = new LearningObject(); | ||||
|         learningObject.hruid = `${getEnvVar(EnvVars.UserContentPrefix)}test_multiple_choice`; | ||||
|         learningObject.hruid = `${getEnvVar(envVars.UserContentPrefix)}test_multiple_choice`; | ||||
|         learningObject.language = Language.English; | ||||
|         learningObject.version = 1; | ||||
|         learningObject.title = 'Multiple choice question for testing'; | ||||
|  |  | |||
|  | @ -1,3 +1,3 @@ | |||
| type LearningPathExample = { | ||||
| interface LearningPathExample { | ||||
|     createLearningPath: () => LearningPath; | ||||
| }; | ||||
| } | ||||
|  |  | |||
|  | @ -3,7 +3,12 @@ import { LearningPathTransition } from '../../../src/entities/content/learning-p | |||
| import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| 
 | ||||
| export function createLearningPathTransition(node: LearningPathNode, transitionNumber: number, condition: string | null, to: LearningPathNode) { | ||||
| export function createLearningPathTransition( | ||||
|     node: LearningPathNode, | ||||
|     transitionNumber: number, | ||||
|     condition: string | null, | ||||
|     to: LearningPathNode | ||||
| ): LearningPathTransition { | ||||
|     const trans = new LearningPathTransition(); | ||||
|     trans.node = node; | ||||
|     trans.transitionNumber = transitionNumber; | ||||
|  | @ -19,7 +24,7 @@ export function createLearningPathNode( | |||
|     version: number, | ||||
|     language: Language, | ||||
|     startNode: boolean | ||||
| ) { | ||||
| ): LearningPathNode { | ||||
|     const node = new LearningPathNode(); | ||||
|     node.learningPath = learningPath; | ||||
|     node.nodeNumber = nodeNumber; | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { EnvVars, getEnvVar } from '../../../src/util/envvars'; | ||||
| import { envVars, getEnvVar } from '../../../src/util/envVars'; | ||||
| import { createLearningPathNode, createLearningPathTransition } from './learning-path-utils'; | ||||
| import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; | ||||
| 
 | ||||
|  | @ -19,7 +19,7 @@ const example: LearningPathExample = { | |||
|     createLearningPath: () => { | ||||
|         const path = new LearningPath(); | ||||
|         path.language = Language.Dutch; | ||||
|         path.hruid = `${getEnvVar(EnvVars.UserContentPrefix)}pn_werking`; | ||||
|         path.hruid = `${getEnvVar(envVars.UserContentPrefix)}pn_werking`; | ||||
|         path.title = 'Werken met notebooks'; | ||||
|         path.description = 'Een korte inleiding tot Python notebooks. Hoe ga je gemakkelijk en efficiënt met de notebooks aan de slag?'; | ||||
|         path.nodes = createNodes(path); | ||||
|  |  | |||
|  | @ -4,18 +4,18 @@ import testMultipleChoiceExample from '../learning-objects/test-multiple-choice/ | |||
| import { dummyLearningObject } from '../learning-objects/dummy/dummy-learning-object-example'; | ||||
| import { createLearningPathNode, createLearningPathTransition } from './learning-path-utils'; | ||||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||
| import { EnvVars, getEnvVar } from '../../../src/util/envvars'; | ||||
| import { envVars, getEnvVar } from '../../../src/util/envVars'; | ||||
| 
 | ||||
| export type ConditionTestLearningPathAndLearningObjects = { | ||||
| export interface ConditionTestLearningPathAndLearningObjects { | ||||
|     branchingObject: LearningObject; | ||||
|     extraExerciseObject: LearningObject; | ||||
|     finalObject: LearningObject; | ||||
|     learningPath: LearningPath; | ||||
| }; | ||||
| } | ||||
| 
 | ||||
| export function createConditionTestLearningPathAndLearningObjects() { | ||||
| export function createConditionTestLearningPathAndLearningObjects(): ConditionTestLearningPathAndLearningObjects { | ||||
|     const learningPath = new LearningPath(); | ||||
|     learningPath.hruid = `${getEnvVar(EnvVars.UserContentPrefix)}test_conditions`; | ||||
|     learningPath.hruid = `${getEnvVar(envVars.UserContentPrefix)}test_conditions`; | ||||
|     learningPath.language = Language.English; | ||||
|     learningPath.title = 'Example learning path with conditional transitions'; | ||||
|     learningPath.description = 'This learning path was made for the purpose of testing conditional transitions'; | ||||
|  | @ -78,7 +78,3 @@ export function createConditionTestLearningPathAndLearningObjects() { | |||
|         learningPath: learningPath, | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| const example: LearningPathExample = { | ||||
|     createLearningPath: () => createConditionTestLearningPathAndLearningObjects().learningPath, | ||||
| }; | ||||
|  |  | |||
|  | @ -21,11 +21,11 @@ export function expectToBeCorrectEntity<T extends object>(actual: { entity: T; n | |||
|     } | ||||
|     for (const property in expected.entity) { | ||||
|         if ( | ||||
|             property! in IGNORE_PROPERTIES && | ||||
|             property in IGNORE_PROPERTIES && | ||||
|             expected.entity[property] !== undefined && // If we don't expect a certain value for a property, we assume it can be filled in by the database however it wants.
 | ||||
|             typeof expected.entity[property] !== 'function' // Functions obviously are not persisted via the database
 | ||||
|         ) { | ||||
|             if (!actual.entity.hasOwnProperty(property)) { | ||||
|             if (!Object.prototype.hasOwnProperty.call(actual.entity, property)) { | ||||
|                 throw new AssertionError({ | ||||
|                     message: `${expected.name} has defined property ${property}, but ${actual.name} is missing it.`, | ||||
|                 }); | ||||
|  | @ -69,7 +69,7 @@ export function expectToBeCorrectEntity<T extends object>(actual: { entity: T; n | |||
|  * @param filtered the representation as FilteredLearningObject | ||||
|  * @param original the original entity added to the database | ||||
|  */ | ||||
| export function expectToBeCorrectFilteredLearningObject(filtered: FilteredLearningObject, original: LearningObject) { | ||||
| export function expectToBeCorrectFilteredLearningObject(filtered: FilteredLearningObject, original: LearningObject): void { | ||||
|     expect(filtered.uuid).toEqual(original.uuid); | ||||
|     expect(filtered.version).toEqual(original.version); | ||||
|     expect(filtered.language).toEqual(original.language); | ||||
|  | @ -105,7 +105,7 @@ export function expectToBeCorrectLearningPath( | |||
|     learningPath: LearningPath, | ||||
|     expectedEntity: LearningPathEntity, | ||||
|     learningObjectsOnPath: FilteredLearningObject[] | ||||
| ) { | ||||
| ): void { | ||||
|     expect(learningPath.hruid).toEqual(expectedEntity.hruid); | ||||
|     expect(learningPath.language).toEqual(expectedEntity.language); | ||||
|     expect(learningPath.description).toEqual(expectedEntity.description); | ||||
|  | @ -136,10 +136,10 @@ export function expectToBeCorrectLearningPath( | |||
|             version: node.version, | ||||
|         }; | ||||
|         expect(expectedLearningPathNodes.keys()).toContainEqual(nodeKey); | ||||
|         const expectedNode = [...expectedLearningPathNodes.entries()].filter( | ||||
|         const expectedNode = [...expectedLearningPathNodes.entries()].find( | ||||
|             ([key, _]) => key.learningObjectHruid === nodeKey.learningObjectHruid && key.language === node.language && key.version === node.version | ||||
|         )[0][1]; | ||||
|         expect(node.start_node).toEqual(expectedNode?.startNode); | ||||
|         )![1]; | ||||
|         expect(node.start_node).toEqual(expectedNode.startNode); | ||||
| 
 | ||||
|         expect(new Set(node.transitions.map((it) => it.next.hruid))).toEqual( | ||||
|             new Set(expectedNode.transitions.map((it) => it.next.learningObjectHruid)) | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Assignment } from '../../../src/entities/assignments/assignment.entity'; | ||||
| import { Class } from '../../../src/entities/classes/class.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| 
 | ||||
| export function makeTestAssignemnts(em: EntityManager<IDatabaseDriver<Connection>>, classes: Array<Class>): Array<Assignment> { | ||||
| export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assignment[] { | ||||
|     const assignment01 = em.create(Assignment, { | ||||
|         within: classes[0], | ||||
|         id: 1, | ||||
|  |  | |||
|  | @ -1,13 +1,9 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Group } from '../../../src/entities/assignments/group.entity'; | ||||
| import { Assignment } from '../../../src/entities/assignments/assignment.entity'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| 
 | ||||
| export function makeTestGroups( | ||||
|     em: EntityManager<IDatabaseDriver<Connection>>, | ||||
|     students: Array<Student>, | ||||
|     assignments: Array<Assignment> | ||||
| ): Array<Group> { | ||||
| export function makeTestGroups(em: EntityManager, students: Student[], assignments: Assignment[]): Group[] { | ||||
|     const group01 = em.create(Group, { | ||||
|         assignment: assignments[0], | ||||
|         groupNumber: 1, | ||||
|  |  | |||
|  | @ -1,14 +1,10 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Submission } from '../../../src/entities/assignments/submission.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| import { Group } from '../../../src/entities/assignments/group.entity'; | ||||
| 
 | ||||
| export function makeTestSubmissions( | ||||
|     em: EntityManager<IDatabaseDriver<Connection>>, | ||||
|     students: Array<Student>, | ||||
|     groups: Array<Group> | ||||
| ): Array<Submission> { | ||||
| export function makeTestSubmissions(em: EntityManager, students: Student[], groups: Group[]): Submission[] { | ||||
|     const submission01 = em.create(Submission, { | ||||
|         learningObjectHruid: 'id03', | ||||
|         learningObjectLanguage: Language.English, | ||||
|  |  | |||
|  | @ -1,13 +1,9 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { ClassJoinRequest, ClassJoinRequestStatus } from '../../../src/entities/classes/class-join-request.entity'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| import { Class } from '../../../src/entities/classes/class.entity'; | ||||
| 
 | ||||
| export function makeTestClassJoinRequests( | ||||
|     em: EntityManager<IDatabaseDriver<Connection>>, | ||||
|     students: Array<Student>, | ||||
|     classes: Array<Class> | ||||
| ): Array<ClassJoinRequest> { | ||||
| export function makeTestClassJoinRequests(em: EntityManager, students: Student[], classes: Class[]): ClassJoinRequest[] { | ||||
|     const classJoinRequest01 = em.create(ClassJoinRequest, { | ||||
|         requester: students[4], | ||||
|         class: classes[1], | ||||
|  |  | |||
|  | @ -1,11 +1,11 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Class } from '../../../src/entities/classes/class.entity'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| import { Teacher } from '../../../src/entities/users/teacher.entity'; | ||||
| 
 | ||||
| export function makeTestClasses(em: EntityManager<IDatabaseDriver<Connection>>, students: Array<Student>, teachers: Array<Teacher>): Array<Class> { | ||||
| export function makeTestClasses(em: EntityManager, students: Student[], teachers: Teacher[]): Class[] { | ||||
|     const studentsClass01 = students.slice(0, 7); | ||||
|     const teacherClass01: Array<Teacher> = teachers.slice(0, 1); | ||||
|     const teacherClass01: Teacher[] = teachers.slice(0, 1); | ||||
| 
 | ||||
|     const class01 = em.create(Class, { | ||||
|         classId: 'id01', | ||||
|  | @ -14,8 +14,8 @@ export function makeTestClasses(em: EntityManager<IDatabaseDriver<Connection>>, | |||
|         students: studentsClass01, | ||||
|     }); | ||||
| 
 | ||||
|     const studentsClass02: Array<Student> = students.slice(0, 2).concat(students.slice(3, 4)); | ||||
|     const teacherClass02: Array<Teacher> = teachers.slice(1, 2); | ||||
|     const studentsClass02: Student[] = students.slice(0, 2).concat(students.slice(3, 4)); | ||||
|     const teacherClass02: Teacher[] = teachers.slice(1, 2); | ||||
| 
 | ||||
|     const class02 = em.create(Class, { | ||||
|         classId: 'id02', | ||||
|  | @ -24,8 +24,8 @@ export function makeTestClasses(em: EntityManager<IDatabaseDriver<Connection>>, | |||
|         students: studentsClass02, | ||||
|     }); | ||||
| 
 | ||||
|     const studentsClass03: Array<Student> = students.slice(1, 4); | ||||
|     const teacherClass03: Array<Teacher> = teachers.slice(2, 3); | ||||
|     const studentsClass03: Student[] = students.slice(1, 4); | ||||
|     const teacherClass03: Teacher[] = teachers.slice(2, 3); | ||||
| 
 | ||||
|     const class03 = em.create(Class, { | ||||
|         classId: 'id03', | ||||
|  | @ -34,8 +34,8 @@ export function makeTestClasses(em: EntityManager<IDatabaseDriver<Connection>>, | |||
|         students: studentsClass03, | ||||
|     }); | ||||
| 
 | ||||
|     const studentsClass04: Array<Student> = students.slice(0, 2); | ||||
|     const teacherClass04: Array<Teacher> = teachers.slice(2, 3); | ||||
|     const studentsClass04: Student[] = students.slice(0, 2); | ||||
|     const teacherClass04: Teacher[] = teachers.slice(2, 3); | ||||
| 
 | ||||
|     const class04 = em.create(Class, { | ||||
|         classId: 'id04', | ||||
|  |  | |||
|  | @ -1,13 +1,9 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { TeacherInvitation } from '../../../src/entities/classes/teacher-invitation.entity'; | ||||
| import { Teacher } from '../../../src/entities/users/teacher.entity'; | ||||
| import { Class } from '../../../src/entities/classes/class.entity'; | ||||
| 
 | ||||
| export function makeTestTeacherInvitations( | ||||
|     em: EntityManager<IDatabaseDriver<Connection>>, | ||||
|     teachers: Array<Teacher>, | ||||
|     classes: Array<Class> | ||||
| ): Array<TeacherInvitation> { | ||||
| export function makeTestTeacherInvitations(em: EntityManager, teachers: Teacher[], classes: Class[]): TeacherInvitation[] { | ||||
|     const teacherInvitation01 = em.create(TeacherInvitation, { | ||||
|         sender: teachers[1], | ||||
|         receiver: teachers[0], | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Attachment } from '../../../src/entities/content/attachment.entity'; | ||||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||
| 
 | ||||
| export function makeTestAttachments(em: EntityManager<IDatabaseDriver<Connection>>, learningObjects: Array<LearningObject>): Array<Attachment> { | ||||
| export function makeTestAttachments(em: EntityManager, learningObjects: LearningObject[]): Attachment[] { | ||||
|     const attachment01 = em.create(Attachment, { | ||||
|         learningObject: learningObjects[1], | ||||
|         name: 'attachment01', | ||||
|  |  | |||
|  | @ -1,9 +1,10 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { LearningObject, ReturnValue } from '../../../src/entities/content/learning-object.entity'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { DwengoContentType } from '../../../src/services/learning-objects/processing/content-type'; | ||||
| import { ReturnValue } from '../../../src/entities/content/return-value.entity'; | ||||
| 
 | ||||
| export function makeTestLearningObjects(em: EntityManager<IDatabaseDriver<Connection>>): Array<LearningObject> { | ||||
| export function makeTestLearningObjects(em: EntityManager): LearningObject[] { | ||||
|     const returnValue: ReturnValue = new ReturnValue(); | ||||
|     returnValue.callbackSchema = ''; | ||||
|     returnValue.callbackUrl = ''; | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { LearningPathTransition } from '../../../src/entities/content/learning-path-transition.entity'; | ||||
| import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; | ||||
| 
 | ||||
| export function makeTestLearningPaths(em: EntityManager<IDatabaseDriver<Connection>>): Array<LearningPath> { | ||||
| export function makeTestLearningPaths(em: EntityManager): LearningPath[] { | ||||
|     const learningPathNode01: LearningPathNode = new LearningPathNode(); | ||||
|     const learningPathNode02: LearningPathNode = new LearningPathNode(); | ||||
|     const learningPathNode03: LearningPathNode = new LearningPathNode(); | ||||
|  | @ -67,7 +67,7 @@ export function makeTestLearningPaths(em: EntityManager<IDatabaseDriver<Connecti | |||
|     learningPathNode05.transitions = [transitions05]; | ||||
|     learningPathNode05.version = 1; | ||||
| 
 | ||||
|     const nodes01: Array<LearningPathNode> = [ | ||||
|     const nodes01: LearningPathNode[] = [ | ||||
|         // LearningPathNode01,
 | ||||
|         // LearningPathNode02,
 | ||||
|     ]; | ||||
|  | @ -81,7 +81,7 @@ export function makeTestLearningPaths(em: EntityManager<IDatabaseDriver<Connecti | |||
|         nodes: nodes01, | ||||
|     }); | ||||
| 
 | ||||
|     const nodes02: Array<LearningPathNode> = [ | ||||
|     const nodes02: LearningPathNode[] = [ | ||||
|         // LearningPathNode03,
 | ||||
|         // LearningPathNode04,
 | ||||
|         // LearningPathNode05,
 | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Answer } from '../../../src/entities/questions/answer.entity'; | ||||
| import { Teacher } from '../../../src/entities/users/teacher.entity'; | ||||
| import { Question } from '../../../src/entities/questions/question.entity'; | ||||
| 
 | ||||
| export function makeTestAnswers(em: EntityManager<IDatabaseDriver<Connection>>, teachers: Array<Teacher>, questions: Array<Question>): Array<Answer> { | ||||
| export function makeTestAnswers(em: EntityManager, teachers: Teacher[], questions: Question[]): Answer[] { | ||||
|     const answer01 = em.create(Answer, { | ||||
|         author: teachers[0], | ||||
|         toQuestion: questions[1], | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Question } from '../../../src/entities/questions/question.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| 
 | ||||
| export function makeTestQuestions(em: EntityManager<IDatabaseDriver<Connection>>, students: Array<Student>): Array<Question> { | ||||
| export function makeTestQuestions(em: EntityManager, students: Student[]): Question[] { | ||||
|     const question01 = em.create(Question, { | ||||
|         learningObjectLanguage: Language.English, | ||||
|         learningObjectVersion: 1, | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { Teacher } from '../../../src/entities/users/teacher.entity'; | ||||
| import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| 
 | ||||
| export function makeTestTeachers(em: EntityManager<IDatabaseDriver<Connection>>): Array<Teacher> { | ||||
| export function makeTestTeachers(em: EntityManager): Teacher[] { | ||||
|     const teacher01 = em.create(Teacher, { | ||||
|         username: 'FooFighters', | ||||
|         firstName: 'Dave', | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl