5.1.5 • Published 2 years ago

@project-sunbird/sunbird-quml-player-v9 v5.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

:diamond_shape_with_a_dot_inside: QuML-player library for Sunbird platform

The QUML player library components are powered by Angular. These components are designed to be used in sunbird consumption platforms (mobile app, web portal, offline desktop app) to drive reusability, maintainability hence reducing the redundant development effort significantly.

:bookmark_tabs: Getting Started

For getting started with a new Angular app, check out the Angular CLI.

For existing apps, follow below-mentioned steps:

:label: Step 1: Install the packages

These are the peerDependencies of the library, need to be installed in order to use this library.

npm install @project-sunbird/sunbird-quml-player-v9 --save
npm install @project-sunbird/sb-styles --save
npm install @project-sunbird/client-services --save
npm install bootstrap@4.6.1 --save
npm install jquery --save
npm install katex --save
npm install lodash-es --save
npm install ngx-bootstrap@6.0.0 --save

Note: As QuML library is build with angular version 10, we are using bootstrap@4.6.1 and ngx-bootstrap@6.0.0 which are the compatible versions. For more reference Check compatibility document for ng-bootstrap here

:label: Step 2: Add CSS

Copy CSS code from the below given styles.css to app's default styles.css or styles.scss
keep quml-carousel.css in root folder.

:label: Step 3: Add question-cursor-implementation.service

Create a question-cursor-implementation.service.ts in a project and which will implement the QuestionCursor abstract class.
QuestionCursor is an abstract class, exported from the library, which needs to be implemented. Basically it has some methods which should make an API request over HTTP

For more information refer question-cursor-implementation.service.ts and do not forgot to add your question list API URL here, for example: https://staging.sunbirded.org/api/question/v1/list

:label: Step 3: Include the styles, scripts and assets in angular.json

Add the following under architect.build.assets for default project

{
  ...
  "build": {
    "builder": "@angular-devkit/build-angular:browser",
    "options": {
      ...
      ...
      "assets": [
        ...
        ...
        {
         "glob": "**/*.*",
         "input": "./node_modules/@project-sunbird/sunbird-quml-player-v9/lib/assets/",
         "output": "/assets/"
        }
      ],
      "styles": [
        ...
        "src/styles.css",
        "./node_modules/@project-sunbird/sb-styles/assets/_styles.scss",
        "./quml-carousel.css",
        "./node_modules/katex/dist/katex.min.css"
      ],
      "scripts": [
        ...
        "./node_modules/katex/dist/katex.min.js",
        "./node_modules/jquery/dist/jquery.min.js"
      ]
    }
  }
  ...
  ...
},

:label: Step 4: Import the modules and components

Import the required modules such as CarouselModule, QumlLibraryModule, HttpClientModule and question-cursor-implementation.service as below:

  import { HttpClientModule } from '@angular/common/http';
  import { QumlLibraryModule, QuestionCursor } from '@project-sunbird/sunbird-quml-player-v9';
  import { CarouselModule } from 'ngx-bootstrap/carousel';
  import { QuestionCursorImplementationService } from './question-cursor-implementation.service';

  @NgModule({
   ...

   imports: [ QumlLibraryModule, CarouselModule.forRoot(), HttpClientModule ],
   providers: [{
     provide: QuestionCursor,
     useClass: QuestionCursorImplementationService
   }]

   ...
  })

 export class AppModule { }

:label: Step 5: Send input to render Quml player

User can get a response from the api/questionset/v1/hierarchy/:do_id or can use the provided mock config for demo

Use the mock config in your component to send input to Quml player as playerConfig
Click to see the mock - playerConfig1

<quml-main-player [playerConfig]="playerConfig" ><quml-main-player>

:orange_circle: Available components

FeatureNotesSelectorCodeInputOutput
Quml PlayerCan be used to render Qumlquml-main-player<quml-main-player [playerConfig]="playerConfig"><quml-main-player>playerConfigplayerEvent, telemetryEvent

:small_red_triangle_down: Input Parameters

  1. playerConfig: Object - Required
{
  context: Object   // Information about the telemetry and default settings for quml API requests
  metadata: Object  // Question hierarchy response
  config: Object    // default player config such as sidebar menu list
}

:small_red_triangle_down: Output Events

  1. playerEvent() - It provides heartbeat event for each action performed in the player.
  2. telemetryEvent() - It provides the sequence of telemetry events such as START, INTERACT, IMPRESSION, SUMMARY, END

Use as web components :earth_asia:

QuML Library can also be used as web component which means user can import this library in any web application and use these custom component. Follow below-mentioned steps to use it in plain javascript project:

  • Insert library as below:
    	```javascript
    	<script  type="text/javascript"  src="sunbird-quml-player.js"></script>
    	```
  • Create a asset folder and copy all the files from here, library requires these assets internally to work well.

  • Get sample playerConfig from here: playerConfig

  • Pass the QuestionListAPI baseUrl for eg. https://staging.sunbirded.org/api/question/v1/list

  • Create a custom html element: sunbird-quml-player

    	```javascript
    	const  qumlPlayerElement = document.createElement('sunbird-quml-player');
    	```
  • Pass data using player-config

    	```javascript
    	qumlPlayerElement.setAttribute('player-config', JSON.stringify(playerConfig));
    	```
    	**Note:** Attribute should be in **string** type
  • Listen for the output events: playerEvent and telemetryEvent

    qumlPlayerElement.addEventListener('playerEvent', (event) => {
      console.log("On playerEvent", event);
    });
    qumlPlayerElement.addEventListener('telemetryEvent', (event) => {
      console.log("On telemetryEvent", event);
    });
  • Append this element to existing element

    const myPlayer = document.getElementById("my-player");
    myPlayer.appendChild(qumlPlayerElement);
  • :arrow_forward: Refer demo example

