Polyv Help Center

Help Center

Add and Modify Video Quiz

Updated: 2022-05-23 19:02:59

Interface URL

https://api.polyv.net/v2/video/save-video-exam

Interface Description

Add and modify quiz questions

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 within 3 minutes
sign Yes String Signature, a 40-character uppercase SHA1 value See signature generation rules
vid Yes string Video ID
examId No string Quiz ID. If empty, a new question is added. If not empty, an existing quiz question is modified.
showTime Yes int Time when the quiz appears, in seconds
question Yes string Quiz question description
choices Yes array of string Quiz options JSON array, maximum 5 options per question
canSkip No boolean Whether the question can be skipped, default: false
explanationIfRight No string Explanation displayed when the answer is correct
showExplanationIfWrong No boolean Whether to show explanation when the answer is wrong, default: true
explanationIfWrong No string Explanation displayed when the answer is wrong
backTime No int Time in seconds to rewind after a wrong answer, -1 means no rewind, default: -1

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 options is sorted by this value. Do not duplicate.
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.

Successful Response JSON Example

{
    "code": 200,
    "status": "success",
    "message": "success",
    "data": {
        "examId": "179228dfe4f"
    }
}

Error Response JSON Example

签名不正确
{
"code":400,
"status":"error",
"message":"the sign is not right",
"data":""
}
时间戳过期
{
"code":400,
"status":"error",
"message":"ptime is too old.",
"data":""
}
vid 不存在
{
    "code": 400,
    "status": "error",
    "message": "video could not find by vid",
    "data": ""
}

Field Description

Field Description
code Return code
status Return status
message Return message
data Operation result
examId Quiz ID

Java Request Example:

    public void testSaveVideoExam() throws Exception {
        String url = "https://api.polyv.net/v2/video/save-video-exam";
        Map<String, String> params = new HashMap<>();
        params.put("userid", userid);
        params.put("vid", "a2dc4f25172872650e7d5c1b8026b13c_a");
        params.put("examId", "179228dfe4f");
        params.put("question", "测试问题");
        params.put("showTime", "12");
        params.put("choices", "[{\"index\":0,\"content\":\"a\",\"isRight\":true},{\"index\":1,\"content\":\"b\",\"isRight\":false},{\"index\":2,\"content\":\"c\",\"isRight\":false},{\"index\":3,\"content\":\"d\",\"isRight\":true}]");
        params.put("canSkip", "false");
        params.put("explanationIfRight", "回答正确后的解答详情");
        params.put("showExplanationIfWrong", "true");
        params.put("explanationIfWrong", "回答错误后的解答详情");
        params.put("backTime", "1");
        params.put("ptime", String.valueOf(System.currentTimeMillis()));
        params.put("sign", getSign(params, secretkey));
        String response = HttpClientUtil.getInstance().sendHttpPost(url, params);
        System.out.println(response);
    }
联系客服,在线咨询