pushword/quiz
最新稳定版本:1.0.0-rc672
Composer 安装命令:
composer require pushword/quiz
包简介
Interactive client-side quizzes (QCM) for Pushword: a {{ quiz(...) }} Twig block, an EditorJS editor, anonymous percentile stats and an optional end-of-quiz conversion form.
README 文档
README
Interactive, (almost) server-less quizzes (QCM) for Pushword.
{{ quiz('…json…') }}Twig block — declare a quiz inline in a page. The payload is a JSON string (not a Twig hash) on purpose: Twig can never choke on its structure, so a malformed quiz degrades gracefully (admins see a detailed error panel, visitors see nothing) instead of 500-ing the page.- EditorJS block — add/remove questions and answers, flag the correct answer(s), attach an image or a video, write the explanation.
- Progressive enhancement — the full quiz is rendered server-side as a
readable, schema.org-tagged Q&A (great for SEO and no-JS);
quiz.jsturns it into a one-question-at-a-time game with immediate feedback and a score donut. - Anonymous percentile —
POST /quiz/resultstores a score (no PII) and returns "better than X% of participants". - Conversion form — set
ctato apushword/conversationform type to show a lead form at the end (pre-filled from a localStorage identity). Optional soft dependency. POST /api/quiz/validate— token-authenticated endpoint (for AI agents) that validates a quiz payload and returns precise{path, message}violations.
Quiz JSON shape
{
"title": "Montagnes du monde",
"difficulty": "Facile",
"feedback": "immediate",
"cta": "newsletter",
"questions": [
{
"q": "Quel est le plus haut sommet du monde ?",
"media": "everest.jpg",
"alt": "Le mont Everest",
"answers": [
{ "a": "Mont Blanc" },
{ "a": "Everest", "correct": true },
{ "a": "K2" }
],
"explanation": "Le mont Everest culmine à 8 849 mètres."
}
],
"results": [
{ "min": 0, "msg": "À retravailler !" },
{ "min": 80, "msg": "Bravo !" }
]
}
A question may carry an image (media) or a video (video); a video reuses
the media image as its poster, so both media and an alt (accessibility)
are required for one. The single source of truth for validity is the Quiz
model + Symfony Validator, shared by the renderer, the editor lint and the API
endpoint.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-10