Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Background:

Presently Sunbird uses hardcoded of BMGS.

If User wants to use this application for hospital or different organisations, Then we have to remove hardcode of BMGS and make it as dynamic.

Jira ticket: https://project-sunbird.atlassian.net/jira/software/c/projects/ED/issues/ED-1957?filter=myopenissues

Problem Statement :

How to start to remove BMGS and from which page, we have to start remove hardcoded from any subtask or we have to start from onboarding steps.

Key Design Problem:

Framework-Details Api’s

Update framework api request as category[i] and we have to change the framework details response categories code also in sunbird SDK.

export enum FrameworkCategoryCode {
    BOARD = 'board',
    MEDIUM = 'medium',
    GRADE_LEVEL = 'gradeLevel',
    SUBJECT = 'subject',
    TOPIC = 'topic',
    PURPOSE = 'purpose'
}

Now change the framework request BMGS to category[i]

export enum FrameworkCategoryCode1 {
    CATEGORY1 = 'category1',
    CATEGORY2 = 'category2',
    CATEGORY3 = 'category3',
    CATEGORY4 = 'category4',
    TOPIC = 'topic',
    PURPOSE = 'purpose'
}

apiRequest.parameters for new request:

{categories: "category1,category2,category3,category4"}

Categories Response for category1:

 {
                    "identifier": "framework1_category1",
                    "code": "category1",
                    "terms": [
                        {
                            "identifier": "framework1_category1_category1term1",
                            "code": "category1term1",
                            "translations": null,
                            "name": "Category1 Term1",
                            "description": "Category1 Term1",
                            "index": 1,
                            "category": "category1",
                            "status": "Live"
                        }
                    ],
                    "translations": null,
                    "name": "Category1",
                    "description": "Category1",
                    "index": 1,
                    "status": "Live"
        }

Remove BMGS hardcoded and use category1 for board, category2 for medium, category3 for gradeLevel and category4 for subject in mobile.

  1. Onboarding : a) Remove BMGS hardcoded and use category1 for board, category2 for medium and category3 for grade in HTML and TS file.

b. we have to use proper methods and variables name for board, medium and grade(onMediumChange, mediumControl, mediumList ) 

c. Update framework API’s request with category[i].

DEFAULT_FRAMEWORK_CATEGORIES should be category1, category2 and category3

const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
      from: CachedItemRequestSourceFrom.SERVER,
      language: this.translate.currentLang,
      requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
    }
this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise()
this.framework = await this.frameworkService.getFrameworkDetails({
            from: CachedItemRequestSourceFrom.SERVER,
            frameworkId: value[0],
            requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
          }).toPromise();

Change FrameworkCategoryCode.BOARD to FrameworkCategoryCode.CATEGORY1

const boardCategoryTermsRequet: GetFrameworkCategoryTermsRequest = {
            frameworkId: this.framework.identifier,
            requiredCategories: [FrameworkCategoryCode.BOARD],
            currentCategoryCode: FrameworkCategoryCode.BOARD,
            language: this.translate.currentLang
          };

          const boardTerm = (await this.frameworkUtilService.getFrameworkCategoryTerms(boardCategoryTermsRequet).toPromise())
            .find(b => b.name === (this.syllabusList.find((s) => s.code === value[0]).name || 'other'));

Change FrameworkCategoryCode.MEDIUM to FrameworkCategoryCode.CATEGORY2

 const nextCategoryTermsRequet: GetFrameworkCategoryTermsRequest = {
            frameworkId: this.framework.identifier,
            requiredCategories: [FrameworkCategoryCode.MEDIUM],
            prevCategoryCode: FrameworkCategoryCode.BOARD,
            currentCategoryCode: FrameworkCategoryCode.MEDIUM,
            language: this.translate.currentLang,
            selectedTermsCodes: this.boardControl.value
          };

          this.mediumList = (await this.frameworkUtilService.getFrameworkCategoryTerms(nextCategoryTermsRequet).toPromise())
            .map(t => ({ name: t.name, code: t.code }));

