Polyv Help Center

Help Center

AnswerCard

Updated: 2021-10-14 16:15:55

Import Component

import AnswerCard from '@polyv/interactions-launch-sdk-ui-default/lib/AnswerCard';

Code Example

<template>
    <!-- 建议弹窗宽度为 800px,弹窗内容高度为 600px -->
  <el-dialog
    :custom-class="'c-interactions-dialog c-interactions-dialog__h600'"
    width="800px"
    title="答题卡"
    :visible.sync="answerCardVisible"
    :close-on-click-modal="false"
  >
    <answer-card
      :lang="lang"
      :core="answerCardCore"
      :result-id="answerCardResultId"
      :channel-setting="{
        defaultLimitTimeAnswer: false,
      }"
    />
  </el-dialog>
</template>

<script>
import AnswerCard from '@polyv/interactions-launch-sdk-ui-default/lib/AnswerCard';
import * as InteractionsLaunchSDK from '@polyv/interactions-launch-sdk';
// 弹窗组件可以选择其他 UI 库组件或自行开发,这里没有限制。
import { Dialog } from 'element-ui';

export default {
  components: {
    ElDialog: Dialog,
    AnswerCard,
  },
  data() {
    return {
      // 中英文设置 'zh_CN'/'en'
      lang: 'zh_CN',

      answerCardCore: null,
      answerCardVisible: false,
      // 需要显示答题卡结果的题目 id
      answerCardResultId: '',
    };
  },
  mounted() {
    // TODO: 关于初始化 InteractionsLaunchSDK 的其他设置
    this.answerCardCore = new InteractionsLaunchSDK.AnswerCard();
    this.answerCardCore.on('show-result', ({ questionId }) => {
      this.answerCardVisible = true;
      this.answerCardResultId = questionId;
    });
  }
}
</script>

Attributes

Attribute Type Default Description
core object null AnswerCard SDK instance
lang string 'zh_CN' Language pack type. Possible values:
'zh_CN' Chinese
'en' English
canStart boolean true Whether the interaction can be initiated currently.
cantStartTips string '当前不可以发起互动' Prompt text when clicking the start button if the interaction cannot be initiated.
resultId string '' AnswerCard ID for which results need to be displayed.
channelSetting object { defaultLimitTimeAnswer: false, answerContentBlankEnabled: false,} Channel custom settings. See ChannelSetting for type definition.
showLog boolean false Whether to display the log tab.

ChannelSetting Object Description

Attribute Type Default Description
defaultLimitTimeAnswer boolean false Sets whether to enable timed answering by default. When enabled, you can set the duration for timed answer cards, and the answer card will automatically stop after the countdown ends.
answerContentBlankEnabled boolean false Sets whether the question stem and option content of the answer card can be empty.
联系客服,在线咨询
在线咨询