diff --git a/projects/collection-editor-library/src/lib/components/editor/editor.component.html b/projects/collection-editor-library/src/lib/components/editor/editor.component.html index ffed017c..766415d3 100755 --- a/projects/collection-editor-library/src/lib/components/editor/editor.component.html +++ b/projects/collection-editor-library/src/lib/components/editor/editor.component.html @@ -60,7 +60,7 @@ -
diff --git a/projects/collection-editor-library/src/lib/components/qumlplayer-page/qumlplayer-page.component.html b/projects/collection-editor-library/src/lib/components/qumlplayer-page/qumlplayer-page.component.html index 7f0bf22a..9594f6c1 100644 --- a/projects/collection-editor-library/src/lib/components/qumlplayer-page/qumlplayer-page.component.html +++ b/projects/collection-editor-library/src/lib/components/qumlplayer-page/qumlplayer-page.component.html @@ -31,71 +31,4 @@

-
-
-
- -
{{questionMetaData?.name}}
-
-
-
-
- -
{{questionMetaData?.board}}
-
-
-
-
- -
{{questionMetaData?.medium}}
-
-
-
-
- -
{{questionMetaData?.gradeLevel}}
-
-
-
-
- -
{{questionMetaData?.subject}}
-
-
-
-
- -
{{questionMetaData?.attributions}}
-
-
-
-
- -
{{questionMetaData?.author}}
-
-
-
-
- -
{{questionMetaData?.audience}}
-
-
-
-
- -
{{questionMetaData?.copyright}}
-
-
-
-
- -
{{questionMetaData?.license}}
-
-
-
-
- -
{{questionMetaData.maxScore? questionMetaData.maxScore : 1}}
-
-
-
\ No newline at end of file + diff --git a/projects/collection-editor-library/src/lib/components/qumlplayer-page/qumlplayer-page.component.ts b/projects/collection-editor-library/src/lib/components/qumlplayer-page/qumlplayer-page.component.ts index 33730fa5..4effca67 100644 --- a/projects/collection-editor-library/src/lib/components/qumlplayer-page/qumlplayer-page.component.ts +++ b/projects/collection-editor-library/src/lib/components/qumlplayer-page/qumlplayer-page.component.ts @@ -4,6 +4,9 @@ import { EditorTelemetryService } from '../../services/telemetry/telemetry.servi import { EditorService } from '../../services/editor/editor.service'; import { ConfigService } from '../../services/config/config.service'; import { TreeService } from '../../services/tree/tree.service'; +import { FrameworkService } from '../../services/framework/framework.service'; +import { filter } from 'rxjs/operators'; + @Component({ selector: 'lib-qumlplayer-page', templateUrl: './qumlplayer-page.component.html', @@ -13,18 +16,63 @@ import { TreeService } from '../../services/tree/tree.service'; export class QumlplayerPageComponent implements OnChanges { qumlPlayerConfig: any; @Input() questionMetaData: any; + @Input() leafFormConfig: any @Input() questionSetHierarchy: any; @Output() public toolbarEmitter: EventEmitter = new EventEmitter(); prevQuestionId: string; showPlayerPreview = false; showPotrait = false; hierarchy: any; + showForm = false; + questionFormConfig: any; + frameworkDetails: any = {}; constructor(public telemetryService: EditorTelemetryService, public configService: ConfigService, public editorService: EditorService, - private treeService: TreeService) { } + private treeService: TreeService, private frameworkService: FrameworkService) { } ngOnChanges() { - this.initQumlPlayer(); + if (_.has(this.questionMetaData, 'data.metadata')) { + this.initQumlPlayer(); + this.questionFormConfig = _.cloneDeep(this.leafFormConfig); + const framework = _.get(this.questionSetHierarchy, 'framework') || _.get(this.editorService.editorConfig, 'context.framework') + if (framework) { + this.fetchFrameWorkDetails(framework); + } else { + this.setFormDefaultValues(); + } + } + } + + fetchFrameWorkDetails(framework) { + this.frameworkService.frameworkData$.pipe( + filter(data => _.get(data, `frameworkdata.${framework}`))).subscribe((frameworkDetails: any) => { + if (frameworkDetails && !frameworkDetails.err) { + const frameworkData = frameworkDetails.frameworkdata[framework].categories; + this.frameworkDetails.frameworkData = frameworkData; + this.setFieldsTerms(); + } + }); + } + + setFieldsTerms() { + const categoryMasterList = this.frameworkDetails.frameworkData; + _.forEach(categoryMasterList, (category) => { + _.forEach(this.questionFormConfig, (formFieldCategory) => { + if (category.code === formFieldCategory.code) { + formFieldCategory.terms = category.terms; + } + }); + }); + this.setFormDefaultValues(); + } + + setFormDefaultValues() { + _.forEach(this.questionFormConfig, (formField) => { + const fieldcode = formField.code; + formField.default = this.questionMetaData[fieldcode]; + formField.editable = false; + }); + this.showForm = true; } initQumlPlayer() { @@ -38,19 +86,17 @@ export class QumlplayerPageComponent implements OnChanges { this.hierarchy.childNodes = [newQuestionId]; this.hierarchy.shuffle = selectedNode.parent.data.metadata.shuffle; if (selectedNode.parent.data.metadata.shuffle === true) { - // tslint:disable-next-line:no-string-literal - this.hierarchy['maxScore'] = 1; + this.hierarchy['outcomeDeclaration'] = {maxScore: {defaultValue: 1}}; } else { if (this.questionMetaData.qType === 'SA') { - this.hierarchy = _.omit(this.hierarchy, 'maxScore'); - } else if (this.questionMetaData.maxScore) { - // tslint:disable-next-line:no-string-literal - this.hierarchy['maxScore'] = this.questionMetaData.maxScore; + this.hierarchy['outcomeDeclaration'] = {maxScore: {defaultValue: 0}}; + } else { + this.hierarchy['outcomeDeclaration'] = {maxScore: {defaultValue: this.questionMetaData?.maxScore}}; } } const parent = this.treeService.getParent()?.data?.metadata; - this.hierarchy.showSolutions = parent?.showSolutions || "No"; - this.hierarchy.showFeedback = parent?.showFeedback || "No"; + this.hierarchy.showSolutions = parent?.showSolutions || false; + this.hierarchy.showFeedback = parent?.showFeedback || false; this.prevQuestionId = newQuestionId; setTimeout(() => { this.showPlayerPreview = true;