Quiz Plugin
mp4e:quiz asks the viewer questions at the moments you choose: the video pauses, the viewer answers and sees why, and a summary ends with the score.
Overview
Quiz (mp4e:quiz, an official plugin) turns a video into a lesson with checkpoints. At each question's time the video pauses and a card shows the question with two to four answers. After an answer the card says Correct or Not quite, marks the right answer and shows your explanation, and Continue plays on. After the last question a summary shows the score, with every answer to review.
Quiz is a family plugin: it has the family's five themes, its common style settings, its minimum readable size and its keyboard and TV-remote navigation.
Adding a quiz to a video
- Install Quiz from the marketplace.
- Add one Quiz overlay covering the whole timeline. It covers the whole frame and places its own card, so do not resize it: pick Centre, Left or Right in
positioninstead. - Enter the questions.
- Pick a theme and a size. Lean-back is for a TV across the room.
- Put the Quiz overlay in your top layer (the highest layer order), so its card sits above your other panels while it waits for an answer.
The questions
questions is a list of questions in seconds of the video. It can also be JSON text, so a single {{listVariable}} can supply the whole list, and any text in a question may use a {{variable}}.
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | - | Names the question in the plugin's events and keeps the viewer's answer through edits. Optional, but without it the question is q1, q2… by its place in the list, which moves when a question is added or removed. |
time | number | - | The second of the video the question comes up at. Required, 0 or more. |
question | string | - | The question. Required. |
options | string[] | - | Two to four answers. Required. |
correct | number | - | The right answer, as its position in options counting from 0. Required. |
explanation | string | - | Why that answer is right, shown after the viewer answers. Optional. |
[
{ "id": "q1", "time": 62, "question": "Why do you rest the dough?",
"options": ["To cool it", "To relax the gluten", "To dry it out"], "correct": 1,
"explanation": "Resting lets the gluten relax, so the dough rolls out without shrinking." },
{ "id": "q2", "time": 148, "question": "How hot should the pan be?",
"options": ["Smoking", "Medium-high", "Barely warm", "Cold"], "correct": 1 }
]A question without text or a time, with fewer than two or more than four answers, or whose correct does not point at one of them is left out. Give every question an id: the viewer's answers and score are kept by id when you edit the questions or a variable changes them.
Settings
Quiz's own settings, plus the family's common style settings (theme, accent, size, surface, textColor, font, radius, motion):
| Prop | Type | Default | Description |
|---|---|---|---|
questions | Question[] | string | [] | The questions (shape below). |
title | string | 'Quiz' | Named above the score on the summary. |
position | 'center' | 'left' | 'right' | 'center' | Where the question card sits in the frame. On a phone-sized player it always spans the frame. |
pause | boolean | true | Stop the video while a question is up; Continue plays on. Off: the question shows over the playing video and closes by itself after answerTime. |
answerTime | number | 20 | Only with pause off: how many seconds of playback a card stays up without the viewer acting (at least 1). A question that runs out counts as skipped. A bar on the card shows the time left. |
retry | boolean | false | After a wrong answer the viewer may try once more before the right answer is shown. |
showSummary | boolean | true | After the last question, show the score with every answer to review. |
summaryAt | number | — | Show the summary when the video reaches this second instead of after the last question. |
persist | boolean | false | Remember a viewer's answers on the same device, so an answered question is not asked again on a later visit. Changing the questions starts fresh. |
How it behaves
- While the video plays every click goes through to the video, your hotspots and the player's controls.
- While a question or the summary is up the quiz takes the pointer and the keys: the arrows move between the answers, Enter answers and then continues, and Escape or Back skips the question. Skip leaves a question unanswered; so does pressing play.
- Space does not answer by accident. The first answer has the focus as a question opens, and Space is the usual play and pause key, so Space answers only once the viewer has moved between the answers with an arrow key or Tab. Enter, a click and a TV remote's OK always answer.
- The card sits above everything else while it is up — other overlays and the captions alike — whatever layer you put the quiz in, so nothing covers the answers or catches a tap meant for them. The caption shows again when the card closes.
- A question comes up when playback reaches its time. Seeking past a question does not ask it; seeking back before a question that was not answered asks it again. An answered question is never asked twice.
- Seeking or opening the player's menu while a card is up keeps the card and the pause.
- At the end of the video the summary (or a question placed in the last moment) still shows, and its Continue leaves the video at its end rather than starting it again.
- With
pauseoff the card shows over the playing video, and a bar on it runs down foranswerTimeseconds of playback; a viewer who pauses keeps the card. - A screen reader hears each question and each verdict as it appears.
- On a phone-sized player the card spans the frame and the answers go two by two. The card always stays clear of the player's controls bar.
Actions and events
Actions, through pluginAction from rules, other plugins and input shortcuts:
| Prop | Type | Default | Description |
|---|---|---|---|
start | — | - | Show the first question not yet answered now, wherever the video is (pausing a playing video when pause is on). With every question answered, show the summary. Answers { shown: "question", id }, { shown: "summary" } or { shown: null }. |
skip | — | - | Close the question on screen without answering it (or close the summary) and play on. Answers { skipped: id } or { skipped: null }. |
hide | — | - | Close what is on screen (playing on if the quiz paused the video) and ask nothing more until show. Questions passed meanwhile are asked again only after seeking back before them. Answers { hidden: true }. |
show | — | - | Undo hide: questions come up again when playback reaches them. Answers { shown: true }. |
reset | — | - | Forget every answer (also the remembered ones), close what is on screen and ask each question again when playback reaches it. Answers { reset: true }. |
{ "type": "pluginAction", "pluginId": "mp4e:quiz", "actionId": "start" }Quiz emits three events:
questionShown{ id }— a question came up: playback reached its time, orstartopened it. It never fires when the video loads or when the settings or a variable change.answered{ id, correct }— the viewer gave a question its final answer (withretryon, a first wrong pick is not final).completed{ score, total }— the quiz reached its end: after the last question, or atsummaryAt. Once, untilreset.
Rules hear them as plugin:mp4e:quiz:questionShown, plugin:mp4e:quiz:answered and plugin:mp4e:quiz:completed:
Trigger: plugin:mp4e:quiz:completed
Condition: eventData.score equals eventData.total
Action: showOverlay certificate-overlayYour page hears them through onEvent (see Player Events). Quiz keeps answers in the player only; saving a score is your application's job:
<MP4EPlayer
src="/video.mp4"
onEvent={(event, data) => {
if (event === 'plugin:emit' && data.event === 'completed') {
// { score, total }
saveScore(data.data.score, data.data.total);
}
}}
/>