@pie-qti/assessment-player 1.0.0-beta.3 → 1.0.0-beta.5

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.
Files changed (134) hide show
  1. package/README.md +28 -7
  2. package/dist/components/createPlayerConnection.svelte.d.ts +90 -0
  3. package/dist/components/createPlayerConnection.svelte.js +151 -0
  4. package/dist/components/createPlayerConnection.svelte.js.map +1 -0
  5. package/dist/components/displaySettings.svelte.d.ts +23 -0
  6. package/dist/components/displaySettings.svelte.js +40 -0
  7. package/dist/components/displaySettings.svelte.js.map +1 -0
  8. package/dist/components/srOnly.d.ts +29 -0
  9. package/dist/components/srOnly.js +55 -0
  10. package/dist/components/srOnly.js.map +1 -0
  11. package/dist/components/submitDialogAction.d.ts +25 -0
  12. package/dist/components/submitDialogAction.js +89 -0
  13. package/dist/components/submitDialogAction.js.map +1 -0
  14. package/dist/core/AssessmentPlayer.d.ts +1102 -53
  15. package/dist/core/AssessmentPlayer.js +2836 -457
  16. package/dist/core/AssessmentPlayer.js.map +1 -1
  17. package/dist/core/AssessmentSessionCoordinator.d.ts +76 -7
  18. package/dist/core/AssessmentSessionCoordinator.js +185 -10
  19. package/dist/core/AssessmentSessionCoordinator.js.map +1 -1
  20. package/dist/core/AutosaveManager.d.ts +104 -0
  21. package/dist/core/AutosaveManager.js +181 -0
  22. package/dist/core/AutosaveManager.js.map +1 -0
  23. package/dist/core/ItemSessionController.d.ts +17 -26
  24. package/dist/core/ItemSessionController.js +33 -73
  25. package/dist/core/ItemSessionController.js.map +1 -1
  26. package/dist/core/NavigationManager.d.ts +18 -50
  27. package/dist/core/NavigationManager.js +21 -83
  28. package/dist/core/NavigationManager.js.map +1 -1
  29. package/dist/core/TimeManager.d.ts +62 -16
  30. package/dist/core/TimeManager.js +148 -57
  31. package/dist/core/TimeManager.js.map +1 -1
  32. package/dist/core/autosave.d.ts +44 -0
  33. package/dist/core/autosave.js +46 -0
  34. package/dist/core/autosave.js.map +1 -0
  35. package/dist/core/deliveryStructure.d.ts +54 -0
  36. package/dist/core/deliveryStructure.js +72 -0
  37. package/dist/core/deliveryStructure.js.map +1 -0
  38. package/dist/core/errors.d.ts +116 -0
  39. package/dist/core/errors.js +77 -0
  40. package/dist/core/errors.js.map +1 -0
  41. package/dist/core/exitBoundaries.d.ts +64 -0
  42. package/dist/core/exitBoundaries.js +98 -0
  43. package/dist/core/exitBoundaries.js.map +1 -0
  44. package/dist/core/feedback.d.ts +46 -0
  45. package/dist/core/feedback.js +47 -0
  46. package/dist/core/feedback.js.map +1 -0
  47. package/dist/core/formatTime.d.ts +8 -0
  48. package/dist/core/formatTime.js +20 -0
  49. package/dist/core/formatTime.js.map +1 -0
  50. package/dist/core/index.d.ts +7 -4
  51. package/dist/core/index.js +4 -1
  52. package/dist/core/index.js.map +1 -1
  53. package/dist/core/navigationPolicy.d.ts +46 -0
  54. package/dist/core/navigationPolicy.js +66 -0
  55. package/dist/core/navigationPolicy.js.map +1 -0
  56. package/dist/core/pause.d.ts +58 -0
  57. package/dist/core/pause.js +101 -0
  58. package/dist/core/pause.js.map +1 -0
  59. package/dist/core/playerEvents.d.ts +51 -0
  60. package/dist/core/playerEvents.js +66 -0
  61. package/dist/core/playerEvents.js.map +1 -0
  62. package/dist/core/reviewState.d.ts +81 -0
  63. package/dist/core/reviewState.js +113 -0
  64. package/dist/core/reviewState.js.map +1 -0
  65. package/dist/core/reviewViews.d.ts +43 -0
  66. package/dist/core/reviewViews.js +88 -0
  67. package/dist/core/reviewViews.js.map +1 -0
  68. package/dist/core/scopeLocks.d.ts +36 -0
  69. package/dist/core/scopeLocks.js +78 -0
  70. package/dist/core/scopeLocks.js.map +1 -0
  71. package/dist/core/sessionRecords.d.ts +31 -0
  72. package/dist/core/sessionRecords.js +74 -0
  73. package/dist/core/sessionRecords.js.map +1 -0
  74. package/dist/core/submissionPolicy.d.ts +65 -0
  75. package/dist/core/submissionPolicy.js +71 -0
  76. package/dist/core/submissionPolicy.js.map +1 -0
  77. package/dist/core/templateDefaults.d.ts +26 -0
  78. package/dist/core/templateDefaults.js +54 -0
  79. package/dist/core/templateDefaults.js.map +1 -0
  80. package/dist/core/testStructure.d.ts +118 -3
  81. package/dist/core/testStructure.js +255 -6
  82. package/dist/core/testStructure.js.map +1 -1
  83. package/dist/core/timePolicy.d.ts +40 -0
  84. package/dist/core/timePolicy.js +106 -0
  85. package/dist/core/timePolicy.js.map +1 -0
  86. package/dist/index.d.ts +7 -4
  87. package/dist/index.js +5 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/integration/ReferenceBackendAdapter.d.ts +64 -101
  90. package/dist/integration/ReferenceBackendAdapter.js +214 -1033
  91. package/dist/integration/ReferenceBackendAdapter.js.map +1 -1
  92. package/dist/integration/api-contract.d.ts +175 -10
  93. package/dist/integration/api-contract.js.map +1 -1
  94. package/dist/integration/assessment-item-scorer.d.ts +56 -5
  95. package/dist/integration/assessment-item-scorer.js +116 -13
  96. package/dist/integration/assessment-item-scorer.js.map +1 -1
  97. package/dist/integration/index.d.ts +2 -2
  98. package/dist/integration/index.js +1 -1
  99. package/dist/integration/index.js.map +1 -1
  100. package/dist/integration/qti-test-parser.d.ts +44 -0
  101. package/dist/integration/qti-test-parser.js +558 -0
  102. package/dist/integration/qti-test-parser.js.map +1 -0
  103. package/dist/integration/session-store.d.ts +54 -0
  104. package/dist/integration/session-store.js +75 -0
  105. package/dist/integration/session-store.js.map +1 -0
  106. package/dist/integration/test-navigation.d.ts +23 -0
  107. package/dist/integration/test-navigation.js +32 -0
  108. package/dist/integration/test-navigation.js.map +1 -0
  109. package/dist/integration/toSectionComposition.js +8 -1
  110. package/dist/integration/toSectionComposition.js.map +1 -1
  111. package/dist/reporting/index.d.ts +3 -0
  112. package/dist/reporting/index.js +3 -0
  113. package/dist/reporting/index.js.map +1 -0
  114. package/dist/reporting/inferBaseType.d.ts +13 -0
  115. package/dist/reporting/inferBaseType.js +26 -0
  116. package/dist/reporting/inferBaseType.js.map +1 -0
  117. package/dist/reporting/serializeAssessmentResult.d.ts +27 -0
  118. package/dist/reporting/serializeAssessmentResult.js +377 -0
  119. package/dist/reporting/serializeAssessmentResult.js.map +1 -0
  120. package/dist/reporting/toAssessmentResultXml.d.ts +39 -0
  121. package/dist/reporting/toAssessmentResultXml.js +304 -0
  122. package/dist/reporting/toAssessmentResultXml.js.map +1 -0
  123. package/dist/reporting/types.d.ts +85 -0
  124. package/dist/reporting/types.js +8 -0
  125. package/dist/reporting/types.js.map +1 -0
  126. package/dist/types/index.d.ts +96 -9
  127. package/dist/types/index.js.map +1 -1
  128. package/package.json +18 -14
  129. package/dist/core/StatePersistenceManager.d.ts +0 -125
  130. package/dist/core/StatePersistenceManager.js +0 -268
  131. package/dist/core/StatePersistenceManager.js.map +0 -1
  132. package/dist/utils/PerformanceMonitor.d.ts +0 -114
  133. package/dist/utils/PerformanceMonitor.js +0 -172
  134. package/dist/utils/PerformanceMonitor.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qti-test-parser.js","sourceRoot":"","sources":["../../src/integration/qti-test-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EACN,iCAAiC,EACjC,6BAA6B,EAC7B,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,iCAAiC,GACjC,MAAM,sBAAsB,CAAC;AAW9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,gFAAgF;AAChF,MAAM,oCAAqC,SAAQ,KAAK;CAAG;AAC3D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,OAAe,EACf,UAgBI,EAAE;IAEN,MAAM,EAAE,IAAI,GAAG,WAAW,EAAE,UAAU,GAAG,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,C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AC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS;QACrF,oBAAoB;QACpB,YAAY;QACZ,OAAO;KACP,CAAC;AACH,CAAC","sourcesContent":["/**\n * QTI assessmentTest XML parser for the reference backend.\n *\n * Extracted verbatim from ReferenceBackendAdapter; the adapter's static\n * `parseAssessmentTestXml` delegates here. Its output feeds both the adapter's\n * session model and (via player-elements' discovery parser) element-side\n * prefetch; keep identifier/href extraction in lockstep with\n * packages/player-elements/src/qti/parseAssessmentTest.ts.\n */\n\nimport { parseXml, serializeXml } from '@pie-qti/qti-processing';\nimport {\n\tcreateResolvedItemDeliveryContext,\n\textractAssessmentStimulusRefs,\n\textractProcessingIncludeRefs,\n\textractQtiStylesheets,\n\tparseAssessmentStimulusXml,\n\tresolveCheckedPackagePath,\n\tresolveCheckedPackagePathFromFile,\n} from '@pie-qti/ims-cp-core';\nimport { parse } from 'node-html-parser';\nimport type {\n\tSecureAssessment,\n\tSecureBranchRule,\n\tSecureItemRef,\n\tSecureItemSessionControl,\n\tTestFeedbackItem,\n\tSecureSection,\n\tSecureTestPart,\n} from './api-contract.js';\nimport { toCanonicalQtiName } from '../core/testStructure.js';\n\n/** Maximum assessmentSection nesting before parsing gives up (QTI 3.0 §2.2). */\nclass AssessmentSectionReferenceLimitError extends Error {}\n/**\n * Parse a QTI assessmentTest XML string into a SecureAssessment structure.\n *\n * Handles:\n * - S1: section-level itemSessionControl\n * - S9: assessmentSectionRef href resolution (requires fileResolver)\n * - T9/T1: outcomeDeclarations + outcomeProcessing extraction\n *\n * @param testXml - Raw QTI assessmentTest XML string\n * @param options.role - Role to assign to items (default: 'candidate')\n * @param options.itemXmlMap - Map of item identifier -> itemXml for pre-loaded items\n * @param options.fileResolver - Async function to load external files by relative href\n * @param options.baseUrl - Base URL for resolving relative hrefs\n */\nexport async function parseAssessmentTestXml(\n\ttestXml: string,\n\toptions: {\n\t\trole?: SecureItemRef['role'];\n\t\titemXmlMap?: Record<string, string>;\n\t\tfileResolver?: (href: string) => Promise<string>;\n\t\tbaseUrl?: string;\n\t\t/**\n\t\t * Shared catalog files the package manifest lists (resource type\n\t\t * `imsqti_catalog_xmlv3p0`): href, XML, or both. Their entries back\n\t\t * every item's `data-catalog-idref` terms; item-level catalogs win\n\t\t * identifier collisions (QTI 3.0 §6.3).\n\t\t */\n\t\tsharedCatalogs?: ReadonlyArray<{ href?: string; xml?: string }>;\n\t\tsectionReferenceLimits?: {\n\t\t\t/** Maximum total inline and external assessmentSection nesting. Defaults to 32. */\n\t\t\tmaxDepth?: number;\n\t\t};\n\t} = {}\n): Promise<SecureAssessment> {\n\tconst { role = 'candidate', itemXmlMap = {}, fileResolver, baseUrl, sharedCatalogs } = options;\n\tconst maxSectionDepth = options.sectionReferenceLimits?.maxDepth ?? 32;\n\tif (!Number.isInteger(maxSectionDepth) || maxSectionDepth < 1) {\n\t\tthrow new Error('sectionReferenceLimits.maxDepth must be a positive integer');\n\t}\n\tconst doc = parseXml(testXml);\n\tconst root = doc.documentElement;\n\tif (!root) throw new Error('Empty assessmentTest XML');\n\n\t// Reads camelCase and QTI 3 kebab-case attribute spellings alike. Empty values\n\t// are treated as missing here; the player-elements discovery parser keeps '' —\n\t// the two are intentionally not shared so each call site keeps its semantics.\n\tconst getAttr = (el: Element, name: string): string | undefined => {\n\t\tconst direct = el.getAttribute(name);\n\t\tif (direct !== null && direct !== '') return direct;\n\t\tconst mapped = el.getAttribute(name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`));\n\t\treturn mapped === null || mapped === '' ? undefined : mapped;\n\t};\n\n\tconst childElements = (el: Element): Element[] =>\n\t\tArray.from(el.childNodes).filter((n): n is Element => n.nodeType === 1);\n\n\tconst childrenByTag = (el: Element, tag: string): Element[] =>\n\t\tchildElements(el).filter((c) => toCanonicalQtiName(c.localName) === tag);\n\n\t/**\n\t * The language `el`'s content is written in, by XML language inheritance (XML 1.0 §2.12):\n\t * its own `xml:lang` (QTI 3 content may also say `lang`), else its nearest ancestor's.\n\t * `xml:lang=\"\"` declares no language and stops the inheritance. The root of an external\n\t * section inherits `inherited`, the language in force at its assessmentSectionRef.\n\t */\n\tconst contentLanguageOf = (el: Element, inherited?: string): string | undefined => {\n\t\tfor (let node: Node | null = el; node && node.nodeType === 1; node = node.parentNode) {\n\t\t\tconst element = node as Element;\n\t\t\tconst name = element.hasAttribute('xml:lang') ? 'xml:lang' : element.hasAttribute('lang') ? 'lang' : null;\n\t\t\tif (name) return element.getAttribute(name)?.trim() || undefined;\n\t\t}\n\t\treturn inherited;\n\t};\n\n\t/** A rubric block's content language: its content body's (QTI 3), else the block's. */\n\tconst rubricLanguageOf = (block: Element, inherited?: string): string | undefined =>\n\t\tcontentLanguageOf(childrenByTag(block, 'contentBody')[0] ?? block, inherited);\n\n\t// Parse itemSessionControl element\n\tconst parseItemSessionControl = (el: Element): SecureItemSessionControl | undefined => {\n\t\tconst isc = childrenByTag(el, 'itemSessionControl')[0];\n\t\tif (!isc) return undefined;\n\t\tconst boolAttr = (name: string): boolean | undefined => {\n\t\t\tconst v = getAttr(isc, name);\n\t\t\treturn v === undefined ? undefined : v !== 'false';\n\t\t};\n\t\tconst intAttr = (name: string): number | undefined => {\n\t\t\tconst v = getAttr(isc, name);\n\t\t\treturn v === undefined ? undefined : parseInt(v, 10);\n\t\t};\n\t\treturn {\n\t\t\tmaxAttempts: intAttr('maxAttempts'),\n\t\t\tshowFeedback: boolAttr('showFeedback') ?? boolAttr('show-feedback'),\n\t\t\tallowReview: boolAttr('allowReview') ?? boolAttr('allow-review'),\n\t\t\tshowSolution: boolAttr('showSolution') ?? boolAttr('show-solution'),\n\t\t\tallowComment: boolAttr('allowComment') ?? boolAttr('allow-comment'),\n\t\t\tallowSkipping: boolAttr('allowSkipping') ?? boolAttr('allow-skipping'),\n\t\t\tvalidateResponses: boolAttr('validateResponses') ?? boolAttr('validate-responses'),\n\t\t};\n\t};\n\n\tconst parseTimeLimits = (el: Element): SecureAssessment['timeLimits'] | undefined => {\n\t\tconst limitsEl = childrenByTag(el, 'timeLimit')[0] ?? childrenByTag(el, 'timeLimits')[0];\n\t\tif (!limitsEl) return undefined;\n\t\tconst numberAttr = (name: string): number | undefined => {\n\t\t\tconst value = getAttr(limitsEl, name);\n\t\t\tif (value === undefined) return undefined;\n\t\t\tconst parsed = Number(value);\n\t\t\treturn Number.isFinite(parsed) ? parsed : undefined;\n\t\t};\n\t\tconst boolAttr = (name: string): boolean | undefined => {\n\t\t\tconst value = getAttr(limitsEl, name);\n\t\t\treturn value === undefined ? undefined : value === 'true';\n\t\t};\n\t\treturn {\n\t\t\tminTime: numberAttr('minTime'),\n\t\t\tmaxTime: numberAttr('maxTime'),\n\t\t\tallowLateSubmission: boolAttr('allowLateSubmission'),\n\t\t};\n\t};\n\n\tconst parseConditionExpressions = (el: Element, tag: string): string[] | undefined => {\n\t\tconst expressions = childrenByTag(el, tag)\n\t\t\t.map((condition) => childElements(condition)[0])\n\t\t\t.filter((expression): expression is Element => Boolean(expression))\n\t\t\t.map((expression) => serializeXml(expression));\n\t\treturn expressions.length > 0 ? expressions : undefined;\n\t};\n\n\tconst parseBranchRules = (el: Element): SecureBranchRule[] | undefined => {\n\t\tconst rules = childrenByTag(el, 'branchRule').flatMap((rule) => {\n\t\t\tconst target = getAttr(rule, 'target');\n\t\t\tif (!target) return [];\n\t\t\tconst expression = childElements(rule)[0];\n\t\t\treturn [{ target, conditionXml: expression ? serializeXml(expression) : undefined }];\n\t\t});\n\t\treturn rules.length > 0 ? rules : undefined;\n\t};\n\n\tconst parseSelection = (el: Element): SecureSection['selection'] => {\n\t\tconst selection = childrenByTag(el, 'selection')[0];\n\t\tif (!selection) return undefined;\n\t\tconst select = Number.parseInt(getAttr(selection, 'select') ?? '', 10);\n\t\tif (!Number.isInteger(select) || select < 0) return undefined;\n\t\tconst withReplacementRaw = getAttr(selection, 'withReplacement');\n\t\treturn {\n\t\t\tselect,\n\t\t\twithReplacement: withReplacementRaw === undefined ? undefined : withReplacementRaw === 'true',\n\t\t};\n\t};\n\n\tconst parseOrdering = (el: Element): SecureSection['ordering'] => {\n\t\tconst ordering = childrenByTag(el, 'ordering')[0];\n\t\tif (!ordering) return undefined;\n\t\treturn { shuffle: getAttr(ordering, 'shuffle') === 'true' };\n\t};\n\n\tconst resolveCheckedHref = (\n\t\thref: string | undefined,\n\t\tsourceHref?: string,\n\t): string | undefined => {\n\t\tif (!href) return undefined;\n\t\tif (sourceHref) {\n\t\t\treturn resolveCheckedPackagePathFromFile(sourceHref, href) ?? undefined;\n\t\t}\n\t\treturn baseUrl\n\t\t\t? resolveCheckedPackagePathFromFile(baseUrl, href) ?? undefined\n\t\t\t: resolveCheckedPackagePath(undefined, href) ?? undefined;\n\t};\n\n\tconst loadText = async (\n\t\thref: string | undefined,\n\t\tsourceHref?: string,\n\t): Promise<string | undefined> => {\n\t\tif (!href) return undefined;\n\t\tconst candidates = [href, resolveCheckedHref(href, sourceHref)].filter((value, index, all): value is string =>\n\t\t\tBoolean(value) && all.indexOf(value) === index\n\t\t);\n\t\tfor (const candidate of candidates) {\n\t\t\tif (itemXmlMap[candidate] !== undefined) {\n\t\t\t\treturn itemXmlMap[candidate];\n\t\t\t}\n\t\t}\n\t\tif (!fileResolver) return undefined;\n\t\tfor (const candidate of candidates) {\n\t\t\ttry {\n\t\t\t\treturn await fileResolver(candidate);\n\t\t\t} catch {\n\t\t\t\t// Try the next candidate before giving up.\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t};\n\n\tconst buildDeliveryContext = async (\n\t\titemXml: string,\n\t\titemHref: string | undefined\n\t): Promise<SecureItemRef['deliveryContext'] | undefined> => {\n\t\tif (!itemHref) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst stimulusXmlByPath: Record<string, string> = {};\n\t\tconst packageTextByPath: Record<string, string> = {};\n\t\tconst preloadText = async (baseHref: string, href: string): Promise<void> => {\n\t\t\tconst resolvedPath = resolveCheckedPackagePathFromFile(baseHref, href);\n\t\t\tif (!resolvedPath) return;\n\t\t\tconst text = await loadText(resolvedPath);\n\t\t\tif (text !== undefined) {\n\t\t\t\tpackageTextByPath[resolvedPath] = text;\n\t\t\t}\n\t\t};\n\t\tfor (const stylesheet of extractQtiStylesheets(itemXml)) {\n\t\t\tawait preloadText(itemHref, stylesheet.href);\n\t\t}\n\t\tfor (const ref of extractAssessmentStimulusRefs(itemXml)) {\n\t\t\tconst stimulusPath = resolveCheckedPackagePathFromFile(itemHref, ref.href);\n\t\t\tif (!stimulusPath) continue;\n\t\t\tconst stimulusXml = await loadText(stimulusPath);\n\t\t\tif (stimulusXml) {\n\t\t\t\tstimulusXmlByPath[stimulusPath] = stimulusXml;\n\t\t\t\tfor (const stylesheet of parseAssessmentStimulusXml(stimulusXml).stylesheets) {\n\t\t\t\t\tawait preloadText(stimulusPath, stylesheet.href);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Preload external processing fragments so the item session's synchronous\n\t\t// resolver stays package-contained. Nested includes resolve relative to the\n\t\t// fragment that references them; the processing engine still validates\n\t\t// namespace, mode, depth, and cycles at build time.\n\t\tconst processingFragments: Record<string, string> = {};\n\t\tconst collectProcessingFragments = async (\n\t\t\tsourceXml: string,\n\t\t\tsourceHref: string,\n\t\t\tseen: Set<string>,\n\t\t): Promise<void> => {\n\t\t\tfor (const includeHref of extractProcessingIncludeRefs(sourceXml)) {\n\t\t\t\tconst fragmentPath = resolveCheckedPackagePathFromFile(sourceHref, includeHref);\n\t\t\t\tif (!fragmentPath || seen.has(fragmentPath)) continue;\n\t\t\t\tseen.add(fragmentPath);\n\t\t\t\tconst fragmentXml = await loadText(fragmentPath);\n\t\t\t\tif (fragmentXml === undefined) continue;\n\t\t\t\tprocessingFragments[fragmentPath] = fragmentXml;\n\t\t\t\tawait collectProcessingFragments(fragmentXml, fragmentPath, seen);\n\t\t\t}\n\t\t};\n\t\tconst fragmentSeen = new Set<string>();\n\t\tawait collectProcessingFragments(itemXml, itemHref, fragmentSeen);\n\t\t// Shared catalog files resolve against the package root, not the item.\n\t\tconst packageCatalogSources: Array<{ href?: string; xml?: string }> = [];\n\t\tfor (const shared of sharedCatalogs ?? []) {\n\t\t\tif (shared.xml) {\n\t\t\t\tpackageCatalogSources.push({ href: shared.href, xml: shared.xml });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!shared.href) continue;\n\t\t\tconst href = resolveCheckedHref(shared.href);\n\t\t\tif (!href) continue;\n\t\t\tconst xml = await loadText(href);\n\t\t\tif (xml !== undefined) packageCatalogSources.push({ href, xml });\n\t\t}\n\t\treturn createResolvedItemDeliveryContext({\n\t\t\titemXml,\n\t\t\titemHref,\n\t\t\treadText: (path) => packageTextByPath[path] ?? stimulusXmlByPath[path] ?? itemXmlMap[path],\n\t\t\t...(Object.keys(processingFragments).length > 0 ? { processingFragments } : {}),\n\t\t\t...(packageCatalogSources.length > 0 ? { packageCatalogSources } : {}),\n\t\t});\n\t};\n\n\tlet resolveSectionRef: (\n\t\tsectionRefEl: Element,\n\t\tsourceHref?: string,\n\t\tancestorHrefs?: readonly string[],\n\t\tdepth?: number,\n\t\tinheritedLanguage?: string,\n\t) => Promise<SecureSection | null>;\n\n\tconst parseItemRef = async (ref: Element, sourceHref?: string): Promise<SecureItemRef> => {\n\t\tconst itemId = getAttr(ref, 'identifier') ?? 'item';\n\t\tconst href = getAttr(ref, 'href');\n\t\tconst itemHref = resolveCheckedHref(href, sourceHref);\n\t\tconst resolvedXml = href && !itemHref\n\t\t\t? ''\n\t\t\t: itemXmlMap[itemId] ??\n\t\t\t\t(href ? itemXmlMap[href] : undefined) ??\n\t\t\t\t(itemHref ? itemXmlMap[itemHref] : undefined) ??\n\t\t\t\t(await loadText(itemHref)) ??\n\t\t\t\t'';\n\t\tconst requiredRaw = getAttr(ref, 'required');\n\t\tconst fixedRaw = getAttr(ref, 'fixed');\n\t\tconst categories = (getAttr(ref, 'category') ?? '').split(/\\s+/).filter(Boolean);\n\t\tconst weights = childrenByTag(ref, 'weight').flatMap((weight) => {\n\t\t\tconst identifier = getAttr(weight, 'identifier');\n\t\t\tconst value = Number(getAttr(weight, 'value'));\n\t\t\treturn identifier && Number.isFinite(value) ? [{ identifier, value }] : [];\n\t\t});\n\t\tconst variableMappings = childrenByTag(ref, 'variableMapping').flatMap((mapping) => {\n\t\t\tconst sourceIdentifier = getAttr(mapping, 'sourceIdentifier');\n\t\t\tconst targetIdentifier = getAttr(mapping, 'targetIdentifier');\n\t\t\treturn sourceIdentifier && targetIdentifier ? [{ sourceIdentifier, targetIdentifier }] : [];\n\t\t});\n\t\tconst templateDefaults = childrenByTag(ref, 'templateDefault').flatMap((templateDefault) => {\n\t\t\tconst templateIdentifier = getAttr(templateDefault, 'templateIdentifier');\n\t\t\tconst expression = childElements(templateDefault)[0];\n\t\t\treturn templateIdentifier && expression\n\t\t\t\t? [{ templateIdentifier, expressionXml: serializeXml(expression) }]\n\t\t\t\t: [];\n\t\t});\n\t\treturn {\n\t\t\tidentifier: itemId,\n\t\t\titemXml: resolvedXml,\n\t\t\trole,\n\t\t\trequired: requiredRaw === undefined ? undefined : requiredRaw !== 'false',\n\t\t\tfixed: fixedRaw === undefined ? undefined : fixedRaw !== 'false',\n\t\t\ttimeLimits: parseTimeLimits(ref),\n\t\t\tdeliveryContext: await buildDeliveryContext(resolvedXml, itemHref),\n\t\t\tbranchRule: parseBranchRules(ref),\n\t\t\tpreConditions: parseConditionExpressions(ref, 'preCondition'),\n\t\t\tweights: weights.length > 0 ? weights : undefined,\n\t\t\tcategories: categories.length > 0 ? categories : undefined,\n\t\t\titemSessionControl: parseItemSessionControl(ref),\n\t\t\tvariableMappings: variableMappings.length > 0 ? variableMappings : undefined,\n\t\t\ttemplateDefaults: templateDefaults.length > 0 ? templateDefaults : undefined,\n\t\t};\n\t};\n\n\t// Parse a single assessmentSection element without flattening nested sections.\n\t// `inheritedLanguage` is the content language at the assessmentSectionRef of an\n\t// external section file, whose own root has no ancestors to inherit it from.\n\tconst parseSection = async (\n\t\tsectionEl: Element,\n\t\tsourceHref?: string,\n\t\tancestorHrefs: readonly string[] = [],\n\t\tdepth = 1,\n\t\tinheritedLanguage?: string,\n\t): Promise<SecureSection> => {\n\t\tconst identifier = getAttr(sectionEl, 'identifier') ?? 'section';\n\t\tif (depth > maxSectionDepth) {\n\t\t\tthrow new AssessmentSectionReferenceLimitError(\n\t\t\t\t`assessmentSection nesting exceeds maxDepth (${maxSectionDepth}) at \"${identifier}\"`,\n\t\t\t);\n\t\t}\n\t\tconst title = getAttr(sectionEl, 'title');\n\t\tconst visibleRaw = getAttr(sectionEl, 'visible');\n\t\tconst visible = visibleRaw === undefined ? true : visibleRaw !== 'false';\n\t\tconst requiredRaw = getAttr(sectionEl, 'required');\n\t\tconst fixedRaw = getAttr(sectionEl, 'fixed');\n\t\tconst keepTogetherRaw = getAttr(sectionEl, 'keepTogether');\n\n\t\tconst itemSessionControl = parseItemSessionControl(sectionEl);\n\t\tconst timeLimits = parseTimeLimits(sectionEl);\n\n\t\t// rubricBlocks\n\t\tconst rubricBlockEls = childrenByTag(sectionEl, 'rubricBlock');\n\t\tconst rubricBlocks = rubricBlockEls.length > 0\n\t\t\t? rubricBlockEls.map((b, idx) => {\n\t\t\t\tconst language = rubricLanguageOf(b, inheritedLanguage);\n\t\t\t\treturn {\n\t\t\t\t\tidentifier: getAttr(b, 'identifier') ?? `${identifier}-rubric-${idx + 1}`,\n\t\t\t\t\tview: (getAttr(b, 'view') ?? 'candidate').split(/\\s+/).filter(Boolean),\n\t\t\t\t\tuse: getAttr(b, 'use'),\n\t\t\t\t\tcontent: serializeXml(b),\n\t\t\t\t\t...(language ? { language } : {}),\n\t\t\t\t};\n\t\t\t})\n\t\t\t: undefined;\n\n\t\tconst assessmentItemRefs: SecureItemRef[] = [];\n\t\tconst sections: SecureSection[] = [];\n\t\tconst children: NonNullable<SecureSection['children']> = [];\n\t\tfor (const child of childElements(sectionEl)) {\n\t\t\tconst name = toCanonicalQtiName(child.localName);\n\t\t\tif (name === 'assessmentItemRef') {\n\t\t\t\tconst item = await parseItemRef(child, sourceHref);\n\t\t\t\tassessmentItemRefs.push(item);\n\t\t\t\tchildren.push({ type: 'item', item });\n\t\t\t} else if (name === 'assessmentSection') {\n\t\t\t\tconst section = await parseSection(child, sourceHref, ancestorHrefs, depth + 1, inheritedLanguage);\n\t\t\t\tsections.push(section);\n\t\t\t\tchildren.push({ type: 'section', section });\n\t\t\t} else if (name === 'assessmentSectionRef') {\n\t\t\t\tconst section = await resolveSectionRef(child, sourceHref, ancestorHrefs, depth + 1, inheritedLanguage);\n\t\t\t\tif (section) {\n\t\t\t\t\tsections.push(section);\n\t\t\t\t\tchildren.push({ type: 'section', section });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tidentifier,\n\t\t\ttitle,\n\t\t\tvisible,\n\t\t\trequired: requiredRaw === undefined ? undefined : requiredRaw !== 'false',\n\t\t\tfixed: fixedRaw === undefined ? undefined : fixedRaw !== 'false',\n\t\t\tassessmentItemRefs,\n\t\t\tsections: sections.length > 0 ? sections : undefined,\n\t\t\tchildren: children.length > 0 ? children : undefined,\n\t\t\trubricBlocks,\n\t\t\titemSessionControl,\n\t\t\ttimeLimits,\n\t\t\tselection: parseSelection(sectionEl),\n\t\t\tordering: parseOrdering(sectionEl),\n\t\t\tpreConditions: parseConditionExpressions(sectionEl, 'preCondition'),\n\t\t\tbranchRule: parseBranchRules(sectionEl),\n\t\t\tkeepTogether: keepTogetherRaw === undefined ? undefined : keepTogetherRaw !== 'false',\n\t\t};\n\t};\n\n\t// Resolve assessmentSectionRef: load and parse referenced section file\n\tresolveSectionRef = async (\n\t\tsectionRefEl: Element,\n\t\tsourceHref?: string,\n\t\tancestorHrefs: readonly string[] = [],\n\t\tdepth = 1,\n\t\tinheritedLanguage?: string,\n\t): Promise<SecureSection | null> => {\n\t\tconst href = getAttr(sectionRefEl, 'href');\n\t\tif (!href) {\n\t\t\tconsole.warn('[ReferenceBackendAdapter] assessmentSectionRef missing href, skipping');\n\t\t\treturn null;\n\t\t}\n\n\t\tif (!fileResolver) {\n\t\t\tconsole.warn(\n\t\t\t\t`[ReferenceBackendAdapter] assessmentSectionRef href=\"${href}\" found but no fileResolver provided, skipping`\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\n\t\ttry {\n\t\t\tconst resolvedHref = resolveCheckedHref(href, sourceHref);\n\t\t\tif (!resolvedHref) {\n\t\t\t\tconsole.warn(`[ReferenceBackendAdapter] assessmentSectionRef href=\"${href}\" is unsafe, skipping`);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (ancestorHrefs.includes(resolvedHref)) {\n\t\t\t\tthrow new AssessmentSectionReferenceLimitError(\n\t\t\t\t\t`Cyclic assessmentSectionRef detected: ${[...ancestorHrefs, resolvedHref].join(' -> ')}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (depth > maxSectionDepth) {\n\t\t\t\tthrow new AssessmentSectionReferenceLimitError(\n\t\t\t\t\t`assessmentSectionRef nesting exceeds maxDepth (${maxSectionDepth}) at \"${resolvedHref}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst sectionXml = await fileResolver(resolvedHref);\n\t\t\tconst secDoc = parseXml(sectionXml);\n\t\t\tconst secRoot = secDoc.documentElement;\n\t\t\tif (!secRoot || toCanonicalQtiName(secRoot.localName) !== 'assessmentSection') {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[ReferenceBackendAdapter] assessmentSectionRef href=\"${href}\": root element is not <assessmentSection>, skipping`\n\t\t\t\t);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// The referenced section stands in for the ref: it inherits the ref's language.\n\t\t\treturn parseSection(\n\t\t\t\tsecRoot,\n\t\t\t\tresolvedHref,\n\t\t\t\t[...ancestorHrefs, resolvedHref],\n\t\t\t\tdepth,\n\t\t\t\tcontentLanguageOf(sectionRefEl, inheritedLanguage),\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof AssessmentSectionReferenceLimitError) throw err;\n\t\t\tconsole.warn(\n\t\t\t\t`[ReferenceBackendAdapter] Failed to load assessmentSectionRef href=\"${href}\":`,\n\t\t\t\terr\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t};\n\n\t// Parse testPart children (sections + sectionRefs)\n\tconst parseSectionsForTestPart = async (testPartEl: Element): Promise<SecureSection[]> => {\n\t\tconst sections: SecureSection[] = [];\n\t\tfor (const child of childElements(testPartEl)) {\n\t\t\tif (toCanonicalQtiName(child.localName) === 'assessmentSection') {\n\t\t\t\tsections.push(await parseSection(child));\n\t\t\t} else if (toCanonicalQtiName(child.localName) === 'assessmentSectionRef') {\n\t\t\t\tconst resolved = await resolveSectionRef(child);\n\t\t\t\tif (resolved) sections.push(resolved);\n\t\t\t}\n\t\t}\n\t\treturn sections;\n\t};\n\n\t// Extract outcomeDeclarations\n\tconst outcomeDeclarations = childrenByTag(root, 'outcomeDeclaration').map((d) => {\n\t\tconst identifier = getAttr(d, 'identifier') ?? 'OUTCOME';\n\t\tconst baseType = getAttr(d, 'baseType') ?? 'float';\n\t\tconst cardinality = getAttr(d, 'cardinality') ?? 'single';\n\t\t// Parse defaultValue if present\n\t\tconst defaultValueEl = childrenByTag(d, 'defaultValue')[0];\n\t\tlet defaultValue: unknown = undefined;\n\t\tif (defaultValueEl) {\n\t\t\tconst valueEl = childrenByTag(defaultValueEl, 'value')[0];\n\t\t\tif (valueEl) {\n\t\t\t\tconst text = valueEl.textContent?.trim() ?? '0';\n\t\t\t\tif (baseType === 'float' || baseType === 'integer') {\n\t\t\t\t\tdefaultValue = Number(text);\n\t\t\t\t} else {\n\t\t\t\t\tdefaultValue = text;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn { identifier, baseType, cardinality, defaultValue };\n\t});\n\n\t// Extract outcomeProcessing XML\n\tconst outcomeProcessingEl = childrenByTag(root, 'outcomeProcessing')[0];\n\tconst outcomeProcessingXml = outcomeProcessingEl\n\t\t? serializeXml(outcomeProcessingEl)\n\t\t: undefined;\n\t// QTI 3 wraps testFeedback content in qti-content-body. Only the body's children are\n\t// kept as content, so the language it is written in travels as `language`.\n\tconst parseTestFeedback = (parent: Element): TestFeedbackItem[] | undefined => {\n\t\tconst items = childrenByTag(parent, 'testFeedback').flatMap((feedback, index) => {\n\t\t\tconst outcomeIdentifier = getAttr(feedback, 'outcomeIdentifier');\n\t\t\tif (!outcomeIdentifier) return [];\n\t\t\tconst body = childrenByTag(feedback, 'contentBody')[0] ?? feedback;\n\t\t\tconst content = Array.from(body.childNodes).map((node) => serializeXml(node)).join('');\n\t\t\tconst language = contentLanguageOf(body);\n\t\t\treturn [{\n\t\t\t\tidentifier: getAttr(feedback, 'identifier') ?? `test-feedback-${index + 1}`,\n\t\t\t\toutcomeIdentifier,\n\t\t\t\tshowHide: (getAttr(feedback, 'showHide') ?? 'show') as 'show' | 'hide',\n\t\t\t\taccess: (getAttr(feedback, 'access') ?? 'atEnd') as 'atEnd' | 'during',\n\t\t\t\tcontent,\n\t\t\t\t...(language ? { language } : {}),\n\t\t\t}];\n\t\t});\n\t\treturn items.length > 0 ? items : undefined;\n\t};\n\tconst testFeedback = parseTestFeedback(root);\n\n\t// Extract assessment-level timeLimits.\n\tconst timeLimits = parseTimeLimits(root);\n\n\t// Parse testParts\n\tconst testPartEls = childrenByTag(root, 'testPart');\n\tconst firstTestPart = testPartEls[0];\n\n\t// Retain top-level compatibility fields while preserving the authoritative\n\t// mode on every testPart below.\n\tconst navigationMode = (getAttr(firstTestPart ?? root, 'navigationMode') ?? 'nonlinear') as\n\t\t| 'linear'\n\t\t| 'nonlinear';\n\tconst submissionMode = (getAttr(firstTestPart ?? root, 'submissionMode') ?? 'simultaneous') as\n\t\t| 'individual'\n\t\t| 'simultaneous';\n\n\tconst testParts: SecureTestPart[] = [];\n\tfor (const tp of testPartEls) {\n\t\tconst tpIdentifier = getAttr(tp, 'identifier') ?? 'part-1';\n\t\tconst tpNavigationMode = (getAttr(tp, 'navigationMode') ?? 'nonlinear') as 'linear' | 'nonlinear';\n\t\tconst tpSubmissionMode = (getAttr(tp, 'submissionMode') ?? 'simultaneous') as\n\t\t\t| 'individual'\n\t\t\t| 'simultaneous';\n\t\tconst tpItemSessionControl = parseItemSessionControl(tp);\n\t\tconst tpTimeLimits = parseTimeLimits(tp);\n\t\tconst tpRubricBlockEls = childrenByTag(tp, 'rubricBlock');\n\t\tconst tpRubricBlocks = tpRubricBlockEls.length > 0\n\t\t\t? tpRubricBlockEls.map((b, idx) => {\n\t\t\t\tconst language = rubricLanguageOf(b);\n\t\t\t\treturn {\n\t\t\t\t\tidentifier: getAttr(b, 'identifier') ?? `${tpIdentifier}-rubric-${idx + 1}`,\n\t\t\t\t\tview: (getAttr(b, 'view') ?? 'candidate').split(/\\s+/).filter(Boolean),\n\t\t\t\t\tuse: getAttr(b, 'use'),\n\t\t\t\t\tcontent: serializeXml(b),\n\t\t\t\t\t...(language ? { language } : {}),\n\t\t\t\t};\n\t\t\t})\n\t\t\t: undefined;\n\n\t\tconst sections = await parseSectionsForTestPart(tp);\n\t\ttestParts.push({\n\t\t\tidentifier: tpIdentifier,\n\t\t\tnavigationMode: tpNavigationMode,\n\t\t\tsubmissionMode: tpSubmissionMode,\n\t\t\tsections,\n\t\t\trubricBlocks: tpRubricBlocks,\n\t\t\ttestFeedback: parseTestFeedback(tp),\n\t\t\titemSessionControl: tpItemSessionControl,\n\t\t\ttimeLimits: tpTimeLimits,\n\t\t\tpreConditions: parseConditionExpressions(tp, 'preCondition'),\n\t\t\tbranchRule: parseBranchRules(tp),\n\t\t});\n\t}\n\n\t// If no testParts, try top-level sections\n\tif (testParts.length === 0) {\n\t\tconst topSections: SecureSection[] = [];\n\t\tfor (const child of childElements(root)) {\n\t\t\tif (toCanonicalQtiName(child.localName) === 'assessmentSection') {\n\t\t\t\ttopSections.push(await parseSection(child));\n\t\t\t} else if (toCanonicalQtiName(child.localName) === 'assessmentSectionRef') {\n\t\t\t\tconst resolved = await resolveSectionRef(child);\n\t\t\t\tif (resolved) topSections.push(resolved);\n\t\t\t}\n\t\t}\n\t\tif (topSections.length > 0) {\n\t\t\ttestParts.push({\n\t\t\t\tidentifier: 'part-1',\n\t\t\t\tnavigationMode,\n\t\t\t\tsubmissionMode,\n\t\t\t\tsections: topSections,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn {\n\t\tidentifier: getAttr(root, 'identifier') ?? 'assessment',\n\t\t// Left empty when absent: shells show a localized generic title, not English text.\n\t\ttitle: getAttr(root, 'title') ?? '',\n\t\tnavigationMode,\n\t\tsubmissionMode,\n\t\ttestParts,\n\t\ttimeLimits,\n\t\toutcomeDeclarations: outcomeDeclarations.length > 0 ? outcomeDeclarations : undefined,\n\t\toutcomeProcessingXml,\n\t\ttestFeedback,\n\t\tbaseUrl,\n\t};\n}\n"]}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * localStorage session store for the reference backend adapter.
3
+ *
4
+ * Sessions store the full assessment (with QTI XML and correct answers) client-side —
5
+ * INSECURE by design; this is a reference implementation, not a production backend.
6
+ */
7
+ import type { AssessmentSessionState, OutcomeProcessingError, SecureAssessment, SessionId } from './api-contract.js';
8
+ import type { ItemTestState } from './assessment-item-scorer.js';
9
+ /**
10
+ * Stored session data (includes full QTI XML - INSECURE)
11
+ */
12
+ export interface StoredSession {
13
+ sessionId: SessionId;
14
+ assessmentId: string;
15
+ candidateId: string;
16
+ /** Full assessment structure with QTI XML */
17
+ assessment: SecureAssessment;
18
+ /** Current state */
19
+ state: AssessmentSessionState;
20
+ /** Created timestamp */
21
+ createdAt: number;
22
+ /** Finalized flag */
23
+ finalized: boolean;
24
+ /**
25
+ * Per-item variables and flags from each item's latest counted submission, read by
26
+ * test-level outcome processing. Absent until the session's first counted submission.
27
+ */
28
+ itemTestStates?: Record<string, ItemTestState>;
29
+ /**
30
+ * Set when test-level outcome processing failed: candidate responses stay persisted,
31
+ * but SCORE/testFeedback outcomes could not be computed and the error must surface
32
+ * to the host instead of failing silently.
33
+ */
34
+ outcomeProcessingError?: OutcomeProcessingError;
35
+ }
36
+ export declare function generateSessionId(assessmentId: string, candidateId: string): SessionId;
37
+ export declare function loadSession(sessionId: SessionId): StoredSession | null;
38
+ /**
39
+ * Persist one session. Returns true only when the write landed: callers propagate the
40
+ * failure honestly (a `saveState` that reports success while nothing was stored would
41
+ * silently lose the draft; a finalize that reports finalized while the flag never
42
+ * persisted would resurrect the test on resume). Best-effort callers (the init write,
43
+ * the outcome-processing-error bookkeeping) may ignore the result.
44
+ */
45
+ export declare function saveSession(session: StoredSession): boolean;
46
+ /**
47
+ * The most recent stored session for an assessment and candidate, or null. Unfinalized
48
+ * sessions only by default: a finalized test has nothing left to resume. This is the
49
+ * reference loader behind `ReferenceBackendAdapter.latestSessionId()`, which demos and
50
+ * tests use to resume a draft after a refresh.
51
+ */
52
+ export declare function findLatestSession(assessmentId: string, candidateId: string, options?: {
53
+ includeFinalized?: boolean;
54
+ }): StoredSession | null;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * localStorage session store for the reference backend adapter.
3
+ *
4
+ * Sessions store the full assessment (with QTI XML and correct answers) client-side —
5
+ * INSECURE by design; this is a reference implementation, not a production backend.
6
+ */
7
+ /**
8
+ * localStorage key prefix of every stored session, defined only here. Saved sessions are
9
+ * found and resumed by it, so the value must not change.
10
+ */
11
+ const STORAGE_PREFIX = 'qti_session_';
12
+ export function generateSessionId(assessmentId, candidateId) {
13
+ return `${assessmentId}:${candidateId}:${Date.now()}`;
14
+ }
15
+ export function loadSession(sessionId) {
16
+ try {
17
+ const key = STORAGE_PREFIX + sessionId;
18
+ const data = localStorage.getItem(key);
19
+ if (!data)
20
+ return null;
21
+ return JSON.parse(data);
22
+ }
23
+ catch {
24
+ return null;
25
+ }
26
+ }
27
+ /**
28
+ * Persist one session. Returns true only when the write landed: callers propagate the
29
+ * failure honestly (a `saveState` that reports success while nothing was stored would
30
+ * silently lose the draft; a finalize that reports finalized while the flag never
31
+ * persisted would resurrect the test on resume). Best-effort callers (the init write,
32
+ * the outcome-processing-error bookkeeping) may ignore the result.
33
+ */
34
+ export function saveSession(session) {
35
+ try {
36
+ const key = STORAGE_PREFIX + session.sessionId;
37
+ localStorage.setItem(key, JSON.stringify(session));
38
+ return true;
39
+ }
40
+ catch (error) {
41
+ // Quota exceeded and friends: the failure is the caller's to surface.
42
+ console.error('Failed to save session to localStorage:', error);
43
+ return false;
44
+ }
45
+ }
46
+ /**
47
+ * The most recent stored session for an assessment and candidate, or null. Unfinalized
48
+ * sessions only by default: a finalized test has nothing left to resume. This is the
49
+ * reference loader behind `ReferenceBackendAdapter.latestSessionId()`, which demos and
50
+ * tests use to resume a draft after a refresh.
51
+ */
52
+ export function findLatestSession(assessmentId, candidateId, options = {}) {
53
+ let latest = null;
54
+ try {
55
+ for (let index = 0; index < localStorage.length; index++) {
56
+ const key = localStorage.key(index);
57
+ if (!key?.startsWith(STORAGE_PREFIX))
58
+ continue;
59
+ const session = loadSession(key.slice(STORAGE_PREFIX.length));
60
+ if (!session)
61
+ continue;
62
+ if (session.assessmentId !== assessmentId || session.candidateId !== candidateId)
63
+ continue;
64
+ if (session.finalized && !options.includeFinalized)
65
+ continue;
66
+ if (!latest || session.createdAt > latest.createdAt)
67
+ latest = session;
68
+ }
69
+ }
70
+ catch {
71
+ return null;
72
+ }
73
+ return latest;
74
+ }
75
+ //# sourceMappingURL=session-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-store.js","sourceRoot":"","sources":["../../src/integration/session-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;;GAGG;AACH,MAAM,cAAc,GAAG,cAAc,CAAC;AA8BtC,MAAM,UAAU,iBAAiB,CAAC,YAAoB,EAAE,WAAmB;IAC1E,OAAO,GAAG,YAAY,IAAI,WAAW,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,SAAoB;IAC/C,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,cAAc,GAAG,SAAS,CAAC;QACvC,MAAM,IAAI,GAA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AE,SAAS;YAC3F,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,gBAAgB;gBAAE,SAAS;YAC7D,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS;gBAAE,MAAM,GAAG,OAAO,CAAC;QACvE,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/**\n * localStorage session store for the reference backend adapter.\n *\n * Sessions store the full assessment (with QTI XML and correct answers) client-side —\n * INSECURE by design; this is a reference implementation, not a production backend.\n */\n\nimport type {\n\tAssessmentSessionState,\n\tOutcomeProcessingError,\n\tSecureAssessment,\n\tSessionId,\n} from './api-contract.js';\nimport type { ItemTestState } from './assessment-item-scorer.js';\n\n/**\n * localStorage key prefix of every stored session, defined only here. Saved sessions are\n * found and resumed by it, so the value must not change.\n */\nconst STORAGE_PREFIX = 'qti_session_';\n\n/**\n * Stored session data (includes full QTI XML - INSECURE)\n */\nexport interface StoredSession {\n\tsessionId: SessionId;\n\tassessmentId: string;\n\tcandidateId: string;\n\t/** Full assessment structure with QTI XML */\n\tassessment: SecureAssessment;\n\t/** Current state */\n\tstate: AssessmentSessionState;\n\t/** Created timestamp */\n\tcreatedAt: number;\n\t/** Finalized flag */\n\tfinalized: boolean;\n\t/**\n\t * Per-item variables and flags from each item's latest counted submission, read by\n\t * test-level outcome processing. Absent until the session's first counted submission.\n\t */\n\titemTestStates?: Record<string, ItemTestState>;\n\t/**\n\t * Set when test-level outcome processing failed: candidate responses stay persisted,\n\t * but SCORE/testFeedback outcomes could not be computed and the error must surface\n\t * to the host instead of failing silently.\n\t */\n\toutcomeProcessingError?: OutcomeProcessingError;\n}\n\nexport function generateSessionId(assessmentId: string, candidateId: string): SessionId {\n\treturn `${assessmentId}:${candidateId}:${Date.now()}`;\n}\n\nexport function loadSession(sessionId: SessionId): StoredSession | null {\n\ttry {\n\t\tconst key = STORAGE_PREFIX + sessionId;\n\t\tconst data = localStorage.getItem(key);\n\t\tif (!data) return null;\n\t\treturn JSON.parse(data) as StoredSession;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Persist one session. Returns true only when the write landed: callers propagate the\n * failure honestly (a `saveState` that reports success while nothing was stored would\n * silently lose the draft; a finalize that reports finalized while the flag never\n * persisted would resurrect the test on resume). Best-effort callers (the init write,\n * the outcome-processing-error bookkeeping) may ignore the result.\n */\nexport function saveSession(session: StoredSession): boolean {\n\ttry {\n\t\tconst key = STORAGE_PREFIX + session.sessionId;\n\t\tlocalStorage.setItem(key, JSON.stringify(session));\n\t\treturn true;\n\t} catch (error) {\n\t\t// Quota exceeded and friends: the failure is the caller's to surface.\n\t\tconsole.error('Failed to save session to localStorage:', error);\n\t\treturn false;\n\t}\n}\n\n/**\n * The most recent stored session for an assessment and candidate, or null. Unfinalized\n * sessions only by default: a finalized test has nothing left to resume. This is the\n * reference loader behind `ReferenceBackendAdapter.latestSessionId()`, which demos and\n * tests use to resume a draft after a refresh.\n */\nexport function findLatestSession(\n\tassessmentId: string,\n\tcandidateId: string,\n\toptions: { includeFinalized?: boolean } = {},\n): StoredSession | null {\n\tlet latest: StoredSession | null = null;\n\ttry {\n\t\tfor (let index = 0; index < localStorage.length; index++) {\n\t\t\tconst key = localStorage.key(index);\n\t\t\tif (!key?.startsWith(STORAGE_PREFIX)) continue;\n\t\t\tconst session = loadSession(key.slice(STORAGE_PREFIX.length));\n\t\t\tif (!session) continue;\n\t\t\tif (session.assessmentId !== assessmentId || session.candidateId !== candidateId) continue;\n\t\t\tif (session.finalized && !options.includeFinalized) continue;\n\t\t\tif (!latest || session.createdAt > latest.createdAt) latest = session;\n\t\t}\n\t} catch {\n\t\treturn null;\n\t}\n\treturn latest;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Test-level navigation: the session-fed declarations the branch rules and preconditions
3
+ * read, and the delivered item refs in order.
4
+ *
5
+ * The pure delivery-rules walk itself (branch rules, preconditions, eligibility) is shared
6
+ * with the player through `core/testStructure.ts` and re-exported here — the reference
7
+ * backend and the client evaluate the same rules; this module is the backend's entry. The
8
+ * adapter threads its RNG so conditional evaluation stays deterministic per session.
9
+ */
10
+ import type { DeclarationMap, QtiValue } from '@pie-qti/qti-processing';
11
+ import type { SecureAssessment, SecureItemRef, TestOutcomeValues } from './api-contract.js';
12
+ import type { StoredSession } from './session-store.js';
13
+ export { firstEligibleItem, nextItemIdentifier } from '../core/testStructure.js';
14
+ /**
15
+ * Context for branch rules and preconditions: test outcomes, every submitted item's variables as
16
+ * `itemIdentifier.VARIABLE`, and `current` unprefixed where the test declares no such outcome.
17
+ */
18
+ export declare function navigationDeclarations(session: StoredSession, outcomes: TestOutcomeValues | undefined, current?: Record<string, QtiValue>): DeclarationMap;
19
+ /** Delivered item refs in order, each with the identifiers of the sections containing it (outermost first). */
20
+ export declare function getItemRefsInOrder(assessment: SecureAssessment): Array<{
21
+ item: SecureItemRef;
22
+ sectionIdentifiers: string[];
23
+ }>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Test-level navigation: the session-fed declarations the branch rules and preconditions
3
+ * read, and the delivered item refs in order.
4
+ *
5
+ * The pure delivery-rules walk itself (branch rules, preconditions, eligibility) is shared
6
+ * with the player through `core/testStructure.ts` and re-exported here — the reference
7
+ * backend and the client evaluate the same rules; this module is the backend's entry. The
8
+ * adapter threads its RNG so conditional evaluation stays deterministic per session.
9
+ */
10
+ import { addItemVariableDeclarations, applyVariableMappings, deliveredItems, testOutcomeDeclarations, } from '../core/testStructure.js';
11
+ export { firstEligibleItem, nextItemIdentifier } from '../core/testStructure.js';
12
+ /**
13
+ * Context for branch rules and preconditions: test outcomes, every submitted item's variables as
14
+ * `itemIdentifier.VARIABLE`, and `current` unprefixed where the test declares no such outcome.
15
+ */
16
+ export function navigationDeclarations(session, outcomes, current = {}) {
17
+ const itemVariables = {};
18
+ for (const { item } of deliveredItems(session.assessment)) {
19
+ const variables = session.itemTestStates?.[item.identifier]?.variables;
20
+ if (variables)
21
+ itemVariables[item.identifier] = applyVariableMappings(variables, item.variableMappings);
22
+ }
23
+ return addItemVariableDeclarations(testOutcomeDeclarations(session.assessment, outcomes), itemVariables, current);
24
+ }
25
+ /** Delivered item refs in order, each with the identifiers of the sections containing it (outermost first). */
26
+ export function getItemRefsInOrder(assessment) {
27
+ return deliveredItems(assessment).map(({ item, sections }) => ({
28
+ item,
29
+ sectionIdentifiers: sections.map((section) => section.identifier),
30
+ }));
31
+ }
32
+ //# sourceMappingURL=test-navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-navigation.js","sourceRoot":"","sources":["../../src/integration/test-navigation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACN,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,uBAAuB,GACvB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEjF;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACrC,OAAsB,EACtB,QAAuC,EACvC,UAAoC,EAAE;IAEtC,MAAM,aAAa,GAA6C,EAAE,CAAC;IACnE,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3D,MAAM,SAAS,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC;QACvE,IAAI,SAAS;YAAE,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,qBAAqB,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACzG,CAAC;IACD,OAAO,2BAA2B,CAAC,uBAAuB,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AACnH,CAAC;AAED,+GAA+G;AAC/G,MAAM,UAAU,kBAAkB,CACjC,UAA4B;IAE5B,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9D,IAAI;QACJ,kBAAkB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;KACjE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Test-level navigation: the session-fed declarations the branch rules and preconditions\n * read, and the delivered item refs in order.\n *\n * The pure delivery-rules walk itself (branch rules, preconditions, eligibility) is shared\n * with the player through `core/testStructure.ts` and re-exported here — the reference\n * backend and the client evaluate the same rules; this module is the backend's entry. The\n * adapter threads its RNG so conditional evaluation stays deterministic per session.\n */\n\nimport type { DeclarationMap, QtiValue } from '@pie-qti/qti-processing';\nimport type { SecureAssessment, SecureItemRef, TestOutcomeValues } from './api-contract.js';\nimport {\n\taddItemVariableDeclarations,\n\tapplyVariableMappings,\n\tdeliveredItems,\n\ttestOutcomeDeclarations,\n} from '../core/testStructure.js';\nimport type { StoredSession } from './session-store.js';\n\nexport { firstEligibleItem, nextItemIdentifier } from '../core/testStructure.js';\n\n/**\n * Context for branch rules and preconditions: test outcomes, every submitted item's variables as\n * `itemIdentifier.VARIABLE`, and `current` unprefixed where the test declares no such outcome.\n */\nexport function navigationDeclarations(\n\tsession: StoredSession,\n\toutcomes: TestOutcomeValues | undefined,\n\tcurrent: Record<string, QtiValue> = {},\n): DeclarationMap {\n\tconst itemVariables: Record<string, Record<string, QtiValue>> = {};\n\tfor (const { item } of deliveredItems(session.assessment)) {\n\t\tconst variables = session.itemTestStates?.[item.identifier]?.variables;\n\t\tif (variables) itemVariables[item.identifier] = applyVariableMappings(variables, item.variableMappings);\n\t}\n\treturn addItemVariableDeclarations(testOutcomeDeclarations(session.assessment, outcomes), itemVariables, current);\n}\n\n/** Delivered item refs in order, each with the identifiers of the sections containing it (outermost first). */\nexport function getItemRefsInOrder(\n\tassessment: SecureAssessment\n): Array<{ item: SecureItemRef; sectionIdentifiers: string[] }> {\n\treturn deliveredItems(assessment).map(({ item, sections }) => ({\n\t\titem,\n\t\tsectionIdentifiers: sections.map((section) => section.identifier),\n\t}));\n}\n"]}
@@ -28,6 +28,10 @@ export function toSectionComposition(player, config = {}) {
28
28
  passageTools: scopedTools(config.passageTools, 'passage'),
29
29
  });
