From fc925702820237e2233bee366b63b99f9ebdce2a Mon Sep 17 00:00:00 2001 From: Lint Action Date: Sat, 17 May 2025 17:59:13 +0000 Subject: [PATCH] style: fix linting issues met Prettier --- backend/src/controllers/learning-paths.ts | 4 +- .../data/content/learning-path-repository.ts | 11 +- .../database-learning-path-provider.ts | 26 +- .../dwengo-api-learning-path-provider.ts | 2 +- .../learning-paths/learning-path-service.ts | 17 +- .../database-learning-path-provider.test.ts | 12 +- .../components/DiscussionSideBarElement.vue | 89 +++-- .../src/components/DiscussionsSideBar.vue | 41 +- frontend/src/components/QandA.vue | 24 +- frontend/src/components/QuestionBox.vue | 237 ++++++----- frontend/src/components/SingleQuestion.vue | 3 +- frontend/src/router/index.ts | 40 +- .../views/discussions/DiscussionForward.vue | 31 +- .../src/views/discussions/NoDiscussion.vue | 9 +- .../views/discussions/SingleDiscussion.vue | 373 +++++++++--------- .../views/learning-paths/LearningPathPage.vue | 84 ++-- 16 files changed, 498 insertions(+), 505 deletions(-) diff --git a/backend/src/controllers/learning-paths.ts b/backend/src/controllers/learning-paths.ts index 88d1ad5d..a38f50e3 100644 --- a/backend/src/controllers/learning-paths.ts +++ b/backend/src/controllers/learning-paths.ts @@ -66,7 +66,7 @@ export async function getLearningPaths(req: AuthenticatedRequest, res: Response) if (req.auth) { const adminUsername = req.auth.username; - const userLearningPaths = await learningPathService.getLearningPathsAdministratedBy(adminUsername) || []; + const userLearningPaths = (await learningPathService.getLearningPathsAdministratedBy(adminUsername)) || []; allLearningPaths = apiLearningPaths.concat(userLearningPaths); } @@ -78,7 +78,7 @@ export async function getLearningPaths(req: AuthenticatedRequest, res: Response) hruidList, language as Language, `HRUIDs: ${hruidList.join(', ')}`, - forGroup, + forGroup ); res.json(learningPaths.data); } diff --git a/backend/src/data/content/learning-path-repository.ts b/backend/src/data/content/learning-path-repository.ts index 6910476e..87a03748 100644 --- a/backend/src/data/content/learning-path-repository.ts +++ b/backend/src/data/content/learning-path-repository.ts @@ -7,10 +7,13 @@ import { LearningPathTransition } from '../../entities/content/learning-path-tra export class LearningPathRepository extends DwengoEntityRepository { public async findByHruidAndLanguage(hruid: string, language: Language): Promise { - return this.findOne({ - hruid: hruid, - language: language, - }, { populate: ['nodes', 'nodes.transitions', 'admins'] }); + return this.findOne( + { + hruid: hruid, + language: language, + }, + { populate: ['nodes', 'nodes.transitions', 'admins'] } + ); } /** diff --git a/backend/src/services/learning-paths/database-learning-path-provider.ts b/backend/src/services/learning-paths/database-learning-path-provider.ts index ff4f9e4d..8c82132e 100644 --- a/backend/src/services/learning-paths/database-learning-path-provider.ts +++ b/backend/src/services/learning-paths/database-learning-path-provider.ts @@ -4,11 +4,7 @@ import { getLearningPathRepository } from '../../data/repositories.js'; import learningObjectService from '../learning-objects/learning-object-service.js'; import { LearningPathNode } from '../../entities/content/learning-path-node.entity.js'; import { LearningPathTransition } from '../../entities/content/learning-path-transition.entity.js'; -import { - getLastSubmissionForGroup, - idFromLearningPathNode, - isTransitionPossible, -} from './learning-path-personalization-util.js'; +import { getLastSubmissionForGroup, idFromLearningPathNode, isTransitionPossible } from './learning-path-personalization-util.js'; import { FilteredLearningObject, LearningObjectNode, @@ -41,9 +37,9 @@ async function getLearningObjectsForNodes(nodes: Collection): version: node.version, language: node.language, }) - .then((learningObject) => [node, learningObject] as [LearningPathNode, FilteredLearningObject | null]), - ), - ), + .then((learningObject) => [node, learningObject] as [LearningPathNode, FilteredLearningObject | null]) + ) + ) ); // Ignore all learning objects that cannot be found such that the rest of the learning path keeps working. @@ -105,14 +101,14 @@ async function convertNode( node: LearningPathNode, learningObject: FilteredLearningObject, personalizedFor: Group | undefined, - nodesToLearningObjects: Map, + nodesToLearningObjects: Map ): Promise { const lastSubmission = personalizedFor ? await getLastSubmissionForGroup(idFromLearningPathNode(node), personalizedFor) : null; const transitions = node.transitions .filter( (trans) => !personalizedFor || // If we do not want a personalized learning path, keep all transitions - isTransitionPossible(trans, optionalJsonStringToObject(lastSubmission?.content)), // Otherwise remove all transitions that aren't possible. + isTransitionPossible(trans, optionalJsonStringToObject(lastSubmission?.content)) // Otherwise remove all transitions that aren't possible. ) .map((trans, i) => { try { @@ -145,10 +141,10 @@ async function convertNode( */ async function convertNodes( nodesToLearningObjects: Map, - personalizedFor?: Group, + personalizedFor?: Group ): Promise { const nodesPromise = Array.from(nodesToLearningObjects.entries()).map(async (entry) => - convertNode(entry[0], entry[1], personalizedFor, nodesToLearningObjects), + convertNode(entry[0], entry[1], personalizedFor, nodesToLearningObjects) ); return await Promise.all(nodesPromise); } @@ -175,7 +171,7 @@ function optionalJsonStringToObject(jsonString?: string): object | null { function convertTransition( transition: LearningPathTransition, index: number, - nodesToLearningObjects: Map, + nodesToLearningObjects: Map ): Transition { const nextNode = nodesToLearningObjects.get(transition.next); if (!nextNode) { @@ -206,10 +202,10 @@ const databaseLearningPathProvider: LearningPathProvider = { const learningPathRepo = getLearningPathRepository(); const learningPaths = (await Promise.all(hruids.map(async (hruid) => learningPathRepo.findByHruidAndLanguage(hruid, language)))).filter( - (learningPath) => learningPath !== null, + (learningPath) => learningPath !== null ); const filteredLearningPaths = await Promise.all( - learningPaths.map(async (learningPath, index) => convertLearningPath(learningPath, index, personalizedFor)), + learningPaths.map(async (learningPath, index) => convertLearningPath(learningPath, index, personalizedFor)) ); return { diff --git a/backend/src/services/learning-paths/dwengo-api-learning-path-provider.ts b/backend/src/services/learning-paths/dwengo-api-learning-path-provider.ts index d4a59b96..77cae652 100644 --- a/backend/src/services/learning-paths/dwengo-api-learning-path-provider.ts +++ b/backend/src/services/learning-paths/dwengo-api-learning-path-provider.ts @@ -19,7 +19,7 @@ async function addProgressToLearningPath(learningPath: LearningPath, personalize learningPath.nodes.map(async (node) => { const lastSubmission = personalizedFor ? await getLastSubmissionForGroup(idFromLearningObjectNode(node), personalizedFor) : null; node.done = Boolean(lastSubmission); - }), + }) ); learningPath.num_nodes = learningPath.nodes.length; diff --git a/backend/src/services/learning-paths/learning-path-service.ts b/backend/src/services/learning-paths/learning-path-service.ts index 16e9d2d0..a2320fa6 100644 --- a/backend/src/services/learning-paths/learning-path-service.ts +++ b/backend/src/services/learning-paths/learning-path-service.ts @@ -1,12 +1,7 @@ import dwengoApiLearningPathProvider from './dwengo-api-learning-path-provider.js'; import databaseLearningPathProvider from './database-learning-path-provider.js'; import { envVars, getEnvVar } from '../../util/envVars.js'; -import { - LearningObjectNode, - LearningPath, - LearningPathIdentifier, - LearningPathResponse, -} from '@dwengo-1/common/interfaces/learning-content'; +import { LearningObjectNode, LearningPath, LearningPathIdentifier, LearningPathResponse } from '@dwengo-1/common/interfaces/learning-content'; import { Language } from '@dwengo-1/common/util/language'; import { Group } from '../../entities/assignments/group.entity.js'; import { LearningPath as LearningPathEntity } from '../../entities/content/learning-path.entity.js'; @@ -46,16 +41,16 @@ export function mapToLearningPath(dto: LearningPath, adminsDto: TeacherDTO[]): L startNode: nodeDto.start_node ?? false, createdAt: new Date(), updatedAt: new Date(), - }), + }) ); dto.nodes.forEach((nodeDto) => { const fromNode = nodes.find( - (it) => it.learningObjectHruid === nodeDto.learningobject_hruid && it.language === nodeDto.language && it.version === nodeDto.version, + (it) => it.learningObjectHruid === nodeDto.learningobject_hruid && it.language === nodeDto.language && it.version === nodeDto.version )!; const transitions = nodeDto.transitions.map((transDto, i) => { const toNode = nodes.find( (it) => - it.learningObjectHruid === transDto.next.hruid && it.language === transDto.next.language && it.version === transDto.next.version, + it.learningObjectHruid === transDto.next.hruid && it.language === transDto.next.language && it.version === transDto.next.version ); if (toNode) { @@ -99,7 +94,7 @@ const learningPathService = { nonUserContentHruids, language, source, - personalizedFor, + personalizedFor ); const result = (userContentLearningPaths.data || []).concat(nonUserContentLearningPaths.data || []); @@ -124,7 +119,7 @@ const learningPathService = { */ async searchLearningPaths(query: string, language: Language, personalizedFor?: Group): Promise { const providerResponses = await Promise.all( - allProviders.map(async (provider) => provider.searchLearningPaths(query, language, personalizedFor)), + allProviders.map(async (provider) => provider.searchLearningPaths(query, language, personalizedFor)) ); return providerResponses.flat(); }, diff --git a/backend/tests/services/learning-path/database-learning-path-provider.test.ts b/backend/tests/services/learning-path/database-learning-path-provider.test.ts index f3b3d4ee..59843701 100644 --- a/backend/tests/services/learning-path/database-learning-path-provider.test.ts +++ b/backend/tests/services/learning-path/database-learning-path-provider.test.ts @@ -151,19 +151,13 @@ describe('DatabaseLearningPathProvider', () => { describe('searchLearningPathsByAdmin', () => { it('returns the learning path owned by the admin', async () => { const expectedLearningPath = mapToLearningPath(testLearningPath02, [mapToTeacherDTO(teacherB)]); - const result = await databaseLearningPathProvider.searchLearningPathsByAdmin( - [teacherB], - expectedLearningPath.language - ); + const result = await databaseLearningPathProvider.searchLearningPathsByAdmin([teacherB], expectedLearningPath.language); expect(result.length).toBe(1); expect(result[0].title).toBe(expectedLearningPath.title); expect(result[0].description).toBe(expectedLearningPath.description); }); - it('returns an empty result when querying admins that do not have custom learning paths', async() => { - const result = await databaseLearningPathProvider.searchLearningPathsByAdmin( - [teacherA], - testLearningPath.language - ); + it('returns an empty result when querying admins that do not have custom learning paths', async () => { + const result = await databaseLearningPathProvider.searchLearningPathsByAdmin([teacherA], testLearningPath.language); expect(result.length).toBe(0); }); }); diff --git a/frontend/src/components/DiscussionSideBarElement.vue b/frontend/src/components/DiscussionSideBarElement.vue index d95d38b2..3bdbe79f 100644 --- a/frontend/src/components/DiscussionSideBarElement.vue +++ b/frontend/src/components/DiscussionSideBarElement.vue @@ -1,19 +1,19 @@