diff --git a/projects/quml-library/src/lib/section-player/section-player.component.spec.data.ts b/projects/quml-library/src/lib/section-player/section-player.component.spec.data.ts index f447148e..f5f26547 100644 --- a/projects/quml-library/src/lib/section-player/section-player.component.spec.data.ts +++ b/projects/quml-library/src/lib/section-player/section-player.component.spec.data.ts @@ -603,6 +603,9 @@ export const mockSectionPlayerConfig = { }, showFeedback: true, showLegend: true, + metadata:{ + shuffleScore:undefined + } }, changes: { attempts: { diff --git a/projects/quml-library/src/lib/section-player/section-player.component.spec.ts b/projects/quml-library/src/lib/section-player/section-player.component.spec.ts index ab550e62..8c94f76a 100644 --- a/projects/quml-library/src/lib/section-player/section-player.component.spec.ts +++ b/projects/quml-library/src/lib/section-player/section-player.component.spec.ts @@ -84,6 +84,15 @@ describe('SectionPlayerComponent', () => { expect(component).toBeTruthy(); }); + it('should set shufflescore on ngOnit',()=>{ + const updatedParentConfig=mockParentConfig + updatedParentConfig.metadata.shuffleScore=2 + component.parentConfig = updatedParentConfig; + spyOn(component,'ngOnInit').and.callThrough() + component.ngOnInit(); + expect(component.shuffleScore).toBe(2) + }) + it('should subscribe to events and set config on every changes', () => { spyOn(component, 'subscribeToEvents'); spyOn(component, 'setConfig'); @@ -847,4 +856,6 @@ describe('SectionPlayerComponent', () => { expect(document.querySelectorAll).toHaveBeenCalled(); expect(element.classList.contains('neutral')) }); + + }); \ No newline at end of file diff --git a/projects/quml-library/src/lib/section-player/section-player.component.ts b/projects/quml-library/src/lib/section-player/section-player.component.ts index 6d91b72f..95f340e4 100644 --- a/projects/quml-library/src/lib/section-player/section-player.component.ts +++ b/projects/quml-library/src/lib/section-player/section-player.component.ts @@ -9,8 +9,6 @@ import { ViewerService } from '../services/viewer-service/viewer-service'; import { eventName, pageId, TelemetryType } from '../telemetry-constants'; import { UtilService } from '../util-service'; -const DEFAULT_SCORE: number = 1; - @Component({ selector: 'quml-section-player', templateUrl: './section-player.component.html', @@ -90,6 +88,7 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit { isAssessEventRaised = false; isShuffleQuestions = false; shuffleOptions: boolean; + shuffleScore:any=1 constructor( public viewerService: ViewerService, @@ -97,6 +96,13 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit { private cdRef: ChangeDetectorRef, public errorService: ErrorService ) { } + + ngOnInit(){ + if(this.parentConfig?.metadata?.shuffleScore){ + this.shuffleScore=this.parentConfig.metadata.shuffleScore + } + } + ngOnChanges(changes: SimpleChanges): void { /* istanbul ignore else */ @@ -435,7 +441,7 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit { const currentIndex = this.myCarousel.getCurrentSlideIndex() - 1; if (this.isShuffleQuestions) { - this.updateScoreBoard(currentIndex, 'correct', undefined, DEFAULT_SCORE); + this.updateScoreBoard(currentIndex, 'correct', undefined, this.shuffleScore); } } @@ -905,7 +911,7 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit { /* istanbul ignore else */ if (isCorrectAnswer) { if (this.isShuffleQuestions) { - return DEFAULT_SCORE; + return this.shuffleScore; } return this.questions[currentIndex].responseDeclaration[key].correctResponse.outcomes.SCORE ? this.questions[currentIndex].responseDeclaration[key].correctResponse.outcomes.SCORE :