Polyv Help Center

Help Center

Lottery

Updated: 2021-10-14 17:47:17

Feature Overview

Allows configuration of prizes, number of winners, and winner selection before the lottery begins. Once configured, the lottery can be started, and after it ends, results such as the winners can be viewed.

  • Only the roles of lecturer, guest, teaching assistant, and administrator are supported to initiate and stop the lottery.
  • Supports custom configuration of information collection fields for winners.
  • Supports setting preset winners.

Code Example

Note: Before starting the following steps, global initialization must be performed. Refer to the documentation.

Basic Flow

const app = new Lottery();

// 订阅事件监听。
app
  .on('LotteryStart', () => {})
  .on('LotteryEnd', () => {})
  // UpdateInLottery 会更新 app.InLottery 最新抽奖状态
  .on('UpdateInLottery', () => {});

// 开始抽奖前
// 获取可参与抽奖的在线人数
app.checkedUserCount(lotteryRange);
// 获取中奖人信息收集配置
app.getCollectInfo();

// 发起抽奖。当抽奖状态变化后会触发 `updateInLottery` 事件,更新抽奖状态。
app.createLottery(createOptions);

// 结束抽奖。
app.endLottery(lotteryId);
// 获取中奖名单
app.getWinnersList(page, lotteryId);
联系客服,在线咨询