From 25fec88cc5972ec1501b9d174600c9d93b6568b0 Mon Sep 17 00:00:00 2001 From: vishnubansal Date: Fri, 28 Jun 2024 18:28:12 +0530 Subject: [PATCH 1/2] update for preview content for public toc --- .../lib/btn-profile/btn-profile.component.ts | 2 +- .../overview/overview.component.html | 12 +++--- .../components/overview/overview.component.ts | 12 ++++-- .../plugins/practice/practice.component.html | 15 ++++---- .../plugins/practice/practice.component.ts | 4 +- .../lib/plugins/practice/practice.service.ts | 37 ++++++++++++++++--- .../ws/viewer/src/lib/viewer.component.html | 5 +++ project/ws/viewer/src/lib/viewer.component.ts | 5 +++ project/ws/viewer/src/lib/viewer.module.ts | 2 + 9 files changed, 70 insertions(+), 24 deletions(-) diff --git a/library/ws-widget/collection/src/lib/btn-profile/btn-profile.component.ts b/library/ws-widget/collection/src/lib/btn-profile/btn-profile.component.ts index 435ca6077..97781fc9f 100644 --- a/library/ws-widget/collection/src/lib/btn-profile/btn-profile.component.ts +++ b/library/ws-widget/collection/src/lib/btn-profile/btn-profile.component.ts @@ -60,7 +60,7 @@ export class BtnProfileComponent extends WidgetBaseComponent super() this.btnAppsConfig = { ...this.basicBtnAppsConfig } this.btnSettingsConfig = { ... this.settingBtnConfig } - if (this.configSvc.unMappedUser.profileDetails.profileStatus === 'VERIFIED') { + if (this.configSvc.unMappedUser && this.configSvc.unMappedUser.profileDetails.profileStatus === 'VERIFIED') { this.verifiedBadge = true } this.updateUserInfo() diff --git a/project/ws/viewer/src/lib/plugins/practice/components/overview/overview.component.html b/project/ws/viewer/src/lib/plugins/practice/components/overview/overview.component.html index 30aa4a676..a05fecff1 100755 --- a/project/ws/viewer/src/lib/plugins/practice/components/overview/overview.component.html +++ b/project/ws/viewer/src/lib/plugins/practice/components/overview/overview.component.html @@ -84,24 +84,24 @@
- - {{'playerbrief.maxAllowedRetake' | translate}} + {{'playerbrief.maxAllowedRetake' | translate}}
diff --git a/project/ws/viewer/src/lib/plugins/practice/components/overview/overview.component.ts b/project/ws/viewer/src/lib/plugins/practice/components/overview/overview.component.ts index 5f3d63225..c65be3217 100755 --- a/project/ws/viewer/src/lib/plugins/practice/components/overview/overview.component.ts +++ b/project/ws/viewer/src/lib/plugins/practice/components/overview/overview.component.ts @@ -23,6 +23,7 @@ export class OverviewComponent implements OnInit, OnChanges, OnDestroy { @Input() instructionAssessment: any @Input() selectedAssessmentCompatibilityLevel: any @Output() userSelection = new EventEmitter() + @Input() forPreview = false questionTYP = NsContent.EPrimaryCategory // staticImage = '/assets/images/exam/practice-test.png' staticImage = '/assets/images/exam/practice-result.png' @@ -60,12 +61,15 @@ export class OverviewComponent implements OnInit, OnChanges, OnDestroy { } ngOnChanges() { - if (this.canAttempt && (this.canAttempt.attemptsMade >= this.canAttempt.attemptsAllowed)) { - if (!this.maxAttempPopup) { - this.showAssessmentPopup() - } + if (!this.forPreview) { + if (this.canAttempt && (this.canAttempt.attemptsMade >= this.canAttempt.attemptsAllowed)) { + if (!this.maxAttempPopup) { + this.showAssessmentPopup() + } + } } + } showAssessmentPopup() { diff --git a/project/ws/viewer/src/lib/plugins/practice/practice.component.html b/project/ws/viewer/src/lib/plugins/practice/practice.component.html index dd834373f..86a861a15 100644 --- a/project/ws/viewer/src/lib/plugins/practice/practice.component.html +++ b/project/ws/viewer/src/lib/plugins/practice/practice.component.html @@ -4,7 +4,8 @@ [primaryCategory]="primaryCategory" [canAttempt]="canAttempt" [noOfQuestions]="noOfQuestions" (userSelection)="getSections($event)" [coursePrimaryCategory]="coursePrimaryCategory" [instructionAssessment]="instructionAssessment" - [selectedAssessmentCompatibilityLevel]="selectedAssessmentCompatibilityLevel"> + [selectedAssessmentCompatibilityLevel]="selectedAssessmentCompatibilityLevel" + [forPreview]="forPreview"> @@ -65,7 +66,7 @@ {{ 'playerbrief.next' | translate }}    - {{ 'playerbrief.submit' | translate }} @@ -682,7 +683,7 @@ {{ 'playerbrief.next' | translate }}    - {{ 'playerbrief.submit' | translate }} @@ -1139,7 +1140,7 @@

- @@ -1736,7 +1737,7 @@

-
+
diff --git a/project/ws/viewer/src/lib/plugins/practice/practice.component.ts b/project/ws/viewer/src/lib/plugins/practice/practice.component.ts index 06d93e399..46743cbe2 100644 --- a/project/ws/viewer/src/lib/plugins/practice/practice.component.ts +++ b/project/ws/viewer/src/lib/plugins/practice/practice.component.ts @@ -143,7 +143,8 @@ export class PracticeComponent implements OnInit, OnChanges, OnDestroy { timeSpentOnQuestions: any = {} charactersPerPage = 1500 showQuestionMarks = 'No' - + forPreview = (window.location.href.includes('public') || window.location.href.includes('author') || + window.location.href.includes('editMode')) constructor( private events: EventService, public dialog: MatDialog, @@ -170,6 +171,7 @@ export class PracticeComponent implements OnInit, OnChanges, OnDestroy { this.showToolTip = false } }) + } toggleToolTip() { diff --git a/project/ws/viewer/src/lib/plugins/practice/practice.service.ts b/project/ws/viewer/src/lib/plugins/practice/practice.service.ts index cb2cf539e..40ba37612 100755 --- a/project/ws/viewer/src/lib/plugins/practice/practice.service.ts +++ b/project/ws/viewer/src/lib/plugins/practice/practice.service.ts @@ -21,6 +21,7 @@ const API_END_POINTS = { CAN_ATTEMPT: (assessmentId: any) => `/apis/proxies/v8/user/assessment/retake/${assessmentId}`, CAN_ATTEMPT_V5: (assessmentId: any) => `/apis/proxies/v8/user/assessment/v5/retake/${assessmentId}`, } +const forcreator = window.location.href.includes('editMode=true') @Injectable({ providedIn: 'root', }) @@ -38,7 +39,9 @@ export class PracticeService { clearResponse = new Subject() constructor( private http: HttpClient, - ) { } + ) { + + } // handleError(error: ErrorEvent) { // let errorMessage = '' @@ -206,7 +209,13 @@ export class PracticeService { } getSection(sectionId: string): Observable { - return this.http.get(`${API_END_POINTS.QUESTION_PAPER_SECTIONS}/${sectionId}`).pipe(retry(2)) + if (forcreator) { + // tslint:disable-next-line: max-line-length + return this.http.get(`${API_END_POINTS.QUESTION_PAPER_SECTIONS}/${sectionId}?editMode=true`).pipe(retry(2)) + } + // tslint:disable-next-line: max-line-length + return this.http.get(`${API_END_POINTS.QUESTION_PAPER_SECTIONS}/${sectionId}`).pipe(retry(2)) + } getQuestions(identifiers: string[], assessmentId: string): Observable<{ count: Number, questions: any[] }> { const data = { @@ -217,11 +226,23 @@ export class PracticeService { }, }, } - return this.http.post<{ count: Number, questions: any[] }>(API_END_POINTS.QUESTION_PAPER_QUESTIONS, data) + if (forcreator) { + // tslint:disable-next-line: max-line-length + return this.http.post<{ count: Number, questions: any[] }>(`${API_END_POINTS.QUESTION_PAPER_QUESTIONS}?editMode=true`, data) + } + + return this.http.post<{ count: Number, questions: any[] }>(API_END_POINTS.QUESTION_PAPER_QUESTIONS, data) + } getSectionV4(sectionId: string): Observable { - return this.http.get(`${API_END_POINTS.QUESTION_PAPER_SECTIONS_V4}/${sectionId}`).pipe(retry(2)) + if (forcreator) { + // tslint:disable-next-line: max-line-length + return this.http.get(`${API_END_POINTS.QUESTION_PAPER_SECTIONS_V4}/${sectionId}?editMode=true`).pipe(retry(2)) + } + // tslint:disable-next-line: max-line-length + return this.http.get(`${API_END_POINTS.QUESTION_PAPER_SECTIONS_V4}/${sectionId}`).pipe(retry(2)) + } getQuestionsV4(identifiers: string[], assessmentId: string): Observable<{ count: Number, questions: any[] }> { const data = { @@ -232,7 +253,13 @@ export class PracticeService { }, }, } - return this.http.post<{ count: Number, questions: any[] }>(API_END_POINTS.QUESTION_PAPER_QUESTIONS_V4, data) + if (forcreator) { + // tslint:disable-next-line: max-line-length + return this.http.post<{ count: Number, questions: any[] }>(`${API_END_POINTS.QUESTION_PAPER_QUESTIONS_V4}?editMode=true`, data) + } + // tslint:disable-next-line: max-line-length + return this.http.post<{ count: Number, questions: any[] }>(API_END_POINTS.QUESTION_PAPER_QUESTIONS_V4, data) + } shuffle(array: any[] | (string | undefined)[]) { let currentIndex = array.length diff --git a/project/ws/viewer/src/lib/viewer.component.html b/project/ws/viewer/src/lib/viewer.component.html index 4bc60b69a..3fae022f8 100755 --- a/project/ws/viewer/src/lib/viewer.component.html +++ b/project/ws/viewer/src/lib/viewer.component.html @@ -80,6 +80,11 @@
+
close diff --git a/project/ws/viewer/src/lib/viewer.component.ts b/project/ws/viewer/src/lib/viewer.component.ts index 9f8327c5e..97216da0c 100755 --- a/project/ws/viewer/src/lib/viewer.component.ts +++ b/project/ws/viewer/src/lib/viewer.component.ts @@ -398,4 +398,9 @@ export class ViewerComponent implements OnInit, OnDestroy, AfterViewChecked { this.completedCount = event } + navigateToBack() { + this.viewerHeaderSideBarToggleService.visibilityStatus.next(true) + window.history.back() + } + } diff --git a/project/ws/viewer/src/lib/viewer.module.ts b/project/ws/viewer/src/lib/viewer.module.ts index 756a49a65..803124157 100755 --- a/project/ws/viewer/src/lib/viewer.module.ts +++ b/project/ws/viewer/src/lib/viewer.module.ts @@ -42,6 +42,7 @@ import { BtnContentFeedbackV2Module, PlayerBriefModule, ContentProgressModule, + BtnPageBackNavModule, } from '@sunbird-cb/collection' import { WidgetResolverModule } from '@sunbird-cb/resolver' @@ -79,6 +80,7 @@ import { SkeletonLoaderModule } from '@sunbird-cb/collection/src/lib/_common/ske MatSnackBarModule, ViewerRoutingModule, ErrorResolverModule, + BtnPageBackNavModule, PipeDurationTransformModule, PipeLimitToModule, PipePublicURLModule, From b3bbecee3b64abf13972ff71ad2fd57f089e261a Mon Sep 17 00:00:00 2001 From: vishnubansal Date: Fri, 28 Jun 2024 18:30:54 +0530 Subject: [PATCH 2/2] update for preview content for public toc --- project/ws/viewer/src/lib/viewer.module.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/project/ws/viewer/src/lib/viewer.module.ts b/project/ws/viewer/src/lib/viewer.module.ts index 803124157..92cee0f4d 100755 --- a/project/ws/viewer/src/lib/viewer.module.ts +++ b/project/ws/viewer/src/lib/viewer.module.ts @@ -41,8 +41,7 @@ import { DisplayContentTypeIconModule, BtnContentFeedbackV2Module, PlayerBriefModule, - ContentProgressModule, - BtnPageBackNavModule, + ContentProgressModule } from '@sunbird-cb/collection' import { WidgetResolverModule } from '@sunbird-cb/resolver' @@ -80,7 +79,6 @@ import { SkeletonLoaderModule } from '@sunbird-cb/collection/src/lib/_common/ske MatSnackBarModule, ViewerRoutingModule, ErrorResolverModule, - BtnPageBackNavModule, PipeDurationTransformModule, PipeLimitToModule, PipePublicURLModule,