@longsightgroup/qti3-player 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +49 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3481 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Longsight, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @longsightgroup/qti3-player
|
|
2
|
+
|
|
3
|
+
Style-neutral web component player for QTI 3 assessment items.
|
|
4
|
+
|
|
5
|
+
This package renders one QTI item at a time, captures responses, validates responses,
|
|
6
|
+
scores attempts through `@longsightgroup/qti3-core`, and emits host-readable state events.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install @longsightgroup/qti3-player
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Use
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { defineQtiAssessmentItemPlayer } from "@longsightgroup/qti3-player";
|
|
18
|
+
|
|
19
|
+
defineQtiAssessmentItemPlayer();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<qti-assessment-item-player id="player"></qti-assessment-item-player>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
const player = document.querySelector("qti-assessment-item-player");
|
|
28
|
+
|
|
29
|
+
await player?.loadXml(xml, {
|
|
30
|
+
status: "interacting",
|
|
31
|
+
sessionControl: {
|
|
32
|
+
validateResponses: true,
|
|
33
|
+
showFeedback: true,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
player?.addEventListener("qti-statechange", (event) => {
|
|
38
|
+
console.log(event.detail.state);
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Styling
|
|
43
|
+
|
|
44
|
+
The player uses light DOM and is style-neutral by design. Host applications can style
|
|
45
|
+
the rendered `qti3-*` classes directly while preserving the item author's QTI shared
|
|
46
|
+
vocabulary classes.
|
|
47
|
+
|
|
48
|
+
See the main repository README for the support matrix and release notes:
|
|
49
|
+
https://github.com/LongsightGroup/qti3
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type QtiAttemptStatus, type QtiAttemptStateV1, type QtiScoreResult } from "@longsightgroup/qti3-core";
|
|
2
|
+
export interface QtiPlayerSessionControl {
|
|
3
|
+
validateResponses?: boolean | undefined;
|
|
4
|
+
showFeedback?: boolean | undefined;
|
|
5
|
+
}
|
|
6
|
+
export type QtiPlayerFetchXml = (url: string) => Promise<string>;
|
|
7
|
+
export type QtiPlayerResolveAsset = (url: string) => string;
|
|
8
|
+
export interface QtiPlayerLoadOptions {
|
|
9
|
+
state?: QtiAttemptStateV1 | undefined;
|
|
10
|
+
status?: QtiAttemptStatus | undefined;
|
|
11
|
+
sessionControl?: QtiPlayerSessionControl | undefined;
|
|
12
|
+
fetchXml?: QtiPlayerFetchXml | undefined;
|
|
13
|
+
resolveAsset?: QtiPlayerResolveAsset | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare const HTMLElementBase: typeof HTMLElement;
|
|
16
|
+
export declare class QtiAssessmentItemPlayer extends HTMLElementBase {
|
|
17
|
+
private documentModel?;
|
|
18
|
+
private session?;
|
|
19
|
+
private resolveAsset;
|
|
20
|
+
private validationMessages;
|
|
21
|
+
private sessionControl;
|
|
22
|
+
loadXml(xml: string, options?: QtiPlayerLoadOptions): Promise<void>;
|
|
23
|
+
loadUrl(url: string, options?: QtiPlayerLoadOptions): Promise<void>;
|
|
24
|
+
scoreAttempt(): QtiScoreResult | undefined;
|
|
25
|
+
reset(): void;
|
|
26
|
+
restore(state: QtiAttemptStateV1): void;
|
|
27
|
+
suspend(): void;
|
|
28
|
+
endAttempt(): void;
|
|
29
|
+
serialize(): QtiAttemptStateV1 | undefined;
|
|
30
|
+
private emitStateChange;
|
|
31
|
+
private render;
|
|
32
|
+
private renderInteraction;
|
|
33
|
+
private renderEmbeddedInteraction;
|
|
34
|
+
private renderContentNodes;
|
|
35
|
+
private renderContentNode;
|
|
36
|
+
private renderTemplateContent;
|
|
37
|
+
private renderPrintedVariable;
|
|
38
|
+
private renderFeedbackContent;
|
|
39
|
+
private updateDynamicBodyState;
|
|
40
|
+
private updateAttemptAvailability;
|
|
41
|
+
private attemptIsCompleted;
|
|
42
|
+
private isFeedbackVisible;
|
|
43
|
+
private isTemplateContentVisible;
|
|
44
|
+
private currentVariableValue;
|
|
45
|
+
private currentTemplateValue;
|
|
46
|
+
private mathTemplateValue;
|
|
47
|
+
private currentResponseValue;
|
|
48
|
+
private applyDefaultStyles;
|
|
49
|
+
private resolveRenderedAssets;
|
|
50
|
+
private validateResponses;
|
|
51
|
+
private renderValidationMessages;
|
|
52
|
+
private clearValidationMessage;
|
|
53
|
+
private renderFeedback;
|
|
54
|
+
}
|
|
55
|
+
export declare function defineQtiAssessmentItemPlayer(): void;
|
|
56
|
+
declare global {
|
|
57
|
+
interface HTMLElementTagNameMap {
|
|
58
|
+
"qti-assessment-item-player": QtiAssessmentItemPlayer;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAQtB,KAAK,cAAc,EAEpB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACtC,MAAM,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACtC,cAAc,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACzC,Y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