Update Online Test API
This API is used to update 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?/<onlineTestId>?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/<onlineTestId>?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.UPDATE
Possible Operation Types:
ALL - Complete access to data
UPDATE - Only to update data
Method:
PATCH
Request Parameters
Parameters | Values Allowed | Default Value | Description |
*onlineTestData | <parameters in JSON Object> | JSON Input |
Parameters | Values Allowed | Default Value | Description |
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 |
maximumAttemptsAllowed | 1-10|unlimited | <Mandatory> | Specify the maximum allowed attempts value |
*questionPerPage | all|one | <Mandatory> | Specify the questions per page |
passPercentage | 1-100 | - | Specify the pass percentage |
shuffleQuestions | true|false | - | Specify the shuffle questions |
showMarksToLearner | true|false | - | Specify if marks must be showed to learners at the end of the test |
description | <Description> | - | Specify the description |
isMandatory | true|false | true | Specify 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 Codes | Description |
---|---|
400 | Invalid parameter value/input parameter missing |
403 | Sorry! You are not authorized to do this operation |
404 | Not found |
422 | Maximum limit exceeded |
500 | Sorry! 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\": \"1Online test API testing\","
+ "\"duration\": 35,"
+ "\"durationFor\": \"test\","
+ "\"description\": \"API Testing\","
+ "\"maximumAttemptsAllowed\": \"3\","
+ "\"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/478346000019479103/batches/478346000019479115/modules/478346000019479119/onlineTests/478346000019559123")
.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/478346000019479103/batches/478346000019479115/modules/478346000019479119/onlineTests/478346000019559123";
const payload = {
name: "1Online test API testing",
duration: 35,
durationFor: "test",
description: "API Testing",
maximumAttemptsAllowed: "3",
questionsPerPage: "all",
isMandatory: true,
passPercentage: 80,
shuffleQuestions: true,
showMarksToLearner: true,
gradeCategoryId: 478346000019553053
};
fetch(url, {
method: "PATCH",
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 PATCH "https://people.zoho.com/api/v1/courses/478346000019479103/batches/478346000019479115/modules/478346000019479119/onlineTests/478346000019559123" \
-H "Authorization: Zoho-oauthtoken YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "1Online test API testing",
"duration": 35,
"durationFor": "test",
"description": "API Testing",
"maximumAttemptsAllowed": "3",
"questionsPerPage": "all",
"isMandatory": true,
"passPercentage": 80,
"shuffleQuestions": true,
"showMarksToLearner": true,
"gradeCategoryId": 478346000019553053
}'
Copiedurl = "https://people.zoho.com/api/v1/courses/478346000019479103/batches/478346000019479115/modules/478346000019479119/onlineTests/478346000019559123";
headers = map();
headers.put("Authorization", "Zoho-oauthtoken YOUR_ACCESS_TOKEN");
headers.put("Content-Type", "application/json");
payload = map();
payload.put("name", "1Online test API testing");
payload.put("duration", 35);
payload.put("durationFor", "test");
payload.put("description", "API Testing");
payload.put("maximumAttemptsAllowed", "3");
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 : PATCH
parameters: payload.toJSON()
headers: headers
];
info response;
Copiedimport requests
url = "https://people.zoho.com/api/v1/courses/478346000019479103/batches/478346000019479115/modules/478346000019479119/onlineTests/478346000019559123"
payload = {
"name": "1Online test API testing",
"duration": 35,
"durationFor": "test",
"description": "API Testing",
"maximumAttemptsAllowed": "3",
"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.patch(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": "1.0",
"resultType": 2,
"testName": "Online test One_update",
"status": "Not ready"
}
}
Show full
Show less