From 01f84d6005a8e4bb8ff4b9b8d45d6007b7156b9a Mon Sep 17 00:00:00 2001 From: vpPavithra Date: Mon, 27 Jul 2026 17:00:37 +0530 Subject: [PATCH] fix(competency,quiz,root): resolve competency artifact URLs and init user language - Use getCompetencyAuthoringUrl for non-preview assessment artifact URLs - Guard mobile dashboard course enrichment so an empty search result no longer drops progress data - Initialize LanguageService from user/org locale in RootComponent - Bump @aastrika_npmjs/comptency to ^2.1.1 --- package.json | 2 +- .../assessment-detail.component.ts | 14 +++++++------- .../route-view-container/quiz/quiz.component.ts | 11 ++++++----- .../viewer/src/lib/routes/quiz/quiz.component.ts | 13 +++++++------ .../resource-collection.component.ts | 12 ++++++------ .../services/mobile-dashboard.service.ts | 15 ++++++++++----- src/app/component/root/root.component.ts | 4 ++++ 7 files changed, 41 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index ec28297ec..e41f4ac5e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ }, "private": true, "dependencies": { - "@aastrika_npmjs/comptency": "^2.0.0", + "@aastrika_npmjs/comptency": "^2.1.1", "@aastrika_npmjs/discussions-ui-v8": "^5.0.1", "@angular/animations": "^21.2.7", "@angular/cdk": "^21.2.5", diff --git a/project/ws/app/src/lib/routes/app-toc/components/assessment-detail/assessment-detail.component.ts b/project/ws/app/src/lib/routes/app-toc/components/assessment-detail/assessment-detail.component.ts index ab3bdc93e..f1a59f08f 100644 --- a/project/ws/app/src/lib/routes/app-toc/components/assessment-detail/assessment-detail.component.ts +++ b/project/ws/app/src/lib/routes/app-toc/components/assessment-detail/assessment-detail.component.ts @@ -9,11 +9,11 @@ import { ActivatedRoute } from '@angular/router' import { LoggerService } from '../../../../../../../../../library/ws-widget/utils/src/public-api' @Component({ - standalone: false, - selector: 'ws-app-assessment-detail', - templateUrl: './assessment-detail.component.html', - styleUrls: ['./assessment-detail.component.scss'], - + standalone: false, + selector: 'ws-app-assessment-detail', + templateUrl: './assessment-detail.component.html', + styleUrls: ['./assessment-detail.component.scss'], + }) export class AssessmentDetailComponent implements OnInit { @@ -123,7 +123,7 @@ export class AssessmentDetailComponent implements OnInit { if (content.artifactUrl) { const artifactUrl = this.forPreview ? this.viewSvc.getAuthoringUrl(content.artifactUrl) - : content.artifactUrl + : this.viewSvc.getCompetencyAuthoringUrl(content.artifactUrl.split('/content')[1]) let quizJSON: NSQuiz.IQuiz = await this.http .get(artifactUrl || '') .toPromise() @@ -151,7 +151,7 @@ export class AssessmentDetailComponent implements OnInit { ).toPromise() const artifactUrl = this.forPreview ? this.viewSvc.getAuthoringUrl(contents.result.content.artifactUrl) - : contents.result.content.artifactUrl + : this.viewSvc.getCompetencyAuthoringUrl(contents.result.content.artifactUrl.split('/content')[1]) let quizJSON: NSQuiz.IQuiz = await this.http .get(artifactUrl || '') .toPromise() diff --git a/project/ws/viewer/src/lib/route-view-container/quiz/quiz.component.ts b/project/ws/viewer/src/lib/route-view-container/quiz/quiz.component.ts index 8f6894227..bb4289978 100644 --- a/project/ws/viewer/src/lib/route-view-container/quiz/quiz.component.ts +++ b/project/ws/viewer/src/lib/route-view-container/quiz/quiz.component.ts @@ -6,11 +6,11 @@ import { PlayerStateService } from '../../player-state.service' import { ValueService } from '@ws-widget/utils' @Component({ - standalone: false, - selector: 'viewer-quiz-container', - templateUrl: './quiz.component.html', - styleUrls: ['./quiz.component.scss'], - + standalone: false, + selector: 'viewer-quiz-container', + templateUrl: './quiz.component.html', + styleUrls: ['./quiz.component.scss'], + }) export class QuizComponent implements OnInit { @Input() isFetchingDataComplete = false @@ -21,6 +21,7 @@ export class QuizComponent implements OnInit { timeLimit: 0, questions: [], isAssessment: false, + passPercentage: 0 } @Input() isPreviewMode = false stateChange = false diff --git a/project/ws/viewer/src/lib/routes/quiz/quiz.component.ts b/project/ws/viewer/src/lib/routes/quiz/quiz.component.ts index c5707cc3d..60ead251b 100644 --- a/project/ws/viewer/src/lib/routes/quiz/quiz.component.ts +++ b/project/ws/viewer/src/lib/routes/quiz/quiz.component.ts @@ -8,11 +8,11 @@ import { WsEvents, EventService } from '@ws-widget/utils' import { ViewerUtilService } from '../../viewer-util.service' @Component({ - standalone: false, - selector: 'viewer-quiz', - templateUrl: './quiz.component.html', - styleUrls: ['./quiz.component.scss'], - + standalone: false, + selector: 'viewer-quiz', + templateUrl: './quiz.component.html', + styleUrls: ['./quiz.component.scss'], + }) export class QuizComponent implements OnInit, OnDestroy { private dataSubscription: Subscription | null = null @@ -26,6 +26,7 @@ export class QuizComponent implements OnInit, OnDestroy { timeLimit: 0, questions: [], isAssessment: false, + passPercentage: 60 } constructor( private activatedRoute: ActivatedRoute, @@ -148,7 +149,7 @@ export class QuizComponent implements OnInit, OnDestroy { } { const artifactUrl = this.forPreview ? this.viewSvc.getAuthoringUrl(content.artifactUrl) - : content.artifactUrl + : this.viewSvc.getCompetencyAuthoringUrl(content.artifactUrl.split('/content')[1]) let quizJSON: NSQuiz.IQuiz = await this.http .get(artifactUrl || '') .toPromise() diff --git a/project/ws/viewer/src/lib/routes/resource-collection/resource-collection.component.ts b/project/ws/viewer/src/lib/routes/resource-collection/resource-collection.component.ts index cfdd99a40..1a41d258a 100644 --- a/project/ws/viewer/src/lib/routes/resource-collection/resource-collection.component.ts +++ b/project/ws/viewer/src/lib/routes/resource-collection/resource-collection.component.ts @@ -8,11 +8,11 @@ import { EventService, WsEvents } from '@ws-widget/utils' import { ViewerUtilService } from '../../viewer-util.service' @Component({ - standalone: false, - selector: 'viewer-resource-collection', - templateUrl: './resource-collection.component.html', - styleUrls: ['./resource-collection.component.scss'], - + standalone: false, + selector: 'viewer-resource-collection', + templateUrl: './resource-collection.component.html', + styleUrls: ['./resource-collection.component.scss'], + }) export class ResourceCollectionComponent implements OnInit, OnDestroy { private dataSubscription: Subscription | null = null @@ -95,7 +95,7 @@ export class ResourceCollectionComponent implements OnInit, OnDestroy { if (this.resourceCollectionData && this.resourceCollectionData.artifactUrl) { const artifactUrl = this.forPreview ? this.viewSvc.getAuthoringUrl(this.resourceCollectionData.artifactUrl) - : this.resourceCollectionData.artifactUrl + : this.viewSvc.getCompetencyAuthoringUrl(this.resourceCollectionData.artifactUrl.split('/content')[1]) manifestFile = await this.http .get(artifactUrl || '') .toPromise() diff --git a/src/app/component/competency-course-list/services/mobile-dashboard.service.ts b/src/app/component/competency-course-list/services/mobile-dashboard.service.ts index 9fe932284..2c6fc1f4b 100644 --- a/src/app/component/competency-course-list/services/mobile-dashboard.service.ts +++ b/src/app/component/competency-course-list/services/mobile-dashboard.service.ts @@ -104,8 +104,11 @@ export class MobileDashboardService { map(({ searchResult, progress }) => { // Enrich titles from search results — never reduces count const rawCourses: any[] = searchResult?.result?.content || searchResult?.content || [] - if (rawCourses.length) { - const named = this.getFormattedCompetencyCoursesWithFilter(rawCourses, competencyLevels, competencyIds) + const named = rawCourses.length + ? this.getFormattedCompetencyCoursesWithFilter(rawCourses, competencyLevels, competencyIds) + : [] + + if (named.length > 0) { named.forEach((n: any) => { const key = String(n.competencyID) if (competencyMap.has(key)) { @@ -118,10 +121,12 @@ export class MobileDashboardService { }) } }) + const enrichedCourses = Array.from(competencyMap.values()) + const withProgress = this.mergeProgressData(enrichedCourses, progress?.data || []) + return this.setCoursesState(withProgress) } - const enrichedCourses = Array.from(competencyMap.values()) - const withProgress = this.mergeProgressData(enrichedCourses, progress?.data || []) - return this.setCoursesState(withProgress) + + return empty }), catchError(() => { const withProgress = this.mergeProgressData(courses, []) diff --git a/src/app/component/root/root.component.ts b/src/app/component/root/root.component.ts index 2395da814..54c451b58 100644 --- a/src/app/component/root/root.component.ts +++ b/src/app/component/root/root.component.ts @@ -59,6 +59,7 @@ import { TranslateService } from '@ngx-translate/core' import { PlaylistService } from '../../services/playlist.service' import { DowntimeConfigService } from '../../services/downtime-config.service' import { ThemeService } from '../../services/theme.service' +import { LanguageService } from '../../services/language.service' @Component({ standalone: false, @@ -144,6 +145,7 @@ export class RootComponent implements OnInit, AfterViewInit, OnDestroy { private themeSvc: ThemeService, private seoSvc: SeoService, @Inject(PLATFORM_ID) private platformId: object, + private langSvc: LanguageService ) { const isBrowser = isPlatformBrowser(this.platformId) this.userEnrollCourse = toSignal( @@ -498,6 +500,8 @@ export class RootComponent implements OnInit, AfterViewInit, OnDestroy { } } this.orgDetails = { ...this.playlistSvc.orgDetails(), ...this.playlistSvc.headerConfig() } + let language = this.configSvc.userProfile.language || this.orgDetails.defaultLang || 'hi' + this.langSvc.setLanguage(language) const homeTabConfig = this.playlistSvc.sections()?.['homeTab'] this.programConfig = this.playlistSvc.programs() this.hasProgramConfig = !!this.programConfig && Object.keys(this.programConfig).length > 0