Update Offline Test API

This API is used to update offline test in modules of course or batch in LMS

Request URL: (Self Paced Course)

https://people.zoho.com/api/v1/courses/<courseId>/modules<moduleId>/offlineTests/<offlineTestId>?offlineTestData = {"name" : <name>, "marks" : <marks>, "duration" : <duration>, "description" : <description>, "isMandatory" : <isMandatory>,"lockUntil" : <lockUntil>, "gradeCategoryId" : "<gradeCategoryId>"}

Request URL: (Blended Learning Course)

https://people.zoho.com/api/v1/courses/<courseId>/batches/<batchId>/modules/<moduleId>/offlineTests/<offlineTestId>?offlineTestData = {"name" : <name>, "marks" : <marks>, "duration" : <duration>, "description" : <description>, "isMandatory" : <isMandatory>,"lockUntil" : <lockUntil>, "gradeCategoryId" : "<gradeCategoryId>"}

Scope:

ZOHOPEOPLE.training.ALL
OR
ZOHOPEOPLE.training.UPDATE

Possible Operation Types:

ALL - Complete access to data
UPDATE - Only to update data

Method:

PATCH

Request Parameters

ParametersValues AllowedDefault ValueDescription
offlineTestData <parameters in JSON Object> JSON Input

 

ParametersValues AllowedDefault ValueDescription
name<File name><Mandatory>Specify the file name
marks<Marks in Integer format><Mandatory>Specify the offline test marks
duration<Duration in minutes><Mandatory>Specify the duration
isMandatorytrue|falsetrueSpecify if the file is mandatory
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

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();

        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{"
            + "\"name\": \"jan03Offline test API Testing\","
            + "\"marks\": 50,"
            + "\"duration\": 35,"
            + "\"description\": \"Nothing to describe\","
            + "\"isMandatory\": true,"
            + "\"gradeCategoryId\": \"478346000019553053\""
            + "}");

        Request request = new Request.Builder()
            .url("https://people.zoho.com/api/v1/courses/478346000025070001/modules/478346000025070013/offlineTests/478346000025070051")
            .patch(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/478346000025070001/modules/478346000025070013/offlineTests/478346000025070051";

const data = {
    name: "jan03Offline test API Testing",
    marks: 50,
    duration: 35,
    description: "Nothing to describe",
    isMandatory: true,
    gradeCategoryId: "478346000019553053"
};

fetch(url, {
    method: "PATCH",
    headers: {
        "Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN",
        "Content-Type": "application/json"
    },
    body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error("Error:", error));
Copiedcurl -X PATCH "https://people.zoho.com/api/v1/courses/478346000025070001/modules/478346000025070013/offlineTests/478346000025070051" \
-H "Authorization: Zoho-oauthtoken YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"jan03Offline test API Testing","marks":50,"duration":35,"description":"Nothing to describe","isMandatory":true,"gradeCategoryId":"478346000019553053"}'
Copiedurl = "https://people.zoho.com/api/v1/courses/478346000025070001/modules/478346000025070013/offlineTests/478346000025070051";

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

data = map();
data.put("name", "jan03Offline test API Testing");
data.put("marks", 50);
data.put("duration", 35);
data.put("description", "Nothing to describe");
data.put("isMandatory", true);
data.put("gradeCategoryId", "478346000019553053");

response = invokeurl
[
    url : url
    type : PATCH
    headers: headers
    parameters: data
];

info response;
Copiedimport requests

url = "https://people.zoho.com/api/v1/courses/478346000025070001/modules/478346000025070013/offlineTests/478346000025070051"

payload = {
    "name": "jan03Offline test API Testing",
    "marks": 50,
    "duration": 35,
    "description": "Nothing to describe",
    "isMandatory": True,
    "gradeCategoryId": "478346000019553053"
}
headers = {
    "Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN",
    "Content-Type": "application/json"
}

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

print(response.text)

Header

CopiedAuthorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf

Response

Copied{
    "code": 200,
    "message": "success",
    "offlineTest": {
        "totalLearnersCount": 0,
        "description": "Description for Offline Test",
        "resources": [],
        "canUserDelete": true,
        "duration": "35 Mins",
        "isMandatoryTest": true,
        "lockUntil": "26-12-2021",
        "gradeCategoryName": "",
        "completedLearnersCount": 0,
        "isLocked": true,
        "gradeCategoryId": "",
        "testId": "219225000000648059",
        "canUserEdit": true,
        "moduleId": "219225000000648001",
        "testMark": "45",
        "testName": "Offline test one_Update"
    }
}