Merge remote-tracking branch 'origin/refactor/common' into feat/user-routes
# Conflicts: # backend/src/controllers/learning-objects.ts
This commit is contained in:
		
						commit
						01b40992e2
					
				
					 15 changed files with 35 additions and 32 deletions
				
			
		|  | @ -6,11 +6,7 @@ import attachmentService from '../services/learning-objects/attachment-service.j | |||
| import { BadRequestException } from '../exceptions/bad-request-exception.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { envVars, getEnvVar } from '../util/envVars.js'; | ||||
| import { | ||||
|     FilteredLearningObject, | ||||
|     LearningObjectIdentifier, | ||||
|     LearningPathIdentifier | ||||
| } from "@dwengo-1/common/interfaces/learning-content"; | ||||
| import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| function getLearningObjectIdentifierFromRequest(req: Request): LearningObjectIdentifier { | ||||
|     if (!req.params.hruid) { | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { Language } from "@dwengo-1/common/util/language"; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| export class LearningObjectIdentifier { | ||||
|     constructor( | ||||
|  |  | |||
|  | @ -69,7 +69,7 @@ async function fetchLearningObjects(learningPathId: LearningPathIdentifier, full | |||
|             nodes.map(async (node) => { | ||||
|                 const learningObjectId: LearningObjectIdentifier = { | ||||
|                     hruid: node.learningobject_hruid, | ||||
|                     language: learningPathId.language | ||||
|                     language: learningPathId.language, | ||||
|                 }; | ||||
|                 return dwengoApiLearningObjectProvider.getLearningObjectById(learningObjectId); | ||||
|             }) | ||||
|  |  | |||
|  | @ -2,11 +2,7 @@ import dwengoApiLearningObjectProvider from './dwengo-api-learning-object-provid | |||
| import { LearningObjectProvider } from './learning-object-provider.js'; | ||||
| import { envVars, getEnvVar } from '../../util/envVars.js'; | ||||
| import databaseLearningObjectProvider from './database-learning-object-provider.js'; | ||||
| import { | ||||
|     FilteredLearningObject, | ||||
|     LearningObjectIdentifier, | ||||
|     LearningPathIdentifier, | ||||
| } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| function getProvider(id: LearningObjectIdentifier): LearningObjectProvider { | ||||
|     if (id.hruid.startsWith(getEnvVar(envVars.UserContentPrefix))) { | ||||
|  |  | |||
|  | @ -74,7 +74,7 @@ export async function createQuestion(questionDTO: QuestionDTO): Promise<Question | |||
|     const loId: LearningObjectIdentifier = { | ||||
|         ...questionDTO.learningObjectIdentifier, | ||||
|         version: questionDTO.learningObjectIdentifier.version ?? 1, | ||||
|     } | ||||
|     }; | ||||
| 
 | ||||
|     try { | ||||
|         await questionRepository.createQuestion({ | ||||
|  | @ -98,10 +98,10 @@ export async function deleteQuestion(questionId: QuestionId): Promise<QuestionDT | |||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     const loId : LearningObjectIdentifier = { | ||||
|     const loId: LearningObjectIdentifier = { | ||||
|         ...questionId.learningObjectIdentifier, | ||||
|         version: questionId.learningObjectIdentifier.version ?? 1 | ||||
|     } | ||||
|         version: questionId.learningObjectIdentifier.version ?? 1, | ||||
|     }; | ||||
| 
 | ||||
|     try { | ||||
|         await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(loId, questionId.sequenceNumber); | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { LearningObjectIdentifier } from "@dwengo-1/common/interfaces/learning-content"; | ||||
| import { LearningObjectIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| export function isValidHttpUrl(url: string): boolean { | ||||
|     try { | ||||
|  |  | |||
|  | @ -48,8 +48,8 @@ describe('LearningPathService', () => { | |||
|             expect(result.data?.length).toBe(1); | ||||
| 
 | ||||
|             // Should include all the nodes, even those pointing to foreign learning objects.
 | ||||
|             expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort()).toEqual( | ||||
|                 example.learningPath.nodes.map((it) => it.learningObjectHruid).sort() | ||||
|             expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort((a, b) => a.localeCompare(b))).toEqual( | ||||
|                 example.learningPath.nodes.map((it) => it.learningObjectHruid).sort((a, b) => a.localeCompare(b)) | ||||
|             ); | ||||
|         }); | ||||
|     }); | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
|     "include": ["src/**/*.ts"], | ||||
|     "compilerOptions": { | ||||
|         "rootDir": "./src", | ||||
|         "outDir": "./dist", | ||||
|         "outDir": "./dist" | ||||
|     }, | ||||
|     "references": [ | ||||
|         { | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl