en un clic
ai-html-validator
// Keeping the AI question generation HTML validator in sync with element implementations.
// Keeping the AI question generation HTML validator in sync with element implementations.
Conventions for writing tRPC routers and procedures in PrairieLearn.
Backwards compatibility rules when changing element controllers in `apps/prairielearn/elements/`.
Write end-to-end browser tests using Playwright.
Dealing with groups and teams in PrairieLearn, and confusion about table/column/variable names.
| name | ai-html-validator |
| description | Keeping the AI question generation HTML validator in sync with element implementations. |
The AI question generation feature validates LLM output against a hand-written allowlist of elements and attributes at apps/prairielearn/src/ee/lib/validateHTML.ts. The validator is independent of each element's Python implementation; it does not introspect pl.check_attribs(...), optional_attribs, or required_attribs. Only elements in SUPPORTED_ELEMENTS (top of validateHTML.ts) are exposed to AI generation — changes to other elements need no validator update.
When a PR changes the generated HTML contract for an element in SUPPORTED_ELEMENTS, flag it unless these stay in sync:
apps/prairielearn/elements/<element>/<element>.py (and/or info.json) — the element's source-of-truth attribute set.apps/prairielearn/src/ee/lib/validateHTML.ts — the element's validation logic.docs/elements/<element>.md — the Attribute | Type | Default | Description table, which apps/prairielearn/src/ee/lib/context-parsers/documentation.ts parses to build the AI prompt context.Do not require all three for unrelated controller internals, prose-only documentation edits, example updates, or validator refactors that do not change the accepted/generated HTML contract.
For each kind of contract change in the element's Python file, the corresponding update in validateHTML.ts: