videoQuestionAndAnswer
1. Create or Update Video Exam
Description
通过问答id新增或修改视频问答题目
接口地址(仅做说明使用):https://api.polyv.net/v2/video/save-video-exam
Call Constraints
- API calls are rate-limited. Click for details. For common call exceptions, click here.
Unit Test
@Test
public void testCreateOrUpdateVideoExam() throws IOException, NoSuchAlgorithmException {
VodCreateOrUpdateVideoExamRequest vodCreateOrUpdateVideoExamRequest = new VodCreateOrUpdateVideoExamRequest();
VodCreateOrUpdateVideoExamResponse vodCreateOrUpdateVideoExamResponse = null;
try {
List<VodCreateOrUpdateVideoExamRequest.Choices> choices = Arrays.asList(
new VodCreateOrUpdateVideoExamRequest.Choices(0, "萝卜", Boolean.TRUE),
new VodCreateOrUpdateVideoExamRequest.Choices(1, "青菜", Boolean.FALSE));
vodCreateOrUpdateVideoExamRequest.setExamId("17982289508")
.setVideoId("1b448be3234406608b7838c7ef6b597c_1")
.setShowTime(2)
.setQuestion("喜欢萝卜还是青菜")
.setChoices(choices)
.setCanSkip(Boolean.FALSE)
.setExplanationIfRight("回答正确后的解答详情")
.setShowExplanationIfWrong(Boolean.TRUE)
.setExplanationIfWrong("回答错误后的解答详情")
.setBackTime(-1);
vodCreateOrUpdateVideoExamResponse = new VodInfoServiceImpl().createOrUpdateVideoExam(
vodCreateOrUpdateVideoExamRequest);
Assert.assertNotNull(vodCreateOrUpdateVideoExamResponse);
if (vodCreateOrUpdateVideoExamResponse != null) {
log.debug("测试新增或修改视频问答成功,{}", JSON.toJSONString(vodCreateOrUpdateVideoExamResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a successful request, a
VodCreateOrUpdateVideoExamResponseobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Validation failed for input object [xxx.chat.VodxxxRequest], failed fields: [pic cannot be empty / msg cannot be empty]].If the server encounters an exception, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation] |
| examId | false | String | Exam ID. If empty, a new question is created. If not empty, an existing exam question is modified. |
| showTime | true | Integer | Time at which the exam appears, in seconds. |
| question | true | String | Exam question description. |
| choices | true | Array | JSON array of exam options. Maximum of 5 options per question. See Choices Parameter Description |
| canSkip | false | Boolean | Whether the question can be skipped. Default: false. |
| explanationIfRight | false | String | Explanation displayed after a correct answer. |
| showExplanationIfWrong | false | Boolean | Whether to display the explanation after a wrong answer. true: display; false: do not display. Default: true. |
| explanationIfWrong | false | String | Explanation displayed after a wrong answer. |
| backTime | false | Integer | Time in seconds to rewind to after a wrong answer. -1 means no rewind. Default: -1. |
Choices Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| index | Integer | Option index. The actual order of options is sorted by this value. Do not duplicate. |
| content | String | Option content. |
| isRight | Boolean | At least one option must be set as the correct answer, otherwise the API returns an error. |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| examId | String | Exam ID |
2. Query Exam Questions for a Single Video
Description
通过视频id查询单个视频的问答题目
接口地址(仅做说明使用):https://api.polyv.net/v2/video/get-video-exam
Call Constraints
- API calls are rate-limited. Click for details. For common call exceptions, click here.
Unit Test
@Test
public void testGetVideoExam() throws IOException, NoSuchAlgorithmException {
VodQueryVideoExamRequest vodQueryVideoExamRequest = new VodQueryVideoExamRequest();
VodQueryVideoExamResponse vodQueryVideoExamResponse = null;
try {
vodQueryVideoExamRequest.setVideoId("1b448be3234406608b7838c7ef6b597c_1");
vodQueryVideoExamResponse = new VodInfoServiceImpl().queryVideoExam(vodQueryVideoExamRequest);
Assert.assertNotNull(vodQueryVideoExamResponse);
log.debug("测试查询单个视频的问答题目成功,{}", JSON.toJSONString(vodQueryVideoExamResponse));
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a successful request, a
VodQueryVideoExamResponseobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Validation failed for input object [xxx.chat.VodxxxRequest], failed fields: [pic cannot be empty / msg cannot be empty]].If the server encounters an exception, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation] |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| exams | Array | List of exams See Exam Parameter Description |
Exam Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| videoId | String | Video ID [corresponds to the vid field in the API documentation] |
| examId | String | Exam ID |
| showTime | Integer | Time at which the exam appears, in seconds. |
| question | String | Exam question description. |
| choices | String | JSON array of exam options. Maximum of 5 options per question. |
| canSkip | Boolean | Whether the question can be skipped. Default: false. |
| explanationIfRight | String | Explanation displayed after a correct answer. |
| showExplanationIfWrong | Boolean | Whether to display the explanation after a wrong answer. |
| explanationIfWrong | String | Explanation displayed after a wrong answer. |
| backTime | Integer | Time in seconds to rewind to after a wrong answer. -1 means no rewind. Default: -1. |
| status | Integer | Whether valid. 1: valid, 0: invalid. Default: 1. |
| type | Integer | Question type. 0: multiple choice, 1: listening question (listening questions are being deprecated). |
| mp3url | String | URL of the mp3 audio file for listening questions (listening questions are being deprecated). |
| illustration | String | Exam image URL. |
| createdTime | Date | Time the exam question was created. |
3. Paginated Query of Video Exam Questions
Description
分页查询视频的问答题目,可按视频id筛选
接口地址(仅做说明使用):https://api.polyv.net/v2/video/list-video-exam
Call Constraints
- API calls are rate-limited. Click for details. For common call exceptions, click here.
Unit Test
@Test
public void testListVideoExam() throws IOException, NoSuchAlgorithmException {
VodListVideoExamRequest request = new VodListVideoExamRequest();
VodListVideoExamResponse response = null;
try {
request.setCurrentPage(1).setPageSize(20);
response = new VodInfoServiceImpl().listVideoExam(request);
Assert.assertNotNull(response);
log.debug("测试分页查询视频的问答题目成功,{}", JSON.toJSONString(response));
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a successful request, a
VodListVideoExamResponseobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Validation failed for input object [xxx.chat.VodxxxRequest], failed fields: [pic cannot be empty / msg cannot be empty]].If the server encounters an exception, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| videoId | false | String | Video ID [corresponds to the vid field in the API documentation]. If empty, queries all exam questions under the account. |
| currentPage | false | Integer | Page number. Default: 1 [corresponds to the page field in the API documentation]. |
| pageSize | false | Integer | Number of records per page. Default: 20. Maximum: 1000. |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| contents | Array | List of exam questions See Exam Parameter Description |
| pageSize | Integer | Number of records per page. Default: 20. |
| currentPage | Integer | Current page [corresponds to the pageNumber field in the API documentation]. |
| totalItems | Integer | Total number of records. |
| totalPage | Integer | Total number of pages [corresponds to the totalPages field in the API documentation]. |
4. Batch Query Exam Answer Logs
Description
通过视频id批量查询答题日志
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/video-exam-log
Call Constraints
API calls are rate-limited. Click for details. For common call exceptions, click here.
pageSizeis fixed at 20.
Unit Test
@Test
public void testGetVideoExamLog() throws IOException, NoSuchAlgorithmException {
VodGetVideoExamLogRequest vodGetVideoExamLogRequest = new VodGetVideoExamLogRequest();
VodGetVideoExamLogResponse vodGetVideoExamLogResponse = null;
try {
vodGetVideoExamLogRequest
//可通过 new VodQueryServiceImpl().queryVideoList()获取
.setVideoIds("1b448be3234406608b7838c7ef6b597c_1")
.setStart(super.getDate(2021, 2, 1))
.setEnd(super.getDate(2021, 3, 12));
vodGetVideoExamLogResponse = new VodInfoServiceImpl().getVideoExamLog(vodGetVideoExamLogRequest);
Assert.assertNotNull(vodGetVideoExamLogResponse);
if (vodGetVideoExamLogResponse != null) {
log.debug("测试批量查询答题日志成功,{}", JSON.toJSONString(vodGetVideoExamLogResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a successful request, a
VodGetVideoExamLogResponseobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Validation failed for input object [xxx.chat.VodxxxRequest], failed fields: [pic cannot be empty / msg cannot be empty]].If the server encounters an exception, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| videoIds | false | String | List of video IDs, separated by commas. If empty, queries data for all videos under the account. [Corresponds to the vids field in the API documentation] |
| start | false | Date | Start date for the query. Format: yyyy-MM-dd. |
| end | false | Date | End date for the query. Format: yyyy-MM-dd. |
| currentPage | false | Integer | Page number. Default: 1 [corresponds to the page field in the API documentation]. |
| pageSize | false | Integer | Number of records per page. Default: 20. |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| contents | Array | List of exam logs See ExamLog Parameter Description |
| pageSize | Integer | Number of records per page. Default: 20. |
| currentPage | Integer | Current page [corresponds to the pageNumber field in the API documentation]. |
| totalItems | Integer | Total number of records. |
| totalPage | Integer | Total number of pages [corresponds to the totalPages field in the API documentation]. |
ExamLog Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| logId | Integer | ID of this log [corresponds to the logid field in the API documentation]. |
| examId | String | ID of the exam this log belongs to. |
| userId | String | Viewer ID. |
| videoId | String | ID of the video the exam belongs to [corresponds to the videoPoolId field in the API documentation]. |
| question | String | Exam title. |
| answer | String | Answer provided by the viewer. |
| isCorrect | Integer | Whether the answer is correct. 1: correct; 0: incorrect. |
| playerId | String | Player ID. |
| ipAddress | String | IP address. |
| province | String | Viewer's province. |
| isp | String | Viewer's ISP. |
| operatingSystem | String | Viewer's operating system. |
| browser | String | Viewer's browser. |
| dateAdded | Date | Date the question was answered. Format: yyyy-MM-dd HH:mm:ss. |
| viewerId | String | Custom viewer ID [corresponds to the viewerid field in the API documentation]. |
| viewerInfo | String | Custom viewer information. |
5. Delete Exam Questions for a Single Video
Description
通过视频id与问答id删除单个视频的问答题目
接口地址(仅做说明使用):https://api.polyv.net/v2/video/delete-video-exam
Call Constraints
- API calls are rate-limited. Click for details. For common call exceptions, click here.
Unit Test
@Test
public void testRemoveVideoExam() throws IOException, NoSuchAlgorithmException {
VodRemoveVideoExamRequest vodRemoveVideoExamRequest = new VodRemoveVideoExamRequest();
Boolean vodRemoveVideoExamResponse = null;
try {
//准备测试数据
String videoExamId = super.createVideoExam();
vodRemoveVideoExamRequest
.setVideoId("1b448be3234406608b7838c7ef6b597c_1").setExamIds(videoExamId);
vodRemoveVideoExamResponse = new VodEditServiceImpl().removeVideoExam(vodRemoveVideoExamRequest);
Assert.assertTrue(vodRemoveVideoExamResponse);
if (vodRemoveVideoExamResponse) {
log.debug("测试删除单个视频的问答题目成功");
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a successful request, a
Booleanobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Validation failed for input object [xxx.chat.VodxxxRequest], failed fields: [pic cannot be empty / msg cannot be empty]].If the server encounters an exception, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| userId | false | String | User ID [corresponds to the userid field in the API documentation]. |
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation]. |
| examIds | false | String | Exam IDs, separated by commas. If not provided, all exam questions for the video are deleted. Example: 17982289509,17982289508. |
Return Object Description
null
