From f244ef7ca295bb9941052cd9a441f335953dd462 Mon Sep 17 00:00:00 2001 From: ramkumar-pacewisdom Date: Thu, 17 Aug 2023 16:45:09 +0530 Subject: [PATCH 1/4] shikshalokam question sets added --- angular.json | 52 +----- server/config/constants.js | 28 +-- server/config/environment.js | 4 +- src/app/app.constant.ts | 6 +- src/app/app.module.ts | 19 +-- src/app/components/player/player-data.ts | 2 +- .../components/player/player.component.html | 5 +- .../player/player.component.spec.ts | 9 - src/app/components/player/player.component.ts | 61 ++++--- .../questionset-create.component.html | 24 ++- .../questionset-create.component.ts | 4 +- src/app/components/questionset-editor/data.ts | 159 +++++++++++++----- .../questionset-editor.component.html | 2 +- .../questionset-editor.component.ts | 30 +++- .../questionset-list.component.html | 4 +- .../questionset-list.component.scss | 4 + .../questionset-workspace.component.scss | 2 +- .../editor-cursor-implementation.service.ts | 6 +- src/app/services/content.service.ts | 9 +- src/app/services/helper/helper.service.ts | 6 +- .../question-cursor-implementation.service.ts | 17 +- src/proxy.conf.json | 6 +- 22 files changed, 272 insertions(+), 187 deletions(-) diff --git a/angular.json b/angular.json index 167a3cd9..51f8f4ab 100644 --- a/angular.json +++ b/angular.json @@ -28,61 +28,23 @@ "src/assets", { "glob": "**/*.*", - "input": "./node_modules/@project-sunbird/sunbird-quml-player/lib/assets/", + "input": "./node_modules/@project-sunbird/sunbird-quml-player-web-component/assets", "output": "/assets/" }, { "glob": "**/*", - "input": "node_modules/@project-sunbird/sunbird-pdf-player-v9/lib/assets/", - "output": "/assets/" - }, - { - "glob": "**/*", - "input": "node_modules/@project-sunbird/sunbird-video-player-v9/lib/assets/", - "output": "/assets/" - }, - { - "glob": "**/*", - "input": "node_modules/@project-sunbird/sunbird-questionset-editor/lib/assets", - "output": "/assets/" - }, - { - "glob": "**/*", - "input": "node_modules/@project-sunbird/sunbird-quml-player/lib/assets/", + "input": "node_modules/@project-sunbird/sunbird-questionset-editor-web-component/assets/", "output": "/assets/" } ], "styles": [ "src/theme.scss", "src/styles.scss", - "./node_modules/@project-sunbird/sb-styles/assets/_styles.scss", - "./src/quml-carousel.css", - "src/assets/styles/styles.scss", - "./node_modules/katex/dist/katex.min.css", - "src/assets/quml-styles/quml-carousel.css", - "src/assets/lib/semantic/semantic.min.css", - "node_modules/font-awesome/css/font-awesome.css", - "node_modules/video.js/dist/video-js.min.css", - "node_modules/@project-sunbird/sunbird-video-player-v9/lib/assets/videojs.markers.min.css", - "node_modules/videojs-http-source-selector/dist/videojs-http-source-selector.css" + "./node_modules/@project-sunbird/sunbird-questionset-editor-web-component/styles.css" ], "scripts": [ - "./node_modules/katex/dist/katex.min.js", - "./node_modules/jquery/dist/jquery.min.js", - "node_modules/epubjs/dist/epub.js", - "src/assets/libs/iziToast/iziToast.min.js", - "node_modules/jquery/dist/jquery.min.js", - "node_modules/jquery.fancytree/dist/jquery.fancytree-all-deps.min.js", - "src/assets/lib/dimmer.min.js", - "src/assets/lib/transition.min.js", - "src/assets/lib/modal.min.js", - "src/assets/lib/semantic-ui-tree-picker.js", - "node_modules/@project-sunbird/client-services/index.js", - "node_modules/video.js/dist/video.js", - "node_modules/@project-sunbird/sunbird-video-player-v9/lib/assets/videojs-markers.js", - "node_modules/videojs-contrib-quality-levels/dist/videojs-contrib-quality-levels.min.js", - "node_modules/videojs-http-source-selector/dist/videojs-http-source-selector.min.js", - "node_modules/@project-sunbird/telemetry-sdk/index.js" + "node_modules/@project-sunbird/sunbird-quml-player-web-component/sunbird-quml-player.js", + "node_modules/@project-sunbird/sunbird-questionset-editor-web-component/sunbird-questionset-editor.js" ], "vendorChunk": true, "extractLicenses": false, @@ -156,9 +118,7 @@ "src/styles.scss" ], "scripts": [ - "src/assets/libs/iziToast/iziToast.min.js", - "node_modules/jquery/dist/jquery.min.js" - ] + "src/assets/libs/iziToast/iziToast.min.js" ] } }, "e2e": { diff --git a/server/config/constants.js b/server/config/constants.js index 8ea831e1..3723a9b1 100644 --- a/server/config/constants.js +++ b/server/config/constants.js @@ -1,13 +1,13 @@ module.exports = { "API": { - "CHANNEL": "/action/channel/v1/*", - "FRAMEWORK": "/api/framework/v1/read/*", + "CHANNEL": "/action/channel/v2/*", + "FRAMEWORK": "/api/framework/v2/read/*", "COMPOSITE": "/action/composite/v3/search", "COMPOSITE_API": "/api/composite/v1/search", - "QUESTION_LIST": "/api/question/v1/list", + "QUESTION_LIST": "/api/question/v2/list", "USERS": "/action/users", "TELEMMETRY": "/action/data/v3/telemetry", - "OBJECT_CATEGORY_DEFINITION": "/action/object/category/definition/v1/*", + "OBJECT_CATEGORY_DEFINITION": "/action/object/category/definition/v2/*", "PREFIX": { "ACTION": "/action", "ASSETS": "/assets", @@ -15,24 +15,24 @@ module.exports = { }, "LEARNER": { "FRAMEWORK": "/learner/framework/v1/read/*", - "QUESTIONSET_HIERARCHY": "/learner/questionset/v1/hierarchy/*" + "QUESTIONSET_HIERARCHY": "/learner/questionset/v2/hierarchy/*" }, "LATEX": { "CONVERT": "/latex/convert" }, "QUESTIONSET": { - "CREATE": "/action/questionset/v1/create", - "READ": "/action/questionset/v1/read/*", - "HIERARCHY_READ": "/action/questionset/v1/hierarchy/*", - "REVIEW": "/action/questionset/v1/review/*", - "REJECT": "/action/questionset/v1/reject/*", - "PUBLISH": "/action/questionset/v1/publish/*", - "RETIRE": "/action/questionset/v1/retire/*" + "CREATE": "/action/questionset/v2/create", + "READ": "/action/questionset/v2/read/*", + "HIERARCHY_READ": "/action/questionset/v2/hierarchy/*", + "REVIEW": "/action/questionset/v2/review/*", + "REJECT": "/action/questionset/v2/reject/*", + "PUBLISH": "/action/questionset/v2/publish/*", + "RETIRE": "/action/questionset/v2/retire/*" }, "ASSET": { - "CREATE": "/action/asset/v1/create", + "CREATE": "/action/asset/v2/create", "CONTENT_UPLOAD_URL": "/action/content/v3/upload/url/*", - "ASSET_UPLOAD": "/action/asset/v1/upload/*" + "ASSET_UPLOAD": "/action/asset/v2/upload/*" } } } diff --git a/server/config/environment.js b/server/config/environment.js index a0ecb8d5..675b57b2 100644 --- a/server/config/environment.js +++ b/server/config/environment.js @@ -4,8 +4,8 @@ const users = require('./users'); let envVariables = { BASE_URL: 'dev.inquiry.sunbird.org' || env.inquiry_portal_base_url, CONTENT_PROXY_URL: 'https://sunbirdstagingpublic.blob.core.windows.net/sunbird-content-staging', - API_AUTH_TOKEN: env.inquiry_portal_api_auth_token || "", - USER_API_TOKEN: env.inquiry_portal_user_api_token || "", + API_AUTH_TOKEN: '' || "", + USER_API_TOKEN: '' || "", PORTAL_COOKIES: "", CHANNEL_ID: env.inquiry_portal_channel_id || "01309282781705830427", USER_ID: env.inquiry_portal_user_id || "", diff --git a/src/app/app.constant.ts b/src/app/app.constant.ts index c0212ba1..5a0fc758 100644 --- a/src/app/app.constant.ts +++ b/src/app/app.constant.ts @@ -1,6 +1,6 @@ export const ApiEndPoints = { getContent: '/api/content/v1/read/', - getQuestionSetHierarchy: '/learner/questionset/v1/hierarchy/', - questionSetRead: '/api/questionset/v1/read/', - questionList: '/api/question/v1/list', + getQuestionSetHierarchy: '/action/questionset/v2/hierarchy/', + questionSetRead: '/action/questionset/v2/read/', + questionList: '/api/question/v2/list', } \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 41fa65d4..6190e03a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -7,9 +7,6 @@ import { HomeComponent } from './components/home/home.component'; import { HeaderComponent } from './components/header/header.component'; import { FooterComponent } from './components/footer/footer.component'; import { HttpClientModule } from '@angular/common/http'; -import { QuestionCursor, QumlLibraryModule } from '@project-sunbird/sunbird-quml-player'; -import { CarouselModule } from 'ngx-bootstrap/carousel'; -import { QuestionCursorImplementationService } from './services/question-cursor-implementation.service'; import { CommonModule } from '@angular/common'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { PlayerContentListComponent } from './components/player-content-list/player-content-list.component'; @@ -21,14 +18,12 @@ import { EditConfigurationComponent } from './components/edit-configuration/edit import { MatDialogModule } from '@angular/material/dialog'; import { MatSelectModule } from '@angular/material/select'; import { MatFormFieldModule } from '@angular/material/form-field'; +import {MatMenuModule} from '@angular/material/menu'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { QuestionsetEditorComponent } from './components/questionset-editor/questionset-editor.component'; -import { QuestionsetEditorLibraryModule, EditorCursor } from '@project-sunbird/sunbird-questionset-editor'; import { FilterComponent } from './components/filter/filter.component'; import { MatCheckboxModule } from '@angular/material/checkbox'; -import { RouterModule } from '@angular/router'; -import { EditorCursorImplementationService } from './editor-cursor-implementation.service'; import { QuestionsetListComponent } from './components/questionset-list/questionset-list.component'; import { QuestionsetWorkspaceComponent } from './components/questionset-workspace/questionset-workspace.component'; import { QuestionsetCreateComponent } from './components/questionset-create/questionset-create.component'; @@ -61,8 +56,6 @@ import { ToasterService } from '../app/services/toaster/toaster.service'; BrowserModule, CommonModule, HttpClientModule, - QumlLibraryModule, - CarouselModule.forRoot(), FormsModule, MatToolbarModule, MatIconModule, @@ -73,18 +66,10 @@ import { ToasterService } from '../app/services/toaster/toaster.service'; MatCheckboxModule, ReactiveFormsModule, BrowserAnimationsModule, - QuestionsetEditorLibraryModule, + MatMenuModule, AppRoutingModule ], providers: [ - { - provide: QuestionCursor, - useExisting: EditorCursorImplementationService - }, - { - provide: EditorCursor, - useExisting: EditorCursorImplementationService - }, ToasterService ], bootstrap: [AppComponent] diff --git a/src/app/components/player/player-data.ts b/src/app/components/player/player-data.ts index df8cfb25..e4a29c98 100644 --- a/src/app/components/player/player-data.ts +++ b/src/app/components/player/player-data.ts @@ -3,7 +3,7 @@ export const SamplePlayerData = { 'context': { 'threshold': 3, 'mode': 'play', - 'authToken': ' ', + 'authToken': '', 'sid': '913b3c6c-2874-26dd-ed0c-c23ddc00b718', 'did': '561c348e631fd225b46a5571cbd42ad1', 'uid': '', diff --git a/src/app/components/player/player.component.html b/src/app/components/player/player.component.html index b70d8d59..9ef76a9e 100644 --- a/src/app/components/player/player.component.html +++ b/src/app/components/player/player.component.html @@ -19,8 +19,9 @@
-
- +
Loading...
+
+
diff --git a/src/app/components/player/player.component.spec.ts b/src/app/components/player/player.component.spec.ts index 49d9a563..f9960ed4 100644 --- a/src/app/components/player/player.component.spec.ts +++ b/src/app/components/player/player.component.spec.ts @@ -83,15 +83,6 @@ describe('PlayerComponent', () => { expect(component.setConfig); }); - it('should navigate to the player page', () => { - component.playerConfig = mockPlayerData.playerConfig; - const router = TestBed.inject(Router); - component.nextContents = [{ id: '1', name: 'first' }, { id: '2', name: 'second' }]; - spyOn(router, 'navigate'); - component.onPlayerEvent({ edata: { type: 'NEXT_CONTENT_PLAY' } }); - expect(router.navigate).toHaveBeenCalled(); - }); - it('should switch to the portrait Mode', () => { component.showPortrait = false; component.switchToPortraitMode(); diff --git a/src/app/components/player/player.component.ts b/src/app/components/player/player.component.ts index b0fd2bd0..35a0b8e8 100644 --- a/src/app/components/player/player.component.ts +++ b/src/app/components/player/player.component.ts @@ -1,13 +1,13 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Router } from '@angular/router'; -import { QumlPlayerConfig } from '@project-sunbird/sunbird-quml-player/lib/quml-library-interface'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { NavigationService } from 'src/app/services/navigation.service'; import { QuestionCursorImplementationService } from 'src/app/services/question-cursor-implementation.service'; import { EditConfigurationComponent } from '../edit-configuration/edit-configuration.component'; import { SamplePlayerData } from './player-data'; +import { environment } from '../../../environments/environment'; @Component({ selector: 'app-player', @@ -15,9 +15,9 @@ import { SamplePlayerData } from './player-data'; styleUrls: ['./player.component.scss'] }) export class PlayerComponent implements OnInit, OnDestroy { - - playerConfig: QumlPlayerConfig; - editConfig = { + @ViewChild('qumlPlayer') qumlPlayer: ElementRef; + playerConfig: any; + editConfig: any = { showFeedback: '', showSubmitConfirmation: '', summaryType: '', @@ -66,13 +66,37 @@ export class PlayerComponent implements OnInit, OnDestroy { metadata, data: {} }; + this.loadPlayer({changeConfig: true}); + } + + loadPlayer(changeConfig?) { + if (changeConfig.changeConfig) { + this.qumlPlayer.nativeElement.innerHTML = ''; + } + const playerConfig = this.playerConfig; + const qumlElement = document.createElement('sunbird-quml-player'); + (window as any).questionListUrl = "/api/question/v2/list"; + qumlElement.setAttribute('player-config', JSON.stringify(playerConfig)); + qumlElement.addEventListener('playerEvent', (event) => { + const customEvent: any = event; + if (customEvent.detail.edata.type === 'NEXT_CONTENT_PLAY') { + this.qumlPlayer.nativeElement.innerHTML = ''; + this.router.navigate(['/player', this.nextContents[0].id]); + } + }); + qumlElement.addEventListener('telemetryEvent', (event) => { + const customEvent: any = event; + console.log("telemetryEvent", customEvent.detail); + }); + + this.qumlPlayer.nativeElement.append(qumlElement); } setConfig(): void { - this.editConfig.showFeedback = this.playerConfig.metadata?.children?.every(child => child.showFeedback === 'Yes') ? 'Yes' : 'No'; + this.editConfig.showFeedback = this.playerConfig.metadata?.children?.every(child => child.showFeedback === true) ? 'Yes' : 'No'; this.editConfig.showSubmitConfirmation = this.playerConfig.metadata.requiresSubmit ? this.playerConfig.metadata.requiresSubmit : ''; this.editConfig.summaryType = this.playerConfig.metadata.summaryType ? this.playerConfig.metadata.summaryType : ''; - this.editConfig.showTimer = this.playerConfig.metadata.showTimer ? this.playerConfig.metadata.showTimer : ''; + this.editConfig.showTimer = this.playerConfig.metadata.showTimer ? 'Yes' : 'No'; } changeConfig(): void { @@ -103,11 +127,11 @@ export class PlayerComponent implements OnInit, OnDestroy { if (result.showFeedback) { if (result.showFeedback === 'Yes') { this.playerConfig.metadata.children.forEach(child => { - child.showFeedback = 'Yes'; + child.showFeedback = true; }); } else { this.playerConfig.metadata.children.forEach(child => { - child.showFeedback = 'No'; + child.showFeedback = false; }); } } @@ -124,14 +148,16 @@ export class PlayerComponent implements OnInit, OnDestroy { /* istanbul ignore else */ if (result.showTimer) { - this.playerConfig.metadata.showTimer = result.showTimer; + this.playerConfig.metadata.showTimer = result.showTimer === 'Yes' ? true: false; /* istanbul ignore else */ if (result.showTimer === 'Yes' && !this.playerConfig.metadata.timeLimits) { - this.playerConfig.metadata.timeLimits = { - maxTime: '120', - warningTime: '10' - }; + const timeLimits ={ + questionSet: { + max: 120 + } + } + this.playerConfig.metadata = {...this.playerConfig.metadata,timeLimits } } } @@ -146,13 +172,6 @@ export class PlayerComponent implements OnInit, OnDestroy { this.showPortrait = false; } - onPlayerEvent(event) { - /* istanbul ignore else */ - if (event?.edata?.type === 'NEXT_CONTENT_PLAY') { - this.router.navigate(['/player', this.nextContents[0].id]); - } - } - ngOnDestroy(): void { this.$unsubscribe.next(); this.$unsubscribe.complete(); diff --git a/src/app/components/questionset-create/questionset-create.component.html b/src/app/components/questionset-create/questionset-create.component.html index 326e9e53..e9f68c0d 100644 --- a/src/app/components/questionset-create/questionset-create.component.html +++ b/src/app/components/questionset-create/questionset-create.component.html @@ -3,7 +3,7 @@
-
diff --git a/src/app/components/questionset-create/questionset-create.component.ts b/src/app/components/questionset-create/questionset-create.component.ts index 18ebffea..6c41523f 100644 --- a/src/app/components/questionset-create/questionset-create.component.ts +++ b/src/app/components/questionset-create/questionset-create.component.ts @@ -22,12 +22,12 @@ export class QuestionsetCreateComponent implements OnInit { } } - createContent(): void { + createContent(primaryCategory:string): void { const requestData = { questionset: { name: 'Untitled QuestionSet', mimeType: 'application/vnd.sunbird.questionset', - primaryCategory: 'Practice Question Set', + primaryCategory: primaryCategory, createdBy: this.userService.userProfile.id, createdFor: [this.userService.userProfile.channelId], framework: this.userService.userProfile.frameworkId, diff --git a/src/app/components/questionset-editor/data.ts b/src/app/components/questionset-editor/data.ts index 4712c699..06e48efd 100644 --- a/src/app/components/questionset-editor/data.ts +++ b/src/app/components/questionset-editor/data.ts @@ -1,111 +1,188 @@ -export const questionSetEditorConfig = { +export const observationEditorConfig = { context: { + programId: 'f72ad8b0-36df-11ec-a56f-4b503455085f', + contributionOrgId: '', user: { id: '5a587cc1-e018-4859-a0a8-e842650b9d64', - fullName: 'N11', - firstName: 'N11', - lastName: '', + fullName: 'Vaibahv Bhuva', + firstName: 'Vaibhav', + lastName: 'Bhuva', orgIds: ['01309282781705830427'] }, - identifier: '', + // identifier: 'do_113395089840529408131', // 'do_1132393548335759361558', // do_11330102570702438417 + identifier: 'do_2138220235204444161749', // 'do_1133610108714352641210', // Observation + authToken: ' ', sid: 'iYO2K6dOSdA0rwq7NeT1TDzS-dbqduvV', did: '7e85b4967aebd6704ba1f604f20056b6', uid: 'bf020396-0d7b-436f-ae9f-869c6780fc45', channel: '01309282781705830427', pdata: { - id: 'dev.inquiry.portal', - ver: '1.0.0', - pid: 'sunbird-inquiry-portal' + id: 'dev.dock.portal', + ver: '2.8.0', + pid: 'creation-portal' }, contextRollup: { - l1: '01309282781705830427', + l1: '01307938306521497658', }, - tags: ['01309282781705830427'], + tags: ['01307938306521497658'], + cdata: [ + { + id: '01307938306521497658', + type: 'sourcing_organization', + }, + { + type: 'project', + id: 'ec5cc850-3f71-11eb-aae1-fb99d9fb6737', + }, + { + type: 'linked_collection', + id: 'do_113140468925825024117' + } + ], timeDiff: 5, - host: '', + objectRollup: { + l1: 'do_113140468925825024117', + l2: 'do_113140468926914560125' + }, + host: 'https://dock.sunbirded.org', defaultLicense: 'CC BY 4.0', endpoint: '/data/v3/telemetry', env: 'questionset_editor', framework: 'ekstep_ncert_k-12', - cloudStorageUrls: [ - 'https://sunbirdstagingpublic.blob.core.windows.net/sunbird-content-staging/', - 'https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/', - 'https://obj.devbb.sunbird.org/sunbird-content-staging/' - ], - cloudStorage: { - presigned_headers: { - 'x-ms-blob-type': 'BlockBlob' + cloudStorageUrls: ['https://s3.ap-south-1.amazonaws.com/ekstep-public-qa/', 'https://ekstep-public-qa.s3-ap-south-1.amazonaws.com/', + 'https://sunbirddev.blob.core.windows.net/sunbird-content-dev/'], + subject: ['English'], + topic: [], + additionalCategories: [ + { + value: 'Classroom Teaching Video', + label: 'Classroom Teaching Video' + }, + { + value: 'Concept Map', + label: 'Concept Map' + }, + { + value: 'Curiosity Question Set', + label: 'Curiosity Question Set' + }, + { + value: 'Textbook', + label: 'Textbook' + }, + { + value: 'Experiential Resource', + label: 'Experiential Resource' + }, + { + value: 'Explanation Video', + label: 'Explanation Video' + }, + { + value: 'Focus Spot', + label: 'Focus Spot' + }, + { + value: 'Learning Outcome Definition', + label: 'Learning Outcome Definition' + }, + { + value: 'Marking Scheme Rubric', + label: 'Marking Scheme Rubric' + }, + { + value: 'Pedagogy Flow', + label: 'Pedagogy Flow' + }, + { + value: 'Lesson Plan', + label: 'Lesson Plan' + }, + { + value: 'Previous Board Exam Papers', + label: 'Previous Board Exam Papers' + }, + { + value: 'TV Lesson', + label: 'TV Lesson' } - }, - additionalCategories: [], + ], labels: { save_collection_btn_label: 'Save as Draft', - }, - correctionComments: false, - sourcingResourceStatus: true, + } }, config: { mode: 'edit', // edit / review / read / sourcingReview // orgReview - enableQuestionCreation: true, editableFields: { - sourcingreview: ['instructions'], + //sourcingreview: ['instructions'], orgreview: ['name', 'instructions', 'learningOutcome'], review: ['name', 'description'], }, maxDepth: 4, objectType: 'QuestionSet', - primaryCategory: 'Practice Question Set', + // primaryCategory: 'Observation', + primaryCategory: 'Observation', isRoot: true, iconClass: 'fa fa-book', showAddCollaborator: false, - enableBulkUpload: false, + enableBulkUpload: true, publicStorageAccount: 'https://dockstorage.blob.core.windows.net/', - hideSubmitForReviewBtn: false, children: { Question: [ 'Multiple Choice Question', - 'Subjective Question' + 'Slider', + 'Text', + 'Date' ] }, - addFromLibrary: false, hierarchy: { level1: { name: 'Section', type: 'Unit', mimeType: 'application/vnd.sunbird.questionset', - primaryCategory: 'Practice Question Set', + primaryCategory: 'Observation', iconClass: 'fa fa-folder-o', - children: {}, - addFromLibrary: true + children: { + Question: [ + 'Multiple Choice Question', + 'Slider', + 'Text', + 'Date' + ] + } }, level2: { name: 'Sub Section', type: 'Unit', mimeType: 'application/vnd.sunbird.questionset', - primaryCategory: 'Practice Question Set', + primaryCategory: 'Observation', iconClass: 'fa fa-folder-o', children: { Question: [ 'Multiple Choice Question', - 'Subjective Question' + 'Slider', + 'Text', + 'Date' ] - }, - addFromLibrary: true + } }, level3: { name: 'Sub Section', type: 'Unit', mimeType: 'application/vnd.sunbird.questionset', - primaryCategory: 'Practice Question Set', + primaryCategory: 'Observation', iconClass: 'fa fa-folder-o', children: { Question: [ - 'Subjective Question' + 'Multiple Choice Question', + 'Slider', + 'Text', + 'Date' ] } } }, contentPolicyUrl: '/term-of-use.html' } -}; +}; \ No newline at end of file diff --git a/src/app/components/questionset-editor/questionset-editor.component.html b/src/app/components/questionset-editor/questionset-editor.component.html index b2bb2237..fc21bffa 100644 --- a/src/app/components/questionset-editor/questionset-editor.component.html +++ b/src/app/components/questionset-editor/questionset-editor.component.html @@ -1 +1 @@ - +
diff --git a/src/app/components/questionset-editor/questionset-editor.component.ts b/src/app/components/questionset-editor/questionset-editor.component.ts index e2f85e14..926c156b 100644 --- a/src/app/components/questionset-editor/questionset-editor.component.ts +++ b/src/app/components/questionset-editor/questionset-editor.component.ts @@ -1,5 +1,5 @@ -import { Component, OnInit } from '@angular/core'; -import { questionSetEditorConfig } from './data'; +import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; +import { observationEditorConfig } from './data'; import { Router, ActivatedRoute } from '@angular/router'; import { UserService } from 'src/app/services/user/user.service'; import { HelperService } from 'src/app/services/helper/helper.service'; @@ -12,7 +12,8 @@ import * as _ from 'lodash-es'; }) export class QuestionsetEditorComponent implements OnInit { - public editorConfig: any = questionSetEditorConfig; + @ViewChild('questionsetEditor') inQuiryEditor: ElementRef; + public editorConfig: any = observationEditorConfig; channelData: any; questionsetData: any; routeParams: any; @@ -60,6 +61,29 @@ export class QuestionsetEditorComponent implements OnInit { this.editorConfig.context.tags = [this.userService.userProfile.channelId]; const additionalCategory = _.merge(this.channelData.contentAdditionalCategories, this.channelData.collectionAdditionalCategories); this.editorConfig.context.additionalCategories = additionalCategory; + setTimeout(() => { + this.loadEditor(); + }); + } + + loadEditor() { + const editorConfig = this.editorConfig; + const questionsetEditorElement = document.createElement('lib-questionset-editor'); + questionsetEditorElement.setAttribute('editor-config', JSON.stringify(editorConfig)); + + questionsetEditorElement.addEventListener('editorEmitter', (event) => { + const customEvent: any = event; + console.log("On editorEvent", customEvent.detail); + if (customEvent.detail.action === 'backContent' || customEvent.detail.action === 'submitContent' || customEvent.detail.action === 'publishContent' || customEvent.detail.action === 'rejectContent') { + if (_.has(this.routeParams, 'state') && this.routeParams.state === 'create') { + this.router.navigate(['/questionset/questionset-list', 1]); + } else { + this.navigationService.goBack(); + } + } + }); + + this.inQuiryEditor.nativeElement.append(questionsetEditorElement); } editorEventListener(event): any { diff --git a/src/app/components/questionset-list/questionset-list.component.html b/src/app/components/questionset-list/questionset-list.component.html index bcdbe85b..d9d92ee1 100644 --- a/src/app/components/questionset-list/questionset-list.component.html +++ b/src/app/components/questionset-list/questionset-list.component.html @@ -26,8 +26,8 @@
-
-
+
+