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

Compass to inquiry pr #60

Merged
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
4 changes: 3 additions & 1 deletion projects/quml-demo-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DataService } from './services/data.service';
export class AppComponent implements OnInit {
contentId = 'do_2138622515299368961170';
playerConfig: any;
telemetryEvents: any = [];

constructor(private dataService: DataService) { }

Expand Down Expand Up @@ -46,6 +47,7 @@ export class AppComponent implements OnInit {
}

getTelemetryEvents(event) {
console.log('event is for telemetry', JSON.stringify(event));
this.telemetryEvents.push(JSON.parse(JSON.stringify(event)));
console.log('event is for telemetry', this.telemetryEvents);
}
}
2 changes: 1 addition & 1 deletion projects/quml-library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@project-sunbird/sunbird-quml-player",
"version": "6.2.0",
"version": "7.0.0-beta.0",
"schematics": "./schematics/collection.json",
"ng-add": {
"save": "dependencies"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
<!-- Show player end page -->
<div class="endPage-container" *ngIf="endPageReached" [ngClass]="endPageReached ? 'endPage-container-height': ''">
<sb-player-end-page *ngIf="endPageReached && showEndPage" [contentName]="parentConfig.contentName"
[outcome]="outcomeLabel" [outcomeLabel]="'Score: '" [userName]="userName" [timeSpentLabel]="durationSpent"
[outcome]="!questionSetEvaluable? outcomeLabel : ''" [outcomeLabel]="!questionSetEvaluable? 'Score: ': ''" [userName]="userName" [timeSpentLabel]="durationSpent"
(replayContent)="replayContent()" (exitContent)="exitContent($event)"
[showExit]="parentConfig?.sideMenuConfig.showExit" [showReplay]="showReplay" [nextContent]="nextContent"
(playNextContent)="playNextContent($event)">

<span *ngIf="questionSetEvaluable" class="mt-8 font-weight-bold d-block">You've succesfully submitted the assessment and response sent for validation</span>

<span class="sb-color-primary mt-8 fnormal font-weight-bold d-block"
*ngIf="attempts?.max && attempts?.current && attempts.max !== attempts.current">Attempt no
{{attempts.current}}/{{attempts.max}}
Expand Down
34 changes: 28 additions & 6 deletions projects/quml-library/src/lib/main-player/main-player.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class MainPlayerComponent implements OnInit, OnChanges {
nextContent: NextContent;
disabledHandle: any;
subscription: Subscription;
questionSetEvaluable: any;

constructor(public viewerService: ViewerService, private utilService: UtilService) { }

Expand Down Expand Up @@ -207,6 +208,7 @@ export class MainPlayerComponent implements OnInit, OnChanges {
this.parentConfig.sideMenuConfig = { ...this.parentConfig.sideMenuConfig, ...this.playerConfig.config.sideMenu };
this.parentConfig.warningTime = _.get(this.playerConfig,'config.warningTime', this.parentConfig.warningTime);
this.parentConfig.showWarningTimer = _.get(this.playerConfig,'config.showWarningTimer', this.parentConfig.showWarningTimer)
this.questionSetEvaluable = this.viewerService.serverValidationCheck(this.playerConfig.metadata?.eval);
if (this.playerConfig?.context?.userData) {
const firstName = this.playerConfig.context.userData?.firstName ?? '';
const lastName = this.playerConfig.context.userData?.lastName ?? '';
Expand Down Expand Up @@ -262,7 +264,9 @@ export class MainPlayerComponent implements OnInit, OnChanges {
/* istanbul ignore else */
if (this.parentConfig.isSectionsAvailable) {
const activeSectionIndex = this.getActiveSectionIndex();
this.updateSectionScore(activeSectionIndex);
if(!this.questionSetEvaluable) {
this.updateSectionScore(activeSectionIndex);
}
}
this.getSummaryObject();
this.loadScoreBoard = true;
Expand All @@ -276,7 +280,9 @@ export class MainPlayerComponent implements OnInit, OnChanges {

if (this.parentConfig.isSectionsAvailable) {
const activeSectionIndex = this.getActiveSectionIndex();
this.updateSectionScore(activeSectionIndex);
if(!this.questionSetEvaluable) {
this.updateSectionScore(activeSectionIndex);
}
this.setNextSection(event, activeSectionIndex);
} else {
this.prepareEnd(event);
Expand Down Expand Up @@ -345,7 +351,11 @@ export class MainPlayerComponent implements OnInit, OnChanges {

prepareEnd(event) {
this.viewerService.pauseVideo();
this.calculateScore();
if(!this.questionSetEvaluable) {
this.calculateScore();
} else {
this.finalScore = 0;
}
this.setDurationSpent();
this.getSummaryObject();
if (this.parentConfig.requiresSubmit && !this.isDurationExpired) {
Expand Down Expand Up @@ -432,7 +442,11 @@ export class MainPlayerComponent implements OnInit, OnChanges {
}

exitContent(event) {
this.calculateScore();
if(!this.questionSetEvaluable) {
this.calculateScore();
} else {
this.finalScore = 0;
}
/* istanbul ignore else */
if (event?.type === 'EXIT') {
this.viewerService.raiseHeartBeatEvent(eventName.endPageExitClicked, TelemetryType.interact, pageId.endPage);
Expand Down Expand Up @@ -468,7 +482,11 @@ export class MainPlayerComponent implements OnInit, OnChanges {

onScoreBoardLoaded(event) {
if (event?.scoreBoardLoaded) {
this.calculateScore();
if(!this.questionSetEvaluable) {
this.calculateScore();
} else {
this.finalScore = 0
}
}
}

Expand Down Expand Up @@ -563,7 +581,11 @@ export class MainPlayerComponent implements OnInit, OnChanges {

@HostListener('window:beforeunload')
ngOnDestroy() {
this.calculateScore();
if(!this.questionSetEvaluable) {
this.calculateScore();
} else {
this.finalScore = 0;
}
this.getSummaryObject();
/* istanbul ignore else */
if (this.isSummaryEventRaised === false) {
Expand Down
13 changes: 13 additions & 0 deletions projects/quml-library/src/lib/mcq/mcq.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'
import { DomSanitizer } from '@angular/platform-browser';

import { McqComponent } from './mcq.component';
import { ViewerService } from '../services/viewer-service/viewer-service';

describe('McqComponent', () => {
let component: McqComponent;
let viewerService;
let fixture: ComponentFixture<McqComponent>;
class ViewServiceMock {
questionSetEvaluable: boolean
}
const question = {
"copyright": "tn",
"subject": [
Expand Down Expand Up @@ -159,6 +164,9 @@ describe('McqComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [McqComponent],
providers: [
{ provide: ViewerService, useClass: ViewServiceMock }
],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
Expand All @@ -167,6 +175,7 @@ describe('McqComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(McqComponent);
component = fixture.componentInstance;
viewerService = TestBed.inject(ViewerService);
component.question = question;
fixture.detectChanges();
});
Expand All @@ -177,21 +186,25 @@ describe('McqComponent', () => {

it('should set layout to IMAGEGRID', () => {
component.question.templateId = 'mcq-horizontal';
viewerService.questionSetEvaluable = false;
component.ngOnInit();
expect(component.layout).toBe('IMAGEGRID');
});
it('should set layout to IMAGEQAGRID', () => {
component.question.templateId = 'mcq-vertical-split';
viewerService.questionSetEvaluable = false;
component.ngOnInit();
expect(component.layout).toBe('IMAGEQAGRID');
});
it('should set layout to MULTIIMAGEGRID', () => {
component.question.templateId = 'mcq-grid-split';
viewerService.questionSetEvaluable = false;
component.ngOnInit();
expect(component.layout).toBe('MULTIIMAGEGRID');
});
it('should not set any layout', () => {
component.question.templateId = 'mcq';
viewerService.questionSetEvaluable = false;
component.ngOnInit();
expect(component.layout).toBeUndefined;
});
Expand Down
8 changes: 6 additions & 2 deletions projects/quml-library/src/lib/mcq/mcq.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit, Input, SecurityContext, Output, EventEmitter, AfterV
import { DomSanitizer } from '@angular/platform-browser';
import { katex } from 'katex';
import { UtilService } from '../util-service';
import { ViewerService } from '../services/viewer-service/viewer-service';
import * as _ from 'lodash-es';

declare const katex: any;
Expand Down Expand Up @@ -35,11 +36,14 @@ export class McqComponent implements OnInit, AfterViewInit {

constructor(
public domSanitizer: DomSanitizer,
public utilService: UtilService) {
public utilService: UtilService,
public viewerService: ViewerService) {
}

ngOnInit() {
this.numberOfCorrectOptions = _.castArray(this.question.responseDeclaration.response1.correctResponse.value).length;
if(!this.viewerService.questionSetEvaluable) {
this.numberOfCorrectOptions = _.castArray(this.question.responseDeclaration.response1.correctResponse.value).length;
}
if (this.question?.solutions) {
this.solutions = this.question.solutions;
}
Expand Down
4 changes: 2 additions & 2 deletions projects/quml-library/src/lib/quml-library.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class QumlLibraryService {

constructor(public utilService: UtilService) { }

async initializeTelemetry(config: QumlPlayerConfig, parentConfig: IParentConfig) {
initializeTelemetry(config: QumlPlayerConfig, parentConfig: IParentConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pavankumar0408 Was this async await not needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not required as it is not triggering end event correctly @rajnishdargan

if (!_.has(config, 'context') || _.isEmpty(config, 'context')) {
return;
}
Expand Down Expand Up @@ -61,7 +61,7 @@ export class QumlLibraryService {
{ id: '2.0', type: 'PlayerVersion' }
])
};
await CsTelemetryModule.instance.init({});
CsTelemetryModule.instance.init({});
CsTelemetryModule.instance.telemetryService.initTelemetry(
{
config: telemetryConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="current-slide" *ngIf="currentSlideIndex !== 0">
{{myCarousel.getCurrentSlideIndex()}}/{{noOfQuestions}}
</div>
<div *ngIf="currentSolutions && showUserSolution">
<div *ngIf="currentSolutions && showUserSolution && !questionSetEvaluable">
<quml-ans (click)="getSolutions()" (keydown)="onAnswerKeyDown($event)"></quml-ans>
</div>
</div>
Expand Down Expand Up @@ -67,7 +67,7 @@
attr.aria-label="question number {{question?.index}}"
(click)="goToSlideClicked($event, question?.index)" (keydown)="onEnter($event, question?.index)"
class="showFeedBack-progressBar"
[ngClass]="(j+1) === myCarousel.getCurrentSlideIndex() ? (question.class === 'skipped' ? 'progressBar-border' : 'progressBar-border ' + question.class) : question.class">
[ngClass]="(j+1) === myCarousel.getCurrentSlideIndex() ? (question.class === 'skipped' ? 'progressBar-border' : (questionSetEvaluable ? 'att-color progressBar-border': 'progressBar-border ' + question.class)) : (questionSetEvaluable ? (question.class === 'skipped'|| question.class === 'unattempted' ? question.class : 'att-color'): question.class)">
{{question?.index}}
</li>
</ul>
Expand All @@ -89,7 +89,7 @@
attr.aria-label="question number {{question?.index}}"
(click)="goToSlideClicked($event, question?.index)" (keydown)="onEnter($event, question?.index)"
class="showFeedBack-progressBar hover-effect"
[ngClass]="(j+1) === myCarousel.getCurrentSlideIndex() ? (question.class === 'skipped' ? 'progressBar-border' : 'progressBar-border ' + question.class) : question.class">
[ngClass]="(j+1) === myCarousel.getCurrentSlideIndex() ? (question.class === 'skipped' ? 'progressBar-border' : (questionSetEvaluable ? 'att-color progressBar-border': 'progressBar-border ' + question.class)) : (questionSetEvaluable ? (question.class === 'skipped'|| question.class === 'unattempted' ? question.class : 'att-color'): question.class)">
{{question?.index}}
</li>
</ul>
Expand Down Expand Up @@ -119,11 +119,11 @@
</div>
</div>

<quml-alert *ngIf="showAlert && showFeedBack" [alertType]="alertType" [isHintAvailable]="showHints"
<quml-alert *ngIf="showAlert && showFeedBack && !questionSetEvaluable" [alertType]="alertType" [isHintAvailable]="showHints"
[showSolutionButton]="showUserSolution && currentSolutions" (showSolution)="viewSolution()" (showHint)="viewHint()"
(closeAlert)="closeAlertBox($event)"></quml-alert>

<quml-mcq-solutions *ngIf="showSolution" [question]="currentQuestion" [options]="currentOptions"
<quml-mcq-solutions *ngIf="showSolution && !questionSetEvaluable" [question]="currentQuestion" [options]="currentOptions"
[solutions]="currentSolutions" [baseUrl]="parentConfig?.baseUrl" [media]="media" [identifier]="currentQuestionIndetifier" (close)="closeSolution()"></quml-mcq-solutions>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('SectionPlayerComponent', () => {
qumlPlayerEvent = new EventEmitter<any>();
qumlQuestionEvent = new EventEmitter<any>();
pauseVideo() { }
serverValidationCheck() {}
}

class ElementRefMock {
Expand Down Expand Up @@ -665,6 +666,34 @@ describe('SectionPlayerComponent', () => {
expect(component.isAssessEventRaised).toBeTruthy();
});

it('store response if eval mode is server', () => {
component.questionSetEvaluable = true;
component.myCarousel = myCarousel;
const option = {
"name": "optionSelect",
"option": {
"label": "<p>Narendra Modi</p>",
"value": 1,
"selected": true
},
"cardinality": "single",
"solutions": []
}
component.optionSelectedObj = {
"name": "optionSelect",
"option": {
"label": "<p>Narendra Modi</p>",
"value": 1,
"selected": true
},
"cardinality": "single",
"solutions": []
}
component.questions = mockSectionQuestions;
component.parentConfig = mockParentConfig;
component.sectionConfig = mockSectionConfig;
component.validateSelectedOption(option, "next");
});

it('should hide the popup once the time is over', fakeAsync(() => {
component.infoPopupTimeOut();
Expand Down
Loading