Change FrameworkCategoryCode.GRADE_LEVEL to FrameworkCategoryCode.CATEGORY3

const nextCategoryTermsRequet: GetFrameworkCategoryTermsRequest = {
            frameworkId: this.framework.identifier,
            requiredCategories: [FrameworkCategoryCode.GRADE_LEVEL],
            prevCategoryCode: FrameworkCategoryCode.MEDIUM,
            currentCategoryCode: FrameworkCategoryCode.GRADE_LEVEL,
            language: this.translate.currentLang,
            selectedTermsCodes: this.mediumControl.value
          };

          this.gradeList = (await this.frameworkUtilService.getFrameworkCategoryTerms(nextCategoryTermsRequet).toPromise())
            .map(t => ({ name: t.name, code: t.code }));

2. Guest Profile :

a) Remove BMGS hardcoded and use category1 for board, category2 for medium and category3 for grade in HTML and TS file.

b). Update framework API’s request with category[i].

DEFAULT_FRAMEWORK_CATEGORIES should be category1, category2, category3 and category4

const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
      language: this.translate.currentLang,
      requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
    };
    this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise()
 const frameworkDetailsRequest: FrameworkDetailsRequest = {
      frameworkId: (this.profile && this.profile.syllabus && this.profile.syllabus[0]) ? this.profile.syllabus[0] : '',
      requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
    };
    this.frameworkService.getFrameworkDetails(frameworkDetailsRequest).toPromise()

3. Guest Edit Profile / Edit logged In profile:

  1. a) Remove BMGS hardcoded and use category1 for board, category2 for medium and category3 for grade in HTML and TS file.

b. we have to use proper methods and variables name for board, medium and grade(onMediumChange, mediumControl, mediumList ) 

c. Update framework API’s request with category[i].

DEFAULT_FRAMEWORK_CATEGORIES should be category1, category2, category3 and category4

const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
      from: CachedItemRequestSourceFrom.SERVER,
      language: this.translate.currentLang,
      requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
    };

    this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise()
 this.framework = await this.frameworkService.getFrameworkDetails({
            from: CachedItemRequestSourceFrom.SERVER,
            frameworkId: value[0],
            requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
          }).toPromise();

Update boardCategoryTermsRequet as category1TermsRequest, category2TermsRequest for medium . category3TermsRequest for grade

this.frameworkUtilService.getFrameworkCategoryTerms(boardCategoryTermsRequet).toPromise()

4. Logged In Profile : a) Remove BMGS hardcoded and use category1 for board, category2 for medium, category3 for grade and category4 for subject TS file.

DEFAULT_FRAMEWORK_CATEGORIES should be category1, category2, category3 and category4

const frameworkDetailsRequest: FrameworkDetailsRequest = {
      frameworkId: id,
      requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
    };
    await this.frameworkService.getFrameworkDetails(frameworkDetailsRequest).toPromise()

5.Help Section (faq-report-issue.page.ts) :

a) Remove BMGS hardcoded and use category1 for board, category2 for medium, category3 for grade and category4 for subject in HTML and TS file

b. Update framework API’s request with category[i].

DEFAULT_FRAMEWORK_CATEGORIES should be category1, category2, category3 and category4

const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
      from: CachedItemRequestSourceFrom.SERVER,
      language: this.translate.currentLang,
      requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
    };

    this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise()

6. relevent-content.page.ts:

a) Remove BMGS hardcoded and use category1 for board, category2 for medium, category3 for grade and category4 for subject TS file

b. Update framework API’s request with category[i].

DEFAULT_FRAMEWORK_CATEGORIES should be category1, category2, category3 and category4

const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
      from: CachedItemRequestSourceFrom.CACHE,
      language: this.translate.currentLang,
      requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
    };

    try {
      const list = await this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise();

7.search :

a) Remove BMGS hardcoded and use category1 for board, category2 for medium, category3 for grade and category4 for subject TS file

b. Update framework API’s request with category[i].

DEFAULT_FRAMEWORK_CATEGORIES should be category1, category2, category3 and category4.

const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
        language: this.translate.currentLang,
        requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
      };
      // Auto update the profile if that board/framework is listed in custodian framework list.
      this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise()

8. Update User Profile (update-profile.service.ts):

a) Remove BMGS hardcoded and use category1 for board, category2 for medium, category3 for grade and category4 for subject TS file

b. Update framework API’s request with category[i].

DEFAULT_FRAMEWORK_CATEGORIES should be category1, category2, category3 and category4.

const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
                language: this.translate.currentLang,
                requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
            };
            // Auto update the profile if that board/framework is listed in custodian framework list.
            this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise()

DEFAULT_FRAMEWORK_CATEGORIES should be category1, category2, category3 and category4.

const frameworkDetailsRequest: FrameworkDetailsRequest = {
                                frameworkId: element.identifier,
                                requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
                            };
                            this.frameworkService.getFrameworkDetails(frameworkDetailsRequest).toPromise()

Search API’s: Search Api’s are using BMGS as Api’s request for searching, filtering and sorting. so removed BMGS and use category1 for board, category2 for medium, category3 for gradeLevel and category4 for subject.

export interface ContentRequest {
    uid?: string | string[];
    primaryCategories: string[];
    audience?: string[];
    pragma?: string[];
    exclPragma?: string[];
    attachFeedback?: boolean;
    attachContentAccess?: boolean;
    attachContentMarker?: boolean;
    sortCriteria?: ContentSortCriteria[];
    recentlyViewed?: boolean;
    localOnly?: boolean;
    resourcesOnly?: boolean;
    limit?: number;
    board?: string[];
    medium?: string[];
    grade?: string[];
    dialcodes?: string[];
    childNodes?: string[];

convert BMGS to category[i] for content aggregator.

this.contentService.getContents({
                        primaryCategories:
                            (searchCriteria.primaryCategories && searchCriteria.primaryCategories.length
                                && searchCriteria.primaryCategories) ||
                            (searchRequest.filters && searchRequest.filters.primaryCategory) ||
                            [],
                        board: searchCriteria.board,
                        medium: searchCriteria.medium,
                        grade: searchCriteria.grade

Remove BMGS from get content handler and search content handler in SDK.

Change BMGS to category1-4 for content properties in client service.

Update the below request BMGS to category1…category4 in mobile and we have to change the request as category1….category4 for search filter and help section in mobile.

userPreferences: {
                    board: this.profile.board,
                    medium: this.profile.medium,
                    gradeLevel: this.profile.grade,
                    subject: this.profile.subject,
                  }

Update Profile:

a) Server Profile:

Now we can use category1, category2, category3 and category4 as update user profile request instead of BMGS.

Example of update profile request.

"request": "request": {
  "userId": "155ce3c5-713e-4749-bc1c-95d09c640914",
  "framework": {
    "id": [
      "framework1"
    ],
    "category1": [
      "Category1 Term1"
    ],
    "category2": [
      "Category2 Term1"
    ],
    "category3": [
      "Category3 Term1"
    ]
  }
}

Update Profile for Logged In user:

Update profile request BMGS to category1, category2, category3 and category4

 this.profileService.updateServerProfile(req).toPromise()

b) Local profile DB :

Update local profile DB keys BMGS to category1, category2, category3 and category4

export interface Profile {
    uid: string;
    handle: string;
    createdAt?: number;
    medium?: string[];
    board?: string[];
    subject?: string[];
    profileType: ProfileType;
    grade?: string[];
    syllabus?: string[];
    source: ProfileSource;
    gradeValue?: { [key: string]: any };
    serverProfile?: ServerProfile;
}

  • No labels