Skip to product menu
Skip to main content

Create Online Test API

This API is used to create online test in modules of course or batch in LMS

Request URL: (Self Paced Course)

https://people.zoho.com/api/v1/courses/<courseId>/modules/<moduleId>/onlineTests?onlineTestData ={"name" : <name> , "duration" : <duration>, "durationFor" : <durationFor>, "description" : <description>, "lockUntil" : <lockUntil>, "maximumAttemptsAllowed" : <maximumAttemptsAllowed>, "questionsPerPage" : <questionsPerPage>, "isMandatory" : <isMandatory> , "passPercentage" : <passPercentage>, "shuffleQuestions" : <shuffleQuestions>, "showMarksToLearner" : <showMarksToLearner>, "gradeCategoryId" : <gradeCategoryId>}

Request URL: (Blended Learning Course)

https://people.zoho.com/api/v1/courses/<courseId>/batches/<batchId>/modules/<moduleId>/onlineTests?onlineTestData ={"name" : <name> , "duration" : <duration>, "durationFor" : <durationFor>, "description" : <description>, "lockUntil" : <lockUntil>, "maximumAttemptsAllowed" : <maximumAttemptsAllowed>, "questionsPerPage" : <questionsPerPage>, "isMandatory" : <isMandatory> , "passPercentage" : <passPercentage>, "shuffleQuestions" : <shuffleQuestions>, "showMarksToLearner" : <showMarksToLearner>, "gradeCategoryId" : <gradeCategoryId>}

Scope:

ZOHOPEOPLE.training.ALL
OR
ZOHOPEOPLE.training.CREATE

Possible Operation Types:

ALL - Complete access to data
CREATE - Only to create data

Method:

POST

Request Parameters

ParametersValues AllowedDefault ValueDescription
*onlineTestData <parameters in JSON Object> JSON Input

 

ParametersValues AllowedDefault ValueDescription
*name<Online test name><Mandatory>Specify the online test name
*durationFor<none|test|question><Mandatory>Specify the duration
*duration<Duration in minutes><Mandatory if duration is not none>Specify the duration
*maximumAttemptsAllowed1-10|unlimited<Mandatory>Specify the maximum allowed attempts value
*questionPerPageall|one<Mandatory>Specify the questions per page
passPercentage1-100-Specify the pass percentage
shuffleQuestionstrue|false-Specify the shuffle questions
showMarksToLearnertrue|false-Specify if marks must be showed to learners at the end of the test
description<Description>-Specify the description
isMandatorytrue|falsetrueSpecify if the test is mandatory or not
lockUntil<lockUntil date in DD-MM-YYYY format>-Specify the lockUntil date
gradeCategoryId<Grade category id>-Specify the Grade category id
resources<files>-Specify resources

*mandatory parameters

Error Codes and Descriptions

Status CodesDescription
400Invalid parameter value/input parameter missing
403Sorry! You are not authorized to do this operation
404Not found
422Maximum limit exceeded
500Sorry! Server error occured

View complete list of LMS API error codes

Threshold Limit: 30 requests | Lock period: 5 minutes

Threshold Limit - Number of API calls allowed within a minute.
Lock Period - Wait time before consecutive API requests.

Request

Copiedimport okhttp3.*;

public class Main {
    public static void main(String[] args) throws Exception {
        OkHttpClient client = new OkHttpClient();

        String jsonPayload = "{"
            + "\"name\": \"Online test API testing\","
            + "\"duration\": 35,"
            + "\"durationFor\": \"test\","
            + "\"description\": \"API Testing\","
            + "\"maximumAttemptsAllowed\": \"2\","
            + "\"questionsPerPage\": \"all\","
            + "\"isMandatory\": true,"
            + "\"passPercentage\": 80,"
            + "\"shuffleQuestions\": true,"
            + "\"showMarksToLearner\": true,"
            + "\"gradeCategoryId\": 478346000019553053"
            + "}";

        RequestBody body = RequestBody.create(
            jsonPayload, MediaType.parse("application/json"));

        Request request = new Request.Builder()
            .url("https://people.zoho.com/api/v1/courses/478346000019479001/modules/478346000019479023/onlineTests")
            .post(body)
            .addHeader("Authorization", "Zoho-oauthtoken YOUR_ACCESS_TOKEN")
            .addHeader("Content-Type", "application/json")
            .build();

        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}
Copiedconst url = "https://people.zoho.com/api/v1/courses/478346000019479001/modules/478346000019479023/onlineTests";

const payload = {
    name: "Online test API testing",
    duration: 35,
    durationFor: "test",
    description: "API Testing",
    maximumAttemptsAllowed: "2",
    questionsPerPage: "all",
    isMandatory: true,
    passPercentage: 80,
    shuffleQuestions: true,
    showMarksToLearner: true,
    gradeCategoryId: 478346000019553053
};

fetch(url, {
    method: "POST",
    headers: {
        "Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN",
        "Content-Type": "application/json"
    },
    body: JSON.stringify(payload)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error("Error:", error));
Copiedcurl -X POST "https://people.zoho.com/api/v1/courses/478346000019479001/modules/478346000019479023/onlineTests" \
-H "Authorization: Zoho-oauthtoken YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
    "name": "Online test API testing",
    "duration": 35,
    "durationFor": "test",
    "description": "API Testing",
    "maximumAttemptsAllowed": "2",
    "questionsPerPage": "all",
    "isMandatory": true,
    "passPercentage": 80,
    "shuffleQuestions": true,
    "showMarksToLearner": true,
    "gradeCategoryId": 478346000019553053
}'
Copiedurl = "https://people.zoho.com/api/v1/courses/478346000019479001/modules/478346000019479023/onlineTests";

headers = map();
headers.put("Authorization", "Zoho-oauthtoken YOUR_ACCESS_TOKEN");
headers.put("Content-Type", "application/json");

payload = map();
payload.put("name", "Online test API testing");
payload.put("duration", 35);
payload.put("durationFor", "test");
payload.put("description", "API Testing");
payload.put("maximumAttemptsAllowed", "2");
payload.put("questionsPerPage", "all");
payload.put("isMandatory", true);
payload.put("passPercentage", 80);
payload.put("shuffleQuestions", true);
payload.put("showMarksToLearner", true);
payload.put("gradeCategoryId", 478346000019553053);

response = invokeurl
[
    url : url
    type : POST
    parameters: payload.toJSON()
    headers: headers
];

info response;
Copiedimport requests

url = "https://people.zoho.com/api/v1/courses/478346000019479001/modules/478346000019479023/onlineTests"

payload = {
    "name": "Online test API testing",
    "duration": 35,
    "durationFor": "test",
    "description": "API Testing",
    "maximumAttemptsAllowed": "2",
    "questionsPerPage": "all",
    "isMandatory": True,
    "passPercentage": 80,
    "shuffleQuestions": True,
    "showMarksToLearner": True,
    "gradeCategoryId": 478346000019553053
}

headers = {
    "Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers, json=payload)

print(response.text)

Show full

Show less

Header

CopiedAuthorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf

Response

Copied{
    "code": 200,
    "message": "success",
    "onlineTest": {
        "previewURL": "https://people.zoho.com/peoplelms/assessments/219225000000669019/preview",
        "totalLearnersCount": 0,
        "resources": [],
        "canUserDelete": true,
        "duration": "35 minutes",
        "isMandatoryTest": true,
        "lockUntil": "27-12-2021",
        "gradeCategoryName": "",
        "completedLearnersCount": 0,
        "isLocked": false,
        "maximumAttemptsAllowed": 5,
        "testId": "219225000000669011",
        "canUserEdit": true,
        "moduleId": "219225000000648001",
        "testMark": "0.0",
        "resultType": 0,
        "testName": "Online test One",
        "status": "Not ready"
    }
}

Show full

Show less