Skip to content

Commit

Permalink
Merge pull request #2243 from vishnubansaltarento/kb-5608-5609-fix
Browse files Browse the repository at this point in the history
Kb 5608 5609 fix
  • Loading branch information
vishnubansaltarento authored Jun 28, 2024
2 parents 74d28e6 + b3bbece commit 123cedf
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,24 @@
</div>
<div>
<div class="ml-5 start-assessment-cta-standalone block md:hidden" *ngIf="selectedAssessmentCompatibilityLevel >= 6">
<button [disabled]="!consentGiven ? 'disabled': null" *ngIf="canAttempt?.attemptsMade < canAttempt?.attemptsAllowed" [class.spinner]="loading" (click)="overviewed('start')" [ngClass]="consentGiven ? 'bg-blue-800 text-white' : 'secondary-standalone text-standalone-black'" class=" text-sm font-semibold py-3 px-5 rounded-full border-none cursor-pointer tracking-wide">
<button [disabled]="!consentGiven ? 'disabled': null" *ngIf="canAttempt?.attemptsMade < canAttempt?.attemptsAllowed || forPreview" [class.spinner]="loading" (click)="overviewed('start')" [ngClass]="consentGiven ? 'bg-blue-800 text-white' : 'secondary-standalone text-standalone-black'" class=" text-sm font-semibold py-3 px-5 rounded-full border-none cursor-pointer tracking-wide">
<span class="padding-xs" i18n>{{'playerbrief.startAssessment' | translate}}</span>
</button>
<mat-hint class="mat-title" *ngIf="canAttempt?.attemptsMade >= canAttempt?.attemptsAllowed">{{'playerbrief.maxAllowedRetake' | translate}}</mat-hint>
<mat-hint class="mat-title" *ngIf="canAttempt?.attemptsMade >= canAttempt?.attemptsAllowed && !forPreview">{{'playerbrief.maxAllowedRetake' | translate}}</mat-hint>
</div>
</div>
</div>
<div class="start-assessment-cta hidden md:block" *ngIf="selectedAssessmentCompatibilityLevel >= 6">
<button [disabled]="!consentGiven ? 'disabled': null" *ngIf="canAttempt?.attemptsMade < canAttempt?.attemptsAllowed" [class.spinner]="loading" (click)="overviewed('start')" [ngClass]="consentGiven ? 'bg-blue-800 text-white' : 'secondary-standalone text-standalone-black'" class="text-sm font-semibold py-3 px-5 rounded-full border-none cursor-pointer tracking-wide">
<button [disabled]="!consentGiven ? 'disabled': null" *ngIf="canAttempt?.attemptsMade < canAttempt?.attemptsAllowed || forPreview" [class.spinner]="loading" (click)="overviewed('start')" [ngClass]="consentGiven ? 'bg-blue-800 text-white' : 'secondary-standalone text-standalone-black'" class="text-sm font-semibold py-3 px-5 rounded-full border-none cursor-pointer tracking-wide">
<span class="padding-xs" i18n>{{'playerbrief.startAssessment' | translate}}</span>
</button>
<mat-hint class="mat-title" *ngIf="canAttempt?.attemptsMade >= canAttempt?.attemptsAllowed">{{'playerbrief.maxAllowedRetake' | translate}}</mat-hint>
<mat-hint class="mat-title" *ngIf="canAttempt?.attemptsMade >= canAttempt?.attemptsAllowed && !forPreview">{{'playerbrief.maxAllowedRetake' | translate}}</mat-hint>
</div>
<div class="start-assessment-cta hidden md:block" *ngIf="selectedAssessmentCompatibilityLevel < 6">
<button *ngIf="canAttempt?.attemptsMade < canAttempt?.attemptsAllowed" [class.spinner]="loading" [disabled]="loading" (click)="overviewed('start')" class="bg-blue-800 text-white text-sm font-semibold py-3 px-5 rounded-full border-none cursor-pointer tracking-wide">
<button *ngIf="canAttempt?.attemptsMade < canAttempt?.attemptsAllowed || forPreview" [class.spinner]="loading" [disabled]="loading" (click)="overviewed('start')" class="bg-blue-800 text-white text-sm font-semibold py-3 px-5 rounded-full border-none cursor-pointer tracking-wide">
<span class="padding-xs" i18n>{{'playerbrief.startAssessment' | translate}}</span>
</button>
<mat-hint class="mat-title" *ngIf="canAttempt?.attemptsMade >= canAttempt?.attemptsAllowed">{{'playerbrief.maxAllowedRetake' | translate}}</mat-hint>
<mat-hint class="mat-title" *ngIf="canAttempt?.attemptsMade >= canAttempt?.attemptsAllowed && !forPreview">{{'playerbrief.maxAllowedRetake' | translate}}</mat-hint>
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class OverviewComponent implements OnInit, OnChanges, OnDestroy {
@Input() instructionAssessment: any
@Input() selectedAssessmentCompatibilityLevel: any
@Output() userSelection = new EventEmitter<NSPractice.TUserSelectionType>()
@Input() forPreview = false
questionTYP = NsContent.EPrimaryCategory
// staticImage = '/assets/images/exam/practice-test.png'
staticImage = '/assets/images/exam/practice-result.png'
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
[primaryCategory]="primaryCategory" [canAttempt]="canAttempt" [noOfQuestions]="noOfQuestions"
(userSelection)="getSections($event)" [coursePrimaryCategory]="coursePrimaryCategory"
[instructionAssessment]="instructionAssessment"
[selectedAssessmentCompatibilityLevel]="selectedAssessmentCompatibilityLevel">
[selectedAssessmentCompatibilityLevel]="selectedAssessmentCompatibilityLevel"
[forPreview]="forPreview">
</viewer-overview>

<!-- Overlay Loader -->
Expand Down Expand Up @@ -65,7 +66,7 @@
<ng-container *ngIf="!isXsmall">{{ 'playerbrief.next' | translate }}</ng-container>
</a>
&nbsp;&nbsp;
<a *ngIf="(currentQuestionIndex + 1) === totalQCount"
<a *ngIf="(currentQuestionIndex + 1) === totalQCount && !forPreview"
class="text-white ws-mat-primary-background margin-xs quest_btn" mat-button (click)="proceedToSubmit()">
<ng-container *ngIf="!isXsmall">{{ 'playerbrief.submit' | translate }}</ng-container>
</a>
Expand Down Expand Up @@ -682,7 +683,7 @@
<ng-container>{{ 'playerbrief.next' | translate }}</ng-container>
</a>
&nbsp;&nbsp;
<a *ngIf="(currentQuestionIndex + 1) === totalQCount" class="text-white ws-mat-primary-background quest_btn"
<a *ngIf="(currentQuestionIndex + 1) === totalQCount && !forPreview" class="text-white ws-mat-primary-background quest_btn"
mat-button (click)="proceedToSubmit()">
<ng-container>{{ 'playerbrief.submit' | translate }}</ng-container>
</a>
Expand Down Expand Up @@ -1139,7 +1140,7 @@ <h3 class="mat-subheading-2">
<div class="flex flex-row" [ngClass]="{'hide-section': paperSections.length < 2}">
<div>
<mat-form-field appearance="none">
<select [disabled]="sectionalTimer ? 'disabled': ''" matNativeControl required class="section-dd" #choosedValue
<select [disabled]="sectionalTimer && !forPreview ? 'disabled': ''" matNativeControl required class="section-dd" #choosedValue
(change)="changeSection($event.target.value)">
<option [value]="section.identifier" [selected]="section.identifier === selectedSectionIdentifier"
*ngFor="let section of paperSections">{{section?.name}}</option>
Expand All @@ -1153,7 +1154,7 @@ <h3 class="mat-subheading-2">
</div>
</div>

<div>
<div *ngIf="!forPreview">
<a [ngClass]="(totalQCount != getAllQuestionAnswer() && assessmentType === 'optionalWeightage') ? 'pointer-events-none secondary-standalone text-standalone-black margin-xs quest_btn justify-right ': 'text-white ws-mat-primary-background margin-xs quest_btn justify-right' "
mat-button (click)="proceedToSubmit()">
<ng-container *ngIf="!isXsmall">{{ 'playerbrief.submitTheTest' | translate }}</ng-container>
Expand Down Expand Up @@ -1726,7 +1727,7 @@ <h3 class="mat-subheading-2">
<div class="flex flex-row">
<div *ngIf="assessmentType !== 'optionalWeightage'">
<mat-form-field appearance="none">
<select [disabled]="sectionalTimer ? 'disabled': ''" matNativeControl required class="section-dd" #choosedValue
<select [disabled]="sectionalTimer && !forPreview ? 'disabled': ''" matNativeControl required class="section-dd" #choosedValue
(change)="changeSection($event.target.value)">
<option [value]="section.identifier" [selected]="section.identifier === selectedSectionIdentifier"
*ngFor="let section of paperSections">{{section?.name}}</option>
Expand All @@ -1736,7 +1737,7 @@ <h3 class="mat-subheading-2">
</div>
</div>

<div>
<div *ngIf="!forPreview">

<a mat-button (click)="proceedToSubmit()" [ngClass]=
"(totalQCount != getAllQuestionAnswer() && assessmentType === 'optionalWeightage') ? 'pointer-events-none secondary-standalone text-standalone-black margin-xs quest_btn_option_weightage': 'text-white ws-mat-primary-background margin-xs quest_btn' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -170,6 +171,7 @@ export class PracticeComponent implements OnInit, OnChanges, OnDestroy {
this.showToolTip = false
}
})

}

