@pie-qti/assessment-player 0.1.19 → 0.1.21

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.
@@ -1 +1 @@
1
- {"version":3,"file":"assessment-item-scorer.js","sourceRoot":"","sources":["../../src/integration/assessment-item-scorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmC,MAAM,sBAAsB,CAAC;AAS/E,MAAM,UAAU,2BAA2B,CAAC,OAAe;IAC1D,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACxF,OAAO,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,EACnC,OAAO,EACP,SAAS,EACT,WAAW,GACiB;IAC5B,MAAM,cAAc,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAE5D,IAAI,CAAC;QACJ,4DAA4D;QAC5D,8EAA8E;QAC9E,4EAA4E;QAC5E,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;YACzB,OAAO;YACP,IAAI,EAAE,QAAQ;SACd,CAAC,CAAC;QAEH,IAAI,WAAW,EAAE,CAAC;YACjB,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACxC,CAAC;QACD,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,OAAO,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAEtH,OAAO;YACN,cAAc;YACd,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;SACnC,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACvC,OAAO;YACN,cAAc;YACd,KAAK,EAAE,CAAC;YACR,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,KAAK;YAChB,aAAa,EAAE,EAAE;SACjB,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["import { Player, type SerializedItemSessionState } from '@pie-qti/item-player';\nimport type { AssessmentScoringResult, ResponseValue } from './api-contract.js';\n\nexport interface AssessmentItemScoringInput {\n\titemXml: string;\n\tresponses: Record<string, ResponseValue>;\n\titemSession?: SerializedItemSessionState;\n}\n\nexport function getAssessmentItemIdentifier(itemXml: string): string {\n\tconst identifierMatch = itemXml.match(/assessmentItem[^>]+identifier=[\"']([^\"']+)[\"']/);\n\treturn identifierMatch?.[1] || 'unknown';\n}\n\n/**\n * Runs QTI ResponseProcessing for one AssessmentItem and normalizes the result\n * to the BackendAdapter scoring shape used by AssessmentPlayer.\n */\nexport function scoreAssessmentItem({\n\titemXml,\n\tresponses,\n\titemSession,\n}: AssessmentItemScoringInput): AssessmentScoringResult {\n\tconst itemIdentifier = getAssessmentItemIdentifier(itemXml);\n\n\ttry {\n\t\t// Use a scorer-grade view of the item for accurate scoring.\n\t\t// NOTE: This reference scorer is intentionally insecure and runs client-side.\n\t\t// In production, scoring must happen server-side with secured item content.\n\t\tconst player = new Player({\n\t\t\titemXml,\n\t\t\trole: 'scorer',\n\t\t});\n\n\t\tif (itemSession) {\n\t\t\tplayer.restoreItemSession(itemSession);\n\t\t}\n\t\tplayer.setResponses(responses);\n\t\tconst result = itemSession ? (player.scoreAttempt().scoring ?? player.processResponses()) : player.processResponses();\n\n\t\treturn {\n\t\t\titemIdentifier,\n\t\t\tscore: result.score,\n\t\t\tmaxScore: result.maxScore,\n\t\t\tcompleted: result.completed,\n\t\t\toutcomeValues: result.outcomeValues,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error('Scoring error:', error);\n\t\treturn {\n\t\t\titemIdentifier,\n\t\t\tscore: 0,\n\t\t\tmaxScore: 1,\n\t\t\tcompleted: false,\n\t\t\toutcomeValues: {},\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"assessment-item-scorer.js","sourceRoot":"","sources":["../../src/integration/assessment-item-scorer.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,8BAA8B,GAE9B,MAAM,sBAAsB,CAAC;AAS9B,MAAM,UAAU,2BAA2B,CAAC,OAAe;IAC1D,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACxF,OAAO,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,EACnC,OAAO,EACP,SAAS,EACT,WAAW,GACiB;IAC5B,MAAM,cAAc,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAE5D,IAAI,CAAC;QACJ,4DAA4D;QAC5D,8EAA8E;QAC9E,4EAA4E;QAC5E,MAAM,UAAU,GAAG,8BAA8B,CAAC;YACjD,OAAO;YACP,IAAI,EAAE,QAAQ;SACd,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CACrC,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CACtD,CAAC;QACF,IAAI,MAAM,CAAC;QACX,IAAI,CAAC;YACJ,MAAM,GAAG,OAAO,CAAC,QAAQ,CACxB,WAAW;gBACV,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE;gBAC5B,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC1E,CAAC,MAAM,EAAE,OAAO,CAAC;YAClB,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAChE,CAAC;gBAAS,CAAC;YACV,OAAO,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;QAED,OAAO;YACN,cAAc;YACd,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;SACnC,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACvC,OAAO;YACN,cAAc;YACd,KAAK,EAAE,CAAC;YACR,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,KAAK;YAChB,aAAa,EAAE,EAAE;SACjB,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["import {\n\tcreateAssessmentItemDefinition,\n\ttype SerializedItemSessionState,\n} from '@pie-qti/item-player';\nimport type { AssessmentScoringResult, ResponseValue } from './api-contract.js';\n\nexport interface AssessmentItemScoringInput {\n\titemXml: string;\n\tresponses: Record<string, ResponseValue>;\n\titemSession?: SerializedItemSessionState;\n}\n\nexport function getAssessmentItemIdentifier(itemXml: string): string {\n\tconst identifierMatch = itemXml.match(/assessmentItem[^>]+identifier=[\"']([^\"']+)[\"']/);\n\treturn identifierMatch?.[1] || 'unknown';\n}\n\n/**\n * Runs QTI ResponseProcessing for one AssessmentItem and normalizes the result\n * to the BackendAdapter scoring shape used by AssessmentPlayer.\n */\nexport function scoreAssessmentItem({\n\titemXml,\n\tresponses,\n\titemSession,\n}: AssessmentItemScoringInput): AssessmentScoringResult {\n\tconst itemIdentifier = getAssessmentItemIdentifier(itemXml);\n\n\ttry {\n\t\t// Use a scorer-grade view of the item for accurate scoring.\n\t\t// NOTE: This reference scorer is intentionally insecure and runs client-side.\n\t\t// In production, scoring must happen server-side with secured item content.\n\t\tconst definition = createAssessmentItemDefinition({\n\t\t\titemXml,\n\t\t\trole: 'scorer',\n\t\t});\n\t\tconst session = definition.openSession(\n\t\t\titemSession ? { restore: itemSession } : { responses },\n\t\t);\n\t\tlet result;\n\t\ttry {\n\t\t\tresult = session.dispatch(\n\t\t\t\titemSession\n\t\t\t\t\t? { action: 'scoreAttempt' }\n\t\t\t\t\t: { action: 'endAttempt', countAttempt: false, validateResponses: false },\n\t\t\t).result?.scoring;\n\t\t\tif (!result) throw new Error('QTI scoring produced no result');\n\t\t} finally {\n\t\t\tsession.dispose();\n\t\t}\n\n\t\treturn {\n\t\t\titemIdentifier,\n\t\t\tscore: result.score,\n\t\t\tmaxScore: result.maxScore,\n\t\t\tcompleted: result.completed,\n\t\t\toutcomeValues: result.outcomeValues,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error('Scoring error:', error);\n\t\treturn {\n\t\t\titemIdentifier,\n\t\t\tscore: 0,\n\t\t\tmaxScore: 1,\n\t\t\tcompleted: false,\n\t\t\toutcomeValues: {},\n\t\t};\n\t}\n}\n"]}
@@ -1,21 +1,21 @@
1
1
  /**
2
2
  * QTI 2.2 Assessment Player - Backend Integration
3
3
  *
4
- * ## Default Behavior: Client-Side Only
4
+ * ## Reference/demo behavior
5
5
  *
6
- * By default, the assessment player runs entirely client-side:
7
- * - No backend required for demos, development, testing
8
- * - Uses ReferenceBackendAdapter with localStorage
9
- * - Scoring performed in-browser using the QTI Player
6
+ * AssessmentPlayer always requires an explicit BackendAdapter. Demos can opt in
7
+ * to ReferenceBackendAdapter, which stores and scores client-side.
10
8
  *
11
9
  * @example
12
10
  * ```typescript
13
11
  * import { AssessmentPlayer } from '@pie-qti/assessment-player';
12
+ * import { ReferenceBackendAdapter } from '@pie-qti/assessment-player/integration';
14
13
  *
15
- * // Client-only mode (default) - no backend needed
16
- * const player = new AssessmentPlayer({
17
- * assessment: myAssessment,
18
- * role: 'candidate'
14
+ * const backend = new ReferenceBackendAdapter();
15
+ * backend.registerAssessment('preview', secureAssessment);
16
+ * const player = await AssessmentPlayer.create({
17
+ * backend,
18
+ * initSession: { assessmentId: 'preview', candidateId: 'local' }
19
19
  * });
20
20
  * ```
21
21
  *
@@ -33,10 +33,9 @@
33
33
  * import { MyBackendAdapter } from './adapters/MyBackendAdapter';
34
34
  *
35
35
  * // Production mode with backend
36
- * const player = new AssessmentPlayer({
36
+ * const player = await AssessmentPlayer.create({
37
37
  * backend: new MyBackendAdapter('https://api.example.com', authToken),
38
- * assessmentId: 'test-001',
39
- * candidateId: 'student-123'
38
+ * initSession: { assessmentId: 'test-001', candidateId: 'student-123' }
40
39
  * });
41
40
  * ```
42
41
  *
@@ -1,21 +1,21 @@
1
1
  /**
2
2
  * QTI 2.2 Assessment Player - Backend Integration
3
3
  *
4
- * ## Default Behavior: Client-Side Only
4
+ * ## Reference/demo behavior
5
5
  *
6
- * By default, the assessment player runs entirely client-side:
7
- * - No backend required for demos, development, testing
8
- * - Uses ReferenceBackendAdapter with localStorage
9
- * - Scoring performed in-browser using the QTI Player
6
+ * AssessmentPlayer always requires an explicit BackendAdapter. Demos can opt in
7
+ * to ReferenceBackendAdapter, which stores and scores client-side.
10
8
  *
11
9
  * @example
12
10
  * ```typescript
13
11
  * import { AssessmentPlayer } from '@pie-qti/assessment-player';
12
+ * import { ReferenceBackendAdapter } from '@pie-qti/assessment-player/integration';
14
13
  *
15
- * // Client-only mode (default) - no backend needed
16
- * const player = new AssessmentPlayer({
17
- * assessment: myAssessment,
18
- * role: 'candidate'
14
+ * const backend = new ReferenceBackendAdapter();
15
+ * backend.registerAssessment('preview', secureAssessment);
16
+ * const player = await AssessmentPlayer.create({
17
+ * backend,
18
+ * initSession: { assessmentId: 'preview', candidateId: 'local' }
19
19
  * });
20
20
  * ```
21
21
  *
@@ -33,10 +33,9 @@
33
33
  * import { MyBackendAdapter } from './adapters/MyBackendAdapter';
34
34
  *
35
35
  * // Production mode with backend
36
- * const player = new AssessmentPlayer({
36
+ * const player = await AssessmentPlayer.create({
37
37
  * backend: new MyBackendAdapter('https://api.example.com', authToken),
38
- * assessmentId: 'test-001',
39
- * candidateId: 'student-123'
38
+ * initSession: { assessmentId: 'test-001', candidateId: 'student-123' }
40
39
  * });
41
40
  * ```
42
41
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AA2BH,0DAA0D;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACN,2BAA2B,EAC3B,mBAAmB,GAEnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["/**\n * QTI 2.2 Assessment Player - Backend Integration\n *\n * ## Default Behavior: Client-Side Only\n *\n * By default, the assessment player runs entirely client-side:\n * - No backend required for demos, development, testing\n * - Uses ReferenceBackendAdapter with localStorage\n * - Scoring performed in-browser using the QTI Player\n *\n * @example\n * ```typescript\n * import { AssessmentPlayer } from '@pie-qti/assessment-player';\n *\n * // Client-only mode (default) - no backend needed\n * const player = new AssessmentPlayer({\n * assessment: myAssessment,\n * role: 'candidate'\n * });\n * ```\n *\n * ## Production: Backend Integration\n *\n * For production deployments, implement BackendAdapter for:\n * - Server-side scoring (secure)\n * - Persistent session storage\n * - Authentication/authorization\n * - Sensitive data protection\n *\n * @example\n * ```typescript\n * import { AssessmentPlayer } from '@pie-qti/assessment-player';\n * import { MyBackendAdapter } from './adapters/MyBackendAdapter';\n *\n * // Production mode with backend\n * const player = new AssessmentPlayer({\n * backend: new MyBackendAdapter('https://api.example.com', authToken),\n * assessmentId: 'test-001',\n * candidateId: 'student-123'\n * });\n * ```\n *\n * See BACKEND-INTEGRATION.md for complete implementation guide.\n */\n\n// Export API contract (TypeScript interfaces)\nexport type {\n\tBackendAdapter,\n\tFeedbackItem,\n\tAssessmentSessionState,\n\tAssessmentScoringResult,\n\tAssessmentRubricBlock,\n\tFinalizeAssessmentRequest,\n\tFinalizeAssessmentResponse,\n\tInitSessionRequest,\n\tInitSessionResponse,\n\tResponseValue,\n\tSaveAssessmentStateRequest,\n\tSaveAssessmentStateResponse,\n\tSecureAssessment,\n\tSecureItemRef,\n\tSecureSection,\n\tSecureTestPart,\n\tSecureTimeLimits,\n\tSessionId,\n\tSubmitTimingEvidence,\n\tSubmitResponsesRequest,\n\tSubmitResponsesResponse,\n} from './api-contract.js';\n\n// Export reference implementation (for development/demos)\nexport { ReferenceBackendAdapter } from './ReferenceBackendAdapter.js';\nexport {\n\tgetAssessmentItemIdentifier,\n\tscoreAssessmentItem,\n\ttype AssessmentItemScoringInput,\n} from './assessment-item-scorer.js';\nexport { toSectionComposition } from './toSectionComposition.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AA2BH,0DAA0D;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACN,2BAA2B,EAC3B,mBAAmB,GAEnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["/**\n * QTI 2.2 Assessment Player - Backend Integration\n *\n * ## Reference/demo behavior\n *\n * AssessmentPlayer always requires an explicit BackendAdapter. Demos can opt in\n * to ReferenceBackendAdapter, which stores and scores client-side.\n *\n * @example\n * ```typescript\n * import { AssessmentPlayer } from '@pie-qti/assessment-player';\n * import { ReferenceBackendAdapter } from '@pie-qti/assessment-player/integration';\n *\n * const backend = new ReferenceBackendAdapter();\n * backend.registerAssessment('preview', secureAssessment);\n * const player = await AssessmentPlayer.create({\n * backend,\n * initSession: { assessmentId: 'preview', candidateId: 'local' }\n * });\n * ```\n *\n * ## Production: Backend Integration\n *\n * For production deployments, implement BackendAdapter for:\n * - Server-side scoring (secure)\n * - Persistent session storage\n * - Authentication/authorization\n * - Sensitive data protection\n *\n * @example\n * ```typescript\n * import { AssessmentPlayer } from '@pie-qti/assessment-player';\n * import { MyBackendAdapter } from './adapters/MyBackendAdapter';\n *\n * // Production mode with backend\n * const player = await AssessmentPlayer.create({\n * backend: new MyBackendAdapter('https://api.example.com', authToken),\n * initSession: { assessmentId: 'test-001', candidateId: 'student-123' }\n * });\n * ```\n *\n * See BACKEND-INTEGRATION.md for complete implementation guide.\n */\n\n// Export API contract (TypeScript interfaces)\nexport type {\n\tBackendAdapter,\n\tFeedbackItem,\n\tAssessmentSessionState,\n\tAssessmentScoringResult,\n\tAssessmentRubricBlock,\n\tFinalizeAssessmentRequest,\n\tFinalizeAssessmentResponse,\n\tInitSessionRequest,\n\tInitSessionResponse,\n\tResponseValue,\n\tSaveAssessmentStateRequest,\n\tSaveAssessmentStateResponse,\n\tSecureAssessment,\n\tSecureItemRef,\n\tSecureSection,\n\tSecureTestPart,\n\tSecureTimeLimits,\n\tSessionId,\n\tSubmitTimingEvidence,\n\tSubmitResponsesRequest,\n\tSubmitResponsesResponse,\n} from './api-contract.js';\n\n// Export reference implementation (for development/demos)\nexport { ReferenceBackendAdapter } from './ReferenceBackendAdapter.js';\nexport {\n\tgetAssessmentItemIdentifier,\n\tscoreAssessmentItem,\n\ttype AssessmentItemScoringInput,\n} from './assessment-item-scorer.js';\nexport { toSectionComposition } from './toSectionComposition.js';\n"]}
@@ -27,15 +27,20 @@ export function toSectionComposition(player, config = {}) {
27
27
  role,
28
28
  passageTools: scopedTools(config.passageTools, 'passage'),
29
29
  });
30
- const sectionItems = player.getCurrentSectionItemRefs().map((item) => ({
31
- identifier: item.identifier,
32
- href: item.href,
33
- title: item.title,
34
- itemXml: item.itemXml,
35
- responses: player.getResponsesForItem(item.identifier),
36
- deliveryContext: item.deliveryContext,
37
- tools: scopedTools(config.itemTools, 'item'),
38
- }));
30
+ const activeSession = player.getCurrentItemSession();
31
+ const sectionItems = player.getCurrentSectionItemRefs().map((item) => {
32
+ const common = {
33
+ identifier: item.identifier,
34
+ href: item.href,
35
+ title: item.title,
36
+ itemXml: item.itemXml,
37
+ deliveryContext: item.deliveryContext,
38
+ tools: scopedTools(config.itemTools, 'item'),
39
+ };
40
+ return item.identifier === currentItem?.identifier && activeSession
41
+ ? { ...common, session: activeSession }
42
+ : { ...common, responses: player.getResponsesForItem(item.identifier) };
43
+ });
39
44
  return resolveQtiSectionComposition({
40
45
  section: {
41
46
  identifier: navState.currentSection?.id ?? 'active-section',
@@ -47,7 +52,6 @@ export function toSectionComposition(player, config = {}) {
47
52
  sharedContext,
48
53
  },
49
54
  activeItemIdentifier: currentItem?.identifier,
50
- responsesByItemIdentifier: Object.fromEntries(sectionItems.map((item) => [item.identifier, item.responses ?? {}])),
51
55
  canPrevious: navState.canPrevious,
52
56
  canNext: navState.canNext,
53
57
  security: config.security,
@@ -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,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,CA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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,yBAAyB,EAAE,MAAM,CAAC,WAAW,CAC5C,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CACnE;QACD,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,MAAM,CAAC,WAAW;KACxB,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 sectionItems: QtiSectionItemRef[] = player.getCurrentSectionItemRefs().map((item) => ({\n\t\tidentifier: item.identifier,\n\t\thref: item.href,\n\t\ttitle: item.title,\n\t\titemXml: item.itemXml,\n\t\tresponses: player.getResponsesForItem(item.identifier),\n\t\tdeliveryContext: item.deliveryContext,\n\t\ttools: scopedTools(config.itemTools, 'item'),\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\tresponsesByItemIdentifier: Object.fromEntries(\n\t\t\tsectionItems.map((item) => [item.identifier, item.responses ?? {}])\n\t\t),\n\t\tcanPrevious: navState.canPrevious,\n\t\tcanNext: navState.canNext,\n\t\tsecurity: config.security,\n\t\thost: config.sectionHost,\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;QAC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AAM,CAAC,SAAS,EAAE,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;KACxB,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});\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-qti/assessment-player",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "QTI Assessment Player supporting QTI 2.2 and 3.0 - Multi-item test player with navigation, sections, and rubric blocks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,21 +28,21 @@
28
28
  ],
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@pie-qti/assessment-toolkit": "0.1.19",
32
- "@pie-qti/default-components": "0.1.19",
33
- "@pie-qti/i18n": "0.1.19",
34
- "@pie-qti/ims-cp-core": "0.1.19",
35
- "@pie-qti/item-player": "0.1.19",
36
- "@pie-qti/qti-common": "0.1.19",
37
- "@pie-qti/qti-processing": "0.1.19",
38
- "@pie-qti/section-player": "0.1.19",
31
+ "@pie-qti/assessment-toolkit": "0.1.21",
32
+ "@pie-qti/default-components": "0.1.21",
33
+ "@pie-qti/i18n": "0.1.21",
34
+ "@pie-qti/ims-cp-core": "0.1.21",
35
+ "@pie-qti/item-player": "0.1.21",
36
+ "@pie-qti/qti-common": "0.1.21",
37
+ "@pie-qti/qti-processing": "0.1.21",
38
+ "@pie-qti/section-player": "0.1.21",
39
39
  "node-html-parser": "^9.0.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@biomejs/biome": "^2.5.6",
43
- "@types/node": "^25.0.3",
42
+ "@biomejs/biome": "^2.5.7",
43
+ "@types/node": "^26.2.0",
44
44
  "svelte": "^5.56.8",
45
- "svelte-check": "^4.3.5",
45
+ "svelte-check": "^4.7.5",
46
46
  "typescript": "^5.9.3"
47
47
  },
48
48
  "exports": {