← Learnosity Build AideCONTENT HISTORY
WHAT CHANGED
Update to Learnosity Build Aide
Snapshot Nov 25, 2026 · 07:29 UTC · version 1.1.0
Collection source: downloaded plugin package.
First saved snapshot
No earlier snapshot is available to establish a change.
Save Learnosity Build Aide and check future changes in Following.
Up to 3 plugins free · no card required.
Compare saved observations
Download comparison JSONFull technical diff · 0 changed fields
Full snapshot data
{
"description": "Guide a developer from the custom-questions-skeleton repo to a custom Question or Feature that is authored in Author API and rendered in Items API — choosing between a Question and a Feature, sequencing the module, scorer, authoring schema, hosting and delivery steps, and catching the failures that report nothing.",
"included_files": [],
"name": "build-custom-questions-and-features",
"skill_md_contents": "---\nname: build-custom-questions-and-features\ndescription: Guide a developer from the custom-questions-skeleton repo to a custom Question or Feature that is authored in Author API and rendered in Items API — choosing between a Question and a Feature, sequencing the module, scorer, authoring schema, hosting and delivery steps, and catching the failures that report nothing.\n---\n\n# Build Custom Questions and Features\n\n**Goal:** Take a developer from the `custom-questions-skeleton` repo to a custom Question or Feature that authors create\nin Author API and learners see in Items API. The skill sets the order of the work, the decision between a Question and\na Feature, and the failure modes between those steps.\n\n**APIs:** `author-api`, `items-api`, `questions-api` (the module contract and the skeleton's local `assessment.php`\nharness are Questions API; production delivery goes through Items API, and authoring goes through Author API's\nQuestion Editor dependency).\n\n## When to use this skill\n\n- **Building** a new custom Question type or custom Feature type from the skeleton.\n- **Debugging** a custom type that does not render, does not save, scores locally but not on the server, or does not\n appear as an authoring tile.\n- **Reviewing** a custom type before its asset URLs are saved into an item bank.\n- **Publishing** a working local build to a host that Learnosity and learners can reach.\n\nWhen a requirement falls outside what the articles, demos and skeleton below describe, say that no documented approach\nwas found, point at the closest documented option in the reference tables, and do not invent an API, event or init\noption to fill the gap.\n\nBuilding a custom type is a lower-level use case by nature. When `search_docs_sources` withholds Questions API or\nQuestion Editor API hits, repeat the search with `off_golden_path_reason` set to the custom type being built.\n\n## Preconditions\n\n- Node.js and Yarn are on the path, at versions satisfying the `engines` field in the repo root `package.json`; a\n version below that range makes `yarn install` fail outright rather than warn. The custom type itself is JavaScript,\n CSS and HTML served as static files; none of it runs on the integrator's backend.\n- The backend language is the integrator's choice. Its only role is signing the Author API and Items API requests in\n Steps 8 and 9, which any Learnosity SDK language, or a hand-rolled signature, can do. The PHP in the skeleton and\n demos is local harness scaffolding: port what it shows into the integration's own language instead of adding PHP.\n- PHP CLI is needed only to run that harness. Each demo's `yarn dev` starts `php -S localhost:12345` alongside\n `webpack watch`, and the harness signs with the PHP SDK committed under `demos/vendor`. On recent PHP the committed\n SDK prints `Deprecated:` notices at the top of the harness page; they are harmless and not a build failure.\n- The custom files are hosted by the integrator. Learnosity loads them from the URLs in the Question or Feature JSON on\n every render, and fetches the scorer for server-side scoring, so those URLs must be reachable from the internet.\n- The target delivery is online. Custom Questions and Features are not available in offline app mode or Local Device\n Assessment.\n- Signed Author API and Items API requests already work in the integration, or will be added with\n `generate-and-troubleshoot-request-signatures`. The skeleton's `config.php` signs with a shared demo consumer that\n is only for the local harness.\n\n## Sequence\n\n### Step 1: Choose a Question or a Feature\n\n| Build a | When the component | Skeleton folder | JSON `type` | Id attribute | Scorer |\n| --- | --- | --- | --- | --- | --- |\n| Custom Question | captures a learner response that is saved, and optionally scored | `demos/custom-question-skeleton` | `custom` | `response_id` | optional |\n| Custom Feature | is interactive or decorative but captures no response (a tool, a viewer, a passage) | `demos/custom-feature-skeleton` | `customfeature` | `feature_id` | none |\n\nA Feature has no `changed`, `validate`, scoring or validation UI. If any learner input must reach a report or a score,\nbuild a Question. Steps 4 and 5 mark the parts that apply to Questions only.\n\nProduces: the skeleton folder used in every later step.\n\n### Step 2: Start from the skeleton\n\nClone or fork `https://github.com/Learnosity/custom-questions-skeleton`, copy the chosen skeleton folder and rename it\nafter the custom type. Set a unique `name` in\nthe copy's `package.json` as well: the repo root declares `demos/*` as Yarn workspaces, and the `yarn install` that\nstarts both `yarn dev` and `yarn prod` fails with `There are more than one workspace with name` while two workspaces\nshare one. Run `yarn dev` from inside that folder, not from the repo root: the root `yarn dev` runs every demo through\n`turbo`, and every demo binds port `12345`.\n\nThe local pages are `http://localhost:12345/assessment.php` (Questions API harness) and\n`http://localhost:12345/authoring.php` (Author API in `item_edit` mode). Both read the JSON files in the folder, so\nneither needs editing. The Question harness shows Save, then Resume and Review once the save succeeds; the Feature\nharness hides Save and Resume and offers Review directly.\n\nConsider running the harness in a container (an image with PHP CLI, Node.js and Yarn, the folder mounted, port `12345`\npublished) so the harness's PHP and Node versions stay off the host and are the same for every developer. The\nskeleton ships no container definition. `yarn dev` binds `php -S` to `localhost`, which inside a container is the\ncontainer's own loopback: override the bind address to `0.0.0.0` in the container, and keep browsing\n`http://localhost:12345` on the host so the pages load from the same origin as outside a container.\n\nProduces: a running local harness that rebuilds `dist/` on save.\n\n### Step 3: Define the JSON contract (`questions-api`)\n\nEdit `question.json` or `feature.json`. This is the object Questions API receives and, for a Question, the object the\nscorer receives on the server.\n\n- Every value the module or scorer needs must be in this JSON at initialization. Attributes added to the object after\n initialization are ignored server-side.\n- Reuse native attributes (`stimulus`, `validation`, `instant_feedback`, `metadata` and others) with their native\n names and shapes instead of inventing equivalents. Their handling by the platform differs per attribute; the\n Creating Custom Questions article lists which are managed and which the module must render.\n- Use snake_case for custom attributes and avoid `type`, `custom_type`, `js`, `css` and `version`.\n- Server-side scoring depends on a valid response being present in the initialization JSON. The Creating Custom\n Questions attribute table names a top-level `valid_response`; the skeleton's `question.json` carries it as\n `validation.valid_response`. Confirm which shape the build in use scores with the Data API scoring check (Runtime\n checks) before authoring content around either.\n\nProduces: the attribute set that Steps 4, 5 and 6 read and expose.\n\n### Step 4: Render the module and signal ready (`questions-api`)\n\nWork in `src/question/index.js` or `src/feature/index.js`. The entry files (`src/question.js`, `src/scorer.js`,\n`src/feature.js`) wrap the classes in `LearnosityAmd.define` and return `{ Question }`, `{ Scorer }` or `{ Feature }`;\nkeep that shape.\n\nBoth kinds:\n\n- Render into `init.$el`, then trigger `ready`. Without `ready` within the allowed time, Questions API raises an\n error for the component.\n- Render only the module's own attributes into `init.$el`. The platform renders `stimulus` and `instructor_stimulus`\n itself, outside the response area, so rendering `stimulus` in the module too produces a duplicate prompt. Confirm\n which attributes the surface in use renders with the attribute-rendering check (Runtime checks) before rendering any\n native attribute.\n- Implement `facade.disable()`. The skeletons call it in `review` state.\n- Prefix every CSS class (the skeleton's `PREFIX` constant) and style in `scss/`.\n- For external libraries or services, retry a failed load up to three times with a short delay, then show a message\n in the component or stop the assessment, per the error-handling article.\n\nQuestions only:\n\n- Trigger `changed` with the response value whenever the learner changes it. The value may be any serializable type;\n it becomes `response` in the scorer.\n- Register the `validate` handler before triggering `ready`. It fires in every state, so it is the place to show\n validation UI and, when `options.showCorrectAnswers` is set, correct answers.\n- In `resume` and `review` states, restore the UI from `init.response`. Review state is what Reports API's item-level\n reports display.\n- Use the `lrnUtils` components and Learnosity's validation classes rather than rebuilding Check Answer, suggested\n answers or correct/incorrect styling; the Creating Custom Questions article and the skeleton README list them.\n\nProduces: a component that renders, saves and reloads in all three states of the local harness.\n\n### Step 5: Implement and verify the scorer (`questions-api`)\n\nQuestions only. Implement the scorer interface stubbed in `src/scorer/index.js`; the Creating Custom Questions article\ndefines each method. The scorer runs on Learnosity's servers as well as in the browser, so it must not touch the DOM or\nimport UI libraries.\n\n- Omitting `js.scorer` disables autoscoring.\n- Code defensively. Learnosity logs only uncaught server-side scorer exceptions; an error the scorer catches is\n invisible unless the integrator logs it to their own service. Do not write error details into the response value.\n- Verify locally with `yarn debug-server-scorer` after editing the question and response in `debugServerScorer.js`. It\n loads `./dist/scorer.js`, so a build must exist.\n- Verify server-side parity with the Data API scoring check before Step 8.\n\nProduces: a scorer whose server-side result matches the browser's.\n\n### Step 6: Define the authoring schema and layout (`author-api`)\n\nEdit `question_editor_init_options.json` and `authoring_custom_layout.html`; check the result at `authoring.php`.\n\n- Register the type in `custom_question_types` or `custom_feature_types`, with a `custom_type`, `editor_schema`,\n `editor_layout`, `js`, `css` and `version`.\n- Add a `question_type_templates` entry whose key equals `custom_type`. It is the tile authors pick, and its\n `defaults` become the JSON of every new instance, including `js` and `css`.\n- Define authorable attributes in `editor_schema.attributes`. Schema types, validation, conditional attributes and\n limits are in the authoring article; layout hooks and utility components are in the editor layout articles.\n- Author API passes these options to Question Editor as `config.dependencies.question_editor_api.init_options`, which\n is exactly what `authoring.php` does.\n\nProduces: `custom_type`, and a tile that creates a valid instance.\n\n### Step 7: Build and host the assets\n\nRun `yarn prod`. Host the contents of `dist/` (`question.js`, `scorer.js`, `question.css` or `feature.js`,\n`feature.css`, plus `authoring_custom_layout.html`) on a server Learnosity and learners can reach, with CORS headers if\nthe host requires them.\n\nDecide how the URLs are addressed before any content is authored, because Step 8 saves them into every instance:\n\n| Option | Cost |\n| --- | --- |\n| Console Custom Questions proxy | One more Console object to manage; the hosted files can move by updating the proxy, without editing saved content |\n| Direct URL to the host | Nothing to set up; moving or renaming the files later means updating every saved Question or Feature |\n\nReplace every `/dist/...` path in `custom_question_types` / `custom_feature_types` and in the template `defaults`\nwith the chosen URLs. To test the production build locally first, point `question.json` or `feature.json` at the same\nURLs and reload `assessment.php`.\n\nProduces: `asset_urls`.\n\n### Step 8: Author items in the integration (`author-api`)\n\nIn the integration's own server-side Author API request, in the backend's language, pass the Step 6 init options with\nthe Step 7 URLs under `config.dependencies.question_editor_api.init_options`, and sign the request per\n`generate-and-troubleshoot-request-signatures`. The harness's `authoring.php` shows the request shape to port. Create an item from the custom tile, save it, and add it to an activity\nif delivery uses activities.\n\nProduces: `item_reference`, and an `activity_id` where used.\n\n### Step 9: Deliver in Items API (`items-api`)\n\nInitialize Items API with the item references or the activity, signed per\n`generate-and-troubleshoot-request-signatures`. Items carrying custom types need no other Items API configuration;\nthey render, save and score through the same session flow as native types, and Reports and analytics read them\nwithout extra work.\n\n- Values the component needs from the host page at runtime, such as an auth token, go in\n `config.questions_api_init_options.custom_widget_options` and are read in the module with\n `init.getCustomWidgetOptions(key)`. Agree the key with whoever initializes Items API.\n\nProduces: a learner session containing the custom Question or Feature.\n\n## Shared identifiers\n\n| Name | Produced by step | Consumed by step(s) | Description |\n| --- | --- | --- | --- |\n| `custom_type` | 6 | 8 | Unique id of the custom type; the `question_type_templates` key must equal it |\n| `asset_urls` | 7 | 8, 9 | Externally reachable `js`, `css` and `editor_layout` URLs, saved into every authored instance |\n| `item_reference` | 8 | 9 | An item saved with the custom Question or Feature, loaded by Items API directly or through an activity |\n\n## Failure modes\n\n### Local harness (Steps 2–5)\n\n| Condition | Result |\n| --- | --- |\n| `yarn dev` run from the repo root | Every demo starts and contends for port `12345`; the page served may not be the one being edited |\n| Harness run in a container with `php -S` still bound to `localhost` | The published port refuses connections from the host |\n| PHP CLI missing | `webpack watch` still builds `dist/`, but the harness at `localhost:12345` serves nothing |\n| `ready` never triggered, or triggered before an awaited render settles | Questions API raises a timeout error for the component |\n| `validate` handler registered after `ready` | Outside the required order; Check Answer can produce no validation UI |\n| `stimulus` rendered by the module | The platform also renders it, so the prompt appears twice; no error |\n| `changed` not triggered | The UI updates but `getResponses()` holds nothing and the attempt is unscored |\n| `init.response` not restored in `resume` / `review` | The saved response exists but the UI shows a blank component |\n| Reload for `resume` / `review` not carrying the saved `session_id`, or deriving a different `response_id` from it | Questions API initializes with no `init.response`, so the component loads blank though the save succeeded |\n| `user_id` placed in the request object instead of the security packet | `ValidationException` at init; the skeleton's `config.php` signs it into the packet, so a hand-rolled harness hits this where the skeleton does not |\n| `yarn debug-server-scorer` before any build | Node cannot find `./dist/scorer.js` |\n| `yarn debug-server-scorer` in a Feature project | The script is declared but `debugServerScorer.js` does not exist; Features have no scorer |\n\n### Scoring (Steps 3, 5)\n\n| Condition | Result |\n| --- | --- |\n| Valid response missing from the initialization JSON, or in a shape the build does not score | Browser scoring may work while server-side scoring is not triggered |\n| Scorer reads an attribute added after initialization | Correct in the browser, wrong or `null` on the server |\n| Scorer touches `window`, `document` or a UI library | Works in the browser, fails on the server |\n| Scorer catches its own exception | No entry in Learnosity's server-side log; only the integrator's own logging records it |\n| Scorer URL relative or on `localhost` | Not reachable from Learnosity's servers, so server-side scoring cannot run |\n\n### Authoring and hosting (Steps 6–8)\n\n| Condition | Result |\n| --- | --- |\n| Template key differs from `custom_type` | The tile is not associated with the custom type's schema and layout |\n| Template `defaults` still hold `/dist/...` URLs | New instances are saved with paths that only resolve on the dev host |\n| Custom attribute named `type`, `js`, `css`, `version` or `custom_type` | Collides with a reserved attribute |\n| Assets moved without a Console proxy | Every saved instance still points at the old URLs and fails to load |\n| Host rejects cross-origin requests | Assets fail to load in Author or Items API; visible only as network errors |\n\n## Runtime checks\n\n| Question | Check |\n| --- | --- |\n| Which content attributes does the surface render itself? | Render with the module rendering none of them, and inspect the DOM: a platform-rendered `stimulus` sits in `.lrn_stimulus` outside `.lrn_response`. A prompt that appears only when the module renders it is the module's to render |\n| What response shape does the Question save? | `questionsApp.getResponses()` in the `assessment.php` console; in Items API, `itemsApp.getResponses()` |\n| Does the browser scorer agree with the intended score? | `questionsApp.getScores()` locally, `itemsApp.getScores()` in delivery |\n| Does the server-side scorer produce the same score? | Run the Data API scoring check from Creating Custom Questions with the Question JSON and saved response; `data[].score` and `data[].max_score` must be non-null and match the browser |\n| Is the scorer loadable without a DOM? | `yarn debug-server-scorer`; the second `score:` line it prints is `maxScore()` |\n| Is the component instance alive and exposing the facade? | `questionsApp.question('<response_id>')` or `questionsApp.feature('<feature_id>')`; `itemsApp.question(...)` / `itemsApp.feature(...)` in delivery |\n| Did Questions API report an error for the component? | The `errorListener` output in the `assessment.php` console |\n| Are the saved asset URLs the hosted ones? | Open the item's Question or Feature JSON in Author API's source view and inspect `js`, `css` |\n| Are the assets reachable from outside the dev machine? | Request each `asset_urls` entry from a host other than the dev machine and check status and CORS headers |\n\n## Reference lookups\n\n| Topic | `source` | `article_id` |\n| --- | --- | --- |\n| Overview, file roles, hosting responsibility, the documented task order, offline caveat | `help_site` | `4414363148561` |\n| Question JSON attributes, `init` and `lrnUtils`, events, states, scorer interface, Data API scoring check | `help_site` | `360000758817` |\n| Feature module, `init` object, `ready` | `help_site` | `360000755458` |\n| `editor_schema`, attribute types, limitations, `custom_type` and tile templates | `help_site` | `360000755098` |\n| Retry, scorer logging and learner-facing error messages | `help_site` | `23833436280861` |\n| Skeleton repo: demo list, scripts, publishing, Learnosity components and validation classes | `github` | `14454712979836724549` |\n| Question skeleton key files and scripts | `github` | `16016163686799668705` |\n| Feature skeleton key files and scripts | `github` | `17130591652527186733` |\n\n## Further reading\n\n| Topic | `source` | `article_id` |\n| --- | --- | --- |\n| `custom_question_types` properties | `help_site` | `16735211203997` |\n| `custom_feature_types` properties | `help_site` | `16735211226141` |\n| Custom Feature attributes | `help_site` | `16685276930717` |\n| Custom Question attributes in the Question types reference | `help_site` | `16684586288925` |\n| Editor layout hooks for a custom type | `help_site` | `360000755258` |\n| Utility components (tabs, accordion) for editor layouts | `help_site` | `360000755118` |\n| Author API `question_editor_api.init_options` | `help_site` | `16852477989405` |\n| Items API `custom_widget_options` | `help_site` | `16560458946461` |\n| Questions API `custom_widget_options` | `help_site` | `16760639142813` |\n| Data API scoring endpoint | `help_site` | `18356466181917` |\n| Console Custom Questions proxies | `help_site` | `360000756198` |\n| CORS and domain allowlisting for externally hosted files | `help_site` | `360000757877` |\n| Items API `getResponses` / `getScores` | `help_site` | `16461122550429`, `16461151401117` |\n| Authoring demo for a custom type with a dynamic schema | `github` | `17292536847172029062` |\n| Custom Feature authoring demo | `demos` | `128529369064418998` |\n| Question type templates demo | `demos` | `5539524231046138876` |\n\n## Related skills\n\n- `generate-and-troubleshoot-request-signatures` — signing the Author API and Items API requests in Steps 8 and 9, and\n resolving `4100x` rejections.\n- `golden-path-author-items-reports` — the Author, Items and Reports API flow that custom types slot into.\n- `install-and-set-up-the-sdk` — installing the server-side SDK used for signing, in the integration's language.\n- `customize-assessment-ui-regions` — the Items API player around the custom component.\n"
}SHA-256 of public snapshot: 5df3a310b9ed5af90389cf500c173cb084c95def6953eee240ffd88f1d5ca8f2