Skip to content

Commit

Permalink
Issue #225417 feat: Enabling True False in Player
Browse files Browse the repository at this point in the history
  • Loading branch information
rajnishdargan committed Aug 23, 2024
2 parents cb66f66 + bdc7f32 commit 2266666
Show file tree
Hide file tree
Showing 43 changed files with 31,175 additions and 5,247 deletions.
33 changes: 31 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"private": true,
"dependencies": {
"@angular/animations": "^16.2.12",
"@angular/cdk": "^16.2.14",
"@angular/common": "^16.2.12",
"@angular/compiler": "^16.2.12",
"@angular/core": "^16.2.12",
Expand All @@ -30,8 +31,8 @@
"@angular/router": "^16.2.12",
"@project-sunbird/client-services": "5.1.2",
"@project-sunbird/sb-styles": "0.0.16",
"@project-sunbird/telemetry-sdk": "1.3.0",
"@project-sunbird/sunbird-player-sdk-v9": "6.0.5",
"@project-sunbird/telemetry-sdk": "1.3.0",
"bootstrap": "^5.3.3",
"core-js": "^2.5.4",
"document-register-element": "^1.7.2",
Expand All @@ -45,14 +46,15 @@
"zone.js": "~0.13.3"
},
"devDependencies": {
"@angular-devkit/core": "^16.2.12",
"@angular-devkit/build-angular": "^16.2.12",
"@angular-devkit/core": "^16.2.12",
"@angular/cli": "^16.2.12",
"@angular/compiler-cli": "^16.2.12",
"@angular/language-service": "^16.2.12",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"ajv": "^8.12.0",
"codelyzer": "^6.0.0",
"concat": "^1.0.3",
"copyfiles": "^2.4.1",
Expand All @@ -68,7 +70,6 @@
"protractor": "~7.0.0",
"ts-node": "~7.0.0",
"tslint": "~6.1.3",
"typescript": "~4.9.5",
"ajv": "^8.12.0"
"typescript": "~4.9.5"
}
}
}
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": "@tekdi/sunbird-quml-player",
"version": "8.0.0",
"version": "9.0.0-beta.9",
"schematics": "./schematics/collection.json",
"ng-add": {
"save": "dependencies"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<ng-container *ngIf="optionsShuffled && (layout === 'VERTICAL' || layout === 'DEFAULT')">
<div id="dragdropSpace" cdkDropList [cdkDropListData]="shuffledOptions" class="asq-horizontal-list" (cdkDropListDropped)="onDrop($event)">
<div class="asq-horizontal-box" *ngFor="let option of shuffledOptions" cdkDrag cdkDragBoundary="#dragdropSpace">
<div [innerHTML]="option.label"></div>
<quml-reorder></quml-reorder>
</div>
</div>
</ng-container>
<ng-container *ngIf="optionsShuffled && (layout === 'HORIZONTAL')">
<div id="dragdropSpace" cdkDropList cdkDropListOrientation="horizontal" [cdkDropListData]="shuffledOptions" class="horizontal-list" (cdkDropListDropped)="onDrop($event)">
<div class="asq-vertical-box" *ngFor="let option of shuffledOptions" cdkDrag cdkDragBoundary="#dragdropSpace">
<div class="drag-handle">
<quml-reorder></quml-reorder>
</div>
<div [innerHTML]="option.label"></div>
</div>
</div>
</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
.asq-horizontal-box{
display: flex;
align-items: center;
justify-content: space-between;
margin: 15px;
border:1px solid #b3a8a869;
cursor: move;
box-shadow: rgba(17, 17, 26, 0.1) 0px 4px 16px, rgba(17, 17, 26, 0.05) 0px 8px 32px;
padding: 15px 20px;
border-radius: 6px;
}
::ng-deep .asq-horizontal-box p{
margin-top: 5px;
margin-bottom: 5px;
}
.cdk-drag-preview {
box-sizing: border-box;
border-radius: 4px;
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2),
0 8px 10px 1px rgba(0, 0, 0, 0.14),
0 3px 14px 2px rgba(0, 0, 0, 0.12);
}
.cdk-drag-placeholder {
opacity: 0;
}

.cdk-drag-animating {
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}

.cdk-drop-list-dragging .asq-horizontal-box:not(.cdk-drag-placeholder) {
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}
::ng-deep .asq-horizontal-box img
{
width: 70px;
height: 70px;
object-fit: contain;
}
//horizontal layout css
.horizontal-list {
display: flex;
justify-content: space-between;
flex-wrap: nowrap;
width: 100%;
padding: 10px;
box-sizing: border-box;
}

