Merge remote-tracking branch 'origin/refactor/common' into feat/user-routes
# Conflicts: # backend/src/controllers/students.ts # backend/src/controllers/teachers.ts # backend/src/interfaces/question.ts # backend/src/services/classes.ts # backend/src/services/students.ts # backend/src/services/teachers.ts
This commit is contained in:
		
						commit
						7d8a0fcbb2
					
				
					 96 changed files with 205 additions and 153 deletions
				
			
		|  | @ -9,7 +9,7 @@ import { | |||
|     getSubmissionRepository, | ||||
| } from '../../../src/data/repositories'; | ||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { StudentRepository } from '../../../src/data/users/student-repository'; | ||||
| import { GroupRepository } from '../../../src/data/assignments/group-repository'; | ||||
| import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository'; | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import { getAttachmentRepository, getLearningObjectRepository } from '../../../s | |||
| import { AttachmentRepository } from '../../../src/data/content/attachment-repository.js'; | ||||
| import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository.js'; | ||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier.js'; | ||||
| import { Language } from '../../../src/entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| describe('AttachmentRepository', () => { | ||||
|     let attachmentRepository: AttachmentRepository; | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import { LearningObjectRepository } from '../../../src/data/content/learning-obj | |||
| import { getLearningObjectRepository } from '../../../src/data/repositories'; | ||||
| import { setupTestApp } from '../../setup-tests'; | ||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| describe('LearningObjectRepository', () => { | ||||
|     let learningObjectRepository: LearningObjectRepository; | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ import { LearningPathRepository } from '../../../src/data/content/learning-path- | |||
| import example from '../../test-assets/learning-paths/pn-werking-example.js'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity.js'; | ||||
| import { expectToBeCorrectEntity } from '../../test-utils/expectations.js'; | ||||
| import { Language } from '../../../src/entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| function expectToHaveFoundPrecisely(expected: LearningPath, result: LearningPath[]): void { | ||||
|     expect(result).toHaveProperty('length'); | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { beforeAll, describe, expect, it } from 'vitest'; | |||
| import { getLearningPathRepository } from '../../../src/data/repositories'; | ||||
| import { LearningPathRepository } from '../../../src/data/content/learning-path-repository'; | ||||
| import { setupTestApp } from '../../setup-tests'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| describe('LearningPathRepository', () => { | ||||
|     let learningPathRepository: LearningPathRepository; | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import { AnswerRepository } from '../../../src/data/questions/answer-repository' | |||
| import { getAnswerRepository, getQuestionRepository, getTeacherRepository } from '../../../src/data/repositories'; | ||||
| import { QuestionRepository } from '../../../src/data/questions/question-repository'; | ||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { TeacherRepository } from '../../../src/data/users/teacher-repository'; | ||||
| 
 | ||||
| describe('AnswerRepository', () => { | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import { QuestionRepository } from '../../../src/data/questions/question-reposit | |||
| import { getQuestionRepository, getStudentRepository } from '../../../src/data/repositories'; | ||||
| import { StudentRepository } from '../../../src/data/users/student-repository'; | ||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| describe('QuestionRepository', () => { | ||||
|     let questionRepository: QuestionRepository; | ||||
|  |  | |||
|  | @ -5,11 +5,11 @@ import example from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-w | |||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||
| import databaseLearningObjectProvider from '../../../src/services/learning-objects/database-learning-object-provider'; | ||||
| import { expectToBeCorrectFilteredLearningObject } from '../../test-utils/expectations'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import learningObjectExample from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example'; | ||||
| import learningPathExample from '../../test-assets/learning-paths/pn-werking-example'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { FilteredLearningObject } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { FilteredLearningObject } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| async function initExampleData(): Promise<{ learningObject: LearningObject; learningPath: LearningPath }> { | ||||
|     const learningObjectRepo = getLearningObjectRepository(); | ||||
|  | @ -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 () => { | ||||
|  |  | |||
|  | @ -4,11 +4,11 @@ import { LearningObject } from '../../../src/entities/content/learning-object.en | |||
| import { getLearningObjectRepository, getLearningPathRepository } from '../../../src/data/repositories'; | ||||
| import learningObjectExample from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example'; | ||||
| import learningObjectService from '../../../src/services/learning-objects/learning-object-service'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| 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'; | ||||
| import { LearningObjectIdentifier, LearningPathIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| const EXPECTED_DWENGO_LEARNING_OBJECT_TITLE = 'Werken met notebooks'; | ||||
| const DWENGO_TEST_LEARNING_OBJECT_ID: LearningObjectIdentifier = { | ||||
|  |  | |||
|  | @ -13,14 +13,14 @@ import learningPathExample from '../../test-assets/learning-paths/pn-werking-exa | |||
| import databaseLearningPathProvider from '../../../src/services/learning-paths/database-learning-path-provider.js'; | ||||
| import { expectToBeCorrectLearningPath } from '../../test-utils/expectations.js'; | ||||
| import learningObjectService from '../../../src/services/learning-objects/learning-object-service.js'; | ||||
| import { Language } from '../../../src/entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { | ||||
|     ConditionTestLearningPathAndLearningObjects, | ||||
|     createConditionTestLearningPathAndLearningObjects, | ||||
| } from '../../test-assets/learning-paths/test-conditions-example.js'; | ||||
| import { Student } from '../../../src/entities/users/student.entity.js'; | ||||
| 
 | ||||
| import { LearningObjectNode, LearningPathResponse } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningObjectNode, LearningPathResponse } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| async function initExampleData(): Promise<{ learningObject: LearningObject; learningPath: LearningPath }> { | ||||
|     const learningObjectRepo = getLearningObjectRepository(); | ||||
|  |  | |||
|  | @ -5,8 +5,8 @@ import { LearningPath } from '../../../src/entities/content/learning-path.entity | |||
| import { getLearningObjectRepository, getLearningPathRepository } from '../../../src/data/repositories'; | ||||
| import learningObjectExample from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example'; | ||||
| import learningPathExample from '../../test-assets/learning-paths/pn-werking-example'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import learningPathService from '../../../src/services/learning-paths/learning-path-service'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| async function initExampleData(): Promise<{ learningObject: LearningObject; learningPath: LearningPath }> { | ||||
|     const learningObjectRepo = getLearningObjectRepository(); | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { LearningObjectExample } from '../learning-object-example'; | ||||
| import { LearningObject } from '../../../../src/entities/content/learning-object.entity'; | ||||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/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'; | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { LearningObjectExample } from '../learning-object-example'; | ||||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| import { loadTestAsset } from '../../../test-utils/load-test-asset'; | ||||
| import { LearningObject } from '../../../../src/entities/content/learning-object.entity'; | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ 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 { Language } from '../../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| 
 | ||||
| const example: LearningObjectExample = { | ||||
|  |  | |||
|  | @ -2,8 +2,8 @@ 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 { Language } from '../../../../src/entities/content/language'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| const example: LearningObjectExample = { | ||||
|     createLearningObject: () => { | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { LearningPathTransition } from '../../../src/entities/content/learning-path-transition.entity'; | ||||
| import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { envVars, getEnvVar } from '../../../src/util/envVars'; | ||||
| import { createLearningPathNode, createLearningPathTransition } from './learning-path-utils'; | ||||
| import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import testMultipleChoiceExample from '../learning-objects/test-multiple-choice/test-multiple-choice-example'; | ||||
| import { dummyLearningObject } from '../learning-objects/dummy/dummy-learning-object-example'; | ||||
| import { createLearningPathNode, createLearningPathTransition } from './learning-path-utils'; | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { AssertionError } from 'node:assert'; | |||
| import { LearningObject } from '../../src/entities/content/learning-object.entity'; | ||||
| import { LearningPath as LearningPathEntity } from '../../src/entities/content/learning-path.entity'; | ||||
| import { expect } from 'vitest'; | ||||
| import { FilteredLearningObject, LearningPath } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { FilteredLearningObject, LearningPath } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| // Ignored properties because they belang for example to the class, not to the entity itself.
 | ||||
| const IGNORE_PROPERTIES = ['parent']; | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| 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'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assignment[] { | ||||
|     const assignment01 = em.create(Assignment, { | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Submission } from '../../../src/entities/assignments/submission.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| import { Group } from '../../../src/entities/assignments/group.entity'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,8 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { ClassJoinRequest, ClassJoinRequestStatus } from '../../../src/entities/classes/class-join-request.entity'; | ||||
| import { ClassJoinRequest } from '../../../src/entities/classes/class-join-request.entity'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| import { Class } from '../../../src/entities/classes/class.entity'; | ||||
| import { ClassJoinRequestStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export function makeTestClassJoinRequests(em: EntityManager, students: Student[], classes: Class[]): ClassJoinRequest[] { | ||||
|     const classJoinRequest01 = em.create(ClassJoinRequest, { | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { DwengoContentType } from '../../../src/services/learning-objects/processing/content-type'; | ||||
| import { ReturnValue } from '../../../src/entities/content/return-value.entity'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { LearningPathTransition } from '../../../src/entities/content/learning-path-transition.entity'; | ||||
| import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Question } from '../../../src/entities/questions/question.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| 
 | ||||
| export function makeTestQuestions(em: EntityManager, students: Student[]): Question[] { | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl