jspsych-tangram 0.0.4 → 0.0.6

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.
@@ -187,7 +187,6 @@ class BaseGameController {
187
187
  const allDone = Object.values(this.state.sectors).every((s) => !!s.completedAt);
188
188
  if (allDone && !this.state.endedAt) {
189
189
  this.state.endedAt = NOW();
190
- console.log("[BaseGameController] all sectors complete");
191
190
  }
192
191
  }
193
192
  // ===== Piece Operations =====
@@ -3155,7 +3154,9 @@ function GameBoard(props) {
3155
3154
  if (allSectorsComplete && !gameCompleted) {
3156
3155
  setGameCompleted(true);
3157
3156
  if (tracker) {
3158
- tracker.finalizeTrial("auto_complete");
3157
+ setTimeout(() => {
3158
+ tracker.finalizeTrial("auto_complete");
3159
+ }, 0);
3159
3160
  }
3160
3161
  }
3161
3162
  };
@@ -3549,9 +3550,11 @@ function startPrepTrial(display_element, params, jsPsych) {
3549
3550
  layoutMode,
3550
3551
  requireAllSlots,
3551
3552
  quickstashMacros,
3553
+ primitiveOrder,
3552
3554
  onInteraction,
3553
3555
  onTrialEnd
3554
3556
  } = params;
3557
+ const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => primitiveOrder.indexOf(a.kind) - primitiveOrder.indexOf(b.kind));
3555
3558
  const prepSectors = Array.from({ length: numQuickstashSlots }, (_, i) => ({
3556
3559
  id: `prep-sector-${i}`,
3557
3560
  tangramId: `prep-sector-${i}`,
@@ -3565,7 +3568,7 @@ function startPrepTrial(display_element, params, jsPsych) {
3565
3568
  const handleControllerReady = (controller, layout, force) => {
3566
3569
  if (quickstashMacros && quickstashMacros.length > 0 && layout) {
3567
3570
  const primsByKind = /* @__PURE__ */ new Map();
3568
- PRIMITIVE_BLUEPRINTS.forEach((p) => primsByKind.set(p.kind, p));
3571
+ PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
3569
3572
  quickstashMacros.forEach((anchorComposite, macroIndex) => {
3570
3573
  const sectorId = `prep-sector-${macroIndex}`;
3571
3574
  const compositeBlueprint = convertAnchorCompositeToPixels(
@@ -3622,7 +3625,7 @@ function startPrepTrial(display_element, params, jsPsych) {
3622
3625
  sectors: prepSectors,
3623
3626
  quickstash: [],
3624
3627
  // No pre-made macros
3625
- primitives: PRIMITIVE_BLUEPRINTS,
3628
+ primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
3626
3629
  layout: layoutMode,
3627
3630
  target: "workspace",
3628
3631
  // Pieces go in sectors
@@ -3683,6 +3686,12 @@ const info = {
3683
3686
  default: [],
3684
3687
  description: "Array of AnchorComposite objects to edit as primitive pieces"
3685
3688
  },
3689
+ /** Array of primitive names in the order they should be displayed */
3690
+ primitive_order: {
3691
+ type: jspsych.ParameterType.OBJECT,
3692
+ default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
3693
+ description: "Array of primitive names in the order they should be displayed"
3694
+ },
3686
3695
  /** Callback fired after each interaction (optional analytics hook) */
3687
3696
  onInteraction: {
3688
3697
  type: jspsych.ParameterType.FUNCTION,
@@ -3726,13 +3735,14 @@ class TangramPrepPlugin {
3726
3735
  this.jsPsych.finishTrial(data);
3727
3736
  };
3728
3737
  const params = {
3729
- numQuickstashSlots: trial.num_quickstash_slots || 4,
3738
+ numQuickstashSlots: trial.num_quickstash_slots,
3730
3739
  maxPiecesPerMacro: trial.max_pieces_per_macro,
3731
3740
  minPiecesPerMacro: trial.min_pieces_per_macro,
3732
3741
  inputMode: trial.input,
3733
3742
  layoutMode: trial.layout,
3734
3743
  requireAllSlots: trial.require_all_slots,
3735
3744
  quickstashMacros: trial.quickstash_macros,
3745
+ primitiveOrder: trial.primitive_order,
3736
3746
  onInteraction: trial.onInteraction,
3737
3747
  onTrialEnd: wrappedOnTrialEnd
3738
3748
  };