30
30
  const activeSession = player.getCurrentItemSession();
31
+ // One shallow snapshot of the section's response records. Inactive items here are
32
+ // read-only composition data (only the active item renders, from its live session),
33
+ // so per-item deep clones would copy every answer on every composition build.
34
+ const sectionResponses = player.getSectionItemResponses();
31
35
  const sectionItems = player.getCurrentSectionItemRefs().map((item) => {
32
36
  const common = {
33
37
  identifier: item.identifier,
@@ -39,9 +43,12 @@ export function toSectionComposition(player, config = {}) {
39
43
  };
40
44
  return item.identifier === currentItem?.identifier && activeSession
41
45
  ? { ...common, session: activeSession }
42
- : { ...common, responses: player.getResponsesForItem(item.identifier) };
46
+ : { ...common, responses: sectionResponses[item.identifier] ?? {} };
43
47
  });
44
48
  return resolveQtiSectionComposition({
49
+ // The assessment the section belongs to: section tool bars name it (catalogs,
50
+ // display-settings session keys), not the section identifier.
51
+ assessmentId: player.getAssessmentId(),
45
52
  section: {
46
53
  identifier: navState.currentSection?.id ?? 'active-section',
47
54
  title: navState.currentSection?.title ?? currentItem?.title,
@@ -1 +1 @@
1
- {"version":3,"file":"toSectionComposition.js","sourceRoot":"","sources":["../../src/integration/toSectionComposition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACN,4BAA4B,GAK5B,MAAM,yBAAyB,CAAC;AAGjC,SAAS,aAAa,CAAC,IAA2C;IACjE,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW,CAAC;QACjB,KAAK,SAAS,CA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AAE,MAAM,CAAC;SAC5C,CAAC;QACF,OAAO,IAAI,CAAC,UAAU,KAAK,WAAW,EAAE,UAAU,IAAI,aAAa;YAClE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE;YACvC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,OAAO,4BAA4B,CAAC;QACnC,OAAO,EAAE;YACR,UAAU,EAAE,QAAQ,CAAC,cAAc,EAAE,EAAE,IAAI,gBAAgB;YAC3D,KAAK,EAAE,QAAQ,CAAC,cAAc,EAAE,KAAK,IAAI,WAAW,EAAE,KAAK;YAC3D,IAAI;YACJ,gBAAgB,EAAE,aAAa,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU;YAC/E,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC;YAClD,QAAQ,EAAE,YAAY;YACtB,aAAa;SACb;QACD,oBAAoB,EAAE,WAAW,EAAE,UAAU;QAC7C,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,MAAM,CAAC,WAAW;QACxB,GAAG,EAAE,MAAM,CAAC,GAAG;KACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { normalizeQtiSharedContext } from '@pie-qti/assessment-toolkit';\nimport {\n\tresolveQtiSectionComposition,\n\ttype QtiSectionItemRef,\n\ttype QtiSectionRole,\n\ttype QtiSectionToolConfig,\n\ttype ResolvedQtiSectionComposition,\n} from '@pie-qti/section-player';\nimport type { AssessmentPlayer, BackendAssessmentPlayerConfig } from '../core/AssessmentPlayer.js';\n\nfunction toSectionRole(role: BackendAssessmentPlayerConfig['role']): QtiSectionRole {\n\tswitch (role) {\n\t\tcase 'author':\n\t\tcase 'candidate':\n\t\tcase 'proctor':\n\t\tcase 'scorer':\n\t\tcase 'testConstructor':\n\t\tcase 'tutor':\n\t\t\treturn role;\n\t\tdefault:\n\t\t\treturn 'candidate';\n\t}\n}\n\nfunction scopedTools(tools: QtiSectionToolConfig[] | undefined, scope: QtiSectionToolConfig['scope']): QtiSectionToolConfig[] | undefined {\n\tif (!tools || tools.length === 0) return undefined;\n\treturn tools.map((tool) => ({ ...tool, scope }));\n}\n\nexport function toSectionComposition(\n\tplayer: AssessmentPlayer,\n\tconfig: Partial<BackendAssessmentPlayerConfig> = {}\n): ResolvedQtiSectionComposition {\n\tconst navState = player.getNavigationState();\n\tconst currentItem = player.getCurrentItem();\n\tconst role = toSectionRole(config.role);\n\tconst sharedContext = normalizeQtiSharedContext({\n\t\trubricBlocks: player.getCurrentSharedRubricBlocks(),\n\t\trole,\n\t\tpassageTools: scopedTools(config.passageTools, 'passage'),\n\t});\n\tconst activeSession = player.getCurrentItemSession();\n\tconst sectionItems: QtiSectionItemRef[] = player.getCurrentSectionItemRefs().map((item) => {\n\t\tconst common = {\n\t\t\tidentifier: item.identifier,\n\t\t\thref: item.href,\n\t\t\ttitle: item.title,\n\t\t\titemXml: item.itemXml,\n\t\t\tdeliveryContext: item.deliveryContext,\n\t\t\ttools: scopedTools(config.itemTools, 'item'),\n\t\t};\n\t\treturn item.identifier === currentItem?.identifier && activeSession\n\t\t\t? { ...common, session: activeSession }\n\t\t\t: { ...common, responses: player.getResponsesForItem(item.identifier) };\n\t});\n\n\treturn resolveQtiSectionComposition({\n\t\tsection: {\n\t\t\tidentifier: navState.currentSection?.id ?? 'active-section',\n\t\t\ttitle: navState.currentSection?.title ?? currentItem?.title,\n\t\t\trole,\n\t\t\tlayoutPreference: sharedContext.passages.length > 0 ? 'split-pane' : 'vertical',\n\t\t\ttools: scopedTools(config.sectionTools, 'section'),\n\t\t\titemRefs: sectionItems,\n\t\t\tsharedContext,\n\t\t},\n\t\tactiveItemIdentifier: currentItem?.identifier,\n\t\tcanPrevious: navState.canPrevious,\n\t\tcanNext: navState.canNext,\n\t\tsecurity: config.security,\n\t\thost: config.sectionHost,\n\t\tpnp: config.pnp,\n\t});\n}\n"]}
1
+ {"version":3,"file":"toSectionComposition.js","sourceRoot":"","sources":["../../src/integration/toSectionComposition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACN,4BAA4B,GAK5B,MAAM,yBAAyB,CAAC;AAGjC,SAAS,aAAa,CAAC,IAA2C;IACjE,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW,CAAC;QACjB,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,iBAAiB,CAAC;QACvB,KAAK,OAAO;YACX,OAAO,IAAI,CAAC;QACb;YACC,OAAO,WAAW,CAAC;IACrB,CAAC;AACF,CAAC;AAED,SAAS,WAAW,CAAC,KAAyC,EAAE,KAAoC;IACnG,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACnD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,oBAAoB,CACnC,MAAwB,EACxB,SAAiD,EAAE;IAEnD,MAAM,QAAQ,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IAC5C,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,aAAa,GAAG,yBAAyB,CAAC;QAC/C,YAAY,EAAE,MAAM,CAAC,4BAA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M,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU;YAC/E,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC;YAClD,QAAQ,EAAE,YAAY;YACtB,aAAa;SACb;QACD,oBAAoB,EAAE,WAAW,EAAE,UAAU;QAC7C,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,MAAM,CAAC,WAAW;QACxB,GAAG,EAAE,MAAM,CAAC,GAAG;KACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { normalizeQtiSharedContext } from '@pie-qti/assessment-toolkit';\nimport {\n\tresolveQtiSectionComposition,\n\ttype QtiSectionItemRef,\n\ttype QtiSectionRole,\n\ttype QtiSectionToolConfig,\n\ttype ResolvedQtiSectionComposition,\n} from '@pie-qti/section-player';\nimport type { AssessmentPlayer, BackendAssessmentPlayerConfig } from '../core/AssessmentPlayer.js';\n\nfunction toSectionRole(role: BackendAssessmentPlayerConfig['role']): QtiSectionRole {\n\tswitch (role) {\n\t\tcase 'author':\n\t\tcase 'candidate':\n\t\tcase 'proctor':\n\t\tcase 'scorer':\n\t\tcase 'testConstructor':\n\t\tcase 'tutor':\n\t\t\treturn role;\n\t\tdefault:\n\t\t\treturn 'candidate';\n\t}\n}\n\nfunction scopedTools(tools: QtiSectionToolConfig[] | undefined, scope: QtiSectionToolConfig['scope']): QtiSectionToolConfig[] | undefined {\n\tif (!tools || tools.length === 0) return undefined;\n\treturn tools.map((tool) => ({ ...tool, scope }));\n}\n\nexport function toSectionComposition(\n\tplayer: AssessmentPlayer,\n\tconfig: Partial<BackendAssessmentPlayerConfig> = {}\n): ResolvedQtiSectionComposition {\n\tconst navState = player.getNavigationState();\n\tconst currentItem = player.getCurrentItem();\n\tconst role = toSectionRole(config.role);\n\tconst sharedContext = normalizeQtiSharedContext({\n\t\trubricBlocks: player.getCurrentSharedRubricBlocks(),\n\t\trole,\n\t\tpassageTools: scopedTools(config.passageTools, 'passage'),\n\t});\n\tconst activeSession = player.getCurrentItemSession();\n\t// One shallow snapshot of the section's response records. Inactive items here are\n\t// read-only composition data (only the active item renders, from its live session),\n\t// so per-item deep clones would copy every answer on every composition build.\n\tconst sectionResponses = player.getSectionItemResponses();\n\tconst sectionItems: QtiSectionItemRef[] = player.getCurrentSectionItemRefs().map((item) => {\n\t\tconst common = {\n\t\t\tidentifier: item.identifier,\n\t\t\thref: item.href,\n\t\t\ttitle: item.title,\n\t\t\titemXml: item.itemXml,\n\t\t\tdeliveryContext: item.deliveryContext,\n\t\t\ttools: scopedTools(config.itemTools, 'item'),\n\t\t};\n\t\treturn item.identifier === currentItem?.identifier && activeSession\n\t\t\t? { ...common, session: activeSession }\n\t\t\t: { ...common, responses: sectionResponses[item.identifier] ?? {} };\n\t});\n\n\treturn resolveQtiSectionComposition({\n\t\t// The assessment the section belongs to: section tool bars name it (catalogs,\n\t\t// display-settings session keys), not the section identifier.\n\t\tassessmentId: player.getAssessmentId(),\n\t\tsection: {\n\t\t\tidentifier: navState.currentSection?.id ?? 'active-section',\n\t\t\ttitle: navState.currentSection?.title ?? currentItem?.title,\n\t\t\trole,\n\t\t\tlayoutPreference: sharedContext.passages.length > 0 ? 'split-pane' : 'vertical',\n\t\t\ttools: scopedTools(config.sectionTools, 'section'),\n\t\t\titemRefs: sectionItems,\n\t\t\tsharedContext,\n\t\t},\n\t\tactiveItemIdentifier: currentItem?.identifier,\n\t\tcanPrevious: navState.canPrevious,\n\t\tcanNext: navState.canNext,\n\t\tsecurity: config.security,\n\t\thost: config.sectionHost,\n\t\tpnp: config.pnp,\n\t});\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export { ASSESSMENT_RESULT_NAMESPACES, AssessmentResultSerializationError, type SerializeAssessmentResultOptions, serializeAssessmentResult, } from './serializeAssessmentResult.js';
2
+ export { type AssessmentResultsData, type AssessmentResultXmlOptions, buildAssessmentResultReport, toAssessmentResultXml, } from './toAssessmentResultXml.js';
3
+ export type { AssessmentItemResult, AssessmentResultContext, AssessmentResultReport, AssessmentResultVersion, AssessmentTestResult, ResultBaseType, ResultCardinality, ResultContextVariable, ResultDatestamp, ResultOutcomeVariable, ResultResponseVariable, ResultSessionIdentifier, ResultSessionStatus, ResultTemplateVariable, ResultVariable, } from './types.js';
@@ -0,0 +1,3 @@
1
+ export { ASSESSMENT_RESULT_NAMESPACES, AssessmentResultSerializationError, serializeAssessmentResult, } from './serializeAssessmentResult.js';
2
+ export { buildAssessmentResultReport, toAssessmentResultXml, } from './toAssessmentResultXml.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporting/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,4BAA4B,EAC5B,kCAAkC,EAElC,yBAAyB,GACzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAGN,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAC","sourcesContent":["export {\n\tASSESSMENT_RESULT_NAMESPACES,\n\tAssessmentResultSerializationError,\n\ttype SerializeAssessmentResultOptions,\n\tserializeAssessmentResult,\n} from './serializeAssessmentResult.js';\nexport {\n\ttype AssessmentResultsData,\n\ttype AssessmentResultXmlOptions,\n\tbuildAssessmentResultReport,\n\ttoAssessmentResultXml,\n} from './toAssessmentResultXml.js';\nexport type {\n\tAssessmentItemResult,\n\tAssessmentResultContext,\n\tAssessmentResultReport,\n\tAssessmentResultVersion,\n\tAssessmentTestResult,\n\tResultBaseType,\n\tResultCardinality,\n\tResultContextVariable,\n\tResultDatestamp,\n\tResultOutcomeVariable,\n\tResultResponseVariable,\n\tResultSessionIdentifier,\n\tResultSessionStatus,\n\tResultTemplateVariable,\n\tResultVariable,\n} from './types.js';\n"]}
@@ -0,0 +1,13 @@
1
+ import type { ResultBaseType } from './types.js';
2
+ /**
3
+ * The base type of a report value that no declaration and no serialized field types: a boolean is
4
+ * a QTI boolean, a whole number an integer (the base type whose value space whole numbers live in),
5
+ * a fractional number a float, anything else a string. A list types itself by its members:
6
+ * integer only when every member is a whole number, float when any member is fractional, else the
7
+ * first member's type (so `[3, 4]` is integer while `[3, 3.5]` stays float and loses nothing).
8
+ *
9
+ * One rule shared by every report writer, so an undeclared value writes the same base type
10
+ * whichever writer reports it — `toAssessmentResultXml` and `serializeAssessmentResult` both
11
+ * delegate here.
12
+ */
13
+ export declare function inferBaseType(value: unknown): ResultBaseType;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The base type of a report value that no declaration and no serialized field types: a boolean is
3
+ * a QTI boolean, a whole number an integer (the base type whose value space whole numbers live in),
4
+ * a fractional number a float, anything else a string. A list types itself by its members:
5
+ * integer only when every member is a whole number, float when any member is fractional, else the
6
+ * first member's type (so `[3, 4]` is integer while `[3, 3.5]` stays float and loses nothing).
7
+ *
8
+ * One rule shared by every report writer, so an undeclared value writes the same base type
9
+ * whichever writer reports it — `toAssessmentResultXml` and `serializeAssessmentResult` both
10
+ * delegate here.
11
+ */
12
+ export function inferBaseType(value) {
13
+ if (Array.isArray(value)) {
14
+ const members = value.filter((entry) => entry !== null && entry !== undefined);
15
+ if (members.length > 0 && members.every((entry) => typeof entry === 'number')) {
16
+ return members.every((entry) => Number.isInteger(entry)) ? 'integer' : 'float';
17
+ }
18
+ return members.length > 0 ? inferBaseType(members[0]) : 'string';
19
+ }
20
+ if (typeof value === 'boolean')
21
+ return 'boolean';
22
+ if (typeof value === 'number')
23
+ return Number.isInteger(value) ? 'integer' : 'float';
24
+ return 'string';
25
+ }
26
+ //# sourceMappingURL=inferBaseType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inferBaseType.js","sourceRoot":"","sources":["../../src/reporting/inferBaseType.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC;QAC/E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;YAC/E,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;QAChF,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACnE,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;IACpF,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import type { ResultBaseType } from './types.js';\n\n/**\n * The base type of a report value that no declaration and no serialized field types: a boolean is\n * a QTI boolean, a whole number an integer (the base type whose value space whole numbers live in),\n * a fractional number a float, anything else a string. A list types itself by its members:\n * integer only when every member is a whole number, float when any member is fractional, else the\n * first member's type (so `[3, 4]` is integer while `[3, 3.5]` stays float and loses nothing).\n *\n * One rule shared by every report writer, so an undeclared value writes the same base type\n * whichever writer reports it — `toAssessmentResultXml` and `serializeAssessmentResult` both\n * delegate here.\n */\nexport function inferBaseType(value: unknown): ResultBaseType {\n\tif (Array.isArray(value)) {\n\t\tconst members = value.filter((entry) => entry !== null && entry !== undefined);\n\t\tif (members.length > 0 && members.every((entry) => typeof entry === 'number')) {\n\t\t\treturn members.every((entry) => Number.isInteger(entry)) ? 'integer' : 'float';\n\t\t}\n\t\treturn members.length > 0 ? inferBaseType(members[0]!) : 'string';\n\t}\n\tif (typeof value === 'boolean') return 'boolean';\n\tif (typeof value === 'number') return Number.isInteger(value) ? 'integer' : 'float';\n\treturn 'string';\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import type { AssessmentResultReport, AssessmentResultVersion } from './types.js';
2
+ /**
3
+ * The QTI Results Reporting namespaces and schema locations, as the 1EdTech schemas declare them:
4
+ * `imsqti_result_v2p2.xsd` (QTI 2.2) and `imsqti_resultv3p0_v1p0.xsd` (QTI 3.0). Both versions use
5
+ * the same camelCase element and attribute names.
6
+ */
7
+ export declare const ASSESSMENT_RESULT_NAMESPACES: Readonly<Record<AssessmentResultVersion, {
8
+ readonly namespace: string;
9
+ readonly schemaLocation: string;
10
+ }>>;
11
+ export interface SerializeAssessmentResultOptions {
12
+ readonly version: AssessmentResultVersion;
13
+ /** Declare `xsi:schemaLocation` for the version's results schema. Default: true. */
14
+ readonly schemaLocation?: boolean;
15
+ }
16
+ /** The report cannot be written as a schema-valid `assessmentResult` of the requested version. */
17
+ export declare class AssessmentResultSerializationError extends Error {
18
+ constructor(message: string);
19
+ }
20
+ /**
21
+ * Writes a QTI Results Reporting `assessmentResult` document. Every value and attribute is
22
+ * XML-escaped (characters XML 1.0 cannot carry become U+FFFD); identifiers the version's schema
23
+ * types as NCName, an unknown base type or cardinality, a session status the version lacks, or an
24
+ * invalid date throw an `AssessmentResultSerializationError`. Durations are written as seconds,
25
+ * the xsd:double form QTI defines.
26
+ */
27
+ export declare function serializeAssessmentResult(report: AssessmentResultReport, options: SerializeAssessmentResultOptions): string;