@citolab/qti-components 10.0.0-next.21 → 10.0.0-next.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/base.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { C as ComputedItemContext } from './session.context.d-9gRdGK4T.js';
2
2
  export { I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './session.context.d-9gRdGK4T.js';
3
- import { C as ComputedContext } from './computed.types.d-6Ht-HNRx.js';
4
- export { a as ComputedItem, S as SessionControl } from './computed.types.d-6Ht-HNRx.js';
3
+ import { C as ComputedContext } from './computed.types.d-6qQNFbu1.js';
4
+ export { a as ComputedItem, S as SessionControl } from './computed.types.d-6qQNFbu1.js';
5
5
  export { C as ConfigContext, V as ValidationDisplayMode, c as configContext } from './config.context.d-Dm11aAuw.js';
6
6
  export { C as ChoiceRole, I as Interaction, a as InteractionContext, R as RecordFieldValues, b as RecordValue, V as ValidityKind, c as ValidityTrigger, i as inferRecordFieldBaseType, d as interactionContext, e as isRecordValue, r as readRecordFieldValues } from './record.d-N1Bq7e1f.js';
7
7
  import { I as ItemContext } from './item.types.d-Zc6ZQDhu.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  qtiTestElements
3
- } from "./chunk-TB2OI3ED.js";
3
+ } from "./chunk-IJKHXJSM.js";
4
4
 
5
5
  // ../qti-test/dist/register.js
6
6
  for (const { tag, ctor } of qtiTestElements) {
@@ -8,4 +8,4 @@ for (const { tag, ctor } of qtiTestElements) {
8
8
  customElements.define(tag, ctor);
9
9
  }
10
10
  }