.asq-vertical-box {
flex: 0 1 25%;
max-width: 25%;
position:relative;
padding: 0px 15px;
border: solid 1px #ccccccab;
color: rgba(0, 0, 0, 0.87);
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
cursor: move;
background: white;
margin:10px;
border-radius: 4px;
min-height:150px;
margin-top:2%;
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
::ng-deep .asq-vertical-box img
{
width: 70px;
height: 70px;
object-fit: contain;
}
::ng-deep .asq-vertical-box p{
line-height: 20px;
margin-top: 5px;
margin-bottom: 5px;
}

.horizontal-list.cdk-drop-list-dragging .asq-vertical-box:not(.cdk-drag-placeholder) {
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}
.centered-align{
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.drag-handle{
position: absolute;
top: 5px;
right: 5px;
cursor: move;
}
@media screen and (max-width: 600px) {
::ng-deep .asq-vertical-box p {
line-height: 14px;
margin-top: 5px;
margin-bottom: 5px;
font-size: 10px;
padding: 7px;
}
.asq-vertical-box{
margin: 0% 1px 10px;
padding:0px;
}
.horizontal-list{
padding:0px;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AsqOptionsComponent } from './asq-options.component';

describe('AsqOptionsComponent', () => {
let component: AsqOptionsComponent;
let fixture: ComponentFixture<AsqOptionsComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AsqOptionsComponent]
});
fixture = TestBed.createComponent(AsqOptionsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Component, Input, Output, OnInit, OnChanges, SimpleChanges, EventEmitter } from '@angular/core';
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { AsqOptions } from '../../interfaces/asq-interface';
import * as _ from 'lodash-es';

@Component({
selector: 'quml-asq-options',
templateUrl: './asq-options.component.html',
styleUrls: ['./asq-options.component.scss'],
})
export class AsqOptionsComponent implements OnInit, OnChanges {
@Input() options: any[];
@Input() layout: string;
@Input() shuffleOptions: boolean;
@Input() replayed: boolean;
@Input() tryAgain?: boolean;
@Output() reorderedOptions = new EventEmitter<AsqOptions[]>();
shuffledOptions: any[];
optionsShuffled = false;
isModalVisible: boolean = false;
selectedImageSrc: string = '';

constructor() {
this.shuffledOptions = [];
}

ngOnInit() {
this.shuffleMTFOptions();

}

ngOnChanges(): void {
if(this.replayed || this.tryAgain) {
this.shuffleMTFOptions();
}
}

shuffleMTFOptions() {
// Shuffle the options
this.shuffledOptions = _.shuffle(this.options);
this.optionsShuffled = true;

// Ensure no item retains its original position
let isSameAsOriginal = this.shuffledOptions.some((item, index) => item.value === this.options[index].value);
while (isSameAsOriginal) {
this.shuffledOptions = _.shuffle(this.options);
isSameAsOriginal = this.shuffledOptions.some((item, index) => item.value === this.options[index].value);
}
}

onDrop(event: CdkDragDrop<any[]>) {
moveItemInArray(this.shuffledOptions, event.previousIndex, event.currentIndex);
this.reorderedOptions.emit(this.shuffledOptions);
}

swapOptions(index1: number, index2: number) {
[this.shuffledOptions[index1], this.shuffledOptions[index2]] = [
this.shuffledOptions[index2],
this.shuffledOptions[index1],
];
}
}
9 changes: 9 additions & 0 deletions projects/quml-library/src/lib/asq/asq.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div *ngIf="questionBody" class="question-body">
<div class="mtf-title">
<p [innerHTML]="questionBody"></p>
</div>
<quml-asq-options [shuffleOptions]="shuffleOptions" [replayed]="replayed" [tryAgain]="tryAgain" *ngIf="interactions?.response1?.options"
[options]="interactions.response1.options" (reorderedOptions)="handleReorderedOptions($event)" [layout]="layout">
</quml-asq-options>
</div>

Empty file.
21 changes: 21 additions & 0 deletions projects/quml-library/src/lib/asq/asq.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AsqComponent } from './asq.component';

describe('AsqComponent', () => {
let component: AsqComponent;
let fixture: ComponentFixture<AsqComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AsqComponent]
});
fixture = TestBed.createComponent(AsqComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit 2266666

Please sign in to comment.