@ecl/quiz

中文文档
5.4.1发布于 2026/11/10EUPL-1.2ESM + CJS近 30 天下载 2816

ECL Quiz

原始使用文档

ECL Quiz component

npm package: @ecl/quiz

npm install --save @ecl/quiz

Parameters

  • "id" (string) (default: random) Unique id for the quiz
  • "variant" (string) (default: 'reveal') Quiz variant; can be 'reveal', 'poll'
  • "with_background" (boolean) (default: false) Use a background color
  • "full_width" (boolean) (default: false) Full width layout
  • "title" (string) (default: '') Quiz title
  • "description" (string) (default: '') Quiz description text
  • "prev_label" (string) (default: '') Label for the previous button
  • "next_label" (string) (default: '') Label for the next button
  • "skip_text" (string) (default: 'Use ESC to skip the quiz') Keyboard skip hint
  • "items" (array) (default: []) Quiz cards; format:
    • "id" (string) (default: random) Unique id for the card
    • "variant" (string) (default: 'reveal') Card variant; can be 'reveal', 'poll'
    • "question" (string) (default: '') Question text
    • "image_display" (string) (default: 'none'): With image, on both side or only in the back (None, Reveal, Always)
    • "picture" (oject) (default: {}) Ecl Picture object
    • "answer" (string) (default: '') Answer text shown on the back of the card
    • "answer_title" (string) (default: '') Title on the back of the card
    • "correct_label" (string) (default: '') Label for the correct answer indicator
    • "incorrect_label" (string) (default: '') Label for the incorrect answer indicator
    • "options" (array) Answer options (poll variant)
    • "icon" (object) Icon on the front of the card following ECL Icon structure
    • "flip_icon" (object) Icon on the flip button following ECL Icon structure
    • "flip_text" (string) (default: '') Flip button helper text (reveal variant)
    • "back_icon" (object) Icon on the back of the card following ECL Icon structure
    • "back_text" (string) (default: '') Text on the back of the card
    • "extra_classes" (string) (default: '') Extra classes for the card
    • "extra_attributes" (array) (default: []) Extra attributes for the card
  • "extra_classes" (string) (default: '') Extra classes (space separated)
  • "extra_attributes" (array) (default: []) Extra attributes
    • "name" (string) Attribute name, eg. 'data-test'
    • "value" (string) Attribute value, eg: 'data-test-1'

Example:

{% include '@ecl/quiz/quiz.html.twig' with {
    title: "Ut enim ad minim veniam ",
    description: "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \n    Excepteur sint occaecat cupidatat non proident, sunt.",
    next_label: "Next",
    prev_label: "Previous",
    items: [
      {
        question: "When you travel in the EU, what happens to yor roaming charges?",
        answer: "You usually pay the same at home, no extra roaming fees.",
        icon: {
          icon: {
            name: "sparkle",
            family: "phosphor",
            size: "xl"
          }
        },
        back_text: "Go back",
        flip_text: "Click to reveal",
        flip_icon: {
          icon: {
            name: "arrow-clockwise",
            family: "phosphor",
            size: "m"
          }
        }
      },
      ...
    ],
    with_background: false
  },
}
 %}

版本与发布记录

@ecl/quiz 共发布 15 个版本,首次发布于 2026/04/23;过去 12 个月发布了 15 个版本。

版本发布日期距今
5.4.1latest2026/11/103 天前
5.4.02026/10/2222 天前
5.3.22026/10/081 个月前
5.3.12026/09/211 个月前
5.3.02026/09/151 个月前
5.2.22026/09/082 个月前

关于 @ecl/quiz 的常见问题

@ecl/quiz 是什么?

ECL Quiz

如何安装 @ecl/quiz?

在项目目录运行 npm install @ecl/quiz,或使用 pnpm add / yarn add / bun add。

@ecl/quiz 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ecl__quiz 是否存在。

@ecl/quiz 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ecl/quiz 可以商用吗?

@ecl/quiz 使用 EUPL-1.2 许可。声明的许可为 EUPL-1.2,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@ecl/quiz 的下载量有多少?

根据 npm 官方下载统计,@ecl/quiz 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,816 次,日均约 94 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ecl/quiz 还在维护吗?

最新版本 5.4.1 发布于 2026/11/10(3 天前);至今共发布 15 个版本,其中过去 12 个月发布了 15 个;首次发布于 2026/04/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。