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 3 Next »

This document will help to configure (enable/disable) discussion forum for any of the learning process
(i.e. groups, course, textbook, etc.)

For Groups:

Enabling discussion forums for groups will be done via UI.
Now to call the create forum API, first, we need to configure a form API that will respond back the request payload for creating the forum.

Step: 1

Configure form API:
Endpoint:

POST: {{host}}/data/v1/form/create

Request payload:

{
    "request": {
        "type": "forum",
        "subType": "group",
        "action": "create",
        "data": {
            "templateName": "defaultTemplate",
            "action": "create",
            "fields": [
                {
                    "category": {
                        "name": "General Discussion", // Forum name
                        "pid": "15", // parent category id, under this category, new forum will be 
                                        creted. it will be a root category.
                        "uid": "1", //  admin user id
                        "description": "",
                        "context": [
                            {
                                "type": "group",
                                "identifier": "_groupId" // to be replaced form client 
                                                            side with actul group id.
                            }
                        ]
                    }
                }
            ]
        }
    }
}


Once created, this form API will be called from the client-side.
Endpoint:

POST: {{host}}/data/v1/form/read

Request payload:

{
    "request": {
        "type": "forum",
        "subType": "group",
        "action": "create"
    }
}

Response:

{
    "id": "api.form.read",
    "params": {
        "resmsgid": "095168d1-b6d6-4f1c-ae0f-d8e1dbed7122",
        "msgid": "64b92bb4-636a-449b-8c57-a2b91fc315fb",
        "status": "successful"
    },
    "responseCode": "OK",
    "result": {
        "form": {
            "type": "forum",
            "subtype": "group",
            "action": "create",
            "component": "*",
            "framework": "*",
            "data": {
                "templateName": "defaultTemplate",
                "action": "create",
                "fields": [
                    {
                        "category": {
                            "name": "General Discussion",
                            "pid": "15",
                            "uid": "1",
                            "description": "",
                            "context": [
                                {
                                    "type": "group",
                                    "identifier": "_groupId"
                                }
                            ]
                        }
                    }
                ]
            },
            "created_on": "2021-02-15T05:33:03.734Z",
            "last_modified_on": "2021-02-15T09:52:41.820Z",
            "rootOrgId": "*"
        }
    },
    "ts": "2021-03-05T10:01:51.700Z",
    "ver": "1.0"
}

NOTE: the context identifier should be replaced from the client-side with actual group_id before calling the “forum create” API. So, in basic words, this form response will work as a request payload for the actual forum create API.

Step 2:

Call the create forum API :

Endpoint:

POST: {{host}}/discussion/forum/v3/create

Request payload:

{
  "category": {
    "name": "General Discussion",
    "pid": "30",
    "uid": "4",
    "description": "",
    "context": [
      {
        "type": "group",
        "identifier": "95502931-e903-45e0-a4f7-f6ae3c97a66f"
      }
    ]
  }
}

Response:

{
  "id": "api.forum.v3.create",
  "ver": "1.0",
  "ets": 1614939498392,
  "params": {
    "resmsgid": "4739650a-cd23-43ce-9634-0e864d243eba",
    "msgid": "",
    "status": "Success"
  },
  "responseCode": "OK",
  "result": {
    "forums": [
      {
        "sbType": "95502931-e903-45e0-a4f7-f6ae3c97a66f",
        "sbIdentifier": "95502931-e903-45e0-a4f7-f6ae3c97a66f",
        "newCid": 93,
        "cids": [
          93
        ]
      }
    ]
  }
}


For courses:

Till now, a Discussion forum for courses can be configured via APIs only.

Below APIs will be used to configure a discussion forum for any of the courses.

Step 1:
Create a parent category. This category id will be used as the root pid
Endpoint:

POST: {{host}}/discussions/api/v2/categories?_uid=1

Request body:

{
    "name": "Course: Parent category "
}

Response:

{
    "code": "ok",
    "payload": {
        "cid": 7, // this cid will used as pid for the next et of apis
        "name": "Course: Parent category ",
        "description": "",
        "descriptionParsed": "",
        "icon": "",
        "bgColor": "#86C1B9",
        "color": "#333",
        "slug": "7/course-parent-category",
        "parentCid": 0,
        "topic_count": 0,
        "post_count": 0,
        "disabled": 0,
        "order": 7,
        "link": "",
        "numRecentReplies": 1,
        "class": "col-md-3 col-xs-6",
        "imageClass": "cover",
        "isSection": 0
    }
}

Step 2:
Call the create forum API:
Endpoint:

POST: {{host}}/discussion/forum/v3/create

Request Body:

{
  "category": {
    "name": "Discussion forum for course",
    "pid": "7", // parent category (take the cid form the above api response)
    "uid": "1", // admin user id
    "description": "",
    "context": [
      {
        "type": "course",
        "identifier": "_courseId" // to be replaced by actual Course_id
      }
    ],
    "privileges": {
      "copyFromCategory": "134" // dummy category with course level privileges
    },
    "subcategories": [
      {
        "name": "Annoucements",
        "description": "",
        "privileges": {
          "copyFromCategory": "120" // dummy category with batch level privileges (for anouncement)
        }
      },
      {
        "name": "General discussions",
        "description": "",
        "privileges": {
          "copyFromCategory": "121" // dummy category with batch level privileges (for GD)
        }
      }
    ]
  }
}

Response:

{
  "id": "api.forum.v3.create",
  "ver": "1.0",
  "ets": 1614939498392,
  "params": {
    "resmsgid": "4739650a-cd23-43ce-9634-0e864d243eba",
    "msgid": "",
    "status": "Success"
  },
  "responseCode": "OK",
  "result": {
    "forums": [
      {
        "sbType": "do_1234",
        "sbIdentifier": "do_1234",
        "newCid": 5,
        "cids": [
          5
        ]
      }
    ]
  }
}
  • No labels