Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling shuffle score #13

Open
wants to merge 2 commits into
base: bootcamp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ export const mockSectionPlayerConfig = {
},
showFeedback: true,
showLegend: true,
metadata:{
shuffleScore:undefined
}
},
changes: {
attempts: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>(component, 'subscribeToEvents');
spyOn<any>(component, 'setConfig');
Expand Down Expand Up @@ -847,4 +856,6 @@ describe('SectionPlayerComponent', () => {
expect(document.querySelectorAll).toHaveBeenCalled();
expect(element.classList.contains('neutral'))
});


});
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -90,13 +88,21 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit {
isAssessEventRaised = false;
isShuffleQuestions = false;
shuffleOptions: boolean;
shuffleScore:any=1

constructor(
public viewerService: ViewerService,
public utilService: UtilService,
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 */
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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 :
Expand Down