IEditorConfig is not generalised and it contains BMGS fields

  • File - editor.ts

    • board, medium, grade Level, subject, topic present in editor.ts file as:

    • Which defines the IEditorConfig interface

      • 1export interface IEditorConfig { 2 context: Context; 3 config: any; 4 metadata?: any; 5 data?: any; 6} 7 8export interface Context { 9 ... 10 ... 11 board?: any; 12 medium?: any; 13 gradeLevel?: any; 14 subject?: any; 15 topic?: any; 16 ... 17 ... 18}
  • This interface defines the editorConfig.

  • These value of board, medium, grade Level, subject, topic are getting attached as default value to question if question set does not have BMGS fields.

  • If question set contains BMGS fields and then BMGS present in editor config get replaced with selected BMGS in question set.

Solution to Generalise interface

  • 1export interface IEditorConfig { 2 context: Context; 3 config: any; 4 metadata?: any; 5 data?: any; 6} 7 8export interface Context { 9 ... 10 ... 11 frameworkDefaultValues?: any 12 ... 13 ... 14}

This frameworkDefaultValues can store board, medium, grade Level, subject, topic, etc as:

1frameworkDefaultValues: { 2 board: 'CBSE', 3 medium: 'English', 4 gradeLevel: 'Class 6' 5 subject: 'Mathematics', 6 ... 7}

or it can also contains any values such as hospital, department, etc

1frameworkDefaultValues: { 2 hospital: 'Apollo', 3 department: 'Cardiology', 4 ... 5 ... 6}

Place where above passed BMGS is currently getting fetched and getting added to question metadata

File - question.component.ts

1_.pick(_.get(this.editorService.editorConfig, 'context'), ['board', 'medium', 2'gradeLevel', 'subject', 'topic'])

If we pass this values in context.frameworkDefaultValues

then this line can also be generalised to

1_.get(this.editorService.editorConfig, 'context.frameworkDefaultValues')

BMGS and other fields hard coding in ConfigService

File - config.service.ts

sessionContext contains hard coded fields name as 

1public sessionContext: Array<string> = ['board', 'medium', 'gradeLevel', 'subject', 2'topic', 'author', 'channel', 'framework', 'copyright', 'attributions', 'audience', 'license']

To remove these hardcoded fields name we can pass it as a config to editor as sessionContextFields

1editorConfig: { 2 config: { 3 sessionContextFields: ['board', 'medium', 'gradeLevel', 'subject', 4 'topic', 'author', 'channel', 'framework', 'copyright', 'attributions', 'audience', 'license'] 5 } 6}

Another File which contains BMGS hard coded is File - SessionContext.ts

This file is not getting used anywhere we can remove this file.


Other files which contains BMGS are mock data for test cases in these files:

1components/assign-page-number/assign-page-number.component.spec.data.ts 2components/editor/editor.component.spec.data.ts 3components/fancy-tree/fancy-tree.component.spec.data.ts 4components/meta-form/meta-form.component.spec.data.ts 5components/question/question.component.spec.data.ts 6components/quml-player/quml-player.component.spec.data.ts 7components/qumlplayer-page/qumlplayer-page.component.spec.data.ts 8services/editor/editor.service.spec.data.ts 9services/tree/tree.service.spec.data.ts

We can remove BMGS fields from these files.


Resource Library

Question in Question bank shows BMGS and various other fields which it’s not configurable

Content-player-page

Hard coded label and field code to fetch the value and display.

Solution 1 - we can use the form config which is being used while question creation to the field code and label and display in this same above format without bringing any new UI change.

Form fields used while question creation


Solution 2-We can define a new form config in which these fields can be set as config. (Not Recommended)

  • It will add additional config to the editor.


Board value is getting displayed to the contents

library-player

library-list.component

Solution:

We can make this field configurable by passing a config to resource-library

1editorConfig = { 2 config: { 3 ... 4 ... 5 libraryConfig: { 6 createdByField: 'board' // board, hospital, school, etc.. 7 } 8 } 9}

Using this libraryConfig we can display whichever value we want to show in above page.


BMGS is present in SessionContext.ts file

This file is not getting used anywhere so can be removed.


BMGS is present in config.service.ts

It defines sessionContext but it is not getting used so can be removed.

So we can remove sessionContext from this file.


Other files which contains BMGS are mock data for test cases in these files:

1library/library.component.spec.data.ts 2library-filter/library-filter.component.spec.data.ts 3library-filter/library-filter.component.spec.ts 4quml-player/quml-player.component.spec.data.ts

We can remove BMGS fields from these files.


QuML Player

data.service.ts

Board,medium,grade,subject,etc present in the getContent method.

Above method is part of demo application which is running player.

As this is not part of player core code we don’t need to remove it


mock data of BMGS for unit test cases

We have mock data of board, board, medium, grade, subject in these files for unit test cases

1/quml-library.service.spec.data.ts 2/main-player/main-player.component.spec.data.ts 3/mcq/mcq.component.spec.ts 4/sa/sa.component.spec.ts 5/section-player/section-player.component.spec.data.ts 6/services/viewer-service/viewer-service.spec.data.ts

We can remove the board, medium, grade, subject from these mock data.