{
  "license": "CC BY 4.0",
  "licenseUrl": "https://creativecommons.org/licenses/by/4.0/",
  "recipe": {
    "slug": "prototype-event-funnel",
    "title": "Count recorded steps in a student prototype",
    "testedWith": "Apache DataFusion 45.2.0",
    "lastReviewed": "2026-09-29"
  },
  "contract": {
    "tableName": "prototype_events",
    "schema": [
      {
        "name": "trial_id",
        "type": "Utf8",
        "description": "Fictional attempt identifier, not a student or person ID."
      },
      {
        "name": "event",
        "type": "Utf8",
        "description": "One recorded step in the toy practice-question flow."
      }
    ]
  },
  "query": "SELECT\n  COUNT(DISTINCT CASE WHEN event = 'flow_started' THEN trial_id END) AS started,\n  COUNT(DISTINCT CASE WHEN event = 'question_opened' THEN trial_id END) AS opened,\n  COUNT(DISTINCT CASE WHEN event = 'answer_submitted' THEN trial_id END) AS submitted\nFROM prototype_events;",
  "fixtureKind": "reproducible",
  "inputRows": [
    {
      "trial_id": "toy-01",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-01",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-01",
      "event": "answer_submitted"
    },
    {
      "trial_id": "toy-02",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-02",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-02",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-02",
      "event": "answer_submitted"
    },
    {
      "trial_id": "toy-03",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-03",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-04",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-04",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-04",
      "event": "answer_submitted"
    },
    {
      "trial_id": "toy-05",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-05",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-06",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-07",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-07",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-08",
      "event": "flow_started"
    }
  ],
  "illustrativeInputRows": [
    {
      "trial_id": "toy-01",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-01",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-01",
      "event": "answer_submitted"
    },
    {
      "trial_id": "toy-02",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-02",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-02",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-02",
      "event": "answer_submitted"
    },
    {
      "trial_id": "toy-03",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-03",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-04",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-04",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-04",
      "event": "answer_submitted"
    },
    {
      "trial_id": "toy-05",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-05",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-06",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-07",
      "event": "flow_started"
    },
    {
      "trial_id": "toy-07",
      "event": "question_opened"
    },
    {
      "trial_id": "toy-08",
      "event": "flow_started"
    }
  ],
  "expectedOutput": {
    "columns": [
      "started",
      "opened",
      "submitted"
    ],
    "rows": [
      {
        "started": 8,
        "opened": 6,
        "submitted": 3
      }
    ]
  },
  "notes": [
    "The included synthetic input rows generate the expected output when timestamps are shifted into the documented query window.",
    "Run this fixture in the public browser SQL playground; the selected query executes locally with DuckDB-Wasm.",
    "Adapt time windows, thresholds, identities, and business definitions before operational use."
  ]
}