answerRecordService
1. Query Channel Quiz Answer Results
Description
查询频道答题卡答题结果
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/question/answer-records
Call Constraints
Unit Test
@Test
public void testGetAnswerRecord() throws Exception, NoSuchAlgorithmException {
LiveQuestionAnswerRecordRequest liveQuestionAnswerRecordRequest = new LiveQuestionAnswerRecordRequest();
List<LiveQuestionAnswerRecordResponse> liveCheckinResponse = null;
try {
String channelId = super.createChannel();
liveQuestionAnswerRecordRequest.setChannelId(channelId);
liveQuestionAnswerRecordRequest.setStartDate(getDate(2020, 10, 01)).setEndDate(getDate(2099, 10, 01));
liveCheckinResponse = new LiveAnswerRecordServiceImpl().getAnswerRecord(liveQuestionAnswerRecordRequest);
Assert.assertNotNull(liveCheckinResponse);
if (liveCheckinResponse != null) {
//to do something ......
log.debug("测试查询频道答题卡答题结果成功{}", JSON.toJSONString(liveCheckinResponse));
}
} 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
If the request is correct, a
LiveQuestionAnswerRecordResponseobject is returned. The B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found inPloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.LivexxxRequest] object validation failed, failure field [pic cannot be empty / msg cannot be empty]].If the server encounters an error during processing, a
PloyvSdkExceptionis thrown. The error message can be found inPloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| startDate | false | Date | Query start time, format: yyyy-MM-dd |
| endDate | false | Date | Query end time, format: yyyy-MM-dd |
| appId | false | String | POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
The return object is List<LiveQuestionAnswerRecordResponse>. The specific elements of LiveQuestionAnswerRecordResponse are as follows:
| Parameter | Type | Description |
|---|---|---|
| questionId | String | Question ID |
| questionTitle | String | Question title |
| times | Integer | The number of times the question was sent, used to distinguish repeated sends of the same question |
| answer | String | Answer to the question |
| total | Integer | Number of respondents |
| options | Array | List of question option details [see Option Parameter Description] |
| records | Array | List of users who answered [see Record Parameter Description] |
| type | String | Question type: R for single choice, C for multiple choice, Q for Q&A |
| itemType | Integer | Answer type: 1 for Q&A, 0 for quiz card |
Option Parameter Description
| Parameter | Type | Description |
|---|---|---|
| title | String | Option title |
| count | Integer | Number of users who selected this option |
| percent | String | Percentage of users who selected this option, e.g., 100.00% |
Record Parameter Description
| Parameter | Type | Description |
|---|---|---|
| viewerId | String | User ID of the respondent |
| nickname | String | Nickname of the respondent |
| answer | String | Answer submitted by the respondent |
| correct | Boolean | Whether the answer submitted by the respondent is correct: false for incorrect, true for correct |
| submitTime | Date | Submission time of the respondent |