toggleToolTip() {
Expand Down
37 changes: 32 additions & 5 deletions project/ws/viewer/src/lib/plugins/practice/practice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
})
Expand All @@ -38,7 +39,9 @@ export class PracticeService {
clearResponse = new Subject()
constructor(
private http: HttpClient,
) { }
) {

}

// handleError(error: ErrorEvent) {
// let errorMessage = ''
Expand Down Expand Up @@ -206,7 +209,13 @@ export class PracticeService {
}

getSection(sectionId: string): Observable<NSPractice.ISectionResponse> {
return this.http.get<NSPractice.ISectionResponse>(`${API_END_POINTS.QUESTION_PAPER_SECTIONS}/${sectionId}`).pipe(retry(2))
if (forcreator) {
// tslint:disable-next-line: max-line-length
return this.http.get<NSPractice.ISectionResponse>(`${API_END_POINTS.QUESTION_PAPER_SECTIONS}/${sectionId}?editMode=true`).pipe(retry(2))
}
// tslint:disable-next-line: max-line-length
return this.http.get<NSPractice.ISectionResponse>(`${API_END_POINTS.QUESTION_PAPER_SECTIONS}/${sectionId}`).pipe(retry(2))

}
getQuestions(identifiers: string[], assessmentId: string): Observable<{ count: Number, questions: any[] }> {
const data = {
Expand All @@ -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<NSPractice.ISectionResponse> {
return this.http.get<NSPractice.ISectionResponse>(`${API_END_POINTS.QUESTION_PAPER_SECTIONS_V4}/${sectionId}`).pipe(retry(2))
if (forcreator) {
// tslint:disable-next-line: max-line-length
return this.http.get<NSPractice.ISectionResponse>(`${API_END_POINTS.QUESTION_PAPER_SECTIONS_V4}/${sectionId}?editMode=true`).pipe(retry(2))
}
// tslint:disable-next-line: max-line-length
return this.http.get<NSPractice.ISectionResponse>(`${API_END_POINTS.QUESTION_PAPER_SECTIONS_V4}/${sectionId}`).pipe(retry(2))

}
getQuestionsV4(identifiers: string[], assessmentId: string): Observable<{ count: Number, questions: any[] }> {
const data = {
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions project/ws/viewer/src/lib/viewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
<mat-spinner></mat-spinner>
</section>
<div *ngIf="isPreview" class="flex flex-1 flex-column mb-3">
<div *ngIf="!viewerHeaderSideBarToggleFlag">
<a i18n-aria-label aria-label="Back" (click)="navigateToBack()" mat-icon-button>
<mat-icon>arrow_back</mat-icon>
</a>
</div>
<div class="flex flex-1 flex-row-reverse">
<a *ngIf="show" class="padding-right-s padding-top-xs" role="button" (click)="show=false">
<mat-icon class="cursor-pointer ws-mat-default-text">close</mat-icon>
Expand Down
5 changes: 5 additions & 0 deletions project/ws/viewer/src/lib/viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,9 @@ export class ViewerComponent implements OnInit, OnDestroy, AfterViewChecked {
this.completedCount = event
}

navigateToBack() {
this.viewerHeaderSideBarToggleService.visibilityStatus.next(true)
window.history.back()
}

}
2 changes: 1 addition & 1 deletion project/ws/viewer/src/lib/viewer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
DisplayContentTypeIconModule,
BtnContentFeedbackV2Module,
PlayerBriefModule,
ContentProgressModule,
ContentProgressModule
} from '@sunbird-cb/collection'

import { WidgetResolverModule } from '@sunbird-cb/resolver'
Expand Down

0 comments on commit 123cedf

Please sign in to comment.