Discussion Forum: Generalisation of Course & Groups integration logic
- 1 Introduction
- 2 Background
- 3 Problem Statement
- 4 Key design problem:
- 5 Solution:
- 5.1 For courses:
- 5.2 For groups:
- 5.2.1 Create Form:
- 5.2.1.1 Endpoint:
- 5.2.1.2 Request Body:
- 5.2.2 Fetching the form data:
- 5.2.3 Fetch the attached category id for a particular sbType:
- 5.2.4 Create forum:
- 5.2.1 Create Form:
- 5.3 Postman collection
- 5.4 Geeralization of api
- 5.5 Generalization api for Update(If there is any mistakes)
- 5.5.1 Mandatory Parameters
- 5.5.2 Update Category Details
- 5.5.3 Required Parameters
- 5.6 Update Group privileges For a category
- 5.6.1 Required Parameters
- 5.6.2 List of privileges
- 5.7 Get groups List
- 6 Add User into group
Introduction
This document describes the key design problem statement and probable solutions for
Discussion-UI library integration with Sunbird Portal (or any partner application).
Background
No API exists to create the forum, add privileges, create groups.
As of now, We are using the admin panel to do so
Problem Statement
How to enable discussion forum from UI?
How can we create a forum without using the admin panel?
How to create sub-categories for a forum?
How to add privileges to the parent category and the sub-categories?
Key design problem:
Single API to create forum, categories, groups, privileges & adding users?
Solution:
Workflow Diagram: <diagram>
A form API will be created based on the action we are intending to add the Discussion for:
For courses:
Request:
{
"request": {
"type": "global",
"subType": "forum",
"action": "course" // It will be varied like: "groups" etc.
}
}
Response:
{
"response": {
"primaryCategory": "course",
"SbRoles": {
"creator": {
"type": "course",
"identifier": "$courseId"
},
"mentor": {
"type": "batch",
"identifier": "$batchId"
}
},
"forum": {
"category": {
"name": "Cateogry name",
"pid": "{parent_category_id}",
"description": "...",
"context": [
{
"type": "course",
"identifier": "$courseId"
}
],
"enbaleGroups": "true/false",
"groups": [
{
"name": "Owner Group",
"privileges": [
"groups:topics:reply",
"groups:topics:create"
]
},
{
"name": "enrolled users group",
"privileges": [
"groups:topics:reply",
"groups:topics:create"
]
}
],
"privileges": {
"copytoChildren": "true/false",
"copyFromCategory": "{category_id}"
}
},
"subcategories": [
{
"name": "Annoucements",
"pid": "{parent_category_id}",
"description": "...",
"context": [
{
"type": "batch",
"identifier": "$batchId"
}
],
"privileges": {
"copyFromCategory": "{category_id}",
"groups": [
{
"name": "enrolled users group",
"privileges": [
"groups:topics:reply"
]
}
],
"users": [
{
"uid": "{nodebb_uid}",
"privileges": [
"groups:topics:reply"
]
}
]
}
},
{
"name": "General discussions",
"pid": "{parent_category_id}",
"description": "...",
"context": [
{
"type": "batch",
"identifier": "$batchId"
}
]
}
]
}
}
}
For groups:
Create Form:
Endpoint:
POST: /data/v1/form/create
Request Body:
Fetching the form data:
Request:
Response:
As it is clear from the response, the form API will be used to perform the below tasks:
To get forum ids mapped to sbIdentifier.
To create a forum for a sbType. ( eg: “course“, “batch“, “group“ )
Fetch the attached category id for a particular sbType:
We will be using the below API to get the category_ids linked to a sbType:
Request:
Response:
Now you can see the payload used to fetch the category ids will be fetched from the above form API itself. We will be using the "SbRoles"
attached for a particular type.
It will vary for other types. For example, groups don't have a creator or enrolled users roles that exist. so it will be different from the courses.
Create forum:
Table to explain all the properties/fields of API
Property | Sub-property | Values | Description |
---|---|---|---|
name |
| {category name} | name of the category. |
pid |
| {parent category id} | under which parent category, this category should get created. |
Context | or | or
|
|
enbaleGroups |
| true / false | If set true then, It will be used to create groups to add privileges to a certain set of user (according to our requirement) |
groups (optional) |
|
|
|
privileges |
|
|
|
| copytoChildren | true/false |
|
| copyFromCategory | {category_id} |
|
copytoChildren |
| true / false | If set, it will take the rules from the given category. |
copyFromCategory |
|
| category_id, from where it should take the privileges. groups are optional when category_id mention here. It will copy the group & privileges from category_id |
subcategories |
|
| categories which is gonna be created under the parent category |
name |
| Example: “Announcement“, “General discussion“ | name of the subcategory |
pid |
|
| parent category id under which the sub-category will be created |
description |
|
| description of the sub-category |
context |
| this is to communicate with the mapping table. | |
privileges |
|
| This is to override the privileges given at category level for group or user |
copyFromCategory |
|
| category_id, from where it should take the privileges. |
groups | It will be used to define certain set of privileges so that it can be used for the categories. this is optional. | ||
users |
| the set of users, the privilges gonaa be set for. |
Postman collection
https://www.getpostman.com/collections/d0ee01a742409791dcc5
Geeralization of api
This api is for creating a context with mappig category and enablig groups ad adding users into groups.
Generalization api for Update(If there is any mistakes)
Mandatory Parameters
1. Master Token(masterToken)
2. Admin UID (adminUid)
Update Category Details
If you want to update parent category for a particular child category. Follow this API curl
Property | Type |
---|---|
cid | path parameter |
adminUid | query parameter |
Authorization | header |
Required Parameters
Path Parameters: you need to pass cid (which category id you have to move forum one category to another category).
Query Parameters: You have to pass admin uid for this api (It is mandatory).
Headers: You need to pass nodebb master token as a authorization token (it is mandatory).
Body: In body all are optional parameters, If you pass any value for a particular field, it will update that field. if you are not passing any parameters it won’t update any thing.
Update Group privileges For a category
If you want to update privileges for a particular group for a category follow this curl
Property | Type |
---|---|
cid | path parameter |
adminUid | query parameter |
Authorization | header |
Required Parameters
Path Parameters: you need to pass cid (which category id you have to enable privileges).
Query Parameters: You have to pass admin uid for this api (It is mandatory).
Headers: You need to pass nodebb master token as a authorization token (it is mandatory).
Body:
Privileges : what are the privileges you wnat to enable.
Groups: To which group you have to add those privileges.
List of privileges
Privilege | Value | Description |
---|---|---|
| true/false | Allow the user get fetch category using api |
| true/false | Allow the user to access category from UI |
| true/false | Access Topics |
| true/false | Create Topics |
| true/false | Reply to Topics |
| true/false | Can access Tag Topics |
| true/false | User can edit the post |
| true/false | User can able to see edit history |
| true/false | user can able to delete post |
| true/false | user can upvote to a post |
| true/false | user can down vote to a post |
| true/false | user can delete the topic |
| true/false | user can see the deleted posts |
| true/false | user can able to remove |
| true/false | user can be a moderator |
Get groups List
To get list of groups, follow the below CURL
Add User into group
We can add user into a particular group manually, Followthis CURL
Property | Type |
---|---|
groupslug | path parameter |
uid | path parameter |
adminUid | query parameter |
Authorization | header |
Required Parameters
Path Parameters: you need to pass group slug (which group we want to addthe user) and nodebb UID (Which user you wnatto add).
Query Parameters: You have to pass admin uid for this api (It is mandatory).
Headers: You need to pass nodebb master token as a authorization token (it is mandatory).
Body: NO
Getting Nodebb UID's By sending Sunbird Identifiers
As we don’t know nodebb uids and we have only sunbird identifiers.so the below api will give you nodebb uids by sending sunbird identifiers.
Form API config for generalization API
Group for course/batch/groups etc:
We are calling this api when the new course created from UI (can be sunbird/IGOT).
the payload looks like
Form Read
Request Payload
Batch
We are calling this api when the new batch created from UI (can be sunbird/IGOT).
Note: sbIds batch mentors id's and this id's added into mentors groups
the payload looks like
Request payload
Groups
Comments
MOM: Generalization of API
participents:
@Rayulu Villa @Vinu Kumar @Venkatanarayana Kadiveti @Sudip Mukherjee
If a user passes both privileges object which contain copyFromCategory and groups object, it should throw error
req payload should contain either privileges or groups not both.
Giving privileges to users directly instead of creating groups, adding privileges and adding him into groups.
subcategories should have copyFromParent.
Unenrolled users should have read access.
We should think of a new way instead of depending on form api configuration(creating new component and there should handle all context configuration).