@qti-components/base 1.0.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 +674 -0
- package/dist/abstract/interaction.d.ts +87 -0
- package/dist/abstract/interaction.js +371 -0
- package/dist/abstract/interaction.js.map +1 -0
- package/dist/abstract/qti-condition-expression.d.ts +5 -0
- package/dist/abstract/qti-condition-expression.js +11 -0
- package/dist/abstract/qti-condition-expression.js.map +1 -0
- package/dist/abstract/qti-expression.d.ts +17 -0
- package/dist/abstract/qti-expression.js +141 -0
- package/dist/abstract/qti-expression.js.map +1 -0
- package/dist/abstract/qti-feedback.d.ts +11 -0
- package/dist/abstract/qti-feedback.js +58 -0
- package/dist/abstract/qti-feedback.js.map +1 -0
- package/dist/abstract/qti-variable-declaration.d.ts +6 -0
- package/dist/abstract/qti-variable-declaration.js +18 -0
- package/dist/abstract/qti-variable-declaration.js.map +1 -0
- package/dist/context/computed-item.context.d.ts +19 -0
- package/dist/context/computed-item.context.js +3 -0
- package/dist/context/computed-item.context.js.map +1 -0
- package/dist/context/computed.context.d.ts +29 -0
- package/dist/context/computed.context.js +3 -0
- package/dist/context/computed.context.js.map +1 -0
- package/dist/context/config.context.d.ts +12 -0
- package/dist/context/config.context.js +3 -0
- package/dist/context/config.context.js.map +1 -0
- package/dist/context/item.context.d.ts +12 -0
- package/dist/context/item.context.js +17 -0
- package/dist/context/item.context.js.map +1 -0
- package/dist/context/qti-assessment-item.context.d.ts +4 -0
- package/dist/context/qti-assessment-item.context.js +3 -0
- package/dist/context/qti-assessment-item.context.js.map +1 -0
- package/dist/context/qti.context.d.ts +12 -0
- package/dist/context/qti.context.js +3 -0
- package/dist/context/qti.context.js.map +1 -0
- package/dist/context/session.context.d.ts +13 -0
- package/dist/context/session.context.js +4 -0
- package/dist/context/session.context.js.map +1 -0
- package/dist/context/test.context.d.ts +12 -0
- package/dist/context/test.context.js +4 -0
- package/dist/context/test.context.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/expression-result.d.ts +18 -0
- package/dist/lib/expression-result.js +2 -0
- package/dist/lib/expression-result.js.map +1 -0
- package/dist/lib/interaction.interface.d.ts +20 -0
- package/dist/lib/interaction.interface.js +2 -0
- package/dist/lib/interaction.interface.js.map +1 -0
- package/dist/lib/qti-rule-base.d.ts +13 -0
- package/dist/lib/qti-rule-base.js +7 -0
- package/dist/lib/qti-rule-base.js.map +1 -0
- package/dist/lib/variables.d.ts +50 -0
- package/dist/lib/variables.js +2 -0
- package/dist/lib/variables.js.map +1 -0
- package/dist/utils/scoring-helper.d.ts +25 -0
- package/dist/utils/scoring-helper.js +129 -0
- package/dist/utils/scoring-helper.js.map +1 -0
- package/dist/utils/utils.d.ts +4 -0
- package/dist/utils/utils.js +28 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { consume } from '@lit/context';
|
|
8
|
+
import { css, html, LitElement } from 'lit';
|
|
9
|
+
import { state } from 'lit/decorators.js';
|
|
10
|
+
import { itemContext } from '../context/qti-assessment-item.context';
|
|
11
|
+
import { qtiContext } from '../context/qti.context';
|
|
12
|
+
export class QtiExpression extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.getVariables = () =>
|
|
16
|
+
// FIXME: if this itself is multiple, this will never enter the qti-multiple switch
|
|
17
|
+
// See this example here: https://github.com/1EdTech/qti-examples/blob/master/qtiv3-examples/packaging/items/Example05-feedbackBlock-adaptive.xml
|
|
18
|
+
Array.from(this.children)
|
|
19
|
+
.map((e) => {
|
|
20
|
+
console.debug('getVariables', e.tagName.toLowerCase());
|
|
21
|
+
switch (e.tagName.toLowerCase()) {
|
|
22
|
+
case 'qti-base-value': {
|
|
23
|
+
return {
|
|
24
|
+
baseType: e.getAttribute('base-type'),
|
|
25
|
+
value: e.textContent.trim(),
|
|
26
|
+
cardinality: 'single'
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
case 'qti-variable': {
|
|
30
|
+
const identifier = e.getAttribute('identifier') || '';
|
|
31
|
+
// Special handling for QTI_CONTEXT
|
|
32
|
+
if (identifier === 'QTI_CONTEXT') {
|
|
33
|
+
if (!this.qtiContext?.QTI_CONTEXT) {
|
|
34
|
+
console.warn('QTI_CONTEXT not available');
|
|
35
|
+
return {
|
|
36
|
+
identifier: 'QTI_CONTEXT',
|
|
37
|
+
baseType: 'record',
|
|
38
|
+
value: this.qtiContext.QTI_CONTEXT,
|
|
39
|
+
cardinality: 'record',
|
|
40
|
+
type: 'context'
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
identifier: 'QTI_CONTEXT',
|
|
45
|
+
baseType: 'record',
|
|
46
|
+
value: this.qtiContext.QTI_CONTEXT,
|
|
47
|
+
cardinality: 'record',
|
|
48
|
+
type: 'context'
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const variable = this.context.variables.find(v => v.identifier === identifier) || null;
|
|
52
|
+
return variable;
|
|
53
|
+
}
|
|
54
|
+
case 'qti-multiple': {
|
|
55
|
+
const multiple = e;
|
|
56
|
+
const values = multiple.getResult();
|
|
57
|
+
console.debug('values', values);
|
|
58
|
+
if (values?.length > 0) {
|
|
59
|
+
return {
|
|
60
|
+
identifier: '',
|
|
61
|
+
baseType: values[0].baseType,
|
|
62
|
+
value: values.map(v => v.value),
|
|
63
|
+
cardinality: 'multiple',
|
|
64
|
+
type: 'response'
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
case 'qti-ordered': {
|
|
70
|
+
const multiple = e;
|
|
71
|
+
const values = multiple.getResult();
|
|
72
|
+
if (values?.length > 0) {
|
|
73
|
+
return {
|
|
74
|
+
identifier: '',
|
|
75
|
+
baseType: values[0].baseType,
|
|
76
|
+
value: values.map(v => v.value),
|
|
77
|
+
cardinality: 'ordered',
|
|
78
|
+
type: 'response'
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
case 'qti-correct': {
|
|
84
|
+
const identifier = e.getAttribute('identifier') || '';
|
|
85
|
+
const responseVariable = this.context?.variables?.find(v => v.identifier === identifier) || null;
|
|
86
|
+
return {
|
|
87
|
+
baseType: responseVariable.baseType,
|
|
88
|
+
value: responseVariable.correctResponse,
|
|
89
|
+
cardinality: responseVariable.cardinality
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
default: {
|
|
93
|
+
// added for use of qti-equal-rounded
|
|
94
|
+
try {
|
|
95
|
+
const expression = e;
|
|
96
|
+
const value = expression.getResult();
|
|
97
|
+
return {
|
|
98
|
+
baseType: 'integer',
|
|
99
|
+
value: value?.toString() || null,
|
|
100
|
+
cardinality: 'single'
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
console.warn('default not sufficient');
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
.filter(v => v !== null);
|
|
111
|
+
}
|
|
112
|
+
// hide the slot with css
|
|
113
|
+
static { this.styles = css `
|
|
114
|
+
slot {
|
|
115
|
+
display: none;
|
|
116
|
+
}
|
|
117
|
+
`; }
|
|
118
|
+
render() {
|
|
119
|
+
return html `<pre>${JSON.stringify(this.result, null, 2)}</pre>
|
|
120
|
+
<slot></slot>`;
|
|
121
|
+
}
|
|
122
|
+
calculate() {
|
|
123
|
+
this.result = this.getResult();
|
|
124
|
+
return this.result;
|
|
125
|
+
}
|
|
126
|
+
getResult() {
|
|
127
|
+
throw new Error('Not implemented');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
__decorate([
|
|
131
|
+
state()
|
|
132
|
+
], QtiExpression.prototype, "result", void 0);
|
|
133
|
+
__decorate([
|
|
134
|
+
consume({ context: itemContext, subscribe: true }),
|
|
135
|
+
state()
|
|
136
|
+
], QtiExpression.prototype, "context", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
consume({ context: qtiContext, subscribe: true }),
|
|
139
|
+
state()
|
|
140
|
+
], QtiExpression.prototype, "qtiContext", void 0);
|
|
141
|
+
//# sourceMappingURL=qti-expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-expression.js","sourceRoot":"","sources":["../../src/abstract/qti-expression.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAapD,MAAM,OAAgB,aAAiB,SAAQ,UAAU;IAAzD;;QAiCE,iBAAY,GAAG,GAA+D,EAAE;QAC9E,mFAAmF;QACnF,iJAAiJ;QAEjJ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;aACtB,GAAG,CAAC,CAAC,CAAU,EAAE,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,OA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IAAI,EAAE,CAAC;IAClD,KAAK,EAAE;8CACwB;AAItB;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACjD,KAAK,EAAE;iDAC0B","sourcesContent":["import { consume } from '@lit/context';\nimport { css, html, LitElement } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport { itemContext } from '../context/qti-assessment-item.context';\nimport { qtiContext } from '../context/qti.context';\n\nimport type { QtiContext, QtiContextType } from '../context/qti.context';\nimport type { ResponseVariable, VariableDeclaration } from '../lib/variables';\nimport type { ItemContext } from '../context/item.context';\n\nexport interface QtiExpressionBase<T> {\n // get assessmentItem(): QtiAssessmentItem;\n\n // getVariables(): VariableDeclaration<number | string | (number | string)[] | null>[];\n calculate(): Readonly<T>;\n}\n\nexport abstract class QtiExpression<T> extends LitElement implements QtiExpressionBase<T> {\n @state()\n protected result: any;\n\n // hide the slot with css\n static override styles = css`\n slot {\n display: none;\n }\n `;\n\n override render() {\n return html`<pre>${JSON.stringify(this.result, null, 2)}</pre>\n <slot></slot>`;\n }\n\n public calculate(): Readonly<T> {\n this.result = this.getResult();\n return this.result;\n }\n\n protected getResult(): Readonly<T> {\n throw new Error('Not implemented');\n }\n\n @consume({ context: itemContext, subscribe: true })\n @state()\n protected context?: ItemContext;\n\n @consume({ context: qtiContext, subscribe: true })\n @state()\n protected qtiContext?: QtiContext;\n\n getVariables = (): (ResponseVariable | VariableDeclaration<QtiContextType>)[] =>\n // FIXME: if this itself is multiple, this will never enter the qti-multiple switch\n // See this example here: https://github.com/1EdTech/qti-examples/blob/master/qtiv3-examples/packaging/items/Example05-feedbackBlock-adaptive.xml\n\n Array.from(this.children)\n .map((e: Element) => {\n console.debug('getVariables', e.tagName.toLowerCase());\n switch (e.tagName.toLowerCase()) {\n case 'qti-base-value': {\n return {\n baseType: e.getAttribute('base-type'),\n value: e.textContent.trim(),\n cardinality: 'single'\n } as ResponseVariable;\n }\n case 'qti-variable': {\n const identifier = e.getAttribute('identifier') || '';\n\n // Special handling for QTI_CONTEXT\n if (identifier === 'QTI_CONTEXT') {\n if (!this.qtiContext?.QTI_CONTEXT) {\n console.warn('QTI_CONTEXT not available');\n return {\n identifier: 'QTI_CONTEXT',\n baseType: 'record',\n value: this.qtiContext.QTI_CONTEXT,\n cardinality: 'record',\n type: 'context'\n } as VariableDeclaration<QtiContextType>;\n }\n return {\n identifier: 'QTI_CONTEXT',\n baseType: 'record',\n value: this.qtiContext.QTI_CONTEXT,\n cardinality: 'record',\n type: 'context'\n } as VariableDeclaration<QtiContextType>;\n }\n\n const variable = this.context.variables.find(v => v.identifier === identifier) || null;\n return variable;\n }\n case 'qti-multiple': {\n const multiple = e as QtiExpression<ResponseVariable[]>;\n\n const values = multiple.getResult();\n console.debug('values', values);\n if (values?.length > 0) {\n return {\n identifier: '',\n baseType: values[0].baseType,\n value: values.map(v => v.value),\n cardinality: 'multiple',\n type: 'response'\n } as ResponseVariable;\n }\n return null;\n }\n case 'qti-ordered': {\n const multiple = e as QtiExpression<ResponseVariable[]>;\n const values = multiple.getResult();\n if (values?.length > 0) {\n return {\n identifier: '',\n baseType: values[0].baseType,\n value: values.map(v => v.value),\n cardinality: 'ordered',\n type: 'response'\n } as ResponseVariable;\n }\n return null;\n }\n case 'qti-correct': {\n const identifier = e.getAttribute('identifier') || '';\n const responseVariable: ResponseVariable =\n this.context?.variables?.find(v => v.identifier === identifier) || null;\n return {\n baseType: responseVariable.baseType,\n value: responseVariable.correctResponse,\n cardinality: responseVariable.cardinality\n } as ResponseVariable;\n }\n default: {\n // added for use of qti-equal-rounded\n try {\n const expression = e as QtiExpression<number>;\n const value = expression.getResult();\n return {\n baseType: 'integer',\n value: value?.toString() || null,\n cardinality: 'single'\n } as ResponseVariable;\n } catch (error) {\n console.warn('default not sufficient');\n }\n return null;\n }\n }\n })\n .filter(v => v !== null);\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare abstract class QtiFeedback extends LitElement {
|
|
3
|
+
#private;
|
|
4
|
+
protected showHide: string;
|
|
5
|
+
outcomeIdentifier: string;
|
|
6
|
+
protected identifier: string;
|
|
7
|
+
showStatus: string;
|
|
8
|
+
private _context?;
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
checkShowFeedback(outcomeIdentifier: string): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { consume } from '@lit/context';
|
|
8
|
+
import { LitElement } from 'lit';
|
|
9
|
+
import { property, state } from 'lit/decorators.js';
|
|
10
|
+
import { itemContext } from '../context/qti-assessment-item.context';
|
|
11
|
+
import { IsNullOrUndefined } from '../utils/utils';
|
|
12
|
+
export class QtiFeedback extends LitElement {
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
super.connectedCallback();
|
|
15
|
+
this.dispatchEvent(new CustomEvent('qti-register-feedback', {
|
|
16
|
+
bubbles: true,
|
|
17
|
+
composed: true,
|
|
18
|
+
detail: this
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
checkShowFeedback(outcomeIdentifier) {
|
|
22
|
+
const outcomeVariable = this._context.variables.find(v => v.identifier === outcomeIdentifier) || null;
|
|
23
|
+
if (this.outcomeIdentifier !== outcomeIdentifier || !outcomeVariable)
|
|
24
|
+
return;
|
|
25
|
+
let isFound = false;
|
|
26
|
+
if (Array.isArray(outcomeVariable.value)) {
|
|
27
|
+
isFound = outcomeVariable.value.includes(this.identifier);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
isFound =
|
|
31
|
+
(!IsNullOrUndefined(this.identifier) &&
|
|
32
|
+
!IsNullOrUndefined(outcomeVariable?.value) &&
|
|
33
|
+
this.identifier === outcomeVariable.value) ||
|
|
34
|
+
false;
|
|
35
|
+
}
|
|
36
|
+
this.#showFeedback(isFound);
|
|
37
|
+
}
|
|
38
|
+
#showFeedback(value) {
|
|
39
|
+
this.showStatus = (value && this.showHide === 'show') || (!value && this.showHide === 'hide') ? 'on' : 'off';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
__decorate([
|
|
43
|
+
property({ type: String, attribute: 'show-hide' })
|
|
44
|
+
], QtiFeedback.prototype, "showHide", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
property({ type: String, attribute: 'outcome-identifier' })
|
|
47
|
+
], QtiFeedback.prototype, "outcomeIdentifier", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
property({ type: String })
|
|
50
|
+
], QtiFeedback.prototype, "identifier", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property({ type: String, attribute: false })
|
|
53
|
+
], QtiFeedback.prototype, "showStatus", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
consume({ context: itemContext, subscribe: true }),
|
|
56
|
+
state()
|
|
57
|
+
], QtiFeedback.prototype, "_context", void 0);
|
|
58
|
+
//# sourceMappingURL=qti-feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-feedback.js","sourceRoot":"","sources":["../../src/abstract/qti-feedback.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD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AAC,KAAK,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/G,CAAC;CACF;AA9CW;IADT,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;6CACxB;AAGpB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;sDAC3B;AAGvB;IADT,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACE;AAGtB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+CACnB;AAIlB;IAFP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAClD,KAAK,EAAE;6CACuB","sourcesContent":["import { consume } from '@lit/context';\nimport { LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { itemContext } from '../context/qti-assessment-item.context';\nimport { IsNullOrUndefined } from '../utils/utils';\n\nimport type { ItemContext } from '../context/item.context';\n\nexport abstract class QtiFeedback extends LitElement {\n @property({ type: String, attribute: 'show-hide' })\n protected showHide: string;\n\n @property({ type: String, attribute: 'outcome-identifier' })\n public outcomeIdentifier: string;\n\n @property({ type: String })\n protected identifier: string;\n\n @property({ type: String, attribute: false })\n public showStatus: string;\n\n @consume({ context: itemContext, subscribe: true })\n @state()\n private _context?: ItemContext;\n\n public override connectedCallback() {\n super.connectedCallback();\n this.dispatchEvent(\n new CustomEvent<QtiFeedback>('qti-register-feedback', {\n bubbles: true,\n composed: true,\n detail: this\n })\n );\n }\n\n public checkShowFeedback(outcomeIdentifier: string) {\n const outcomeVariable = this._context.variables.find(v => v.identifier === outcomeIdentifier) || null;\n if (this.outcomeIdentifier !== outcomeIdentifier || !outcomeVariable) return;\n let isFound = false;\n if (Array.isArray(outcomeVariable.value)) {\n isFound = outcomeVariable.value.includes(this.identifier);\n } else {\n isFound =\n (!IsNullOrUndefined(this.identifier) &&\n !IsNullOrUndefined(outcomeVariable?.value) &&\n this.identifier === outcomeVariable.value) ||\n false;\n }\n\n this.#showFeedback(isFound);\n }\n\n #showFeedback(value: boolean) {\n this.showStatus = (value && this.showHide === 'show') || (!value && this.showHide === 'hide') ? 'on' : 'off';\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { Cardinality } from '../lib/expression-result';
|
|
3
|
+
export declare abstract class QtiVariableDeclaration extends LitElement {
|
|
4
|
+
render(): import("lit").TemplateResult<1>;
|
|
5
|
+
protected defaultValues(cardinality: Cardinality): string | string[];
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { html, LitElement } from 'lit';
|
|
2
|
+
export class QtiVariableDeclaration extends LitElement {
|
|
3
|
+
render() {
|
|
4
|
+
return html `<slot></slot>`;
|
|
5
|
+
}
|
|
6
|
+
defaultValues(cardinality) {
|
|
7
|
+
const htmlValues = Array.from(this.querySelectorAll('qti-default-value > qti-value'));
|
|
8
|
+
if (htmlValues.length === 0) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const defaultValues = htmlValues.map(n => n.innerHTML.trim());
|
|
12
|
+
if (defaultValues.length > 1 || cardinality === 'multiple' || cardinality === 'ordered') {
|
|
13
|
+
return defaultValues;
|
|
14
|
+
}
|
|
15
|
+
return defaultValues[0];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=qti-variable-declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-variable-declaration.js","sourceRoot":"","sources":["../../src/abstract/qti-variable-declaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC,MAAM,OAAgB,sBAAuB,SAAQ,UAAU;IACpD,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;IAES,aAAa,CAAC,WAAwB;QAC9C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,+BAA+B,CAAC,CAAC,CAAC;QAEtF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9D,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,KAAK,UAAU,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YACxF,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;CACF","sourcesContent":["import { html, LitElement } from 'lit';\n\nimport type { Cardinality } from '../lib/expression-result';\n\nexport abstract class QtiVariableDeclaration extends LitElement {\n override render() {\n return html`<slot></slot>`;\n }\n\n protected defaultValues(cardinality: Cardinality) {\n const htmlValues = Array.from(this.querySelectorAll('qti-default-value > qti-value'));\n\n if (htmlValues.length === 0) {\n return null;\n }\n\n const defaultValues = htmlValues.map(n => n.innerHTML.trim());\n if (defaultValues.length > 1 || cardinality === 'multiple' || cardinality === 'ordered') {\n return defaultValues;\n }\n return defaultValues[0];\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { VariableDeclaration } from '../lib/variables';
|
|
2
|
+
export type ComputedItemContext = {
|
|
3
|
+
identifier: string;
|
|
4
|
+
href?: string;
|
|
5
|
+
correct?: boolean;
|
|
6
|
+
incorrect?: boolean;
|
|
7
|
+
completed?: boolean;
|
|
8
|
+
adaptive?: boolean;
|
|
9
|
+
timeDependent?: boolean;
|
|
10
|
+
title?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
score?: number;
|
|
13
|
+
maxScore?: number;
|
|
14
|
+
completionStatus?: string;
|
|
15
|
+
variables: ReadonlyArray<VariableDeclaration<string | string[] | null>>;
|
|
16
|
+
};
|
|
17
|
+
export declare const computedItemContext: {
|
|
18
|
+
__context__: Readonly<ComputedItemContext>;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed-item.context.js","sourceRoot":"","sources":["../../src/context/computed-item.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAoB7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAgC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\n\nimport type { VariableDeclaration } from '../lib/variables';\n\nexport type ComputedItemContext = {\n identifier: string;\n href?: string;\n correct?: boolean;\n incorrect?: boolean;\n completed?: boolean;\n adaptive?: boolean;\n timeDependent?: boolean;\n title?: string;\n label?: string;\n score?: number;\n maxScore?: number;\n completionStatus?: string;\n variables: ReadonlyArray<VariableDeclaration<string | string[] | null>>;\n};\n\nexport const computedItemContext = createContext<Readonly<ComputedItemContext>>(Symbol('computedItemContext'));\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { View } from './session.context';
|
|
2
|
+
import type { ComputedItemContext } from './computed-item.context';
|
|
3
|
+
export type ComputedItem = ComputedItemContext & {
|
|
4
|
+
categories?: string[];
|
|
5
|
+
type?: 'info' | 'regular';
|
|
6
|
+
index?: number;
|
|
7
|
+
active?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type ComputedContext = {
|
|
10
|
+
view: View;
|
|
11
|
+
identifier: string;
|
|
12
|
+
title: string;
|
|
13
|
+
testParts: {
|
|
14
|
+
active?: boolean;
|
|
15
|
+
identifier: string;
|
|
16
|
+
navigationMode: 'linear' | 'nonlinear';
|
|
17
|
+
submissionMode: 'individual' | 'simultaneous';
|
|
18
|
+
sections: {
|
|
19
|
+
active?: boolean;
|
|
20
|
+
identifier: string;
|
|
21
|
+
title: string;
|
|
22
|
+
completed?: boolean;
|
|
23
|
+
items: ComputedItem[];
|
|
24
|
+
}[];
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
export declare const computedContext: {
|
|
28
|
+
__context__: Readonly<ComputedContext>;
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed.context.js","sourceRoot":"","sources":["../../src/context/computed.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA+B7C,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAA4B,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\n\nimport type { View } from './session.context';\nimport type { ComputedItemContext } from './computed-item.context';\n\nexport type ComputedItem = ComputedItemContext & {\n categories?: string[]; // not necessary for outside world\n type?: 'info' | 'regular';\n index?: number;\n active?: boolean;\n};\n\nexport type ComputedContext = {\n view: View;\n identifier: string;\n title: string;\n testParts: {\n active?: boolean;\n identifier: string;\n navigationMode: 'linear' | 'nonlinear';\n submissionMode: 'individual' | 'simultaneous';\n sections: {\n active?: boolean;\n identifier: string;\n title: string;\n completed?: boolean;\n items: ComputedItem[];\n }[];\n }[];\n};\n\nexport const computedContext = createContext<Readonly<ComputedContext>>(Symbol('computedContext'));\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type CorrectResponseMode = 'internal' | 'full';
|
|
2
|
+
export interface ConfigContext {
|
|
3
|
+
infoItemCategory?: string;
|
|
4
|
+
reportValidityAfterScoring?: boolean;
|
|
5
|
+
disableAfterIfMaxChoicesReached?: boolean;
|
|
6
|
+
correctResponseMode?: CorrectResponseMode;
|
|
7
|
+
inlineChoicePrompt?: string;
|
|
8
|
+
fullCorrectResponseOnlyWhenIncorrect?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const configContext: {
|
|
11
|
+
__context__: Readonly<ConfigContext>;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.context.js","sourceRoot":"","sources":["../../src/context/config.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAa7C,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAA0B,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\n\nexport type CorrectResponseMode = 'internal' | 'full';\n\nexport interface ConfigContext {\n infoItemCategory?: string;\n reportValidityAfterScoring?: boolean;\n disableAfterIfMaxChoicesReached?: boolean;\n correctResponseMode?: CorrectResponseMode;\n inlineChoicePrompt?: string;\n fullCorrectResponseOnlyWhenIncorrect?: boolean;\n}\n\nexport const configContext = createContext<Readonly<ConfigContext>>(Symbol('configContext'));\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VariableDeclaration } from '../lib/variables';
|
|
2
|
+
export interface ItemContext {
|
|
3
|
+
identifier?: string;
|
|
4
|
+
href?: string;
|
|
5
|
+
variables?: ReadonlyArray<VariableDeclaration<string | string[] | null>>;
|
|
6
|
+
/**
|
|
7
|
+
* Optional per-interaction opaque state, keyed by responseIdentifier.
|
|
8
|
+
* Used for interactions that support state save/restore (e.g. PCI).
|
|
9
|
+
*/
|
|
10
|
+
state?: Record<string, string | null>;
|
|
11
|
+
}
|
|
12
|
+
export declare const itemContextVariables: VariableDeclaration<string | string[]>[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const itemContextVariables = [
|
|
2
|
+
{
|
|
3
|
+
identifier: 'completionStatus',
|
|
4
|
+
cardinality: 'single',
|
|
5
|
+
baseType: 'string',
|
|
6
|
+
value: 'unknown',
|
|
7
|
+
type: 'outcome'
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
identifier: 'numAttempts',
|
|
11
|
+
cardinality: 'single',
|
|
12
|
+
baseType: 'integer',
|
|
13
|
+
value: '0',
|
|
14
|
+
type: 'response'
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
//# sourceMappingURL=item.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.context.js","sourceRoot":"","sources":["../../src/context/item.context.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC;QACE,UAAU,EAAE,kBAAkB;QAC9B,WAAW,EAAE,QAAQ;QACrB,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,SAAS;KAChB;IACD;QACE,UAAU,EAAE,aAAa;QACzB,WAAW,EAAE,QAAQ;QACrB,QAAQ,EAAE,SAAS;QACnB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,UAAU;KACjB;CAC0C,CAAC","sourcesContent":["import type { VariableDeclaration } from '../lib/variables';\n\nexport interface ItemContext {\n identifier?: string;\n href?: string;\n variables?: ReadonlyArray<VariableDeclaration<string | string[] | null>>;\n /**\n * Optional per-interaction opaque state, keyed by responseIdentifier.\n * Used for interactions that support state save/restore (e.g. PCI).\n */\n state?: Record<string, string | null>;\n}\n\nexport const itemContextVariables = [\n {\n identifier: 'completionStatus',\n cardinality: 'single',\n baseType: 'string',\n value: 'unknown',\n type: 'outcome'\n },\n {\n identifier: 'numAttempts',\n cardinality: 'single',\n baseType: 'integer',\n value: '0',\n type: 'response'\n }\n] as VariableDeclaration<string | string[]>[];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti-assessment-item.context.js","sourceRoot":"","sources":["../../src/context/qti-assessment-item.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAc,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\n\nimport type { ItemContext } from './item.context';\n\nexport const itemContext = createContext<ItemContext>(Symbol('item'));\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type QtiContextType = {
|
|
2
|
+
testIdentifier: string;
|
|
3
|
+
candidateIdentifier: string;
|
|
4
|
+
environmentIdentifier: string;
|
|
5
|
+
[key: string]: string | string[];
|
|
6
|
+
};
|
|
7
|
+
export interface QtiContext {
|
|
8
|
+
QTI_CONTEXT: QtiContextType;
|
|
9
|
+
}
|
|
10
|
+
export declare const qtiContext: {
|
|
11
|
+
__context__: Readonly<QtiContext>;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qti.context.js","sourceRoot":"","sources":["../../src/context/qti.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAa7C,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAuB,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\n\nexport type QtiContextType = {\n testIdentifier: string;\n candidateIdentifier: string;\n environmentIdentifier: string;\n [key: string]: string | string[]; // Allow for additional context variables\n};\n\nexport interface QtiContext {\n QTI_CONTEXT: QtiContextType;\n}\n\nexport const qtiContext = createContext<Readonly<QtiContext>>(Symbol('qtiContext'));\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type View = 'author' | 'candidate' | 'proctor' | 'scorer' | 'testConstructor' | 'tutor' | '';
|
|
2
|
+
export interface SessionContext {
|
|
3
|
+
navPartId?: string | null;
|
|
4
|
+
navSectionId?: string | null;
|
|
5
|
+
navItemRefId?: string | null;
|
|
6
|
+
navItemLoading?: boolean;
|
|
7
|
+
navTestLoading?: boolean;
|
|
8
|
+
view?: View;
|
|
9
|
+
}
|
|
10
|
+
export declare const INITIAL_SESSION_CONTEXT: Readonly<SessionContext>;
|
|
11
|
+
export declare const sessionContext: {
|
|
12
|
+
__context__: Readonly<SessionContext>;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.context.js","sourceRoot":"","sources":["../../src/context/session.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAa7C,MAAM,CAAC,MAAM,uBAAuB,GAA6B,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAEvF,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAA2B,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\n\nexport type View = 'author' | 'candidate' | 'proctor' | 'scorer' | 'testConstructor' | 'tutor' | '';\n\nexport interface SessionContext {\n navPartId?: string | null;\n navSectionId?: string | null;\n navItemRefId?: string | null;\n navItemLoading?: boolean;\n navTestLoading?: boolean;\n view?: View;\n}\n\nexport const INITIAL_SESSION_CONTEXT: Readonly<SessionContext> = { view: 'candidate' };\n\nexport const sessionContext = createContext<Readonly<SessionContext>>(Symbol('testContext'));\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ItemContext } from './item.context';
|
|
2
|
+
import type { VariableDeclaration } from '../lib/variables';
|
|
3
|
+
export interface TestContext {
|
|
4
|
+
items: (ItemContext & {
|
|
5
|
+
category?: string;
|
|
6
|
+
})[];
|
|
7
|
+
testOutcomeVariables?: VariableDeclaration<string | string[] | null>[];
|
|
8
|
+
}
|
|
9
|
+
export declare const INITIAL_TEST_CONTEXT: Readonly<TestContext>;
|
|
10
|
+
export declare const testContext: {
|
|
11
|
+
__context__: Readonly<TestContext>;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.context.js","sourceRoot":"","sources":["../../src/context/test.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAU7C,MAAM,CAAC,MAAM,oBAAoB,GAA0B,EAAE,KAAK,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,CAAC;AAEnG,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAwB,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\n\nimport type { ItemContext } from './item.context';\nimport type { VariableDeclaration } from '../lib/variables';\n\nexport interface TestContext {\n items: (ItemContext & { category?: string })[];\n testOutcomeVariables?: VariableDeclaration<string | string[] | null>[];\n}\n\nexport const INITIAL_TEST_CONTEXT: Readonly<TestContext> = { items: [], testOutcomeVariables: [] };\n\nexport const testContext = createContext<Readonly<TestContext>>(Symbol('testContext'));\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from './context/computed-item.context';
|
|
2
|
+
export * from './context/computed.context';
|
|
3
|
+
export * from './context/config.context';
|
|
4
|
+
export * from './context/item.context';
|
|
5
|
+
export * from './context/qti-assessment-item.context';
|
|
6
|
+
export * from './context/qti.context';
|
|
7
|
+
export * from './context/session.context';
|
|
8
|
+
export * from './context/test.context';
|
|
9
|
+
export * from './abstract/interaction';
|
|
10
|
+
export * from './abstract/qti-variable-declaration';
|
|
11
|
+
export * from './abstract/qti-condition-expression';
|
|
12
|
+
export * from './abstract/qti-feedback';
|
|
13
|
+
export * from './abstract/qti-expression';
|
|
14
|
+
export * from './lib/expression-result';
|
|
15
|
+
export * from './lib/interaction.interface';
|
|
16
|
+
export * from './lib/variables';
|
|
17
|
+
export * from './lib/qti-rule-base';
|
|
18
|
+
export * from './utils/scoring-helper';
|
|
19
|
+
export * from './utils/utils';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './context/computed-item.context';
|
|
2
|
+
export * from './context/computed.context';
|
|
3
|
+
export * from './context/config.context';
|
|
4
|
+
export * from './context/item.context';
|
|
5
|
+
export * from './context/qti-assessment-item.context';
|
|
6
|
+
export * from './context/qti.context';
|
|
7
|
+
export * from './context/session.context';
|
|
8
|
+
export * from './context/test.context';
|
|
9
|
+
export * from './abstract/interaction';
|
|
10
|
+
export * from './abstract/qti-variable-declaration';
|
|
11
|
+
export * from './abstract/qti-condition-expression';
|
|
12
|
+
export * from './abstract/qti-feedback';
|
|
13
|
+
export * from './abstract/qti-expression';
|
|
14
|
+
export * from './lib/expression-result';
|
|
15
|
+
export * from './lib/interaction.interface';
|
|
16
|
+
export * from './lib/variables';
|
|
17
|
+
export * from './lib/qti-rule-base';
|
|
18
|
+
export * from './utils/scoring-helper';
|
|
19
|
+
export * from './utils/utils';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AAEvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAE1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC","sourcesContent":["export * from './context/computed-item.context';\nexport * from './context/computed.context';\nexport * from './context/config.context';\nexport * from './context/item.context';\nexport * from './context/qti-assessment-item.context';\nexport * from './context/qti.context';\nexport * from './context/session.context';\nexport * from './context/test.context';\n\nexport * from './abstract/interaction';\nexport * from './abstract/qti-variable-declaration';\nexport * from './abstract/qti-condition-expression';\nexport * from './abstract/qti-feedback';\nexport * from './abstract/qti-expression';\n\nexport * from './lib/expression-result';\nexport * from './lib/interaction.interface';\nexport * from './lib/variables';\nexport * from './lib/qti-rule-base';\n\nexport * from './utils/scoring-helper';\nexport * from './utils/utils';\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface directedPair {
|
|
2
|
+
destination: string;
|
|
3
|
+
source: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ResponseInteraction {
|
|
6
|
+
responseIdentifier: string;
|
|
7
|
+
response: string | string[];
|
|
8
|
+
state?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface Calculate {
|
|
11
|
+
calculate: () => string | string[];
|
|
12
|
+
}
|
|
13
|
+
export type float = number;
|
|
14
|
+
export type integer = number;
|
|
15
|
+
export type BaseType = 'boolean' | 'directedPair' | 'duration' | 'float' | 'integer' | 'string' | 'identifier' | 'pair' | 'record';
|
|
16
|
+
export type Multiple = string | string[][];
|
|
17
|
+
export type Ordered = string | string[][];
|
|
18
|
+
export type Cardinality = 'multiple' | 'ordered' | 'single' | 'record';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression-result.js","sourceRoot":"","sources":["../../src/lib/expression-result.ts"],"names":[],"mappings":"","sourcesContent":["export interface directedPair {\n destination: string;\n source: string;\n}\n\n// PK: EVENT: response from a INTERACTION_RESPONSE qti-interaction\nexport interface ResponseInteraction {\n responseIdentifier: string;\n response: string | string[];\n state?: string | null;\n}\n\nexport interface Calculate {\n calculate: () => string | string[];\n}\n\nexport type float = number;\nexport type integer = number;\n\n// export type string|string[] = string | string[];\n\nexport type BaseType =\n | 'boolean'\n | 'directedPair'\n | 'duration'\n | 'float'\n | 'integer'\n | 'string'\n | 'identifier'\n | 'pair'\n | 'record'; // record is a special type for QTI context variables\n\nexport type Multiple = string | string[][];\nexport type Ordered = string | string[][];\n\nexport type Cardinality = 'multiple' | 'ordered' | 'single' | 'record';\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface IInteraction {
|
|
2
|
+
/** The correct response for this interaction */
|
|
3
|
+
correctResponse: Readonly<string | string[] | null>;
|
|
4
|
+
/** Shows which choices are correct with inline indicators */
|
|
5
|
+
showCorrectResponse: boolean;
|
|
6
|
+
/** Shows a cloned interaction with the correct answers filled in */
|
|
7
|
+
showFullCorrectResponse: boolean;
|
|
8
|
+
/** Shows feedback on candidate's selections compared to correct response */
|
|
9
|
+
showCandidateCorrection: boolean;
|
|
10
|
+
response: string | string[];
|
|
11
|
+
responseIdentifier: string;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
readonly: boolean;
|
|
14
|
+
validate(): boolean;
|
|
15
|
+
reportValidity(): boolean;
|
|
16
|
+
reset(): void;
|
|
17
|
+
saveResponse(value: string | string[]): void;
|
|
18
|
+
toggleCorrectResponse(show: boolean): void;
|
|
19
|
+
toggleCandidateCorrection(show: boolean): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.interface.js","sourceRoot":"","sources":["../../src/lib/interaction.interface.ts"],"names":[],"mappings":"","sourcesContent":["export interface IInteraction {\n /** The correct response for this interaction */\n correctResponse: Readonly<string | string[] | null>;\n /** Shows which choices are correct with inline indicators */\n showCorrectResponse: boolean;\n /** Shows a cloned interaction with the correct answers filled in */\n showFullCorrectResponse: boolean;\n /** Shows feedback on candidate's selections compared to correct response */\n showCandidateCorrection: boolean;\n // value: string;\n response: string | string[];\n responseIdentifier: string;\n disabled: boolean;\n readonly: boolean;\n validate(): boolean;\n reportValidity(): boolean;\n reset(): void;\n saveResponse(value: string | string[]): void;\n toggleCorrectResponse(show: boolean): void;\n toggleCandidateCorrection(show: boolean): void;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for any object that can process QTI rules
|
|
4
|
+
*/
|
|
5
|
+
export interface QtiRuleBase {
|
|
6
|
+
process(): any;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Abstract base class for QTI rule DOM elements
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class QtiRuleElement extends LitElement implements QtiRuleBase {
|
|
12
|
+
abstract process(): any;
|
|
13
|
+
}
|