Edit Pre Learning Activity - Online Test
This API is used to update an online test in pre-learning activity
Request URL:
https://people.zoho.com/api/v1/courses/<courseId>/settings/precourseactivities/onlineTests/<testId>?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.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) {
OkHttpClient client = new OkHttpClient();
String jsonData = "{"
+ "\"name\": \"updateOnline test API testing\","
+ "\"duration\": 35,"
+ "\"durationFor\": \"test\","
+ "\"description\": \"API Testing\","
+ "\"lockUntil\": \"04-01-2022\","
+ "\"maximumAttemptsAllowed\": \"2\","
+ "\"questionsPerPage\": \"all\","
+ "\"isMandatory\": true,"
+ "\"passPercentage\": 80,"
+ "\"shuffleQuestions\": true,"
+ "\"showMarksToLearner\": true,"
+ "\"gradeCategoryId\": 478346000019558215"
+ "}";
RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonData);
Request request = new Request.Builder()
.url("https://people.zoho.com/api/v1/courses/478346000019328001/settings/precourseactivities/onlineTests/478346000019559269")
.patch(body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Zoho-oauthtoken YOUR_ACCESS_TOKEN")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
} catch (Exception e) {
e.printStackTrace();
}
}
}
Copiedconst url = "https://people.zoho.com/api/v1/courses/478346000019328001/settings/precourseactivities/onlineTests/478346000019559269";
const data = {
name: "updateOnline test API testing",
duration: 35,
durationFor: "test",
description: "API Testing",
lockUntil: "04-01-2022",
maximumAttemptsAllowed: "2",
questionsPerPage: "all",
isMandatory: true,
passPercentage: 80,
shuffleQuestions: true,
showMarksToLearner: true,
gradeCategoryId: 478346000019558215
};
fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN"
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
Copiedcurl -X PATCH "https://people.zoho.com/api/v1/courses/478346000019328001/settings/precourseactivities/onlineTests/478346000019559269" \
-H "Content-Type: application/json" \
-H "Authorization: Zoho-oauthtoken YOUR_ACCESS_TOKEN" \
-d '{
"name": "updateOnline test API testing",
"duration": 35,
"durationFor": "test",
"description": "API Testing",
"lockUntil": "04-01-2022",
"maximumAttemptsAllowed": "2",
"questionsPerPage": "all",
"isMandatory": true,
"passPercentage": 80,
"shuffleQuestions": true,
"showMarksToLearner": true,
"gradeCategoryId": 478346000019558215
}'
Copiedurl = "https://people.zoho.com/api/v1/courses/478346000019328001/settings/precourseactivities/onlineTests/478346000019559269";
headers = map();
headers.put("Content-Type", "application/json");
headers.put("Authorization", "Zoho-oauthtoken YOUR_ACCESS_TOKEN");
data = map();
data.put("name", "updateOnline test API testing");
data.put("duration", 35);
data.put("durationFor", "test");
data.put("description", "API Testing");
data.put("lockUntil", "04-01-2022");
data.put("maximumAttemptsAllowed", "2");
data.put("questionsPerPage", "all");
data.put("isMandatory", true);
data.put("passPercentage", 80);
data.put("shuffleQuestions", true);
data.put("showMarksToLearner", true);
data.put("gradeCategoryId", 478346000019558215);
response = invokeurl
[
url : url
type : PATCH
parameters: data.toString()
headers: headers
];
info response;
Copiedimport requests
url = "https://people.zoho.com/api/v1/courses/478346000019328001/settings/precourseactivities/onlineTests/478346000019559269"
headers = {
"Content-Type": "application/json",
"Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN"
}
data = {
"name": "updateOnline test API testing",
"duration": 35,
"durationFor": "test",
"description": "API Testing",
"lockUntil": "04-01-2022",
"maximumAttemptsAllowed": "2",
"questionsPerPage": "all",
"isMandatory": True,
"passPercentage": 80,
"shuffleQuestions": True,
"showMarksToLearner": True,
"gradeCategoryId": 478346000019558215
}
response = requests.patch(url, headers=headers, json=data)
try:
print(response.json()) # Handle response safely
except ValueError:
print(response.text) # Print raw response if JSON decoding fails
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/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"
}
}
Show full
Show less