@qti-components/test 1.8.0 → 1.10.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.d.ts +4 -0
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +16 -28
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -1
- package/dist/components/qti-assessment-test/qti-assessment-test.d.ts +5 -0
- package/dist/components/qti-assessment-test/qti-assessment-test.js +2 -5
- package/dist/components/qti-assessment-test/qti-assessment-test.js.map +1 -1
- package/dist/components/qti-number-selected/qti-number-selected.js +2 -1
- package/dist/components/qti-number-selected/qti-number-selected.js.map +1 -1
- package/dist/components/qti-test/qti-test.d.ts +16 -2
- package/dist/components/qti-test/qti-test.js +33 -6
- package/dist/components/qti-test/qti-test.js.map +1 -1
- package/dist/components/qti-test-variables/qti-test-variables.js +2 -1
- package/dist/components/qti-test-variables/qti-test-variables.js.map +1 -1
- package/dist/components/test-check-item/test-check-item.d.ts +2 -0
- package/dist/components/test-check-item/test-check-item.js +16 -3
- package/dist/components/test-check-item/test-check-item.js.map +1 -1
- package/dist/components/test-container/test-container.d.ts +3 -0
- package/dist/components/test-container/test-container.js +5 -1
- package/dist/components/test-container/test-container.js.map +1 -1
- package/dist/components/test-end-attempt/test-end-attempt.js +2 -1
- package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
- package/dist/components/test-item-link/test-item-link.js +2 -8
- package/dist/components/test-item-link/test-item-link.js.map +1 -1
- package/dist/components/test-item-to-speech/test-item-to-speech.d.ts +61 -15
- package/dist/components/test-item-to-speech/test-item-to-speech.js +287 -103
- package/dist/components/test-item-to-speech/test-item-to-speech.js.map +1 -1
- package/dist/components/test-navigation/test-navigation.d.ts +9 -9
- package/dist/components/test-navigation/test-navigation.js +68 -21
- package/dist/components/test-navigation/test-navigation.js.map +1 -1
- package/dist/components/test-next/test-next.js +2 -8
- package/dist/components/test-next/test-next.js.map +1 -1
- package/dist/components/test-prev/test-prev.js +2 -8
- package/dist/components/test-prev/test-prev.js.map +1 -1
- package/dist/components/test-scoring-buttons/test-scoring-buttons.d.ts +1 -1
- package/dist/components/test-scoring-buttons/test-scoring-buttons.js +6 -8
- package/dist/components/test-scoring-buttons/test-scoring-buttons.js.map +1 -1
- package/dist/components/test-section-link/test-section-link.js +2 -8
- package/dist/components/test-section-link/test-section-link.js.map +1 -1
- package/dist/components/test-view-toggle/test-view-toggle.js +2 -5
- package/dist/components/test-view-toggle/test-view-toggle.js.map +1 -1
- package/dist/components/test-view-toggle/test-view.js +2 -5
- package/dist/components/test-view-toggle/test-view.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/item-ref-selection.js.map +1 -1
- package/dist/internal/test-host.context.d.ts +24 -0
- package/dist/internal/test-host.context.js +3 -0
- package/dist/internal/test-host.context.js.map +1 -0
- package/dist/mixins/index.d.ts +1 -0
- package/dist/mixins/index.js +1 -0
- package/dist/mixins/index.js.map +1 -1
- package/dist/mixins/test-base.d.ts +7 -2
- package/dist/mixins/test-base.js +55 -20
- package/dist/mixins/test-base.js.map +1 -1
- package/dist/mixins/test-navigation.mixin.d.ts +3 -4
- package/dist/mixins/test-navigation.mixin.js +26 -40
- package/dist/mixins/test-navigation.mixin.js.map +1 -1
- package/dist/mixins/test-processing.mixin.js +3 -1
- package/dist/mixins/test-processing.mixin.js.map +1 -1
- package/dist/mixins/test-state.mixin.d.ts +33 -0
- package/dist/mixins/test-state.mixin.js +131 -0
- package/dist/mixins/test-state.mixin.js.map +1 -0
- package/dist/mixins/test-view.mixin.js +3 -2
- package/dist/mixins/test-view.mixin.js.map +1 -1
- package/dist/public-events.d.ts +62 -0
- package/dist/public-events.js +33 -0
- package/dist/public-events.js.map +1 -0
- package/dist/types/iqti-test.d.ts +8 -5
- package/dist/types/iqti-test.js.map +1 -1
- package/dist/types/qti-test-state.d.ts +45 -0
- package/dist/types/qti-test-state.js +2 -0
- package/dist/types/qti-test-state.js.map +1 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-navigation.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-navigation.mixin.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AA8DhE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2C,UAAa,EAAE,EAAE;IAC7F,MAAe,mBAAoB,SAAQ,UAAU;QA0BnD,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YA1BW,aAAQ,GAA8B,IAAI,CAAC;YAC3C,mBAAc,GAAW,KAAK,CAAC;YAC3B,8BAAyB,GAAqC,IAAI,CAAC;YACnE,kCAA6B,GAAyC,IAAI,CAAC;YAI3G,4BAA4B;YACpB,sBAAiB,GAA2B,IAAI,CAAC;YACjD,iBAAY,GAAU,EAAE,CAAC;YACzB,kBAAa,GAAG,CAAC,CAAC;YAE1B,mCAAmC;YAC3B,kBAAa,GAAG;gBACtB,aAAa,EAAE,CAAC;gBAChB,cAAc,EAAE,CAAC;gBACjB,gBAAgB,EAAE,CAAC;gBACnB,cAAc,EAAE,CAAC;gBACjB,UAAU,EAAE,KAAK;aAClB,CAAC;YAEF,4DAA4D;YACpD,yBAAoB,GAAG,IAAI,GAAG,EAAU,CAAC;YACzC,0BAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;YAIhD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC5B,CAAC;QAED,8CAA8C;QAC9C,aAAa;QACb,8CAA8C;QAE9C;;;;WAIG;QACI,UAAU,CAAC,IAAwB,EAAE,EAAW;YACrD,MAAM,QAAQ,GAAG,EAAE,IAAI,IAAI,CAAC,uBAAuB,C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,OAAO,EAAE,OAAO;qBACjB,CAAC,CAAC;oBACH,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,IAAI;iBACf,CAAC,CACH,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KACF;IAnnB6B;QAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA4C;IAC3C;QAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DAAgC;IAC3B;QAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;0EAAoE;IACnE;QAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8EAA4E;IAknB7G,OAAO,mBAA4D,CAAC;AACtE,CAAC,CAAC","sourcesContent":["import { property } from 'lit/decorators.js';\n\nimport { qtiTransformItem } from '@qti-components/transformers';\n\nimport type { QtiAssessmentStimulusRefConnectedEvent } from '@qti-components/elements';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { transformItemApi, transformTestApi } from '@qti-components/transformers';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentSection } from '../components/qti-assessment-section/qti-assessment-section';\nimport type { QtiTestPart } from '../components/qti-test-part/qti-test-part';\nimport type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';\nimport type { TestNavigation } from '../components/test-navigation/test-navigation';\nimport type { TestContainer } from '../components/test-container/test-container';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport type PostLoadTransformCallback = (\n transformer: transformItemApi,\n itemRef: QtiAssessmentItemRef\n) => transformItemApi | Promise<transformItemApi>;\n\nexport type PostLoadTestTransformCallback = (\n transformer: transformTestApi,\n testElement: QtiAssessmentTest\n) => transformTestApi | Promise<transformTestApi>;\n\nexport interface NavigationError {\n message: string;\n details?: any;\n itemId?: string;\n sectionId?: string;\n}\n\n/**\n * Exactly what this mixin adds. `IQtiTest` composes it (see ../types/iqti-test, which\n * re-exports it), and `TestNavigationClass` below `implements` it, so the interface and the\n * class cannot drift apart.\n *\n * This was `declare class TestNavigationInterface {}` — EMPTY — so the returned\n * `Constructor<TestNavigationInterface> & T` added nothing and every member the mixin\n * contributes was erased from the public type. `QtiTest` looked as though it had no\n * `navigate` or `postLoadTransformCallback`, and consumers had to intersect the class with\n * `IQtiTest` by hand to describe one element.\n *\n * `showLoadingIndicators` and `retryNavigation` used to be listed on the `IQtiTest` side with\n * no implementation anywhere in the repo, so calling `retryNavigation()` would have thrown.\n * They are gone rather than stubbed: there was no behaviour to preserve.\n */\nexport interface ITestNavigationMixin {\n navigate: 'item' | 'section' | null;\n requestTimeout: number;\n postLoadTransformCallback: PostLoadTransformCallback | null;\n postLoadTestTransformCallback: PostLoadTestTransformCallback | null;\n navigateTo(type: 'item' | 'section', id?: string): void;\n getLoadingProgress(): {\n expectedItems: number;\n connectedItems: number;\n expectedStimulus: number;\n loadedStimulus: number;\n isComplete: boolean;\n };\n}\n\n/**\n * Navigation mixin for QTI test components\n *\n * Provides comprehensive navigation functionality with:\n * - Efficient item/section loading with AbortController support\n * - Stimulus reference coordination and duplicate prevention\n * - Proper event timing and state management\n * - Error handling and edge case coverage\n */\nexport const TestNavigationMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestNavigationClass extends superClass implements ITestNavigationMixin {\n @property({ type: String }) navigate: 'item' | 'section' | null = null;\n @property({ type: Number }) requestTimeout: number = 30000;\n @property({ attribute: false }) postLoadTransformCallback: PostLoadTransformCallback | null = null;\n @property({ attribute: false }) postLoadTestTransformCallback: PostLoadTestTransformCallback | null = null;\n\n public _testElement: QtiAssessmentTest;\n\n // Navigation state tracking\n private _activeController: AbortController | null = null;\n private _loadResults: any[] = [];\n private _navigationId = 0;\n\n // Simple loading progress tracking\n private _loadingState = {\n expectedItems: 0,\n connectedItems: 0,\n expectedStimulus: 0,\n loadedStimulus: 0,\n isComplete: false\n };\n\n // Track loaded/loading stimulus hrefs to prevent duplicates\n private _loadedStimulusHrefs = new Set<string>();\n private _loadingStimulusHrefs = new Set<string>();\n\n constructor(...args: any[]) {\n super(...args);\n this._bindEventHandlers();\n }\n\n // ===========================================\n // PUBLIC API\n // ===========================================\n\n /**\n * Navigate to a specific item or section\n * @param type - Navigation type ('item' or 'section')\n * @param id - Target identifier (optional, falls back to first available)\n */\n public navigateTo(type: 'item' | 'section', id?: string): void {\n const targetId = id || this._getDefaultNavigationId(type);\n\n if (targetId) {\n this.dispatchEvent(\n new CustomEvent('qti-request-navigation', {\n detail: { type, id: targetId },\n bubbles: true,\n composed: true\n })\n );\n }\n }\n\n // ===========================================\n // EVENT HANDLER SETUP\n // ===========================================\n\n private _bindEventHandlers(): void {\n this.addEventListener('qti-request-navigation', this._handleNavigationRequest.bind(this));\n this.addEventListener('qti-assessment-test-connected', this._handleTestConnected.bind(this));\n this.addEventListener('qti-assessment-item-connected', this._handleItemConnected.bind(this));\n this.addEventListener('qti-assessment-stimulus-ref-connected', this._handleStimulusRefConnected.bind(this));\n }\n\n private _handleTestConnected(e: CustomEvent<QtiAssessmentTest>): void {\n this._testElement = e.detail;\n this._initializeNavigation();\n }\n\n /**\n * Handle item connection events - track connected items and discover stimulus references\n */\n private _handleItemConnected(e: CustomEvent<QtiAssessmentItemRef>): void {\n const itemRef = e.detail;\n\n // Increment connected items count\n this._loadingState.connectedItems++;\n\n // Count stimulus references in this item and add to expected\n const stimulusRefs = itemRef.querySelectorAll('qti-assessment-stimulus-ref');\n this._loadingState.expectedStimulus += stimulusRefs.length;\n\n this._checkLoadingComplete();\n }\n\n /**\n * Handle stimulus reference connection events with duplicate prevention\n */\n private async _handleStimulusRefConnected(e: QtiAssessmentStimulusRefConnectedEvent): Promise<void> {\n e.preventDefault();\n\n const { element, item } = e;\n console.info('Stimulus ref connected:', {\n identifier: element.identifier,\n href: element.href,\n item: item.identifier\n });\n\n // Check if this stimulus href is already loaded or currently loading\n if (this._loadedStimulusHrefs.has(element.href)) {\n console.info('Stimulus already loaded, skipping:', element.href);\n this._loadingState.loadedStimulus++;\n this._checkLoadingComplete();\n return;\n }\n\n if (this._loadingStimulusHrefs.has(element.href)) {\n console.info('Stimulus already loading, skipping duplicate:', element.href);\n this._loadingState.loadedStimulus++;\n this._checkLoadingComplete();\n return;\n }\n\n // Mark as currently loading\n this._loadingStimulusHrefs.add(element.href);\n console.info('Starting stimulus load:', element.href);\n\n try {\n await this._loadStimulusRef(element, item);\n this._loadedStimulusHrefs.add(element.href);\n this._loadingState.loadedStimulus++;\n console.info('Stimulus loaded successfully:', element.href);\n this._checkLoadingComplete();\n } catch (error) {\n if (error.name !== 'AbortError') {\n console.warn(`Failed to load stimulus ${element.identifier}:`, error);\n }\n // Still count as \"processed\" even if failed to avoid hanging\n this._loadingState.loadedStimulus++;\n this._checkLoadingComplete();\n } finally {\n // Remove from loading set regardless of outcome\n this._loadingStimulusHrefs.delete(element.href);\n }\n }\n\n // ===========================================\n // NAVIGATION FLOW\n // ===========================================\n\n private _getDefaultNavigationId(type: 'item' | 'section'): string | undefined {\n if (type === 'section') {\n return this._testElement?.querySelector<QtiAssessmentSection>('qti-assessment-section')?.identifier;\n }\n return (\n this.sessionContext?.navItemRefId ??\n this._testElement?.querySelector<QtiAssessmentItemRef>('qti-assessment-item-ref')?.identifier\n );\n }\n\n private _initializeNavigation(): void {\n if (!this.navigate) return;\n\n const id = this._getDefaultNavigationId(this.navigate);\n if (id) {\n this.navigateTo(this.navigate, id);\n }\n }\n\n private _isLinearNavigationRestricted(type: 'item' | 'section', targetId: string): boolean {\n const currentItemId = this.sessionContext?.navItemRefId;\n if (!currentItemId) return false;\n\n // Never restrict navigating to the same item\n if (type === 'item' && targetId === currentItemId) return false;\n\n const currentItemRef = this._testElement?.querySelector(`qti-assessment-item-ref[identifier=\"${currentItemId}\"]`);\n if (!currentItemRef) return false;\n\n const section = currentItemRef.closest('qti-assessment-section') as QtiAssessmentSection;\n const testPart = currentItemRef.closest('qti-test-part') as QtiTestPart;\n\n const navigationMode = (section?.navigationMode ||\n section?.getAttribute('navigation-mode') ||\n testPart?.navigationMode ||\n testPart?.getAttribute('navigation-mode') ||\n 'nonlinear') as string;\n\n if (navigationMode !== 'linear') return false;\n\n const allItemRefs = Array.from(\n this._testElement?.querySelectorAll('qti-assessment-item-ref') || []\n ) as QtiAssessmentItemRef[];\n const currentIndex = allItemRefs.findIndex(ref => ref.identifier === currentItemId);\n\n if (type === 'item') {\n const targetIndex = allItemRefs.findIndex(ref => ref.identifier === targetId);\n if (targetIndex === -1 || currentIndex === -1) return false;\n\n // Only allow moving to the next item in linear mode\n return targetIndex !== currentIndex + 1;\n }\n\n // Sections are generally restricted in linear mode unless we are moving to the next one\n return true;\n }\n\n /**\n * Main navigation request handler with proper lifecycle management\n */\n private async _handleNavigationRequest({ detail }: CustomEvent<{ type: 'item' | 'section'; id: string }>) {\n if (!detail?.id) return;\n\n if (this._isLinearNavigationRestricted(detail.type, detail.id)) {\n this._handleNavigationError(new Error('Navigation restricted in linear mode'), detail.type, detail.id);\n return;\n }\n\n this._cancelPreviousNavigation();\n const navigationId = ++this._navigationId;\n const controller = new AbortController();\n\n try {\n this._dispatchLoadingStarted(detail.type, detail.id);\n this._activeController = controller;\n\n await this._executeNavigation(detail.type, detail.id, navigationId, controller);\n } catch (error) {\n this._handleNavigationError(error, detail.type, detail.id);\n } finally {\n if (this._activeController === controller) {\n this._activeController = null;\n }\n this._dispatchLoadingEnded(detail.type, detail.id);\n }\n }\n\n private _handleNavigationError(error: any, type: string, id: string): void {\n if (error.name !== 'AbortError') {\n this._dispatchError(this._createNavigationError(error, type, id));\n }\n }\n\n private async _executeNavigation(\n type: 'item' | 'section',\n id: string,\n navigationId: number,\n controller: AbortController\n ): Promise<void> {\n if (type === 'item') {\n await this._navigateToItem(id, navigationId, controller);\n } else {\n await this._navigateToSection(id, navigationId, controller);\n }\n }\n\n /**\n * Navigate to specific item with simple state tracking\n */\n private async _navigateToItem(itemId: string, navigationId: number, controller: AbortController): Promise<void> {\n const itemRef = this._findItemRef(itemId);\n this._updateSessionContext(itemRef, itemId);\n\n this._resetLoadingState();\n this._loadingState.expectedItems = 1;\n\n await this._loadItems([itemId], navigationId, controller);\n await this._waitForLoadingComplete(navigationId, controller);\n if (this._isStaleNavigation(navigationId, controller)) return;\n\n this._dispatchTestLoaded(this._loadResults);\n }\n\n /**\n * Navigate to section with simple state tracking\n */\n private async _navigateToSection(\n sectionId: string,\n navigationId: number,\n controller: AbortController\n ): Promise<void> {\n const sectionEl = this._findSection(sectionId);\n const navPartId = sectionEl?.closest('qti-test-part')?.identifier;\n\n this.sessionContext = {\n ...this.sessionContext,\n navPartId,\n navSectionId: sectionId,\n navItemRefId: null\n };\n\n const itemIds = this._getSectionItemIds(sectionId);\n\n this._resetLoadingState();\n this._loadingState.expectedItems = itemIds.length;\n\n await this._loadItems(itemIds, navigationId, controller);\n await this._waitForLoadingComplete(navigationId, controller);\n if (this._isStaleNavigation(navigationId, controller)) return;\n\n this._dispatchTestLoaded(this._loadResults);\n }\n\n // ===========================================\n // LOADING STATE MANAGEMENT\n // ===========================================\n\n /**\n * Reset loading state for new navigation\n */\n private _resetLoadingState(): void {\n this._loadingState = {\n expectedItems: 0,\n connectedItems: 0,\n expectedStimulus: 0,\n loadedStimulus: 0,\n isComplete: false\n };\n\n // Clear stimulus tracking - start fresh for new navigation\n this._loadedStimulusHrefs.clear();\n this._loadingStimulusHrefs.clear();\n }\n\n /**\n * Check if loading is complete and dispatch events accordingly\n */\n private _checkLoadingComplete(): void {\n const allItemsConnected = this._loadingState.connectedItems >= this._loadingState.expectedItems;\n const allStimulusLoaded = this._loadingState.loadedStimulus >= this._loadingState.expectedStimulus;\n\n if (allItemsConnected && allStimulusLoaded && !this._loadingState.isComplete) {\n this._loadingState.isComplete = true;\n }\n }\n\n /**\n * Wait for loading to complete with simple polling\n */\n private async _waitForLoadingComplete(navigationId: number, controller: AbortController): Promise<void> {\n while (!this._loadingState.isComplete) {\n if (this._isStaleNavigation(navigationId, controller)) return;\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n }\n\n /**\n * Get current loading progress for external consumption\n */\n public getLoadingProgress() {\n return { ...this._loadingState };\n }\n\n /**\n * Load stimulus reference with simple tracking\n */\n private async _loadStimulusRef(\n element: { identifier: string; href: string },\n item: QtiAssessmentItem\n ): Promise<void> {\n console.info('Loading stimulus:', element.href);\n const stimulus = await this._loadStimulus(element.href);\n console.info('Stimulus loaded, applying content:', stimulus ? 'has content' : 'no content');\n this._applyStimulusContent(stimulus, element, item);\n }\n\n private _applyStimulusContent(\n stimulus: DocumentFragment | null,\n element: { identifier: string },\n item: QtiAssessmentItem\n ): void {\n if (!stimulus) {\n console.warn('No stimulus content to apply');\n return;\n }\n\n const elements = stimulus.querySelectorAll('qti-stimulus-body, qti-stylesheet');\n console.info(`Found ${elements.length} stimulus elements to apply for ${element.identifier}`);\n\n if (elements.length === 0) {\n console.warn('No qti-stimulus-body or qti-stylesheet elements found in stimulus');\n return;\n }\n\n // Try multiple target selection strategies\n let targets: Element[] = [];\n\n // Strategy 1: Search inside the actual item element first.\n // This keeps stimulus placement working when items are rendered in a shadow root.\n const specificTarget = item.querySelector(`[data-stimulus-idref=\"${element.identifier}\"]`);\n\n if (specificTarget) {\n targets.push(specificTarget);\n console.info('Found specific target:', specificTarget);\n } else {\n // Strategy 2: Any element with matching stimulus idref\n const allTargetsWithId = Array.from(this.querySelectorAll(`[data-stimulus-idref=\"${element.identifier}\"]`));\n\n if (allTargetsWithId.length > 0) {\n targets = allTargetsWithId;\n console.info('Found targets by identifier:', allTargetsWithId.length);\n } else {\n // Strategy 3: Any stimulus idref target (fallback)\n const allStimulusTargets = Array.from(this.querySelectorAll('[data-stimulus-idref]'));\n targets = allStimulusTargets;\n console.info('Using fallback targets:', allStimulusTargets.length);\n }\n }\n\n if (targets.length === 0) {\n console.warn('No targets found for stimulus content');\n return;\n }\n\n // Apply content to all targets\n targets.forEach((target, index) => {\n target.innerHTML = '';\n const clonedElements = Array.from(elements).map(el => el.cloneNode(true) as Element);\n target.append(...clonedElements);\n console.info(`Applied stimulus content to target ${index + 1}/${targets.length}`);\n });\n } // ===========================================\n // LOADING INFRASTRUCTURE\n // ===========================================\n\n /**\n * Cancel previous navigation and clean up all state\n */\n private _cancelPreviousNavigation(): void {\n if (this._activeController) {\n this._activeController.abort();\n console.info('Previous navigation request cancelled');\n }\n\n this._clearNavigationState();\n }\n\n private _clearNavigationState(): void {\n this._clearLoadedItems();\n this._resetLoadingState();\n this._loadResults = [];\n }\n\n /**\n * Load items with simple tracking\n */\n private async _loadItems(itemIds: string[], navigationId: number, controller: AbortController): Promise<void> {\n if (!this._testElement || itemIds.length === 0) return;\n\n const itemRefs = itemIds.map(id => this._findItemRef(id));\n this._clearLoadedItems();\n this._clearStimulusRef();\n\n const results = await Promise.all(itemRefs.map(ref => this._loadSingleItem(ref, navigationId, controller)));\n const validResults = results.filter(Boolean);\n\n if (this._isStaleNavigation(navigationId, controller)) return;\n\n validResults.forEach(({ itemRef, doc }) => {\n if (itemRef && doc) itemRef.xmlDoc = doc;\n });\n\n // Restore per-item state as early as possible (before iframe-based interactions initialize).\n // Some PCIs (including IMS conformance examples) only support restoration via getInstance(state),\n // so the state needs to be present on the provided itemContext at initial render time.\n validResults.forEach(({ itemRef }) => {\n const itemId = itemRef?.identifier;\n if (!itemRef || !itemId) return;\n\n const savedState = this.testContext.items.find(i => i.identifier === itemId)?.state;\n if (savedState === undefined) return;\n\n itemRef.updateComplete.then(() => {\n const assessmentItem = itemRef.assessmentItem as QtiAssessmentItem | null;\n if (!assessmentItem) return;\n assessmentItem.state = savedState;\n });\n });\n\n this._loadResults = validResults;\n }\n\n private async _loadSingleItem(itemRef: QtiAssessmentItemRef, navigationId: number, controller: AbortController) {\n try {\n // The shuffle seed lives on QTI_CONTEXT, which is provided by the descendant\n // `<test-navigation>`. Since context flows downward, read it from that element\n // so seeded item shuffling during navigation matches `test-container`.\n const seed = (this.querySelector('test-navigation') as TestNavigation | null)?.qtiContext?.QTI_CONTEXT?.seed;\n let transformer = (await qtiTransformItem().load(itemRef.href, controller.signal)).shuffleInteractions(seed);\n\n if (this.postLoadTransformCallback) {\n transformer = await this.postLoadTransformCallback(transformer, itemRef);\n }\n\n if (this._isStaleNavigation(navigationId, controller)) {\n return null;\n }\n\n return { itemRef, doc: transformer.htmlDoc(this._customElementRegistry()) };\n } catch (error) {\n if (error.name === 'AbortError') {\n console.info(`Item load for ${itemRef.identifier} was aborted`);\n throw error;\n }\n console.warn(`Failed to load item ${itemRef.identifier}:`, error);\n return null;\n }\n }\n\n private async _loadStimulus(href: string): Promise<DocumentFragment | null> {\n const transformer = await qtiTransformItem().load(href, this._activeController?.signal);\n return transformer.htmlDoc(this._customElementRegistry());\n }\n\n private _customElementRegistry(): CustomElementRegistry | undefined {\n const container = this.querySelector<TestContainer>('test-container');\n if (!container) return undefined;\n return container.customElementRegistry ?? undefined;\n }\n\n // ===========================================\n // UTILITIES\n // ===========================================\n\n private _findItemRef(itemId: string): QtiAssessmentItemRef {\n const itemRef = this._testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${itemId}\"]`\n );\n\n if (!itemRef) {\n throw new Error(`Item with identifier \"${itemId}\" not found`);\n }\n\n return itemRef;\n }\n\n private _findSection(sectionId: string): QtiAssessmentSection | null {\n return (\n this._testElement?.querySelector<QtiAssessmentSection>(`qti-assessment-section[identifier=\"${sectionId}\"]`) ||\n null\n );\n }\n\n private _updateSessionContext(itemRef: QtiAssessmentItemRef, itemId: string): void {\n const navPartId = itemRef.closest('qti-test-part')?.identifier;\n const navSectionId = itemRef.closest('qti-assessment-section')?.identifier;\n\n this.sessionContext = {\n ...this.sessionContext,\n navPartId,\n navSectionId,\n navItemRefId: itemId\n };\n }\n\n private _getSectionItemIds(sectionId: string): string[] {\n return Array.from(\n this._testElement.querySelectorAll<QtiAssessmentItemRef>(\n `qti-assessment-section[identifier=\"${sectionId}\"] > qti-assessment-item-ref`\n )\n )\n .map(ref => ref.identifier)\n .filter(Boolean);\n }\n\n private _clearLoadedItems(): void {\n const itemRefs = this._testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref');\n Array.from(itemRefs || []).forEach(element => {\n element.xmlDoc = null;\n });\n }\n\n private _clearStimulusRef(): void {\n this.querySelectorAll('[data-stimulus-idref]').forEach(el => (el.innerHTML = ''));\n }\n\n private _isStaleNavigation(navigationId: number, controller: AbortController): boolean {\n return controller.signal.aborted || navigationId !== this._navigationId;\n }\n\n private _createNavigationError(error: any, type: string, id: string): NavigationError {\n return {\n message: error.message || `Failed to load ${type}: ${id}`,\n details: error,\n itemId: type === 'item' ? id : undefined,\n sectionId: type === 'section' ? id : undefined\n };\n }\n\n // ===========================================\n // EVENT DISPATCHING\n // ===========================================\n\n private _dispatchLoadingStarted(type: string, id: string): void {\n this.dispatchEvent(\n new CustomEvent('qti-navigation-loading-started', {\n detail: { type, id },\n bubbles: true,\n composed: true\n })\n );\n }\n\n private _dispatchLoadingEnded(type: string, id: string): void {\n this.dispatchEvent(\n new CustomEvent('qti-navigation-loading-ended', {\n detail: { type, id },\n bubbles: true,\n composed: true\n })\n );\n }\n\n private _dispatchError(error: NavigationError): void {\n this.dispatchEvent(\n new CustomEvent('qti-navigation-error', {\n detail: error,\n bubbles: true,\n composed: true\n })\n );\n }\n\n private _dispatchTestLoaded(results: any[]): void {\n requestAnimationFrame(() => {\n this.dispatchEvent(\n new CustomEvent('qti-test-loaded', {\n detail: results.map(({ itemRef }) => ({\n identifier: itemRef?.identifier,\n element: itemRef\n })),\n bubbles: true,\n composed: true\n })\n );\n });\n }\n }\n\n return TestNavigationClass as Constructor<ITestNavigationMixin> & T;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"test-navigation.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-navigation.mixin.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MA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IAAY,EAAE,EAAU;YACpD,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,8BAA8B,EAAE;gBAC9C,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;gBACpB,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;aACf,CAAC,CACH,CAAC;QACJ,CAAC;QAEO,cAAc,CAAC,KAAsB;YAC3C,cAAc,CAAC,IAAI,EAAE,6BAA6B,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;QAED,uHAAuH;QAC/G,mBAAmB,CAAC,OAAc,EAAE,IAAwB,EAAE,EAAU;YAC9E,qBAAqB,CAAC,GAAG,EAAE;gBACzB,cAAc,CACZ,IAAI,EACJ,oBAAoB,EACpB,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;oBAC5B,UAAU,EAAE,OAAO,EAAE,UAAU;oBAC/B,OAAO,EAAE,OAAO;iBACjB,CAAC,CAAC,CACJ,CAAC;gBACF,cAAc,CAAC,IAAI,EAAE,qBAAqB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YAC5D,CAAC,CAAC,CAAC;QACL,CAAC;KACF;IAlmB6B;QAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA4C;IAC3C;QAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DAAgC;IAC3B;QAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;0EAAoE;IACnE;QAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8EAA4E;IAimB7G,OAAO,mBAA4D,CAAC;AACtE,CAAC,CAAC","sourcesContent":["import { property } from 'lit/decorators.js';\n\nimport { qtiTransformItem } from '@qti-components/transformers';\n\nimport { dispatchPublic, listenPublic } from '../public-events';\n\nimport type { QtiAssessmentStimulusRefConnectedEvent } from '@qti-components/elements';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { transformItemApi, transformTestApi } from '@qti-components/transformers';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentSection } from '../components/qti-assessment-section/qti-assessment-section';\nimport type { QtiTestPart } from '../components/qti-test-part/qti-test-part';\nimport type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';\nimport type { TestContainer } from '../components/test-container/test-container';\nimport type { PostLoadTestTransformCallback } from '../internal/test-host.context';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport type PostLoadTransformCallback = (\n transformer: transformItemApi,\n itemRef: QtiAssessmentItemRef\n) => transformItemApi | Promise<transformItemApi>;\n\nexport type { PostLoadTestTransformCallback };\n\nexport interface NavigationError {\n message: string;\n details?: any;\n itemId?: string;\n sectionId?: string;\n}\n\n/**\n * Exactly what this mixin adds. `IQtiTest` composes it (see ../types/iqti-test, which\n * re-exports it), and `TestNavigationClass` below `implements` it, so the interface and the\n * class cannot drift apart.\n *\n * This was `declare class TestNavigationInterface {}` — EMPTY — so the returned\n * `Constructor<TestNavigationInterface> & T` added nothing and every member the mixin\n * contributes was erased from the public type. `QtiTest` looked as though it had no\n * `navigate` or `postLoadTransformCallback`, and consumers had to intersect the class with\n * `IQtiTest` by hand to describe one element.\n *\n * `showLoadingIndicators` and `retryNavigation` used to be listed on the `IQtiTest` side with\n * no implementation anywhere in the repo, so calling `retryNavigation()` would have thrown.\n * They are gone rather than stubbed: there was no behaviour to preserve.\n */\nexport interface ITestNavigationMixin {\n navigate: 'item' | 'section' | null;\n requestTimeout: number;\n postLoadTransformCallback: PostLoadTransformCallback | null;\n postLoadTestTransformCallback: PostLoadTestTransformCallback | null;\n navigateTo(type: 'item' | 'section', id?: string): void;\n getLoadingProgress(): {\n expectedItems: number;\n connectedItems: number;\n expectedStimulus: number;\n loadedStimulus: number;\n isComplete: boolean;\n };\n}\n\n/**\n * Navigation mixin for QTI test components\n *\n * Provides comprehensive navigation functionality with:\n * - Efficient item/section loading with AbortController support\n * - Stimulus reference coordination and duplicate prevention\n * - Proper event timing and state management\n * - Error handling and edge case coverage\n */\nexport const TestNavigationMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestNavigationClass extends superClass implements ITestNavigationMixin {\n @property({ type: String }) navigate: 'item' | 'section' | null = null;\n @property({ type: Number }) requestTimeout: number = 30000;\n @property({ attribute: false }) postLoadTransformCallback: PostLoadTransformCallback | null = null;\n @property({ attribute: false }) postLoadTestTransformCallback: PostLoadTestTransformCallback | null = null;\n\n public _testElement: QtiAssessmentTest;\n\n // Navigation state tracking\n private _activeController: AbortController | null = null;\n private _loadResults: any[] = [];\n private _navigationId = 0;\n\n // Simple loading progress tracking\n private _loadingState = {\n expectedItems: 0,\n connectedItems: 0,\n expectedStimulus: 0,\n loadedStimulus: 0,\n isComplete: false\n };\n\n // Track loaded/loading stimulus hrefs to prevent duplicates\n private _loadedStimulusHrefs = new Set<string>();\n private _loadingStimulusHrefs = new Set<string>();\n\n constructor(...args: any[]) {\n super(...args);\n this._bindEventHandlers();\n }\n\n // ===========================================\n // PUBLIC API\n // ===========================================\n\n /**\n * Navigate to a specific item or section\n * @param type - Navigation type ('item' or 'section')\n * @param id - Target identifier (optional, falls back to the current position, or the first one before there is any)\n */\n public navigateTo(type: 'item' | 'section', id?: string): void {\n const targetId = id || this._getDefaultNavigationId(type);\n\n if (targetId) {\n dispatchPublic(this, 'cito-test-navigate', { type, id: targetId });\n }\n }\n\n // ===========================================\n // EVENT HANDLER SETUP\n // ===========================================\n\n private _bindEventHandlers(): void {\n listenPublic(this, 'cito-test-navigate', this._handleNavigationRequest.bind(this));\n listenPublic(this, 'cito-test-loaded', this._handleTestConnected.bind(this));\n this.addEventListener('qti-assessment-item-connected', this._handleItemConnected.bind(this));\n this.addEventListener('qti-assessment-stimulus-ref-connected', this._handleStimulusRefConnected.bind(this));\n }\n\n private _handleTestConnected(e: CustomEvent<QtiAssessmentTest>): void {\n this._testElement = e.detail;\n this._initializeNavigation();\n }\n\n /**\n * Handle item connection events - track connected items and discover stimulus references\n */\n private _handleItemConnected(e: CustomEvent<QtiAssessmentItemRef>): void {\n const itemRef = e.detail;\n\n // Increment connected items count\n this._loadingState.connectedItems++;\n\n // Count stimulus references in this item and add to expected\n const stimulusRefs = itemRef.querySelectorAll('qti-assessment-stimulus-ref');\n this._loadingState.expectedStimulus += stimulusRefs.length;\n\n this._checkLoadingComplete();\n }\n\n /**\n * Handle stimulus reference connection events with duplicate prevention\n */\n private async _handleStimulusRefConnected(e: QtiAssessmentStimulusRefConnectedEvent): Promise<void> {\n e.preventDefault();\n\n const { element, item } = e;\n console.info('Stimulus ref connected:', {\n identifier: element.identifier,\n href: element.href,\n item: item.identifier\n });\n\n // Check if this stimulus href is already loaded or currently loading\n if (this._loadedStimulusHrefs.has(element.href)) {\n console.info('Stimulus already loaded, skipping:', element.href);\n this._loadingState.loadedStimulus++;\n this._checkLoadingComplete();\n return;\n }\n\n if (this._loadingStimulusHrefs.has(element.href)) {\n console.info('Stimulus already loading, skipping duplicate:', element.href);\n this._loadingState.loadedStimulus++;\n this._checkLoadingComplete();\n return;\n }\n\n // Mark as currently loading\n this._loadingStimulusHrefs.add(element.href);\n console.info('Starting stimulus load:', element.href);\n\n try {\n await this._loadStimulusRef(element, item);\n this._loadedStimulusHrefs.add(element.href);\n this._loadingState.loadedStimulus++;\n console.info('Stimulus loaded successfully:', element.href);\n this._checkLoadingComplete();\n } catch (error) {\n if (error.name !== 'AbortError') {\n console.warn(`Failed to load stimulus ${element.identifier}:`, error);\n }\n // Still count as \"processed\" even if failed to avoid hanging\n this._loadingState.loadedStimulus++;\n this._checkLoadingComplete();\n } finally {\n // Remove from loading set regardless of outcome\n this._loadingStimulusHrefs.delete(element.href);\n }\n }\n\n // ===========================================\n // NAVIGATION FLOW\n // ===========================================\n\n private _getDefaultNavigationId(type: 'item' | 'section'): string | undefined {\n if (type === 'section') {\n return (\n this.sessionContext?.navSectionId ??\n this._testElement?.querySelector<QtiAssessmentSection>('qti-assessment-section')?.identifier\n );\n }\n return (\n this.sessionContext?.navItemRefId ??\n this._testElement?.querySelector<QtiAssessmentItemRef>('qti-assessment-item-ref')?.identifier\n );\n }\n\n private _initializeNavigation(): void {\n if (!this.navigate) return;\n\n const id = this._getDefaultNavigationId(this.navigate);\n if (id) {\n this.navigateTo(this.navigate, id);\n }\n }\n\n private _isLinearNavigationRestricted(type: 'item' | 'section', targetId: string): boolean {\n const currentItemId = this.sessionContext?.navItemRefId;\n if (!currentItemId) return false;\n\n // Never restrict navigating to the same item\n if (type === 'item' && targetId === currentItemId) return false;\n\n const currentItemRef = this._testElement?.querySelector(`qti-assessment-item-ref[identifier=\"${currentItemId}\"]`);\n if (!currentItemRef) return false;\n\n const section = currentItemRef.closest('qti-assessment-section') as QtiAssessmentSection;\n const testPart = currentItemRef.closest('qti-test-part') as QtiTestPart;\n\n const navigationMode = (section?.navigationMode ||\n section?.getAttribute('navigation-mode') ||\n testPart?.navigationMode ||\n testPart?.getAttribute('navigation-mode') ||\n 'nonlinear') as string;\n\n if (navigationMode !== 'linear') return false;\n\n const allItemRefs = Array.from(\n this._testElement?.querySelectorAll('qti-assessment-item-ref') || []\n ) as QtiAssessmentItemRef[];\n const currentIndex = allItemRefs.findIndex(ref => ref.identifier === currentItemId);\n\n if (type === 'item') {\n const targetIndex = allItemRefs.findIndex(ref => ref.identifier === targetId);\n if (targetIndex === -1 || currentIndex === -1) return false;\n\n // Only allow moving to the next item in linear mode\n return targetIndex !== currentIndex + 1;\n }\n\n // Sections are generally restricted in linear mode unless we are moving to the next one\n return true;\n }\n\n /**\n * Main navigation request handler with proper lifecycle management\n */\n private async _handleNavigationRequest({ detail }: CustomEvent<{ type: 'item' | 'section'; id: string }>) {\n if (!detail?.id) return;\n\n if (this._isLinearNavigationRestricted(detail.type, detail.id)) {\n this._handleNavigationError(new Error('Navigation restricted in linear mode'), detail.type, detail.id);\n return;\n }\n\n this._cancelPreviousNavigation();\n const navigationId = ++this._navigationId;\n const controller = new AbortController();\n\n try {\n this._dispatchLoadingStarted(detail.type, detail.id);\n this._activeController = controller;\n\n await this._executeNavigation(detail.type, detail.id, navigationId, controller);\n } catch (error) {\n this._handleNavigationError(error, detail.type, detail.id);\n } finally {\n if (this._activeController === controller) {\n this._activeController = null;\n }\n this._dispatchLoadingEnded(detail.type, detail.id);\n }\n }\n\n private _handleNavigationError(error: any, type: string, id: string): void {\n if (error.name !== 'AbortError') {\n this._dispatchError(this._createNavigationError(error, type, id));\n }\n }\n\n private async _executeNavigation(\n type: 'item' | 'section',\n id: string,\n navigationId: number,\n controller: AbortController\n ): Promise<void> {\n if (type === 'item') {\n await this._navigateToItem(id, navigationId, controller);\n } else {\n await this._navigateToSection(id, navigationId, controller);\n }\n }\n\n /**\n * Navigate to specific item with simple state tracking\n */\n private async _navigateToItem(itemId: string, navigationId: number, controller: AbortController): Promise<void> {\n const itemRef = this._findItemRef(itemId);\n this._updateSessionContext(itemRef, itemId);\n\n this._resetLoadingState();\n this._loadingState.expectedItems = 1;\n\n await this._loadItems([itemId], navigationId, controller);\n await this._waitForLoadingComplete(navigationId, controller);\n if (this._isStaleNavigation(navigationId, controller)) return;\n\n this._dispatchTestLoaded(this._loadResults, 'item', itemId);\n }\n\n /**\n * Navigate to section with simple state tracking\n */\n private async _navigateToSection(\n sectionId: string,\n navigationId: number,\n controller: AbortController\n ): Promise<void> {\n const sectionEl = this._findSection(sectionId);\n const navPartId = sectionEl?.closest('qti-test-part')?.identifier;\n\n this.sessionContext = {\n ...this.sessionContext,\n navPartId,\n navSectionId: sectionId,\n navItemRefId: null\n };\n\n const itemIds = this._getSectionItemIds(sectionId);\n\n this._resetLoadingState();\n this._loadingState.expectedItems = itemIds.length;\n\n await this._loadItems(itemIds, navigationId, controller);\n await this._waitForLoadingComplete(navigationId, controller);\n if (this._isStaleNavigation(navigationId, controller)) return;\n\n this._dispatchTestLoaded(this._loadResults, 'section', sectionId);\n }\n\n // ===========================================\n // LOADING STATE MANAGEMENT\n // ===========================================\n\n /**\n * Reset loading state for new navigation\n */\n private _resetLoadingState(): void {\n this._loadingState = {\n expectedItems: 0,\n connectedItems: 0,\n expectedStimulus: 0,\n loadedStimulus: 0,\n isComplete: false\n };\n\n // Clear stimulus tracking - start fresh for new navigation\n this._loadedStimulusHrefs.clear();\n this._loadingStimulusHrefs.clear();\n }\n\n /**\n * Check if loading is complete and dispatch events accordingly\n */\n private _checkLoadingComplete(): void {\n const allItemsConnected = this._loadingState.connectedItems >= this._loadingState.expectedItems;\n const allStimulusLoaded = this._loadingState.loadedStimulus >= this._loadingState.expectedStimulus;\n\n if (allItemsConnected && allStimulusLoaded && !this._loadingState.isComplete) {\n this._loadingState.isComplete = true;\n }\n }\n\n /**\n * Wait for loading to complete with simple polling\n */\n private async _waitForLoadingComplete(navigationId: number, controller: AbortController): Promise<void> {\n while (!this._loadingState.isComplete) {\n if (this._isStaleNavigation(navigationId, controller)) return;\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n }\n\n /**\n * Get current loading progress for external consumption\n */\n public getLoadingProgress() {\n return { ...this._loadingState };\n }\n\n /**\n * Load stimulus reference with simple tracking\n */\n private async _loadStimulusRef(\n element: { identifier: string; href: string },\n item: QtiAssessmentItem\n ): Promise<void> {\n console.info('Loading stimulus:', element.href);\n const stimulus = await this._loadStimulus(element.href);\n console.info('Stimulus loaded, applying content:', stimulus ? 'has content' : 'no content');\n this._applyStimulusContent(stimulus, element, item);\n }\n\n private _applyStimulusContent(\n stimulus: DocumentFragment | null,\n element: { identifier: string },\n item: QtiAssessmentItem\n ): void {\n if (!stimulus) {\n console.warn('No stimulus content to apply');\n return;\n }\n\n // Place the whole qti-assessment-stimulus, not just its body: its `lang` is what the stimulus\n // content inherits its language from.\n const root = stimulus.querySelector('qti-assessment-stimulus');\n\n if (!root) {\n console.warn('No qti-assessment-stimulus element found in stimulus');\n return;\n }\n\n // Try multiple target selection strategies\n let targets: Element[] = [];\n\n // Strategy 1: Search inside the actual item element first.\n // This keeps stimulus placement working when items are rendered in a shadow root.\n const specificTarget = item.querySelector(`[data-stimulus-idref=\"${element.identifier}\"]`);\n\n if (specificTarget) {\n targets.push(specificTarget);\n console.info('Found specific target:', specificTarget);\n } else {\n // Strategy 2: Any element with matching stimulus idref\n const allTargetsWithId = Array.from(this.querySelectorAll(`[data-stimulus-idref=\"${element.identifier}\"]`));\n\n if (allTargetsWithId.length > 0) {\n targets = allTargetsWithId;\n console.info('Found targets by identifier:', allTargetsWithId.length);\n } else {\n // Strategy 3: Any stimulus idref target (fallback)\n const allStimulusTargets = Array.from(this.querySelectorAll('[data-stimulus-idref]'));\n targets = allStimulusTargets;\n console.info('Using fallback targets:', allStimulusTargets.length);\n }\n }\n\n if (targets.length === 0) {\n console.warn('No targets found for stimulus content');\n return;\n }\n\n // Apply content to all targets\n targets.forEach((target, index) => {\n target.innerHTML = '';\n target.append(root.cloneNode(true));\n console.info(`Applied stimulus content to target ${index + 1}/${targets.length}`);\n });\n } // ===========================================\n // LOADING INFRASTRUCTURE\n // ===========================================\n\n /**\n * Cancel previous navigation and clean up all state\n */\n private _cancelPreviousNavigation(): void {\n if (this._activeController) {\n this._activeController.abort();\n console.info('Previous navigation request cancelled');\n }\n\n this._clearNavigationState();\n }\n\n private _clearNavigationState(): void {\n this._clearLoadedItems();\n this._resetLoadingState();\n this._loadResults = [];\n }\n\n /**\n * Load items with simple tracking\n */\n private async _loadItems(itemIds: string[], navigationId: number, controller: AbortController): Promise<void> {\n if (!this._testElement || itemIds.length === 0) return;\n\n const itemRefs = itemIds.map(id => this._findItemRef(id));\n this._clearLoadedItems();\n this._clearStimulusRef();\n\n const results = await Promise.all(itemRefs.map(ref => this._loadSingleItem(ref, navigationId, controller)));\n const validResults = results.filter(Boolean);\n\n if (this._isStaleNavigation(navigationId, controller)) return;\n\n validResults.forEach(({ itemRef, doc }) => {\n if (itemRef && doc) itemRef.xmlDoc = doc;\n });\n\n // Restore per-item state as early as possible (before iframe-based interactions initialize).\n // Some PCIs (including IMS conformance examples) only support restoration via getInstance(state),\n // so the state needs to be present on the provided itemContext at initial render time.\n validResults.forEach(({ itemRef }) => {\n const itemId = itemRef?.identifier;\n if (!itemRef || !itemId) return;\n\n const savedState = this.testContext.items.find(i => i.identifier === itemId)?.state;\n if (savedState === undefined) return;\n\n itemRef.updateComplete.then(() => {\n const assessmentItem = itemRef.assessmentItem as QtiAssessmentItem | null;\n if (!assessmentItem) return;\n assessmentItem.state = savedState;\n });\n });\n\n this._loadResults = validResults;\n }\n\n private async _loadSingleItem(itemRef: QtiAssessmentItemRef, navigationId: number, controller: AbortController) {\n try {\n // The same seed `test-container` shuffled the item order with.\n const seed = this.qtiContext?.QTI_CONTEXT?.seed;\n let transformer = (await qtiTransformItem().load(itemRef.href, controller.signal)).shuffleInteractions(seed);\n\n if (this.postLoadTransformCallback) {\n transformer = await this.postLoadTransformCallback(transformer, itemRef);\n }\n\n if (this._isStaleNavigation(navigationId, controller)) {\n return null;\n }\n\n return { itemRef, doc: transformer.htmlDoc(this._customElementRegistry()) };\n } catch (error) {\n if (error.name === 'AbortError') {\n console.info(`Item load for ${itemRef.identifier} was aborted`);\n throw error;\n }\n console.warn(`Failed to load item ${itemRef.identifier}:`, error);\n return null;\n }\n }\n\n private async _loadStimulus(href: string): Promise<DocumentFragment | null> {\n const transformer = await qtiTransformItem().load(href, this._activeController?.signal);\n return transformer.htmlDoc(this._customElementRegistry());\n }\n\n private _customElementRegistry(): CustomElementRegistry | undefined {\n const container = this.querySelector<TestContainer>('test-container');\n if (!container) return undefined;\n return container.customElementRegistry ?? undefined;\n }\n\n // ===========================================\n // UTILITIES\n // ===========================================\n\n private _findItemRef(itemId: string): QtiAssessmentItemRef {\n const itemRef = this._testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${itemId}\"]`\n );\n\n if (!itemRef) {\n throw new Error(`Item with identifier \"${itemId}\" not found`);\n }\n\n return itemRef;\n }\n\n private _findSection(sectionId: string): QtiAssessmentSection | null {\n return (\n this._testElement?.querySelector<QtiAssessmentSection>(`qti-assessment-section[identifier=\"${sectionId}\"]`) ||\n null\n );\n }\n\n private _updateSessionContext(itemRef: QtiAssessmentItemRef, itemId: string): void {\n const navPartId = itemRef.closest('qti-test-part')?.identifier;\n const navSectionId = itemRef.closest('qti-assessment-section')?.identifier;\n\n this.sessionContext = {\n ...this.sessionContext,\n navPartId,\n navSectionId,\n navItemRefId: itemId\n };\n }\n\n private _getSectionItemIds(sectionId: string): string[] {\n return Array.from(\n this._testElement.querySelectorAll<QtiAssessmentItemRef>(\n `qti-assessment-section[identifier=\"${sectionId}\"] > qti-assessment-item-ref`\n )\n )\n .map(ref => ref.identifier)\n .filter(Boolean);\n }\n\n private _clearLoadedItems(): void {\n const itemRefs = this._testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref');\n Array.from(itemRefs || []).forEach(element => {\n element.xmlDoc = null;\n });\n }\n\n private _clearStimulusRef(): void {\n this.querySelectorAll('[data-stimulus-idref]').forEach(el => (el.innerHTML = ''));\n }\n\n private _isStaleNavigation(navigationId: number, controller: AbortController): boolean {\n return controller.signal.aborted || navigationId !== this._navigationId;\n }\n\n private _createNavigationError(error: any, type: string, id: string): NavigationError {\n return {\n message: error.message || `Failed to load ${type}: ${id}`,\n details: error,\n itemId: type === 'item' ? id : undefined,\n sectionId: type === 'section' ? id : undefined\n };\n }\n\n // ===========================================\n // EVENT DISPATCHING\n // ===========================================\n\n private _dispatchLoadingStarted(type: string, id: string): void {\n dispatchPublic(this, 'cito-test-navigation-started', { type: type as 'item' | 'section', id });\n }\n\n private _dispatchLoadingEnded(type: string, id: string): void {\n this.dispatchEvent(\n new CustomEvent('qti-navigation-loading-ended', {\n detail: { type, id },\n bubbles: true,\n composed: true\n })\n );\n }\n\n private _dispatchError(error: NavigationError): void {\n dispatchPublic(this, 'cito-test-navigation-failed', error);\n }\n\n /** The items are in the DOM: tell hosts the new position rendered (`cito-test-navigated`) and which items it holds. */\n private _dispatchTestLoaded(results: any[], type: 'item' | 'section', id: string): void {\n requestAnimationFrame(() => {\n dispatchPublic(\n this,\n 'cito-test-rendered',\n results.map(({ itemRef }) => ({\n identifier: itemRef?.identifier,\n element: itemRef\n }))\n );\n dispatchPublic(this, 'cito-test-navigated', { type, id });\n });\n }\n }\n\n return TestNavigationClass as Constructor<ITestNavigationMixin> & T;\n};\n"]}
|
|
@@ -17,7 +17,9 @@ export const TestProcessingMixin = (superClass) => {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
outcomeProcessing() {
|
|
20
|
-
|
|
20
|
+
// Inside the loaded test: `test-container` renders it into its own shadow root, which a
|
|
21
|
+
// `querySelector` on this element does not reach. Without a loaded test, look in the light DOM.
|
|
22
|
+
const outcomeProcessor = (this._testElement ?? this).querySelector('qti-outcome-processing');
|
|
21
23
|
if (!outcomeProcessor)
|
|
22
24
|
return false;
|
|
23
25
|
outcomeProcessor?.process();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-processing.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-processing.mixin.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2C,UAAa,EAAE,EAAE;IAC7F,MAAe,qBAAsB,SAAQ,UAAU;QACrD,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,CAAC,CAAiC,EAAE,EAAE;gBACnF,IAAI,CAAC,WAAW,GAAG;oBACjB,GAAG,IAAI,CAAC,WAAW;oBACnB,oBAAoB,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;iBAC5F,CAAC;gBACF,CAAC,CA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AAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,IAAI,CAAC;QAC/F,CAAC;KAEF;IAED,OAAO,qBAAiE,CAAC;AAC3E,CAAC,CAAC","sourcesContent":["import type { QtiOutcomeProcessing } from '../components/qti-outcome-processing/qti-outcome-processing';\nimport type { OutcomeVariable, VariableDeclaration } from '@qti-components/base';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestProcessingInterface {\n updateOutcomeVariable(identifier: string, value: string | string[] | undefined): void;\n getOutcome(identifier: string): Readonly<OutcomeVariable>;\n getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;\n outcomeProcessing(): boolean;\n}\nexport const TestProcessingMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestProcessingElement extends superClass implements TestProcessingInterface {\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-register-variable', (e: CustomEvent<{ variable: any }>) => {\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: [...(this.testContext.testOutcomeVariables || []), e.detail.variable]\n };\n e.stopPropagation();\n });\n // wordt aangeroepen vanuit de processingtemplate\n this.addEventListener(\n 'qti-set-outcome-value',\n (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\n }\n );\n }\n\n outcomeProcessing(): boolean {\n // Inside the loaded test: `test-container` renders it into its own shadow root, which a\n // `querySelector` on this element does not reach. Without a loaded test, look in the light DOM.\n const outcomeProcessor = (this._testElement ?? this).querySelector(\n 'qti-outcome-processing'\n ) as unknown as QtiOutcomeProcessing;\n if (!outcomeProcessor) return false;\n outcomeProcessor?.process();\n return true;\n }\n\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n\n public updateOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n const outcomeVariable = this.getOutcome(identifier);\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : [...v.value, value as string]\n };\n })\n };\n }\n\n public getOutcome(identifier: string): Readonly<OutcomeVariable> {\n return this.getVariable(identifier) as OutcomeVariable;\n }\n public getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>> {\n return this.testContext.testOutcomeVariables?.find(v => v.identifier === identifier) || null;\n }\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n }\n\n return TestProcessingElement as Constructor<TestProcessingInterface> & T;\n};\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { QtiTestState } from '../types/qti-test-state';
|
|
2
|
+
import type { TestBaseInterface } from './test-base';
|
|
3
|
+
type Constructor<T = {}> = abstract new (...args: any[]) => T;
|
|
4
|
+
declare global {
|
|
5
|
+
interface GlobalEventHandlersEventMap {
|
|
6
|
+
'qti-state-changed': CustomEvent<QtiTestState>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export interface ITestStateMixin {
|
|
10
|
+
/**
|
|
11
|
+
* The candidate's persistable state: what they answered and where they are.
|
|
12
|
+
*
|
|
13
|
+
* Assign a stored state to resume. It may be assigned at any time: before the test document
|
|
14
|
+
* has loaded it is held and applied as soon as the test connects — before the first item
|
|
15
|
+
* loads, so items and the initial navigation start from it — and after that it is applied
|
|
16
|
+
* immediately and the test navigates to the restored position.
|
|
17
|
+
*
|
|
18
|
+
* Items are matched by item-ref identifier; items the state does not mention start fresh, and
|
|
19
|
+
* stored items, test outcomes or a position the test no longer has are ignored. Restoring is a
|
|
20
|
+
* resume, so linear-mode navigation restrictions do not apply.
|
|
21
|
+
*/
|
|
22
|
+
state: QtiTestState;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Persist and resume a test session through one value, `state`, and one event,
|
|
26
|
+
* `qti-state-changed`.
|
|
27
|
+
*
|
|
28
|
+
* Sits directly on top of `TestBaseMixin`, so its `qti-assessment-test-connected` listener runs
|
|
29
|
+
* after the base has built `testContext.items` from the item-refs, and before the navigation
|
|
30
|
+
* mixin's listener picks the first item to load.
|
|
31
|
+
*/
|
|
32
|
+
export declare const TestStateMixin: <T extends Constructor<TestBaseInterface>>(superClass: T) => Constructor<ITestStateMixin> & T;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { QTI_TEST_STATE_VERSION } from '../types/qti-test-state';
|
|
2
|
+
import { dispatchPublic, listenPublic } from '../public-events';
|
|
3
|
+
const copy = (value) => Array.isArray(value) ? [...value] : (value ?? null);
|
|
4
|
+
const isQtiTestState = (value) => {
|
|
5
|
+
const state = value;
|
|
6
|
+
return (state?.version === QTI_TEST_STATE_VERSION &&
|
|
7
|
+
Array.isArray(state.test?.items) &&
|
|
8
|
+
Array.isArray(state.test?.outcomes) &&
|
|
9
|
+
typeof state.session === 'object' &&
|
|
10
|
+
state.session !== null);
|
|
11
|
+
};
|
|
12
|
+
const toState = (test, session) => ({
|
|
13
|
+
version: QTI_TEST_STATE_VERSION,
|
|
14
|
+
test: {
|
|
15
|
+
items: (test?.items ?? [])
|
|
16
|
+
.filter(item => item.identifier)
|
|
17
|
+
.map(item => ({
|
|
18
|
+
identifier: item.identifier,
|
|
19
|
+
variables: (item.variables ?? []).map(v => ({
|
|
20
|
+
identifier: v.identifier,
|
|
21
|
+
...(v.type ? { type: v.type } : {}),
|
|
22
|
+
value: copy(v.value)
|
|
23
|
+
})),
|
|
24
|
+
...(item.state ? { state: { ...item.state } } : {})
|
|
25
|
+
})),
|
|
26
|
+
outcomes: (test?.testOutcomeVariables ?? []).map(v => ({ identifier: v.identifier, value: copy(v.value) }))
|
|
27
|
+
},
|
|
28
|
+
session: {
|
|
29
|
+
...(session?.navPartId !== undefined ? { navPartId: session.navPartId } : {}),
|
|
30
|
+
...(session?.navSectionId !== undefined ? { navSectionId: session.navSectionId } : {}),
|
|
31
|
+
...(session?.navItemRefId !== undefined ? { navItemRefId: session.navItemRefId } : {})
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Persist and resume a test session through one value, `state`, and one event,
|
|
36
|
+
* `qti-state-changed`.
|
|
37
|
+
*
|
|
38
|
+
* Sits directly on top of `TestBaseMixin`, so its `qti-assessment-test-connected` listener runs
|
|
39
|
+
* after the base has built `testContext.items` from the item-refs, and before the navigation
|
|
40
|
+
* mixin's listener picks the first item to load.
|
|
41
|
+
*/
|
|
42
|
+
export const TestStateMixin = (superClass) => {
|
|
43
|
+
class TestStateClass extends superClass {
|
|
44
|
+
/** A state assigned before the test connected, applied when it does. */
|
|
45
|
+
#pending = null;
|
|
46
|
+
/**
|
|
47
|
+
* False while a test document is loading. Loading resets both contexts and rebuilds them, so
|
|
48
|
+
* the intermediate states are empty — emitting one would invite a host to save it over the
|
|
49
|
+
* real one.
|
|
50
|
+
*/
|
|
51
|
+
#ready = false;
|
|
52
|
+
#lastEmitted = null;
|
|
53
|
+
constructor(...args) {
|
|
54
|
+
super(...args);
|
|
55
|
+
this.addEventListener('qti-testdoc-loaded', () => {
|
|
56
|
+
this.#ready = false;
|
|
57
|
+
this.#lastEmitted = null;
|
|
58
|
+
});
|
|
59
|
+
listenPublic(this, 'cito-test-loaded', () => {
|
|
60
|
+
if (this.#pending) {
|
|
61
|
+
this.#apply(this.#pending);
|
|
62
|
+
this.#pending = null;
|
|
63
|
+
}
|
|
64
|
+
this.#ready = true;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
get state() {
|
|
68
|
+
return toState(this.testContext, this.sessionContext);
|
|
69
|
+
}
|
|
70
|
+
set state(value) {
|
|
71
|
+
if (!isQtiTestState(value)) {
|
|
72
|
+
console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!this.#ready) {
|
|
76
|
+
this.#pending = value;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const { navItemRefId, navSectionId } = this.sessionContext;
|
|
80
|
+
this.#apply(value);
|
|
81
|
+
const restored = this.sessionContext;
|
|
82
|
+
if (restored.navItemRefId && restored.navItemRefId !== navItemRefId) {
|
|
83
|
+
this.#requestNavigation('item', restored.navItemRefId);
|
|
84
|
+
}
|
|
85
|
+
else if (!restored.navItemRefId && restored.navSectionId && restored.navSectionId !== navSectionId) {
|
|
86
|
+
this.#requestNavigation('section', restored.navSectionId);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
updated(changed) {
|
|
90
|
+
super.updated(changed);
|
|
91
|
+
if (!this.#ready || !(changed.has('testContext') || changed.has('sessionContext')))
|
|
92
|
+
return;
|
|
93
|
+
const state = this.state;
|
|
94
|
+
const serialized = JSON.stringify(state);
|
|
95
|
+
if (serialized === this.#lastEmitted)
|
|
96
|
+
return;
|
|
97
|
+
this.#lastEmitted = serialized;
|
|
98
|
+
dispatchPublic(this, 'cito-test-state-changed', state);
|
|
99
|
+
}
|
|
100
|
+
#apply(state) {
|
|
101
|
+
// Before the items load this only fills the test context; items already on screen are
|
|
102
|
+
// updated too.
|
|
103
|
+
for (const saved of state.test.items)
|
|
104
|
+
this.updateItemVariables(saved.identifier, saved.variables, saved.state);
|
|
105
|
+
const savedOutcomes = new Map(state.test.outcomes.map(outcome => [outcome.identifier, outcome.value]));
|
|
106
|
+
this.testContext = {
|
|
107
|
+
...this.testContext,
|
|
108
|
+
testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v)
|
|
109
|
+
};
|
|
110
|
+
// Written before any navigation request, so the linear-mode restriction — which compares
|
|
111
|
+
// against the current position — sees the restored item as current and lets it load.
|
|
112
|
+
this.sessionContext = { ...this.sessionContext, ...this.#validSession(state.session) };
|
|
113
|
+
}
|
|
114
|
+
/** A stored position may point at an item or section a revised test no longer has. */
|
|
115
|
+
#validSession(session) {
|
|
116
|
+
const exists = (selector, id) => !!id && !!this._testElement?.querySelector(`${selector}[identifier="${CSS.escape(id)}"]`);
|
|
117
|
+
return {
|
|
118
|
+
...(exists('qti-test-part', session.navPartId) ? { navPartId: session.navPartId } : {}),
|
|
119
|
+
...(exists('qti-assessment-section', session.navSectionId) ? { navSectionId: session.navSectionId } : {}),
|
|
120
|
+
...(this.testContext.items.some(i => i.identifier === session.navItemRefId)
|
|
121
|
+
? { navItemRefId: session.navItemRefId }
|
|
122
|
+
: {})
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
#requestNavigation(type, id) {
|
|
126
|
+
dispatchPublic(this, 'cito-test-navigate', { type, id });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return TestStateClass;
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=test-state.mixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-state.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-state.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgChE,MAAM,IAAI,GAAG,CAAC,KAAkC,EAAS,EAAE,CACzD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAE,KAAmC,IAAI,IAAI,CAAC,CAAC;AAErF,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE;IAC/D,MAAM,KAAK,GAAG,KAA4B,CAAC;IAC3C,OAAO,CACL,KAAK,EAAE,OA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C,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACzF,CAAC;QAED,sFAAsF;QACtF,aAAa,CAAC,OAA4B;YACxC,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAE,EAA6B,EAAE,EAAE,CACjE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,QAAQ,gBAAgB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;YAC5F,OAAO;gBACL,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvF,GAAG,CAAC,MAAM,CAAC,wBAAwB,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzG,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,OAAO,CAAC,YAAY,CAAC;oBACzE,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE;oBACxC,CAAC,CAAC,EAAE,CAAC;aACR,CAAC;QACJ,CAAC;QAED,kBAAkB,CAAC,IAAwB,EAAE,EAAU;YACrD,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3D,CAAC;KACF;IAED,OAAO,cAAkD,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["import { QTI_TEST_STATE_VERSION } from '../types/qti-test-state';\nimport { dispatchPublic, listenPublic } from '../public-events';\n\nimport type { PropertyValues } from 'lit';\nimport type { SessionContext, TestContext } from '@qti-components/base';\nimport type { QtiTestState, QtiTestStateSession } from '../types/qti-test-state';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\ntype Value = string | string[] | null;\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'qti-state-changed': CustomEvent<QtiTestState>;\n }\n}\n\nexport interface ITestStateMixin {\n /**\n * The candidate's persistable state: what they answered and where they are.\n *\n * Assign a stored state to resume. It may be assigned at any time: before the test document\n * has loaded it is held and applied as soon as the test connects — before the first item\n * loads, so items and the initial navigation start from it — and after that it is applied\n * immediately and the test navigates to the restored position.\n *\n * Items are matched by item-ref identifier; items the state does not mention start fresh, and\n * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a\n * resume, so linear-mode navigation restrictions do not apply.\n */\n state: QtiTestState;\n}\n\nconst copy = (value: Readonly<Value> | undefined): Value =>\n Array.isArray(value) ? [...value] : ((value as string | null | undefined) ?? null);\n\nconst isQtiTestState = (value: unknown): value is QtiTestState => {\n const state = value as QtiTestState | null;\n return (\n state?.version === QTI_TEST_STATE_VERSION &&\n Array.isArray(state.test?.items) &&\n Array.isArray(state.test?.outcomes) &&\n typeof state.session === 'object' &&\n state.session !== null\n );\n};\n\nconst toState = (test: Readonly<TestContext>, session: Readonly<SessionContext>): QtiTestState => ({\n version: QTI_TEST_STATE_VERSION,\n test: {\n items: (test?.items ?? [])\n .filter(item => item.identifier)\n .map(item => ({\n identifier: item.identifier,\n variables: (item.variables ?? []).map(v => ({\n identifier: v.identifier,\n ...(v.type ? { type: v.type } : {}),\n value: copy(v.value)\n })),\n ...(item.state ? { state: { ...item.state } } : {})\n })),\n outcomes: (test?.testOutcomeVariables ?? []).map(v => ({ identifier: v.identifier, value: copy(v.value) }))\n },\n session: {\n ...(session?.navPartId !== undefined ? { navPartId: session.navPartId } : {}),\n ...(session?.navSectionId !== undefined ? { navSectionId: session.navSectionId } : {}),\n ...(session?.navItemRefId !== undefined ? { navItemRefId: session.navItemRefId } : {})\n }\n});\n\n/**\n * Persist and resume a test session through one value, `state`, and one event,\n * `qti-state-changed`.\n *\n * Sits directly on top of `TestBaseMixin`, so its `qti-assessment-test-connected` listener runs\n * after the base has built `testContext.items` from the item-refs, and before the navigation\n * mixin's listener picks the first item to load.\n */\nexport const TestStateMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestStateClass extends superClass implements ITestStateMixin {\n /** A state assigned before the test connected, applied when it does. */\n #pending: QtiTestState | null = null;\n\n /**\n * False while a test document is loading. Loading resets both contexts and rebuilds them, so\n * the intermediate states are empty — emitting one would invite a host to save it over the\n * real one.\n */\n #ready = false;\n\n #lastEmitted: string | null = null;\n\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-testdoc-loaded', () => {\n this.#ready = false;\n this.#lastEmitted = null;\n });\n listenPublic(this, 'cito-test-loaded', () => {\n if (this.#pending) {\n this.#apply(this.#pending);\n this.#pending = null;\n }\n this.#ready = true;\n });\n }\n\n get state(): QtiTestState {\n return toState(this.testContext, this.sessionContext);\n }\n\n set state(value: QtiTestState) {\n if (!isQtiTestState(value)) {\n console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);\n return;\n }\n if (!this.#ready) {\n this.#pending = value;\n return;\n }\n\n const { navItemRefId, navSectionId } = this.sessionContext;\n this.#apply(value);\n\n const restored = this.sessionContext;\n if (restored.navItemRefId && restored.navItemRefId !== navItemRefId) {\n this.#requestNavigation('item', restored.navItemRefId);\n } else if (!restored.navItemRefId && restored.navSectionId && restored.navSectionId !== navSectionId) {\n this.#requestNavigation('section', restored.navSectionId);\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n if (!this.#ready || !(changed.has('testContext') || changed.has('sessionContext'))) return;\n\n const state = this.state;\n const serialized = JSON.stringify(state);\n if (serialized === this.#lastEmitted) return;\n this.#lastEmitted = serialized;\n dispatchPublic(this, 'cito-test-state-changed', state);\n }\n\n #apply(state: QtiTestState): void {\n // Before the items load this only fills the test context; items already on screen are\n // updated too.\n for (const saved of state.test.items) this.updateItemVariables(saved.identifier, saved.variables, saved.state);\n\n const savedOutcomes = new Map(state.test.outcomes.map(outcome => [outcome.identifier, outcome.value]));\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v =>\n savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v\n )\n };\n\n // Written before any navigation request, so the linear-mode restriction — which compares\n // against the current position — sees the restored item as current and lets it load.\n this.sessionContext = { ...this.sessionContext, ...this.#validSession(state.session) };\n }\n\n /** A stored position may point at an item or section a revised test no longer has. */\n #validSession(session: QtiTestStateSession): QtiTestStateSession {\n const exists = (selector: string, id: string | null | undefined) =>\n !!id && !!this._testElement?.querySelector(`${selector}[identifier=\"${CSS.escape(id)}\"]`);\n return {\n ...(exists('qti-test-part', session.navPartId) ? { navPartId: session.navPartId } : {}),\n ...(exists('qti-assessment-section', session.navSectionId) ? { navSectionId: session.navSectionId } : {}),\n ...(this.testContext.items.some(i => i.identifier === session.navItemRefId)\n ? { navItemRefId: session.navItemRefId }\n : {})\n };\n }\n\n #requestNavigation(type: 'item' | 'section', id: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type, id });\n }\n }\n\n return TestStateClass as Constructor<ITestStateMixin> & T;\n};\n"]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { listenPublic } from '../public-events';
|
|
1
2
|
export const TestViewMixin = (superClass) => {
|
|
2
3
|
class TestViewClass extends superClass {
|
|
3
4
|
constructor(...args) {
|
|
4
5
|
super(...args);
|
|
5
6
|
this.sessionContext = { ...this.sessionContext, view: 'candidate' };
|
|
6
|
-
this
|
|
7
|
+
listenPublic(this, 'cito-test-switch-view', e => {
|
|
7
8
|
this.sessionContext = { ...this.sessionContext, view: e.detail };
|
|
8
9
|
this._updateElementView();
|
|
9
10
|
});
|
|
10
|
-
this
|
|
11
|
+
listenPublic(this, 'cito-test-loaded', () => {
|
|
11
12
|
this._updateElementView();
|
|
12
13
|
});
|
|
13
14
|
this.addEventListener('qti-assessment-item-connected', (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-view.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-view.mixin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-view.mixin.js","sourceRoot":"","sources":["../../src/mixins/test-view.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAahD,MAAM,CAAC,MAAM,aAAa,GAAG,CAA2C,UAAa,EAAE,EAAE;IACvF,MAAe,aAAc,SAAQ,UAAU;QAC7C,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,IAAI,CAAC,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;YAEpE,YAAY,CAAC,IAAI,EAAE,uBAAuB,EAAE,CAAC,CAAC,EAAE;gBAC9C,IAAI,CAAC,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;gBACjE,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,CAAC,CAAC,CAAC;YACH,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,EAAE;gBAC1C,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,gBAAgB,CAAC,+BAA+B,EAAE,CAAC,CAAc,EAAE,EAAE;gBACxE,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC1B,IAAI,CAAC,6BAA6B,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;QACL,CAAC;QAED,UAAU,CAAC,iBAAyD;YAClE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;YACpC,IAAI,iBAAiB,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC5C,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,+EAA+E;QACvE,kBAAkB;YACxB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAE9E,YAAY,CAAC,OAAO,CAAC,CAAC,OAAoB,EAAE,EAAE;oBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAC9F,CAAC,CAAC,CAAC;gBAEH,MAAM,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CACvD,uCAAuC,IAAI,CAAC,cAAc,CAAC,YAAY,IAAI,CAC5E,CAAC;gBACF,MAAM,cAAc,GAAG,iBAAiB,EAAE,cAAc,CAAC;gBAEzD,IAAI,cAAc;oBAAE,IAAI,CAAC,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC9F,CAAC;QACH,CAAC;QAED,mDAAmD;QAC3C,6BAA6B,CAAC,cAAiC;YACrE,IAAI,CAAC,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1E,CAAC;QAED,oFAAoF;QAC7E,wBAAwB,CAAC,eAAkC,EAAE,KAAW,IAAS,CAAC;KAC1F;IAED,OAAO,aAAmD,CAAC;AAC7D,CAAC,CAAC","sourcesContent":["import { listenPublic } from '../public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestViewInterface {\n updateAssessmentItemView(assessmentItem: QtiAssessmentItem, view: View): void;\n}\n\nexport const TestViewMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestViewClass extends superClass implements TestViewInterface {\n constructor(...args: any[]) {\n super(...args);\n this.sessionContext = { ...this.sessionContext, view: 'candidate' };\n\n listenPublic(this, 'cito-test-switch-view', e => {\n this.sessionContext = { ...this.sessionContext, view: e.detail };\n this._updateElementView();\n });\n listenPublic(this, 'cito-test-loaded', () => {\n this._updateElementView();\n });\n this.addEventListener('qti-assessment-item-connected', (e: CustomEvent) => {\n this._updateElementView();\n this._setCorrectResponseVisibility(e.detail);\n });\n }\n\n willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n super.willUpdate(changedProperties);\n if (changedProperties.has('sessionContext')) {\n this._updateElementView();\n }\n }\n\n // Method to handle view updates for elements based on the current context view\n private _updateElementView() {\n if (this._testElement) {\n const viewElements = Array.from(this._testElement.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', element.getAttribute('view') === this.sessionContext.view);\n });\n\n const assessmentItemRef = this._testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this.sessionContext.navItemRefId}\"]`\n );\n const assessmentItem = assessmentItemRef?.assessmentItem;\n\n if (assessmentItem) this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);\n }\n }\n\n // Event handler for connected QTI assessment items\n private _setCorrectResponseVisibility(assessmentItem: QtiAssessmentItem): void {\n this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);\n }\n\n /** Extension point for packages that add view-dependent assessment presentation. */\n public updateAssessmentItemView(_assessmentItem: QtiAssessmentItem, _view: View): void {}\n }\n\n return TestViewClass as Constructor<TestViewInterface> & T;\n};\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { View } from '@qti-components/base';
|
|
2
|
+
import type { PublicEventDeclaration } from '@qti-components/elements/public-events';
|
|
3
|
+
import type { QtiTestState } from './types/qti-test-state';
|
|
4
|
+
/**
|
|
5
|
+
* The public events of the test. The name tells you it is public: everything here starts with
|
|
6
|
+
* `cito-`; every other event is internal plumbing and may change in any release.
|
|
7
|
+
*
|
|
8
|
+
* Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense
|
|
9
|
+
* (the test dispatches them). All bubble and are composed.
|
|
10
|
+
*
|
|
11
|
+
* `deprecated` is the name this event had before it became public. One helper (`dispatchPublic`,
|
|
12
|
+
* `listenPublic`) sends or handles both names until the next major, then the field goes.
|
|
13
|
+
*/
|
|
14
|
+
export interface NavigationTarget {
|
|
15
|
+
type: 'item' | 'section';
|
|
16
|
+
id: string;
|
|
17
|
+
}
|
|
18
|
+
export interface NavigationFailure {
|
|
19
|
+
message: string;
|
|
20
|
+
details?: unknown;
|
|
21
|
+
itemId?: string;
|
|
22
|
+
sectionId?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface PublicEventMap {
|
|
25
|
+
'cito-test-navigate': CustomEvent<NavigationTarget>;
|
|
26
|
+
'cito-test-end-attempt': CustomEvent<unknown>;
|
|
27
|
+
'cito-test-update-outcome': CustomEvent<{
|
|
28
|
+
assessmentItemRefId: string;
|
|
29
|
+
outcomeVariableId: string;
|
|
30
|
+
value: number | string;
|
|
31
|
+
}>;
|
|
32
|
+
'cito-test-switch-view': CustomEvent<View>;
|
|
33
|
+
'cito-test-navigated': CustomEvent<NavigationTarget>;
|
|
34
|
+
'cito-test-navigation-started': CustomEvent<NavigationTarget>;
|
|
35
|
+
'cito-test-navigation-failed': CustomEvent<NavigationFailure>;
|
|
36
|
+
'cito-test-rendered': CustomEvent<{
|
|
37
|
+
identifier: string;
|
|
38
|
+
element: Element;
|
|
39
|
+
}[]>;
|
|
40
|
+
'cito-test-state-changed': CustomEvent<QtiTestState>;
|
|
41
|
+
'cito-item-ref-connected': CustomEvent<{
|
|
42
|
+
identifier: string;
|
|
43
|
+
href: string;
|
|
44
|
+
category: string;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
export type PublicEventName = keyof PublicEventMap;
|
|
48
|
+
export declare const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration>;
|
|
49
|
+
declare global {
|
|
50
|
+
interface HTMLElementEventMap extends PublicEventMap {
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Dispatch a public event, and its deprecated name with the same `detail` object. The detail is
|
|
55
|
+
* always an object so `listenPublic` can tell the two apart from one dispatch.
|
|
56
|
+
*/
|
|
57
|
+
export declare function dispatchPublic<K extends PublicEventName>(target: EventTarget, name: K, detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never): void;
|
|
58
|
+
/**
|
|
59
|
+
* Listen for a public event and its deprecated name; the handler runs once for a sender that
|
|
60
|
+
* dispatched both. See `listenDeclared`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function listenPublic<K extends PublicEventName>(target: EventTarget, name: K, handler: (e: PublicEventMap[K]) => void): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';
|
|
2
|
+
export const PUBLIC_EVENTS = {
|
|
3
|
+
'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },
|
|
4
|
+
'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },
|
|
5
|
+
'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },
|
|
6
|
+
'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },
|
|
7
|
+
'cito-test-navigated': { kind: 'notification', scope: 'test' },
|
|
8
|
+
'cito-test-navigation-started': {
|
|
9
|
+
kind: 'notification',
|
|
10
|
+
scope: 'test',
|
|
11
|
+
deprecated: 'qti-navigation-loading-started'
|
|
12
|
+
},
|
|
13
|
+
'cito-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'qti-navigation-error' },
|
|
14
|
+
'cito-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'qti-test-loaded' },
|
|
15
|
+
'cito-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'qti-assessment-test-connected' },
|
|
16
|
+
'cito-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'qti-state-changed' },
|
|
17
|
+
'cito-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'qti-assessment-item-ref-connected' }
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Dispatch a public event, and its deprecated name with the same `detail` object. The detail is
|
|
21
|
+
* always an object so `listenPublic` can tell the two apart from one dispatch.
|
|
22
|
+
*/
|
|
23
|
+
export function dispatchPublic(target, name, detail) {
|
|
24
|
+
dispatchDeclared(target, PUBLIC_EVENTS, name, detail);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Listen for a public event and its deprecated name; the handler runs once for a sender that
|
|
28
|
+
* dispatched both. See `listenDeclared`.
|
|
29
|
+
*/
|
|
30
|
+
export function listenPublic(target, name, handler) {
|
|
31
|
+
listenDeclared(target, PUBLIC_EVENTS, name, handler);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=public-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-events.js","sourceRoot":"","sources":["../src/public-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAiD1F,MAAM,CAAC,MAAM,aAAa,GAAoD;IAC5E,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAAE;IAC9F,uBAAuB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,E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sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `cito-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the name this event had before it became public. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'cito-test-navigate': CustomEvent<NavigationTarget>;\n 'cito-test-end-attempt': CustomEvent<unknown>;\n 'cito-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'cito-test-switch-view': CustomEvent<View>;\n 'cito-test-navigated': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-started': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'cito-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `cito-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'cito-test-state-changed': CustomEvent<QtiTestState>;\n 'cito-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },\n 'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },\n 'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },\n 'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },\n 'cito-test-navigated': { kind: 'notification', scope: 'test' },\n 'cito-test-navigation-started': {\n kind: 'notification',\n scope: 'test',\n deprecated: 'qti-navigation-loading-started'\n },\n 'cito-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'qti-navigation-error' },\n 'cito-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'qti-test-loaded' },\n 'cito-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'qti-assessment-test-connected' },\n 'cito-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'qti-state-changed' },\n 'cito-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'qti-assessment-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n"]}
|