11
- //# sourceMappingURL=chunk-JIDSFFFD.js.map
11
+ //# sourceMappingURL=chunk-DJQE4M7B.js.map
@@ -1303,12 +1303,6 @@ __decorate2([
1303
1303
  __decorate2([
1304
1304
  property2({ type: Boolean, converter: stringToBooleanConverter2, attribute: "keep-together" })
1305
1305
  ], QtiAssessmentSection.prototype, "keepTogether", void 0);
1306
- __decorate2([
1307
- property2({ type: String, attribute: "navigation-mode" })
1308
- ], QtiAssessmentSection.prototype, "navigationMode", void 0);
1309
- __decorate2([
1310
- property2({ type: String, attribute: "submission-mode" })
1311
- ], QtiAssessmentSection.prototype, "submissionMode", void 0);
1312
1306
  __decorate2([
1313
1307
  consume2({ context: testContext, subscribe: true })
1314
1308
  ], QtiAssessmentSection.prototype, "_testContext", void 0);
@@ -1911,10 +1905,10 @@ var QtiTestVariablesExpression = class {
1911
1905
  const uniqueItems = [...new Set(this.includedItems.map((item) => item.item))];
1912
1906
  items.forEach((item) => {
1913
1907
  if (uniqueItems.includes(item.identifier)) {
1914
- const variable = item.variables.find((vr) => vr.identifier === this.itemVariable);
1908
+ const variable2 = item.variables.find((vr) => vr.identifier === this.itemVariable);
1915
1909
  const weight = this.includedItems.find((i) => i.item === item.identifier)?.weight ?? 1;
1916
- if (variable) {
1917
- const value = Number(variable.value);
1910
+ if (variable2) {
1911
+ const value = Number(variable2.value);
1918
1912
  if (!Number.isNaN(value)) {
1919
1913
  total += value * weight;
1920
1914
  }
@@ -1928,6 +1922,41 @@ var QtiTestVariablesExpression = class {
1928
1922
  // ../qti-test/dist/types/qti-test-state.js
1929
1923
  var QTI_TEST_STATE_VERSION = 1;
1930
1924
 
1925
+ // ../qti-test/dist/state-from-contexts.js
1926
+ var VARIABLE_TYPES = ["response", "outcome", "template", "context"];
1927
+ var valueOf = (value) => {
1928
+ if (value === null || value === void 0)
1929
+ return null;
1930
+ if (Array.isArray(value))
1931
+ return value.map(String);
1932
+ return String(value);
1933
+ };
1934
+ var variable = ({ identifier, type, value }) => ({
1935
+ identifier,
1936
+ ...VARIABLE_TYPES.includes(type) ? { type } : {},
1937
+ value: valueOf(value)
1938
+ });
1939
+ var stateFromContexts = (testContext2, sessionContext2) => ({
1940
+ version: QTI_TEST_STATE_VERSION,
1941
+ test: {
1942
+ items: (testContext2?.items ?? []).filter((item) => item?.identifier).map((item) => ({
1943
+ identifier: item.identifier,
1944
+ variables: (item.variables ?? []).map(variable),
1945
+ ...item.state ? { state: { ...item.state } } : {}
1946
+ })),
1947
+ outcomes: (testContext2?.testOutcomeVariables ?? []).map((v) => ({
1948
+ identifier: v.identifier,
1949
+ value: valueOf(v.value)
1950
+ }))
1951
+ },
1952
+ session: {
1953
+ ...sessionContext2?.plugins && Object.keys(sessionContext2.plugins).length > 0 ? { plugins: { ...sessionContext2.plugins } } : {},
1954
+ ...sessionContext2?.navPartId !== void 0 ? { navPartId: sessionContext2.navPartId } : {},
1955
+ ...sessionContext2?.navSectionId !== void 0 ? { navSectionId: sessionContext2.navSectionId } : {},
1956
+ ...sessionContext2?.navItemRefId !== void 0 ? { navItemRefId: sessionContext2.navItemRefId } : {}
1957
+ }
1958
+ });
1959
+
1931
1960
  // ../qti-test/dist/components/qti-test/qti-test.js
1932
1961
  import { ContextProvider, provide as provide3 } from "@lit/context";
1933
1962
  import { html as html9, LitElement as LitElement10 } from "lit";
@@ -2179,10 +2208,7 @@ var TestNavigationMixin = (superClass) => {
2179
2208
  const currentItemRef = this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${currentItemId}"]`);
2180
2209
  if (!currentItemRef)
2181
2210
  return false;
2182
- const section = currentItemRef.closest("qti-assessment-section");
2183
- const testPart = currentItemRef.closest("qti-test-part");
2184
- const navigationMode = section?.navigationMode || section?.getAttribute("navigation-mode") || testPart?.navigationMode || testPart?.getAttribute("navigation-mode") || "nonlinear";
2185
- if (navigationMode !== "linear")
2211
+ if (currentItemRef.closest("qti-test-part")?.getAttribute("navigation-mode") !== "linear")
2186
2212
  return false;
2187
2213
  const allItemRefs = Array.from(this._testElement?.querySelectorAll("qti-assessment-item-ref") || []);
2188
2214
  const currentIndex = allItemRefs.findIndex((ref) => ref.identifier === currentItemId);
@@ -2646,14 +2672,14 @@ var TestBaseMixin = (superClass) => {
2646
2672
  this._updateItemVariablesInTestContext(identifier, fullVariables, void 0, context.valid);
2647
2673
  } else {
2648
2674
  const newVariables = [...assessmentItem.variables];
2649
- for (const variable of itemContext.variables) {
2650
- if (variable.identifier === "completionStatus" && variable.value === "not_attempted")
2675
+ for (const variable2 of itemContext.variables) {
2676
+ if (variable2.identifier === "completionStatus" && variable2.value === "not_attempted")
2651
2677
  continue;
2652
- const currentVariable = newVariables.find((v) => v.identifier === variable.identifier);
2678
+ const currentVariable = newVariables.find((v) => v.identifier === variable2.identifier);
2653
2679
  if (currentVariable) {
2654
- currentVariable.value = variable.value;
2680
+ currentVariable.value = variable2.value;
2655
2681
  } else {
2656
- newVariables.push(variable);
2682
+ newVariables.push(variable2);
2657
2683
  }
2658
2684
  }
2659
2685
  assessmentItem.variables = newVariables;
@@ -2753,9 +2779,9 @@ var TestBaseMixin = (superClass) => {
2753
2779
  return {
2754
2780
  ...itemContext,
2755
2781
  // Keep other properties of the item context
2756
- variables: variables.map((variable) => {
2757
- const matchingVariable = itemContext.variables.find((v) => v.identifier === variable.identifier);
2758
- return matchingVariable ? { ...matchingVariable, ...variable } : variable;
2782
+ variables: variables.map((variable2) => {
2783
+ const matchingVariable = itemContext.variables.find((v) => v.identifier === variable2.identifier);
2784
+ return matchingVariable ? { ...matchingVariable, ...variable2 } : variable2;
2759
2785
  }),
2760
2786
  ...state6 !== void 0 ? { state: state6 ? { ...state6 } : void 0 } : {},
2761
2787
  ...valid !== void 0 ? { valid } : {}
@@ -2800,27 +2826,6 @@ var isQtiTestState = (value) => {
2800
2826
  const state6 = value;
2801
2827
  return state6?.version === QTI_TEST_STATE_VERSION && Array.isArray(state6.test?.items) && Array.isArray(state6.test?.outcomes) && typeof state6.session === "object" && state6.session !== null;
2802
2828
  };
2803
- var toState = (test, session) => ({
2804
- version: QTI_TEST_STATE_VERSION,
2805
- test: {
2806
- items: (test?.items ?? []).filter((item) => item.identifier).map((item) => ({
2807
- identifier: item.identifier,
2808
- variables: (item.variables ?? []).map((v) => ({
2809
- identifier: v.identifier,
2810
- ...v.type ? { type: v.type } : {},
2811
- value: copy(v.value)
2812
- })),
2813
- ...item.state ? { state: { ...item.state } } : {}
2814
- })),
2815
- outcomes: (test?.testOutcomeVariables ?? []).map((v) => ({ identifier: v.identifier, value: copy(v.value) }))
2816
- },
2817
- session: {
2818
- ...session?.plugins && Object.keys(session.plugins).length > 0 ? { plugins: { ...session.plugins } } : {},
2819
- ...session?.navPartId !== void 0 ? { navPartId: session.navPartId } : {},
2820
- ...session?.navSectionId !== void 0 ? { navSectionId: session.navSectionId } : {},
2821
- ...session?.navItemRefId !== void 0 ? { navItemRefId: session.navItemRefId } : {}
2822
- }
2823
- });
2824
2829
  var TestStateMixin = (superClass) => {
2825
2830
  class TestStateClass extends superClass {
2826
2831
  /** A state assigned before the test connected, applied when it does. */
@@ -2864,7 +2869,7 @@ var TestStateMixin = (superClass) => {
2864
2869
  this.sessionContext = { ...this.sessionContext, plugins: next };
2865
2870
  }
2866
2871
  get state() {
2867
- return toState(this.testContext, this.sessionContext);
2872
+ return stateFromContexts(this.testContext, this.sessionContext);
2868
2873
  }
2869
2874
  set state(value) {
2870
2875
  if (!isQtiTestState(value)) {
@@ -3519,8 +3524,6 @@ var TestNavigation = class extends LitElement13 {
3519
3524
  active: false,
3520
3525
  identifier: section.identifier,
3521
3526
  title: section.title,
3522
- // QTI defines both modes on the test part only; the section attributes go in roadmap T1d.
3523
- ...this.#sectionModes(section.identifier),
3524
3527
  allowSkipping: section.sessionControl.allowSkipping,
3525
3528
  items: ownItemRefs(section).map((item) => ({
3526
3529
  ...this.initContext?.find((i) => i.identifier === item.identifier),
@@ -3550,14 +3553,6 @@ var TestNavigation = class extends LitElement13 {
3550
3553
  item.categories.includes(this.configContext?.infoItemCategory) ? null : index++
3551
3554
  ]));
3552
3555
  }
3553
- /** The non-QTI `navigation-mode` / `submission-mode` a section declares, as before; removed in T1d. */
3554
- #sectionModes(identifier) {
3555
- const section = this.#testElement.querySelector(`qti-assessment-section[identifier="${CSS.escape(identifier)}"]`);
3556
- return {
3557
- navigationMode: section?.getAttribute("navigation-mode") ?? void 0,
3558
- submissionMode: section?.getAttribute("submission-mode") ?? void 0
3559
- };
3560
- }
3561
3556
  /**
3562
3557
  * Extract default values from a qti-context-declaration element
3563
3558
  */
@@ -3729,7 +3724,7 @@ var TestNavigation = class extends LitElement13 {
3729
3724
  #lockUsedItems() {
3730
3725
  if (!this.#testElement || !this.computedContext)
3731
3726
  return;
3732
- const items = new Map(this.computedContext.testParts.flatMap((part) => part.sections.flatMap((section) => (section.submissionMode || part.submissionMode) === "simultaneous" ? [] : section.items.map((item) => [item.identifier, item]))));
3727
+ const items = new Map(this.computedContext.testParts.flatMap((part) => part.submissionMode === "simultaneous" ? [] : part.sections.flatMap((section) => section.items.map((item) => [item.identifier, item]))));
3733
3728
  for (const itemRef of this.#testElement.querySelectorAll("qti-assessment-item-ref")) {
3734
3729
  const element = itemRef.assessmentItem;
3735
3730
  if (!element)
@@ -3921,11 +3916,8 @@ var TestNext = class extends LitElement14 {
3921
3916
  const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3922
3917
  if (!testPart)
3923
3918
  return;
3924
- const activeSection = testPart.sections.find((s) => s.active);
3925
- const navigationMode = activeSection?.navigationMode || testPart.navigationMode;
3926
- const submissionMode = activeSection?.submissionMode || testPart.submissionMode;
3927
3919
  const activeItem = this.sectionItems[this.itemIndex];
3928
- const isLinearIndividual = navigationMode === "linear" && submissionMode === "individual";
3920
+ const isLinearIndividual = testPart.navigationMode === "linear" && testPart.submissionMode === "individual";
3929
3921
  this._internalDisabled = !this.computedContext || this.itemIndex < 0 || this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 || isLinearIndividual && !activeItem?.done;
3930
3922
  }
3931
3923
  _requestItem(identifier) {
@@ -3985,8 +3977,7 @@ var TestPrev = class extends LitElement15 {
3985
3977
  }
3986
3978
  checkDisabled() {
3987
3979
  const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
3988
- const activeSection = testPart?.sections.find((s) => s.active);
3989
- const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || "nonlinear";
3980
+ const navigationMode = testPart?.navigationMode ?? "nonlinear";
3990
3981
  this._internalDisabled = navigationMode === "linear" || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;
3991
3982
  }
3992
3983
  _requestItem(identifier) {
@@ -4063,6 +4054,7 @@ export {
4063
4054
  QtiTestVariables,
4064
4055
  QtiTestVariablesExpression,
4065
4056
  QTI_TEST_STATE_VERSION,
4057
+ stateFromContexts,
4066
4058
  QtiTest,
4067
4059
  TestContainer,
4068
4060
  TestEndAttempt,
@@ -4085,4 +4077,4 @@ export {
4085
4077
  * Portions Copyright (c) 2013, the Dart project authors.
4086
4078
  *)
4087
4079
  */
4088
- //# sourceMappingURL=chunk-TB2OI3ED.js.map
4080
+ //# sourceMappingURL=chunk-IJKHXJSM.js.map