Skip to main content

ClassOnlive API example: creating a course by topic

ClassOnlive API documentation example

David Chong avatar
Written by David Chong
Updated over a week ago

Let's show an example using different API requests to create a topic-based course.

To do this, we use the POST content request. You can find the explanation and example of the request in our API documentation under “CONTENT” -> “General Content” -> “Creating Content”.

  POST https://www.apiclassonlive.com/api/v1/eyJhzI1NiJ9.eyjUzLjUz.../content  

This method must include the course title and course type in its request body. In our case “Topics”:

  { 
"title": "Example Title",
"type": "Topics"
}

If everything went well, this request returns an object with the following structure:

  { 
"ok": true,
"contentId": 33078
}

This object will contain the “contentId” key which will identify the created course from now on.

Now that we have the course created, let's add a topic. For this example, see our documentation under "CONTENT" -> "Topics" -> "Adding a topic to a course."

  POST https://www.apiclassonlive.com/api/v1/ eyJhzI1NiJ9.eyjUzLjUz.../theme  

Its corresponding request body would be the following:

  { 
"title":"Topic Title"
"description":"Topic Description"
"contentId":33078 // contentId received from the previous response
"order":1 // Position that the created topic will occupy
}

The response we will receive will be the next:

  { 
"ok": true,
"themeId": 38
}

Where “themeId” will be the identifier that refers to the new theme created.

With this request we can create as many themes as necessary for our course.

A theme itself cannot store any type of resource for the student. Themes store modules. Which in turn store the content that the student can view.

The next step is to create a module associated with the theme. To do this, you can see how to create a module in the “CONTENT” -> “Themes” -> “Adding a module to a theme” section of the documentation.

  POST https://www.apiclassonlive.com/api/v1/eyJhzI1NiJ9.eyjUzLjUz.../theme/addModule  

Where your request body will be similar to the following:

  { 
"title":"Module title"
"description":"Description of the new module"
"themeId":38,
"contentId":33078
"order":1 // Position that the module will occupy within the theme
}

As a result of this request we will receive an object with the following structure:

  { 
"ok": true,
"moduleId": 60
}

Now our course contains a topic which in turn contains a module.

To add material to this module there are currently no methods available in our API so the process of adding material must be done from our website.

Once we have our course prepared the next step would be to be able to add students to it.

For this, we have the content/student request. You can see more details about it in the API section “USERS” -> “Applicant/Student” -> “Add a Student to a Content.”

  POST https://www.apiclassonlive.com/api/v1/eyJhzI1NiJ9.eyjUzLjUz.../content/student  

With its corresponding request body:

  { 
"email": "[email protected]",
"contentId": 33078,
"name": "student name",
"themes": ["38"],
}

The “themes” key is optional . This is only useful when adding students to a "Topics" course. It's used to add a student to a topic-based course, but you don't want them to have access to all the topics in the course. If this is the case, you must specify the "themeId" to which you want to add the student within the Array.

Otherwise, if you want the student to access all the topics, it's not necessary to add this key.

If everything went well, you will receive the following response:

  { 
"link": "https://subdomain.classonlive.com/sala-webinar/titulo-de-ejemplo?code=Xs9JH7T/neCiFL93TWAQfQ==", // You will only receive the room access link if the course is a Single Session or Multiple Session
"name": "student name",
"email": "[email protected]",
"applicantId": 142829,
"ok": true,
"isNewUser": true,
"password": "8476235" // You will only receive it if it is new user
}

With this method we can add as many students as we want.

Now we will receive the resources added previously from the web so that the student of the course can consume them.

As it is a course by topics, we must go to the section “CONTENT RESOURCES” -> “Resource topics/modules” -> “Receive resources from a module”.

  GET https://www.apiclassonlive.com/api/v1/eyJhzI1NiJ9.eyjUzLjUz.../theme/getmoduleresources/60  

We will receive a response similar to the following:

  "resources": [ 
{
"resourceType": "Video",
"title": "new video",
"description": "This is the description of the video",
"resourceId": 285095
},
{
"resourceType": "Resource",
"title": "Title of the resource",
"description": "This is the description of the document",
"resourceId": 380443
},
{
"resourceType": "Session",
"resourceId": 614091,
"initOneDayDate": 1621404000000,
"initMidLongDate": null,
"endMidLongDate": null,
"theContentDuration": "d30m",
"theContentMethod": "Broadcast",
"theContentType": "One_Day",
"theAssignedExpert": "[email protected]"
},...

All the resources associated with the module added as a parameter in the request appear here. With this object, we can list these resources on our website.

If we also want to provide the access link to the resource, we must call the following request. You can find more details in the documentation under “CONTENT RESOURCES” -> “Resource topics/modules” -> “Receive the link to a resource from a module”.

  GET https://www.apiclassonlive.com/api/v1/eyJhzI1NiJ9.eyjUzLjUz.../content/getmoduleresourcelink/Resource/380443  

This request consists of two parameters. “Resource” is the “resourceType” received from the request described above. In this case, the type is “Resource”, and 380443 is the resource identifier also received from the previous request.

The response we will receive next will have this structure:

  { 
"ok": true,
"link": "https://www.example.com/archivo.pdf"
}

With this, we finish the example of how to create a topics type course, add topics and modules within each topic and finally show the resources of a module so that students have access to them.

Did this answer your question?