@pie-element/mc-populated-blank
v0.2.10
Published
Multiple-choice option populates an inline blank in a sentence template (Svelte 5 PIE element)
Maintainers
Keywords
Readme
@pie-element/mc-populated-blank
Svelte 5 PIE element where the learner picks a multiple-choice option and that choice fills a blank in a sentence/template.
This element is the PIE counterpart for Star Learnosity CQT "populated blank" interactions. The CQT family had several published custom_type flavors, but they are all variants of the same base interaction:
- one selected choice
- one correctness key
- selected choice rendered into a blank target
- optional audio/transcript support
What the original CQT flavors mean
The historical Learnosity CQT names mostly describe layout/stimulus differences, not different scoring logic:
sel_vic: sentence-style vocabulary in context, with audio/transcript supportsr-vic: sentence-style vocabulary in context, typically no audio buttonsel_r1-g_plusggg: lead token before blank (before_cloze_1) plus choice setsel_r1-_gplusggg: blank with a shorter/token-focused stem arrangementsel_r1-_plusggg: audio-first blank + choicessel_r1-gg_plusggg: token-sequence variant with larger glyph-like tokenssel_r1-_ggplusggg: blank appears before trailing tokens (after_cloze_*)sel_r1-s3_plusggg: stimulus-heavy variant (often image/sentence block + blank + choices)
The shared behavior across these flavors is now represented by one element with configuration, instead of one element per flavor.
Flavor to model mapping (quick defaults)
Use this as a practical starting point when mapping Learnosity CQT payloads into mc-populated-blank models.
| Learnosity custom_type | Typical layout meaning | Suggested interactionMode | Suggested choiceMode | Template hint |
| --- | --- | --- | --- | --- |
| sel_vic | sentence cloze with audio/transcript | populate_blank | text | <p>{before} {{blank}} {after}</p> |
| sr-vic | sentence cloze without listen button | populate_blank | text | <p>{before} {{blank}} {after}</p> |
| sel_r1-g_plusggg | lead token before blank | populate_blank | text | <p>{before_cloze_1} {{blank}}</p> |
| sel_r1-_gplusggg | short stem + blank | populate_blank | text | <p>{before/after segments around {{blank}}}</p> |
| sel_r1-_plusggg | audio-first blank + horizontal choices | populate_blank | text | <p>{{blank}}</p> |
| sel_r1-gg_plusggg | token-sequence style before blank | populate_blank | text | <p>{before_1}{before_2} {{blank}}</p> |
| sel_r1-_ggplusggg | blank before trailing tokens | populate_blank | text | <p>{{blank}} {after_1}{after_2}</p> |
| sel_r1-s3_plusggg | stimulus-heavy/image-first variant | populate_blank | text or image | include stimulus in prompt/sentenceHtml; keep single blank in template |
Notes:
choiceModeshould beimageonly when distractors are image choices; otherwise usetext.- Current model contract is single-blank for
populate_blank; dual-cloze source shapes are normalized to one{{blank}}. correctChoiceIdshould always map from Learnosityvalid_response.nameto canonicaldistractor_n.- Layout defaults are tuned from original CQT visual baselines, but they are not fixed: override through
model.layoutLimitswhen host/theme requirements differ.
Authoring model
prompt(optional) andpromptEnabledtemplate: HTML string containing exactly one literal{{blank}}tokeninteractionMode:populate_blank|audio_mc_onlychoiceMode:text|imagechoices:{ id, labelHtml? }or{ id, imageUrl, imageAlt }per modecorrectChoiceIdhasAudio,audioUrl,audioTranscript(audioUrlrequired whenhasAudio=true)autoplayAudioEnabled,completeAudioEnabled(optional integration flags)showVisibleTranscript(optional): profile-driven default; override when transcript should always show/hidelayoutLimits(optional): numeric visual constraints; defaults are based on current CQT parity behavior and can be overridden per itemlayoutProfilePresets(optional): named preset map bylayoutProfile; use profile as a template and override withlayoutLimitsaudioButtonSkin/audioButtonSkinsByLocale(optional): override listen-button skin URLsuiText(optional): override labels/messages (show/hide correct, answer choices, autoplay prompt, transcript label, missing-audio message)choiceGroupLabel(optional): accessibility label used when no visible prompt is present
layoutLimits keys (all optional, positive numbers)
blankStandaloneWidthRemblankWideWidthRemblankUnderlineWidthPxblankUnderlineWideWidthPxhorizontalChoiceWidthPxhorizontalChoiceWidthVwhorizontalChoiceTileMinHeightRemhorizontalChoiceContentMinHeightRemselectedImageMaxHeightRemchoiceImageMaxHeightRemlistenButtonSizePxstimulusMinColumnPxtextMinColumnPxlegendMaxCharschoiceGroupGapRemchoiceRowGapRemtoggleButtonGapRemhorizontalChoiceRadioTopMarginRemaudioBlankTemplateMarginTopRemaudioBlankTemplateMarginBottomRemaudioInstructionsMaxWidthPxnarrowHorizontalChoiceMaxWidthPxstimulusGridColumnGapRemstimulusGridRowGapRemstimulusSentenceMarginTopRemstimulusChoicesMarginTopRemtokenGridColumnGapRemtokenGridRowGapRemtokenTemplateMarginTopRemtokenInlineTokenGapRemtokenChoicesMarginTopReminlineGridColumnGapReminlineGridRowGapReminlineTemplateMarginTopReminlineChoicesMarginTopRem
Session
choiceId: selected choice id
Implementation hints
- Controller invariants: in
populate_blank, template must contain exactly one{{blank}}; inaudio_mc_only, template must not contain{{blank}}. - Choice normalization: choices are polymorphic by
choiceMode(text vialabelHtml, image viaimageUrl/imageAlt). - Delivery rendering: template is split around
{{blank}}; selected choice content is rendered into the blank slot. - Layout limits are model-driven: delivery reads
model.layoutLimits(blank widths/underline widths, choice tile sizing, image max heights, listen button size, layout column minimums); defaults are CQT-informed but overrideable. - Responsive parity controls:
audioInstructionsMaxWidthPxandnarrowHorizontalChoiceMaxWidthPxare explicitly configurable to tune desktop vs narrow-width CQT behavior. - Evaluate mode behavior: when evaluate/correct-answer mode is enabled, delivery can render
correctChoiceIdin the blank/choice state. - Audio error behavior: no TTS fallback is used; when
hasAudio=trueand no playableaudioUrlis provided, delivery shows an explicit error message (configurable viauiText.audioResourceUnavailable). - Prompt-off accessibility: when
promptis empty, delivery useschoiceGroupLabel(or fallback UI text) as the radiogroup accessible name. - Print parity: print view mirrors prompt/template/choice presentation with the same blank-token contract.
Theming hooks (pie-* classes)
Delivery now exposes stable pie-* classes so hosts can theme this element with the same class-oriented approach used by other PIE elements.
- Root/container:
pie-element,pie-element-mc-populated-blank,pie-delivery-root - Prompt/audio/template:
pie-prompt,pie-audio-container,pie-audio-player,pie-audio-transcript,pie-template-line,pie-sentence-line - Blank display:
pie-blank-slot,pie-blank-slot-standalone,pie-blank-value,pie-blank-image - Choice group:
pie-choices-fieldset,pie-choices-legend,pie-choices - Choice rows/items:
pie-choice,pie-choice-horizontal,pie-choice-selected,pie-choice-label,pie-choice-image - Choice controls:
pie-choice-radio,pie-choice-radio-inline,pie-choice-radio-bottom - Evaluate/toggle feedback:
pie-toggle-correct-answer,pie-result-feedback,pie-choice-feedback-correct,pie-choice-feedback-incorrect
Bundled CQT variant CSS
To avoid runtime dependency on cross-origin Learnosity stylesheet loading, this element bundles variant-specific CSS in delivery:
- Variant CSS files:
src/delivery/cqt-css/*.css - Variant mapping:
src/delivery/variant-css-map.ts - Applied by
model.customType(for examplesel_r1-_plusggg)
Each variant CSS file is intentionally scoped with .mc-populated-blank-root.variant-* selectors so styles only apply to this element instance and do not leak into other PIE elements.
Maintenance workflow
- Fetch the latest Learnosity
question.cssfor each supported CQT variant. - Update the matching file under
src/delivery/cqt-css/. - Keep the source URL comment at the top of each CSS file current.
- If a new
custom_typeis introduced, add it insrc/delivery/variant-css-map.tswith:variantIdvariantClasssourceUrl- imported
cssText
- Run
bun run buildin this package and validate the demo variants.
Builds
Same layout as @pie-element/simple-cloze: delivery, controller, author, print, plus IIFE bundle for script-tag loading.
bun run buildDemos
- element-demo:
apps/element-demo→/mc-populated-blank/deliver(sample configs undersrc/lib/samples/mc-populated-blank.json). - pie-players item-demos:
mc-populated-blank-synthetic-demos.json(generated from the same models as element-demo).
Architecture notes live in the aces-archdocs repo: docs/projects/itembankviewer/learnosity-cqt-to-pie.md (Star CQT → PIE alignment).
