Discussion Forum: Integration

scThis document describes integrating the Discussion library into any application


NodeBB Category & Topic creation:

The below diagram explains the category & topics created for a Course & Batch. The same can be used for any other types like Group, Quiz, etc.

Category → It is like a container( can hold Sub-containers, Topics)

Topic → This will be always added to the container(Category, Sub-Category). This is a discussion topic/thread created within the category. Users can participate in the topic/discussion.

Post → This will be always added to the Topic. This is the user response/reply given for the discussion topic/thread. The user is participating in the topic by posting.

 

 

Sunbird Identifier - NodeBB Category mapping

Sunbird content(identifier) mapping to NodeBB Category. This is the new collection added to the Mongo DB to store the sunbird identifier mapping with the nodebb category.

Schema:

SbType

SbIdentifier

cid

Data

SbType

SbIdentifier

cid

Data

Course

do_11317805943810457614592

5

{JSON}

Batch

01316730820300800028

6

{JSON}

Group

123475d2-c299-45f6-992e-a22d081431bd

7

{JSON}

 

 

Store Sunbird identifier mapped with NodeBB category

Post: {host}/discussion/forum/v2/create

Request:

{ "request": { "sbType": "course", "sbIdentifier": "do_11317805943810457614592" "cid": 16 } }

Response:

{ "id": "api.discussions.category.forum", "ver": "1.0", "ets": 1609741189797, "params": { "resmsgid": "c9c1842d-3dfb-45df-b827-c31522f13fa4", "msgid": "", "status": "successful" }, "responseCode": "OK", "result": [ { "_id": "5ff2b287ac74be004547f69e", "sbType": "course", "sbIdentifier": "do_11317805943810457614592", "cid": 16, "__v": 0 } ] }

Remove NodeBB category mapped with Sunbird identifier

Post: {host}/discussion/forum/v2/remove

Request:

{ "request": { "sbType": "course", "sbIdentifier": "do_11317805943810457614592" "cid": 16 } }

Response:

If the mapped category exists with the Sunbird identifier :

If the mapped category does not exist with the Sunbird identifier :

Get Category mapped to Sunbird Identifier

API to get the NodeBB category(or categories) mapped to the sunbird content or Group etc.

Post: {host}/discussion/forum/v2/read

Request:

Response:

 

Generalisation Api

Context creation api : /discussion/forum/v3/create

Request Payload

Response

Portal Integration API’s to launch/show discussion-UI library:

 

While launching the discussion forum below are the required parameters

Propetry

Type

Comments

Propetry

Type

Comments

forumId

String []

Send category linked to the course/batch/group etc.. The value should be always an array of strings(categoryId)


example
[6, 8, 13] - For multiple categories
[6] - For sinalge category

username

String

Nodebb username

 

Parent application(portal) will show the forum icon or library widget based on NodeBB category mapped for the course or group or etc.

Refer: Get Category mapped to Sunbird Identifier

If any category is mapped, then show the forum icon or widget on the page. So that users can participate in the discussion.

Get Username(NodeBB)

on Clicking of forum icon in portal, we should make an API call to get NodeBB username. If the user is already registered, we get user details. If he is the first time user, then we will register the user into NodeBB & send user details.

POST: {{host}}/discussion/user/v1/create

Request:

“username”: Sunbird logged-in username(sunbirdId from profile page)
”identifier”: Sunbird logged-in user identifier

Response:

Get User by userId

https://dev.sunbirded.org/discussions/api/uid/{user_iid}?_uid=1

ex: https://dev.sunbirded.org/discussions/api/uid/1?_uid=1

response:

Get User profile details by Username

Add the above response in to the discussion API

https://dev.sunbirded.org/discussions/api/user/vinukumar_vs

response:

User Privileges for specific Category/Topic

To know the user is moderator or guest

Cookie: To know the logged-in user session

 

Get NodeBB user token

Once the user has created/logged-in successfully into nodebb, we have to generate the token for the user. We should use this token in all further requests of the user.

GET: http://localhost:4567/api/v1/users/3/tokens?_uid=3

_uid: Is mandatory to get a token for that user.

Note: We have to use the master token to get this details

Request:

Response:

CURL:

 

Get Category permissions for the user

This is to get the privileges of the logged-in user for a given category. It helps to know what permissions the user having on a specific category.

GET: http://localhost:4567/api/category/8?_uid=3

Note: We have to use the token got from above api (fpr _uid: 3) & send it in headers of Authorization & Authentication

Request:

Response:

CURL:


Get Category Id’s For Creators and Enrolled Users API

Request: {{host}}/discussion/forum/v2/read

Request Object

Response

 

Get category ID’s for mentors

Request

Response

 

Request
api: {{host}}/discussion/user/v1/create

username : Sunbird username

identifier: Sunbird Identifier

Request Object

Response

Getting the user info by UID

Request

Response

Discussion Forum Middleware API’s

This the swagger documentation for all discussions forum middleware api’s.

http://641.qa.docs.sunbird.org/3.5.0/apis/discussionForum//

Create forum: Single API to create Categories, Groups & Privileges

This API is used to create a forum for a sunbird Identifier & Type mapped. This single API allows as to do the below operations

  1. Creating Category & Sub-Categories

  2. Creating Groups & adding a user into the group

  3. Creating Privileges for the group

  4. Adding Sinbird Identifier & Type by mapping to a category into SbCategory table

 

Discussion forum apis

1. Category Details

Request:

Response:

 

2. Category List

Request:

Response:

 

3. category create

Request:

Response: