Skip to product menu
Skip to main content

Add Pre Learning Activity - Online Test

This API is used to create online test in pre learning activity 

Request URL: 

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

Header:

Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf

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

CopiedOkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "");

Request request = new Request.Builder()
    .url("https://people.zoho.com/api/v1/courses/219225000000642002/settings/precourseactivities/onlineTests?onlineTestData={\"name\":\"Online test One\",\"duration\":35,\"durationFor\":\"test\",\"description\":\"Description for Online test\",\"lockUntil\":\"01-01-2022\",\"maximumAttemptsAllowed\":\"5\",\"questionsPerPage\":\"all\",\"isMandatory\":true,\"passPercentage\":80,\"shuffleQuestions\":true,\"showMarksToLearner\":true,\"gradeCategoryId\":\"\"}")
    .post(body)
    .addHeader("Authorization", "Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf")
    .build();

Response response = client.newCall(request).execute();
System.out.println(response.body().string());
Copiedfetch("https://people.zoho.com/api/v1/courses/219225000000642002/settings/precourseactivities/onlineTests?onlineTestData=" + encodeURIComponent(JSON.stringify({
    "name": "Online test One",
    "duration": 35,
    "durationFor": "test",
    "description": "Description for Online test",
    "lockUntil": "01-01-2022",
    "maximumAttemptsAllowed": "5",
    "questionsPerPage": "all",
    "isMandatory": true,
    "passPercentage": 80,
    "shuffleQuestions": true,
    "showMarksToLearner": true,
    "gradeCategoryId": ""
})), {
    method: "POST",
    headers: {
        "Authorization": "Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf"
    }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
Copiedcurl --location --request POST 'https://people.zoho.com/api/v1/courses/219225000000642002/settings/precourseactivities/onlineTests?onlineTestData={"name":"Online test One","duration":35,"durationFor":"test","description":"Description for Online test","lockUntil":"01-01-2022","maximumAttemptsAllowed":"5","questionsPerPage":"all","isMandatory":true,"passPercentage":80,"shuffleQuestions":true,"showMarksToLearner":true,"gradeCategoryId":""}' \
--header 'Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf'
CopiedonlineTestData = Map();
onlineTestData.put("name", "Online test One");
onlineTestData.put("duration", 35);
onlineTestData.put("durationFor", "test");
onlineTestData.put("description", "Description for Online test");
onlineTestData.put("lockUntil", "01-01-2022");
onlineTestData.put("maximumAttemptsAllowed", "5");
onlineTestData.put("questionsPerPage", "all");
onlineTestData.put("isMandatory", true);
onlineTestData.put("passPercentage", 80);
onlineTestData.put("shuffleQuestions", true);
onlineTestData.put("showMarksToLearner", true);
onlineTestData.put("gradeCategoryId", "");

try
{
    response = invokeUrl
    [
        url: "https://people.zoho.com/api/v1/courses/219225000000642002/settings/precourseactivities/onlineTests?onlineTestData=" + onlineTestData.toString()
        type: POST
        headers: map("Authorization" -> "Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf")
    ];
}
catch(e)
{
    info "Exception while making the API request.";
}
Copiedimport requests

url = "https://people.zoho.com/api/v1/courses/219225000000642002/settings/precourseactivities/onlineTests"
params = {
    "onlineTestData": {
        "name": "Online test One",
        "duration": 35,
        "durationFor": "test",
        "description": "Description for Online test",
        "lockUntil": "01-01-2022",
        "maximumAttemptsAllowed": "5",
        "questionsPerPage": "all",
        "isMandatory": True,
        "passPercentage": 80,
        "shuffleQuestions": True,
        "showMarksToLearner": True,
        "gradeCategoryId": ""
    }
}
headers = {
    "Authorization": "Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf"
}

response = requests.post(url, params=params, headers=headers)
print(response.text)

Header

CopiedAuthorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf

Respomse

Copied{
    "code": "200",
    "message": "success",
    "onlineTest": {
        "previewURL": "https://people.zoho.com/peoplelms/assessments/219225000000671009/preview",
        "showMarksToLearner": "Yes",
        "totalLearnersCount": 0,
        "resources": [],
        "canUserDelete": true,
        "duration": "35 minutes",
        "isMandatoryTest": false,
        "lockUntil": "",
        "gradeCategoryName": "",
        "completedLearnersCount": 0,
        "isLocked": false,
        "maximumAttemptsAllowed": 1,
        "testId": "219225000000671001",
        "canUserEdit": true,
        "moduleId": 0,
        "testMark": "1.0",
        "testName": "Online test One_Update",
        "status": "Not ready"
    }
}