Receive quiz progress and results from an embedded fall risk quiz.
Embed the quizUrl returned by Create an assessment.
Add noAutoNav=true when the parent application owns navigation:
<iframe
id="fallRiskQuizIframe"
title="Fall risk quiz"
src="https://your-client.gofa.app/fall-risk/result-id/quiz?noAutoNav=true"
allow="camera"
></iframe>Messages have this shape:
{
"source": "gofa-quiz",
"type": "RESULTS_SET",
"payload": { "ageGroup": "70to79" }
}type | Payload | Meaning |
|---|---|---|
STATE_TRANSITION | Current state and step state | The quiz moved between steps. |
QUIZ_STARTED | Step and state | The participant started the quiz. |
QUIZ_ENDED | Final step and state | The quiz completed. |
RESULTS_SET | Quiz result state, including answers and derived ageGroup when available | Results were set in the flow. |
The current page sends source: "gofa-quiz" and uses a wildcard target origin.
Validate the sender in the parent:
const iframe = document.getElementById("fallRiskQuizIframe") as HTMLIFrameElement | null;
const expectedOrigin = "https://your-client.gofa.app";
window.addEventListener("message", (event) => {
const { source, type, payload } = event.data ?? {};
if (
event.origin !== expectedOrigin ||
event.source !== iframe?.contentWindow ||
source !== "gofa-quiz"
) return;
if (type === "QUIZ_ENDED") {
// noAutoNav=true leaves the next navigation to the host application.
}
if (type === "RESULTS_SET") {
// Treat payload as health data and persist only through your controlled path.
}
});Without noAutoNav=true, the page automatically navigates to the result view
after completion. With it, handle the next step after QUIZ_ENDED yourself.
Always validate event.origin, event.source, source, and the payload before
using a message. Do not log full quiz answers.