:bookmark_tabs: QuML Player Contribution Guide

Repo Setup

  • Install Node 12.x and Angular 10
  • Clone the Repo with desired release-branch - https://github.com/project-sunbird/sunbird-quml-player
  • Add the your baseUrl in the environment.ts and proxy.conf.json files
  • If there any changes in API endpoints, update the app.constant.ts file
  • Change the default content ID in app.component.ts file
  • Run npm i in root folder
  • Run npm i in projects/quml-library
  • Open two terminal windows (on root folder)
  • Run npm run build once this run completes, run the next command - let it be running on 1st terminal window
  • Run npm run serve on second terminal window (This will copy assets from the quml-library to the library dist folder)
  • Now it will be served on http://localhost:4200/
  • To run the web-component npm run build-web-component
5.0.5

2 years ago

5.0.4

2 years ago

5.1.5

2 years ago

5.1.4

2 years ago

5.1.3

2 years ago

5.1.2

2 years ago

5.1.0

2 years ago

5.0.3

2 years ago

5.0.2

2 years ago

4.9.8

2 years ago

4.9.9

2 years ago

4.10.0

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

4.9.7

2 years ago

4.9.4

2 years ago

4.9.3

2 years ago

4.9.5

2 years ago

4.9.0

2 years ago

4.9.2

2 years ago

4.9.1

2 years ago

4.8.12

2 years ago

4.8.11

2 years ago

4.8.13

2 years ago

4.8.9

2 years ago

4.8.8

2 years ago

4.8.5

2 years ago

4.8.4

2 years ago

4.8.7

2 years ago

4.8.6

2 years ago

4.8.3

2 years ago

4.8.2

2 years ago

4.8.10

2 years ago

4.8.1

2 years ago

4.8.0

2 years ago

4.7.0

2 years ago

4.7.5

2 years ago

4.7.2

2 years ago

4.7.1

2 years ago

4.7.4

2 years ago

4.7.3

2 years ago

4.6.6

2 years ago

4.6.3

2 years ago

4.6.5

2 years ago

4.6.4

2 years ago

4.5.8

2 years ago

4.5.7

2 years ago

4.5.9

2 years ago

4.5.4

2 years ago

4.5.3

2 years ago

4.5.6

2 years ago

4.5.5

2 years ago

4.6.1

2 years ago

4.6.0

2 years ago

4.4.14

2 years ago

4.4.17

2 years ago

4.4.16

2 years ago

4.4.15

2 years ago

4.6.2

2 years ago

4.5.10

2 years ago

4.5.11

2 years ago

4.5.14

2 years ago

4.5.12

2 years ago

4.5.13

2 years ago

4.5.0

2 years ago

4.5.2

2 years ago

4.5.1

2 years ago

4.4.10

3 years ago

4.4.13

3 years ago

4.4.12

3 years ago

4.4.11

3 years ago

4.4.2

3 years ago

4.4.9

3 years ago

4.4.8

3 years ago

4.4.5

3 years ago

4.4.4

3 years ago

4.4.7

3 years ago

4.4.6

3 years ago

4.3.19

3 years ago

4.4.1

3 years ago

4.4.0

3 years ago

4.3.18

3 years ago

4.3.17

3 years ago

4.3.16

3 years ago

4.3.15

3 years ago

4.3.13

3 years ago

4.3.14

3 years ago

4.3.9

3 years ago

4.3.12

3 years ago

4.3.11

3 years ago

4.3.10

3 years ago

4.3.8

3 years ago

4.3.6

3 years ago

4.3.5

3 years ago

4.3.7

3 years ago

4.2.8

3 years ago

4.3.2

3 years ago

4.3.1

3 years ago

4.3.3

3 years ago

4.2.7

3 years ago

4.2.6

3 years ago

4.1.25

3 years ago

4.2.3

3 years ago

4.2.5

3 years ago

4.2.4

3 years ago

4.2.2

3 years ago

4.1.24

3 years ago

4.2.1

3 years ago

4.1.20

3 years ago

4.1.21

3 years ago

4.1.22

3 years ago

4.2.0

3 years ago

4.1.23

3 years ago

4.1.19

3 years ago

4.1.16

3 years ago

4.1.17

3 years ago

4.1.18

3 years ago

4.1.14

3 years ago

4.1.15

3 years ago

4.1.13

3 years ago

4.1.11

3 years ago

4.1.12

3 years ago

4.1.10

3 years ago

4.1.9

3 years ago

4.1.6

3 years ago

4.1.7

3 years ago

4.1.5

3 years ago

4.1.3

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago