Get Quiz Questions for a Single Video
Updated: 2022-05-23 19:02:59
Interface URL
https://api.polyv.net/v2/video/get-video-exam
Interface Description
Get quiz questions for a single video
Supported Format
JSON
Request Method
POST
Request Parameters
| Parameter | Required | Type & Range | Description |
|---|---|---|---|
| userid | Yes | string | User ID |
| ptime | Yes | long | Current time in milliseconds (13 digits), valid for 3 minutes |
| sign | Yes | String | Signature, a 40-character uppercase SHA1 value See signature generation rules |
| vid | Yes | string | Video ID |
Example of Successful JSON Response
{
"code": 200,
"status": "success",
"message": "success",
"data": {
"exams": [
{
"examId": "17922407aac",
"vid": "a2dc4f25172872650e7d5c1b8026b13c_a",
"showTime": 12,
"question": "测试问题",
"choices": "[{\"index\":0,\"content\":\"a\",\"right\":true},{\"index\":1,\"content\":\"b\",\"right\":false},{\"index\":2,\"content\":\"c\",\"right\":false},{\"index\":3,\"content\":\"d\",\"right\":true}]",
"explanationIfRight": "回答正确后的解答详情",
"explanationIfWrong": "回答错误后的解答详情",
"showExplanationIfWrong": false,
"backTime": -1,
"canSkip": false,
"illustration": "",
"type": 0,
"mp3Url": "",
"status": 1,
"createdTime": 1619777319000
}
]
}
}
Example of Error JSON Response
签名不正确
{
"code":400,
"status":"error",
"message":"the sign is not right",
"data":""
}
时间戳过期
{
"code":400,
"status":"error",
"message":"ptime is too old.",
"data":""
}
Field Description
| Field | Type | Description |
|---|---|---|
| code | int | Return code |
| status | string | Return status |
| message | string | Return message |
| data | object | Operation result |
| exams | object[] | Quiz list |
| vid | string | Video ID |
| examId | string | Quiz ID |
| showTime | int | Time when the quiz appears, in seconds |
| qustion | string | Quiz question description |
| choices | array of string | Quiz options JSON array, up to 5 options per question |
| canSkip | boolean | Whether it can be skipped, default: false |
| explanationIfRight | string | Explanation after answering correctly |
| showExplanationIfWrong | string | Whether to show explanation after answering incorrectly |
| explanationIfWrong | string | Explanation after answering incorrectly |
| backTime | int | Seconds to go back after wrong answer, -1 means no rewind, default: -1 |
| status | int | Whether valid, 1: valid, 0: invalid, default: 1 |
| type | int | Question type, 0: multiple choice, 1: listening question (listening questions will be deprecated soon) |
| mp3url | string | MP3 audio file URL for listening questions (listening questions will be deprecated soon) |
| illustration | string | Quiz image URL |
Choices Parameter Description
示例
[
{
"index": 0,
"content": "a",
"isRight": true
},
{
"index": 1,
"content": "b",
"isRight": false
},
{
"index": 2,
"content": "c",
"isRight": false
},
{
"index": 3,
"content": "d",
"isRight": true
}
]
| Parameter | Required | Type & Range | Description |
|---|---|---|---|
| index | Yes | int | Option index, the actual order of questions is sorted by this value, must not be duplicated |
| content | Yes | string | Option content |
| isRight | No | boolean | At least one option must be set as the correct answer, otherwise the interface returns an error. |
Java Request Example:
public void testGetVideoExam() throws Exception {
String url = "https://api.polyv.net/v2/video/get-video-exam";
Map<String, String> params = new HashMap<>();
params.put("userid", userid);
params.put("vid", "a2dc4f25172872650e7d5c1b8026b13c_a");
params.put("ptime", String.valueOf(System.currentTimeMillis()));
params.put("sign", getSign(params, secretkey));
String response = HttpClientUtil.getInstance().sendHttpGet(url + "?" + PolyvTool.mapJoinNotEncode(params));
System.out.println(response);
}
