@m2c2kit/assessment-color-shapes 0.8.31 → 0.8.32

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/index.min.js CHANGED
@@ -1 +1 @@
1
- import{Game as he,RandomDraws as _,Sprite as de,Scene as y,M2Error as oe,WebColors as i,Transition as q,Shape as p,Label as ne,Action as h,Timer as j,Easings as Te,TransitionDirection as me}from"@m2c2kit/core";import{LocalePicker as ue,Instructions as H,CountdownScene as _e,Grid as se,Button as V}from"@m2c2kit/addons";class fe extends he{constructor(){const e={fixation_duration_ms:{default:500,description:"How long fixation scene is shown, milliseconds.",type:"number"},shape_colors:{type:"array",description:"Array of colors for shapes.",items:{type:"object",properties:{colorName:{type:"string",description:"Human-friendly name of color."},rgbaColor:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}}}},default:[{colorName:"black",rgbaColor:[0,0,0,1]},{colorName:"green",rgbaColor:[0,158,115,1]},{colorName:"yellow",rgbaColor:[240,228,66,1]},{colorName:"blue",rgbaColor:[0,114,178,1]},{colorName:"orange",rgbaColor:[213,94,0,1]},{colorName:"pink",rgbaColor:[204,121,167,1]}]},number_of_shapes_shown:{default:3,description:"How many shapes to show on the grid at one time.",type:"integer"},number_of_shapes_changing_color:{default:2,description:"If a different color trial, how many shapes should change color (minimum is 2, because changes are swaps with other shapes).",type:"integer"},shapes_presented_duration_ms:{default:2e3,description:"How long the shapes are shown, milliseconds.",type:"number"},shapes_removed_duration_ms:{default:1e3,description:"How long to show a blank square after shapes are removed, milliseconds.",type:"number"},cells_per_side:{default:3,description:"How many cell positions for each side of the square grid (e.g., 3 is a 3x3 grid; 4 is a 4x4 grid).",type:"integer"},number_of_different_colors_trials:{default:6,type:"integer",description:"Number of trials where the shapes have different colors."},number_of_trials:{default:12,description:"How many trials to run.",type:"integer"},show_trials_complete_scene:{default:!0,type:"boolean",description:"After the final trial, should a completion scene be shown? Otherwise, the game will immediately end."},instruction_type:{default:"long",description:"Type of instructions to show, 'short' or 'long'.",type:"string",enum:["short","long"]},instructions:{default:null,type:["object","null"],description:"When non-null, an InstructionsOptions object that will completely override the built-in instructions."},show_quit_button:{type:"boolean",default:!1,description:"Should the activity quit button be shown?"},show_fps:{type:"boolean",default:!1,description:"Should the FPS be shown?"},show_locale_picker:{type:"boolean",default:!1,description:"Should the icon that allows the participant to switch the locale be shown?"},seed:{type:["string","null"],default:null,description:"Optional seed for the seeded pseudo-random number generator. When null, the default Math.random() is used."}},f={activity_begin_iso8601_timestamp:{type:"string",format:"date-time",description:"ISO 8601 timestamp at the beginning of the game activity."},trial_begin_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the beginning of the trial. Null if trial was skipped."},trial_end_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the end of the trial (when user presses 'Same' or 'Different'). Null if trial was skipped."},trial_index:{type:["integer","null"],description:"Index of the trial within this assessment, 0-based."},present_shapes:{description:"Configuration of shapes shown to the user in the presentation phase. Null if trial was skipped.",type:["array","null"],items:{type:"object",properties:{shape_index:{type:"integer",description:"Index of the shape within the library of shapes, 0-based"},color_name:{type:"string",description:"Human-friendly name of color."},rgba_color:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}},location:{type:"object",description:"Location of shape.",properties:{row:{type:"number",description:"Row of the shape, 0-based."},column:{type:"number",description:"Column of the shape, 0-based."}}}}}},response_shapes:{description:"Configuration of shapes shown to the user in the response phase. Null if trial was skipped.",type:["array","null"],items:{type:"object",properties:{shape_index:{type:"integer",description:"Index of the shape within the library of shapes, 0-based"},color_name:{type:"string",description:"Human-friendly name of color."},rgba_color:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}},location:{type:"object",description:"Location of shape.",properties:{row:{type:"number",description:"Row of the shape, 0-based."},column:{type:"number",description:"Column of the shape, 0-based."}}}}}},response_time_duration_ms:{type:["number","null"],description:"Milliseconds from when the response configuration of shapes is shown until the user taps a response. Null if trial was skipped."},user_response:{type:["string","null"],enum:["same","different"],description:"User's response to whether the shapes are same colors or different."},user_response_correct:{type:["boolean","null"],description:"Was the user's response correct?"},quit_button_pressed:{type:"boolean",description:"Was the quit button pressed?"}},a={name:"Color Shapes",id:"color-shapes",publishUuid:"394cb010-2ccf-4a87-9d23-cda7fb07a960",version:"0.8.31 (92cfffbe)",moduleMetadata:{name:"@m2c2kit/assessment-color-shapes",version:"0.8.31",dependencies:{"@m2c2kit/addons":"0.3.32","@m2c2kit/core":"0.3.33"}},translation:{configuration:{baseLocale:"en-US"},"en-US":{localeName:"English",INSTRUCTIONS_TITLE:"Color Shapes",SHORT_INSTRUCTIONS_TEXT_PAGE_1:"Try to remember the color of 3 shapes, because they will soon disappear. When the shapes reappear, answer whether they have the SAME or DIFFERENT colors as they had before",INSTRUCTIONS_TEXT_PAGE_1:"Try to remember the color of 3 shapes, because they will soon disappear.",INSTRUCTIONS_TEXT_PAGE_2:"Next you will see the same shapes reappear.",INSTRUCTIONS_TEXT_PAGE_3:"Answer whether the shapes have the SAME or DIFFERENT colors as they had before.",START_BUTTON_TEXT:"START",NEXT_BUTTON_TEXT:"Next",BACK_BUTTON_TEXT:"Back",GET_READY_COUNTDOWN_TEXT:"GET READY!",SAME_BUTTON_TEXT:"Same",DIFFERENT_BUTTON_TEXT:"Different",TRIALS_COMPLETE_SCENE_TEXT:"This activity is complete.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"},"es-MX":{localeName:"Espa\xF1ol",INSTRUCTIONS_TITLE:"Formas de Color",INSTRUCTIONS_TEXT_PAGE_1:"Intenta recordar el color de las 3 formas, porque pronto desaparecer\xE1n.",INSTRUCTIONS_TEXT_PAGE_2:"Luego ver\xE1s reaparecer las mismas formas.",INSTRUCTIONS_TEXT_PAGE_3:"Responde si las formas tienen el MISMO o DIFERENTE color que antes.",START_BUTTON_TEXT:"COMENZAR",NEXT_BUTTON_TEXT:"Siguiente",BACK_BUTTON_TEXT:"Atr\xE1s",GET_READY_COUNTDOWN_TEXT:"PREP\xC1RESE",SAME_BUTTON_TEXT:"Mismo",DIFFERENT_BUTTON_TEXT:"Diferente",TRIALS_COMPLETE_SCENE_TEXT:"Esta actividad est\xE1 completa.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"},"de-DE":{localeName:"Deutsch",INSTRUCTIONS_TITLE:"Farb-Formen",INSTRUCTIONS_TEXT_PAGE_1:"Oben und unten sehen Sie Symbolpaare.",INSTRUCTIONS_TEXT_PAGE_2:"Ihre Aufgabe wird es sein, auf dasjenige untere Paar zu tippen, welches mit einem der obigen Paare exakt \xFCbereinstimmt.",INSTRUCTIONS_TEXT_PAGE_3:"Versuchen Sie bitte, so schnell und korrekt wie m\xF6glich zu sein.",START_BUTTON_TEXT:"START",NEXT_BUTTON_TEXT:"Weiter",BACK_BUTTON_TEXT:"Vorherige",GET_READY_COUNTDOWN_TEXT:"BEREIT MACHEN",SAME_BUTTON_TEXT:"Gleich",DIFFERENT_BUTTON_TEXT:"Unterschiedlich",TRIALS_COMPLETE_SCENE_TEXT:"Die Aufgabe ist beendet.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"}},shortDescription:"Color Shapes is a visual array change detection task, measuring intra-item feature binding, where participants determine if shapes change color across two sequential presentations of shape stimuli.",longDescription:'Color Shapes is a change detection paradigm used to measure visual short-term memory binding (Parra et al., 2009). Participants are asked to memorize the shapes and colors of three different polygons for 3 seconds. The three polygons are then removed from the screen and re-displayed at different locations, either having the same or different colors. Participants are then asked to decide whether the combination of colors and shapes are the "Same" or "Different" between the study and test phases.',showFps:e.show_fps.default,width:400,height:800,trialSchema:f,parameters:e,fonts:[{fontName:"roboto",url:"fonts/roboto/Roboto-Regular.ttf"}],images:[{imageName:"instructions-1",height:256,width:256,url:"images/cs-instructions-1.png"},{imageName:"instructions-2",height:256,width:256,url:"images/cs-instructions-2.png"},{imageName:"instructions-3",height:350,width:300,url:"images/cs-instructions-3.png",localize:!0},{imageName:"circle-x",height:32,width:32,url:"images/circle-x.svg"}]};super(a)}async initialize(){await super.initialize();const e=this,f=e.getParameter("seed");typeof f=="string"&&_.setSeed(f);const I=96,a=350,c=e.getParameter("number_of_shapes_shown"),x=this.makeShapes(I);if(e.getParameter("show_quit_button")){const n=new de({imageName:"circle-x",position:{x:380,y:20},isUserInteractionEnabled:!0});e.addFreeNode(n),n.onTapDown(s=>{e.removeAllFreeNodes(),s.handled=!0;const r=new y;e.addScene(r),e.presentScene(r),e.addTrialData("quit_button_pressed",!0),e.trialComplete(),e.cancel()})}let O;e.getParameter("show_locale_picker")&&(O=new ue,e.addFreeNode(O));let T;const A=e.getParameter("instructions");if(A)T=H.create(A);else switch(e.getParameter("instruction_type")){case"short":{T=H.create({instructionScenes:[{title:"INSTRUCTIONS_TITLE",text:"SHORT_INSTRUCTIONS_TEXT_PAGE_1",imageName:"instructions-1",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"START_BUTTON_TEXT",nextButtonBackgroundColor:i.Green,nextSceneTransition:q.none()}]});break}case"long":{T=H.create({instructionScenes:[{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_1",imageName:"instructions-1",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"NEXT_BUTTON_TEXT",backButtonText:"BACK_BUTTON_TEXT"},{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_2",imageName:"instructions-2",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"NEXT_BUTTON_TEXT",backButtonText:"BACK_BUTTON_TEXT"},{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_3",imageName:"instructions-3",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"START_BUTTON_TEXT",nextButtonBackgroundColor:i.Green,backButtonText:"BACK_BUTTON_TEXT"}]});break}default:throw new oe("invalid value for instruction_type")}T[0].onAppear(()=>{e.addTrialData("activity_begin_iso8601_timestamp",this.beginIso8601Timestamp)}),e.addScenes(T);const K=new _e({milliseconds:3e3,text:"GET_READY_COUNTDOWN_TEXT",zeroDwellMilliseconds:1e3,transition:q.none()});e.addScene(K);const Z=e.getParameter("cells_per_side"),Y=e.getParameter("cells_per_side"),G=e.getParameter("number_of_trials"),R=e.getParameter("shape_colors"),U=[],M=e.getParameter("cells_per_side"),$=M,re=e.getParameter("number_of_different_colors_trials"),ae=_.fromRangeWithoutReplacement(re,0,G-1);for(let n=0;n<G;n++){const s=new Array,r=new Array,b=_.fromRangeWithoutReplacement(c,0,x.length-1),N=_.fromRangeWithoutReplacement(c,0,R.length-1),L=o=>!!(o.map(t=>t.row===0&&t.column===0).some(t=>t===!0)&&o.map(t=>t.row===1&&t.column===1).some(t=>t===!0)&&o.map(t=>t.row===2&&t.column===2).some(t=>t===!0)||o.map(t=>t.row===2&&t.column===0).some(t=>t===!0)&&o.map(t=>t.row===1&&t.column===1).some(t=>t===!0)&&o.map(t=>t.row===0&&t.column===2).some(t=>t===!0)),l=o=>{const t=new Set(o.map(C=>C.row)).size,E=new Set(o.map(C=>C.column)).size;return!(t!==1&&E!==1)};let W=!1,k;do k=_.fromGridWithoutReplacement(c,M,$),!l(k)&&!L(k)?W=!0:W=!1;while(!W);for(let o=0;o<c;o++){const t={shape:x[b[o]],shapeIndex:b[o],color:R[N[o]].rgbaColor,colorName:R[N[o]].colorName,location:k[o]};s.push(t)}let z=!1,v;do v=_.fromGridWithoutReplacement(c,M,$),!l(v)&&!L(v)?z=!0:z=!1;while(!z);for(let o=0;o<c;o++){const t={shape:s[o].shape,shapeIndex:b[o],color:s[o].color,colorName:R[N[o]].colorName,location:v[o]};r.push(t)}let ee=0;if(ae.includes(n)){const o=e.getParameter("number_of_shapes_changing_color");if(o>c)throw new oe(`number_of_shapes_changing_color is ${o}, but it must be less than or equal to number_of_shapes_shown (which is ${c}).`);const E=_.fromRangeWithoutReplacement(o,0,c-1).map(u=>r[u]);ee=E.length;const C=E[0].color;for(let u=0;u<o;u++){const te=E[u];u+1<o?te.color=E[u+1].color:te.color=C}}U.push({presentShapes:s,responseShapes:r,numberOfShapesWithDifferentColors:ee})}const w=new y;e.addScene(w);const Q=new p({rect:{size:{width:a,height:a}},fillColor:i.Transparent,strokeColor:i.Gray,lineWidth:4,position:{x:200,y:300}});w.addChild(Q);const ie=new ne({text:"+",fontSize:32,fontColor:i.Black,localize:!1});Q.addChild(ie),w.onAppear(()=>{e.addTrialData("activity_begin_iso8601_timestamp",this.beginIso8601Timestamp),e.addTrialData("trial_begin_iso8601_timestamp",new Date().toISOString()),w.run(h.sequence([h.wait({duration:e.getParameter("fixation_duration_ms")}),h.custom({callback:()=>{e.presentScene(S)}})]))});const S=new y;e.addScene(S);const le=new p({rect:{size:{width:a,height:a}},fillColor:i.Transparent,strokeColor:i.Gray,lineWidth:4,position:{x:200,y:300}});S.addChild(le);const B=new se({rows:Z,columns:Y,size:{width:a,height:a},position:{x:200,y:300},backgroundColor:i.Transparent,gridLineColor:i.Transparent});S.addChild(B),S.onAppear(()=>{const n=U[e.trialIndex];for(let s=0;s<n.presentShapes.length;s++){const r=n.presentShapes[s].shape;r.fillColor=n.presentShapes[s].color,r.position={x:0,y:0},B.addAtCell(r,n.presentShapes[s].location.row,n.presentShapes[s].location.column)}S.run(h.sequence([h.wait({duration:e.getParameter("shapes_presented_duration_ms")}),h.custom({callback:()=>{B.removeAllGridChildren()}}),h.wait({duration:e.getParameter("shapes_removed_duration_ms")}),h.custom({callback:()=>{B.removeAllGridChildren(),e.presentScene(m)}})]))});const m=new y;e.addScene(m);const ce=new p({rect:{size:{width:a,height:a}},fillColor:i.Transparent,strokeColor:i.Gray,lineWidth:4,position:{x:200,y:300}});m.addChild(ce);const F=new se({rows:Z,columns:Y,size:{width:a,height:a},position:{x:200,y:300},backgroundColor:i.Transparent,gridLineColor:i.Transparent});m.addChild(F),m.onAppear(()=>{const n=U[e.trialIndex];for(let s=0;s<n.responseShapes.length;s++){const r=n.responseShapes[s].shape;r.fillColor=n.responseShapes[s].color,r.position={x:0,y:0},F.addAtCell(r,n.responseShapes[s].location.row,n.responseShapes[s].location.column)}X.isUserInteractionEnabled=!0,D.isUserInteractionEnabled=!0,j.startNew("rt")});const X=new V({text:"SAME_BUTTON_TEXT",position:{x:100,y:700},size:{width:150,height:50}});m.addChild(X),X.onTapDown(()=>{X.isUserInteractionEnabled=!1,J(!1)});const D=new V({text:"DIFFERENT_BUTTON_TEXT",position:{x:300,y:700},size:{width:150,height:50}});m.addChild(D),D.onTapDown(()=>{D.isUserInteractionEnabled=!1,J(!0)});const J=n=>{const s=j.elapsed("rt");j.remove("rt"),F.removeAllGridChildren(),e.addTrialData("trial_end_iso8601_timestamp",new Date().toISOString());const r=U[e.trialIndex];e.addTrialData("response_time_duration_ms",s),e.addTrialData("user_response",n?"different":"same");const b=r.numberOfShapesWithDifferentColors===0&&!n||r.numberOfShapesWithDifferentColors>0&&n;e.addTrialData("user_response_correct",b);const N=r.presentShapes.map(l=>({shape_index:l.shapeIndex,color_name:l.colorName,rgba_color:l.color,location:l.location}));e.addTrialData("present_shapes",N),e.addTrialData("quit_button_pressed",!1);const L=r.responseShapes.map(l=>({shape_index:l.shapeIndex,color_name:l.colorName,rgba_color:l.color,location:l.location}));e.addTrialData("response_shapes",L),e.addTrialData("trial_index",e.trialIndex),e.trialComplete(),e.trialIndex<G?e.presentScene(w):e.presentScene(g,q.slide({direction:me.Left,duration:500,easing:Te.sinusoidalInOut}))},g=new y;e.addScene(g);const pe=new ne({text:"TRIALS_COMPLETE_SCENE_TEXT",position:{x:200,y:400}});g.addChild(pe);const P=new V({text:"TRIALS_COMPLETE_SCENE_BUTTON_TEXT",position:{x:200,y:650}});P.isUserInteractionEnabled=!0,P.onTapDown(()=>{P.isUserInteractionEnabled=!1,g.removeAllChildren(),e.end()}),g.addChild(P),g.onSetup(()=>{e.removeAllFreeNodes()})}makeShapes(e){const f=new p({path:{pathString:d[0],height:e},lineWidth:0}),I=new p({path:{pathString:d[1],height:e},lineWidth:0}),a=new p({path:{pathString:d[2],height:e*.8},lineWidth:0}),c=new p({path:{pathString:d[3],height:e},lineWidth:0}),x=new p({path:{pathString:d[4],height:e*.8},lineWidth:0}),O=new p({path:{pathString:d[5],height:e},lineWidth:0}),T=new p({path:{pathString:d[6],height:e},lineWidth:0}),A=new p({path:{pathString:d[7],height:e},lineWidth:0});return[f,I,a,c,x,O,T,A]}}const d=["M0 89.94v-2L131.95 0h2v88.7c2.34 1.6 4.47 3.11 6.65 4.55 42.77 28.22 85.54 56.42 128.3 84.63v2c-44.65 29.65-89.3 59.29-133.95 88.94h-1v-90.84C89.44 148.72 44.72 119.33 0 89.94Z","M162 188c-.33 27-.67 54-1 81-26.87-26.18-53.74-52.35-80-77.94V269H0C0 180.83 0 92.67.04 4.5.04 3 .67 1.5 1 0c24.64 29.1 49.15 58.31 73.96 87.26 28.88 33.7 58.01 67.17 87.04 100.74Z","M3 148.86V61.12C41.76 40.75 80.52 20.37 119.28 0h2.91c21.32 20.7 42.64 41.4 63.96 62.11v89.71c-38.44 20.04-76.88 40.09-115.31 60.13h-2.91L3.01 148.86Z","M134 0h2c7.26 22.31 14.38 44.67 21.86 66.9 3.91 11.61 5.47 29.91 13.25 33.27C203 113.94 236.86 123.13 270 134v1L136 269h-1c-11.04-33.58-22.08-67.16-33.21-101.03C67.87 156.98 33.93 145.99 0 135v-1L134 0Z","M107 0h1l108 108v1c-26.67 35.33-53.33 70.66-80 106h-1c-8.82-35.03-17.64-70.07-27-107.28C98.62 145.01 89.81 180 81.01 215h-1C53.33 179.66 26.67 144.33 0 109v-2L107 0Z","M0 1C2.17.67 4.33.05 6.5.04 58.33-.01 110.17 0 162 0v270H2c26.2-22.17 52.41-44.33 78.86-66.71V67.4c-3.85-3.22-7.35-6.2-10.9-9.11C46.64 39.18 23.32 20.09 0 1Z","M95 268.99h-1C62.66 238.66 31.33 208.33 0 178V88C26.67 58.67 53.33 29.33 80 0h1c0 29.45 0 58.89-.01 88.38 35.99 29.57 72 59.09 108.01 88.61v1l-94 91Z","M13 0h67l135 135v1L81 270c-27-.33-54-.67-81-1 11.73-12.51 23.61-24.87 35.16-37.54 33.14-36.35 66.14-72.82 100.23-110.38C94.4 80.52 53.7 40.26 13 0Z"];export{fe as ColorShapes};
1
+ import{Game as de,RandomDraws as v,Sprite as me,Scene as B,M2Error as ne,WebColors as S,Transition as $,Shape as w,Label as oe,Action as y,Timer as H,Easings as fe,TransitionDirection as ge}from"@m2c2kit/core";import{LocalePicker as _e,Instructions as Z,CountdownScene as Te,Grid as ie,Button as Y}from"@m2c2kit/addons";class T extends Error{constructor(...e){super(...e),this.name="M2Error",Object.setPrototypeOf(this,T.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,T)}}class f{constructor(e,t){if(this._groups=new Array,!Array.isArray(e))throw new T("DataCalc constructor expects an array of observations as first argument");for(let r=0;r<e.length;r++)if(e[r]===null||typeof e[r]!="object"||Array.isArray(e[r]))throw new T(`DataCalc constructor expects all elements to be objects (observations). Element at index ${r} is ${typeof e[r]}. Element: ${JSON.stringify(e[r])}`);this._observations=this.deepCopy(e);const o=new Set;for(const r of e)for(const s of Object.keys(r))o.add(s);for(const r of this._observations)for(const s of o)s in r||(r[s]=null);t?.groups&&(this._groups=Array.from(t.groups))}get groups(){return this._groups}get observations(){return this._observations}get rows(){return this._observations}pull(e){if(this._observations.length===0)return console.warn(`DataCalc.pull(): No observations available to pull variable "${e}" from. Returning null.`),null;this.verifyObservationsContainVariable(e);const t=this._observations.map(o=>o[e]);return t.length===1?t[0]:t}get length(){return this._observations.length}filter(e){if(this._groups.length>0)throw new T(`filter() cannot be used on grouped data. The data are currently grouped by ${this._groups.join(", ")}. Ungroup the data first using ungroup().`);return new f(this._observations.filter(e),{groups:this._groups})}groupBy(...e){return e.forEach(t=>{this.verifyObservationsContainVariable(t)}),new f(this._observations,{groups:e})}ungroup(){return new f(this._observations)}mutate(e){if(this._groups.length>0)throw new T(`mutate() cannot be used on grouped data. The data are currently grouped by ${this._groups.join(", ")}. Ungroup the data first using ungroup().`);const t=this._observations.map(o=>{let r={...o};for(const[s,n]of Object.entries(e))r={...r,[s]:n(o)};return r});return new f(t,{groups:this._groups})}summarize(e){if(this._groups.length===0){const t={};for(const[o,r]of Object.entries(e))if(typeof r=="object"&&r!==null&&"summarizeFunction"in r){const s=r;t[o]=s.summarizeFunction(this,s.parameters,s.options)}else t[o]=r;return new f([t],{groups:this._groups})}return this.summarizeByGroups(e)}summarizeByGroups(e){const t=new Map;this._observations.forEach(r=>{const s=this._groups.map(i=>typeof r[i]=="object"?JSON.stringify(r[i]):r[i]).join("|");t.has(s)||t.set(s,[]);const n=t.get(s);n?n.push(r):t.set(s,[r])});const o=[];return t.forEach((r,s)=>{const n=s.split("|"),i=r[0],a={};this._groups.forEach((h,m)=>{const _=n[m],I=typeof i[h];if(I==="number")a[h]=Number(_);else if(I==="boolean")a[h]=_==="true";else if(_.startsWith("{")||_.startsWith("["))try{a[h]=JSON.parse(_)}catch{throw new T(`Failed to parse group value ${_} as JSON for group ${h}`)}else a[h]=_});const l=new f(r);for(const[h,m]of Object.entries(e))if(typeof m=="object"&&m!==null&&"summarizeFunction"in m){const _=m;a[h]=_.summarizeFunction(l,_.parameters,_.options)}else a[h]=m;o.push(a)}),new f(o,{groups:this._groups})}select(...e){const t=[],o=[];e.forEach(i=>{i.startsWith("-")?o.push(i.substring(1)):t.push(i)}),[...t.length>0?t:Object.keys(this._observations[0]||{}),...o].forEach(i=>{this.verifyObservationsContainVariable(i)});const s=new Set(o),n=this._observations.map(i=>{const a={};return t.length>0?t.forEach(l=>{s.has(l)||(a[l]=i[l])}):Object.keys(i).forEach(l=>{s.has(l)||(a[l]=i[l])}),a});return new f(n,{groups:this._groups})}arrange(...e){if(this._groups.length>0)throw new T(`arrange() cannot be used on grouped data. The data are currently grouped by ${this._groups.join(", ")}. Ungroup the data first using ungroup().`);const t=[...this._observations].sort((o,r)=>{for(const s of e){let n=s,i=1;if(s.startsWith("-")&&(n=s.substring(1),i=-1),!(n in o)||!(n in r))throw new T(`arrange(): variable ${n} does not exist in all observations`);const a=o[n],l=r[n];if(typeof a!=typeof l)return i*(String(a)<String(l)?-1:1);if(a<l)return-1*i;if(a>l)return 1*i}return 0});return new f(t,{groups:this._groups})}distinct(){const e=new Set,t=this._observations.filter(o=>{const r=JSON.stringify(this.normalizeForComparison(o));return e.has(r)?!1:(e.add(r),!0)});return new f(t,{groups:this._groups})}rename(e){if(this._observations.length===0)throw new T("Cannot rename variables on an empty dataset");Object.values(e).forEach(o=>{this.verifyObservationsContainVariable(o)});const t=this._observations.map(o=>{const r={};for(const[s,n]of Object.entries(o)){const i=Object.entries(e).find(([,a])=>a===s)?.[0];i?r[i]=n:Object.values(e).includes(s)||(r[s]=n)}return r});return new f(t,{groups:this._groups})}innerJoin(e,t){if(this._groups.length>0||e._groups.length>0)throw new T("innerJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");t.forEach(s=>{this.verifyObservationsContainVariable(s),e.verifyObservationsContainVariable(s)});const o=new Map;e.observations.forEach(s=>{if(this.hasNullJoinKeys(s,t))return;const n=t.map(a=>JSON.stringify(this.normalizeForComparison(s[a]))).join("|"),i=o.get(n)||[];i.push(s),o.set(n,i)});const r=[];return this._observations.forEach(s=>{if(this.hasNullJoinKeys(s,t))return;const n=t.map(a=>JSON.stringify(this.normalizeForComparison(s[a]))).join("|"),i=o.get(n)||[];i.length>0&&i.forEach(a=>{const l={...s};Object.entries(a).forEach(([h,m])=>{t.includes(h)||(l[h]=m)}),r.push(l)})}),new f(r)}leftJoin(e,t){if(this._groups.length>0||e._groups.length>0)throw new T("leftJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");t.forEach(s=>{this.verifyObservationsContainVariable(s),e.verifyObservationsContainVariable(s)});const o=new Map;e.observations.forEach(s=>{if(this.hasNullJoinKeys(s,t))return;const n=t.map(a=>JSON.stringify(this.normalizeForComparison(s[a]))).join("|"),i=o.get(n)||[];i.push(s),o.set(n,i)});const r=[];return this._observations.forEach(s=>{if(this.hasNullJoinKeys(s,t)){r.push({...s});return}const n=t.map(a=>JSON.stringify(this.normalizeForComparison(s[a]))).join("|"),i=o.get(n)||[];i.length>0?i.forEach(a=>{const l={...s};Object.entries(a).forEach(([h,m])=>{t.includes(h)||(l[h]=m)}),r.push(l)}):r.push({...s})}),new f(r)}rightJoin(e,t){if(this._groups.length>0||e._groups.length>0)throw new T("rightJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");t.forEach(n=>{this.verifyObservationsContainVariable(n),e.verifyObservationsContainVariable(n)});const o=new Map;e.observations.forEach(n=>{if(this.hasNullJoinKeys(n,t))return;const i=t.map(l=>JSON.stringify(this.normalizeForComparison(n[l]))).join("|"),a=o.get(i)||[];a.push(n),o.set(i,a)});const r=[],s=new Set;return this._observations.forEach(n=>{if(this.hasNullJoinKeys(n,t))return;const i=t.map(l=>JSON.stringify(this.normalizeForComparison(n[l]))).join("|"),a=o.get(i)||[];a.length>0&&(a.forEach(l=>{const h={...n};Object.entries(l).forEach(([m,_])=>{t.includes(m)||(h[m]=_)}),r.push(h)}),s.add(i))}),e.observations.forEach(n=>{if(this.hasNullJoinKeys(n,t)){r.push({...n});return}const i=t.map(a=>JSON.stringify(this.normalizeForComparison(n[a]))).join("|");s.has(i)||(r.push({...n}),s.add(i))}),new f(r)}fullJoin(e,t){if(this._groups.length>0||e._groups.length>0)throw new T("fullJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");t.forEach(n=>{this.verifyObservationsContainVariable(n),e.verifyObservationsContainVariable(n)});const o=new Map;e.observations.forEach(n=>{if(this.hasNullJoinKeys(n,t))return;const i=t.map(l=>JSON.stringify(this.normalizeForComparison(n[l]))).join("|"),a=o.get(i)||[];a.push(n),o.set(i,a)});const r=[],s=new Set;return this._observations.forEach(n=>{if(this.hasNullJoinKeys(n,t)){r.push({...n});return}const i=t.map(l=>JSON.stringify(this.normalizeForComparison(n[l]))).join("|"),a=o.get(i)||[];a.length>0?(a.forEach(l=>{const h={...n};Object.entries(l).forEach(([m,_])=>{t.includes(m)||(h[m]=_)}),r.push(h)}),s.add(i)):r.push({...n})}),e.observations.forEach(n=>{if(this.hasNullJoinKeys(n,t)){r.push({...n});return}const i=t.map(a=>JSON.stringify(this.normalizeForComparison(n[a]))).join("|");s.has(i)||(r.push({...n}),s.add(i))}),new f(r)}slice(e,t){if(this._groups.length>0)throw new T("slice() cannot be used on grouped data. Ungroup the data first using ungroup().");let o;if(e>=this._observations.length)return new f([],{groups:this._groups});if(t===void 0){const r=e<0?this._observations.length+e:e;o=[this._observations[r]]}else o=this._observations.slice(e,t);return new f(o,{groups:this._groups})}bindRows(e){if(this._observations.length>0&&e.observations.length>0){const t=new Set(Object.keys(this._observations[0])),o=new Set(Object.keys(e.observations[0]));[...t].filter(s=>o.has(s)).forEach(s=>{const n=this.getVariableType(s),i=e.getVariableType(s);n!==i&&console.warn(`Warning: bindRows() is combining datasets with different data types for variable '${s}'. Left dataset has type '${n}' and right dataset has type '${i}'.`)})}return new f([...this._observations,...e.observations])}getVariableType(e){if(this._observations.length===0)return"unknown";const t={};this._observations.forEach(s=>{if(e in s){const n=s[e],i=n===null?"null":Array.isArray(n)?"array":typeof n;t[i]=(t[i]||0)+1}});let o=0,r="unknown";for(const[s,n]of Object.entries(t))n>o&&(o=n,r=s);return r}verifyObservationsContainVariable(e){if(!this._observations.every(t=>e in t))throw new T(`Variable ${e} does not exist for each item (row) in the data array.`)}variableExists(e){return this._observations.some(t=>e in t)}isNonMissingNumeric(e){return typeof e=="number"&&!isNaN(e)&&isFinite(e)}isMissingNumeric(e){return typeof e=="number"&&(isNaN(e)||!isFinite(e))||e===null||typeof e>"u"}normalizeForComparison(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>this.normalizeForComparison(t)):Object.keys(e).sort().reduce((t,o)=>(t[o]=this.normalizeForComparison(e[o]),t),{})}deepCopy(e,t=new WeakMap){if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);const o=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));t.set(e,o);const r=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of r){const n=Object.getOwnPropertyDescriptor(e,s);n&&Object.defineProperty(o,s,{...n,value:this.deepCopy(e[s],t)})}return o}hasNullJoinKeys(e,t){return t.some(o=>e[o]===null||e[o]===void 0)}}console.log("\u26AA @m2c2kit/data-calc version 0.8.5 (d289d12c)");class be extends de{constructor(){const e={fixation_duration_ms:{default:500,description:"How long fixation scene is shown, milliseconds.",type:"number"},shape_colors:{type:"array",description:"Array of colors for shapes.",items:{type:"object",properties:{colorName:{type:"string",description:"Human-friendly name of color."},rgbaColor:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}}}},default:[{colorName:"black",rgbaColor:[0,0,0,1]},{colorName:"green",rgbaColor:[0,158,115,1]},{colorName:"yellow",rgbaColor:[240,228,66,1]},{colorName:"blue",rgbaColor:[0,114,178,1]},{colorName:"orange",rgbaColor:[213,94,0,1]},{colorName:"pink",rgbaColor:[204,121,167,1]}]},number_of_shapes_shown:{default:3,description:"How many shapes to show on the grid at one time.",type:"integer"},number_of_shapes_changing_color:{default:2,description:"If a different color trial, how many shapes should change color (minimum is 2, because changes are swaps with other shapes).",type:"integer"},shapes_presented_duration_ms:{default:2e3,description:"How long the shapes are shown, milliseconds.",type:"number"},shapes_removed_duration_ms:{default:1e3,description:"How long to show a blank square after shapes are removed, milliseconds.",type:"number"},cells_per_side:{default:3,description:"How many cell positions for each side of the square grid (e.g., 3 is a 3x3 grid; 4 is a 4x4 grid).",type:"integer"},number_of_different_colors_trials:{default:6,type:"integer",description:"Number of trials where the shapes have different colors."},number_of_trials:{default:12,description:"How many trials to run.",type:"integer"},show_trials_complete_scene:{default:!0,type:"boolean",description:"After the final trial, should a completion scene be shown? Otherwise, the game will immediately end."},instruction_type:{default:"long",description:"Type of instructions to show, 'short' or 'long'.",type:"string",enum:["short","long"]},instructions:{default:null,type:["object","null"],description:"When non-null, an InstructionsOptions object that will completely override the built-in instructions."},show_quit_button:{type:"boolean",default:!1,description:"Should the activity quit button be shown?"},show_fps:{type:"boolean",default:!1,description:"Should the FPS be shown?"},show_locale_picker:{type:"boolean",default:!1,description:"Should the icon that allows the participant to switch the locale be shown?"},seed:{type:["string","null"],default:null,description:"Optional seed for the seeded pseudo-random number generator. When null, the default Math.random() is used."},scoring:{type:"boolean",default:!1,description:"Should scoring data be generated? Default is false."}},t={activity_begin_iso8601_timestamp:{type:"string",format:"date-time",description:"ISO 8601 timestamp at the beginning of the game activity."},trial_begin_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the beginning of the trial. Null if trial was skipped."},trial_end_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the end of the trial (when user presses 'Same' or 'Different'). Null if trial was skipped."},trial_index:{type:["integer","null"],description:"Index of the trial within this assessment, 0-based."},present_shapes:{description:"Configuration of shapes shown to the user in the presentation phase. Null if trial was skipped.",type:["array","null"],items:{type:"object",properties:{shape_index:{type:"integer",description:"Index of the shape within the library of shapes, 0-based"},color_name:{type:"string",description:"Human-friendly name of color."},rgba_color:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}},location:{type:"object",description:"Location of shape.",properties:{row:{type:"number",description:"Row of the shape, 0-based."},column:{type:"number",description:"Column of the shape, 0-based."}}}}}},response_shapes:{description:"Configuration of shapes shown to the user in the response phase. Null if trial was skipped.",type:["array","null"],items:{type:"object",properties:{shape_index:{type:"integer",description:"Index of the shape within the library of shapes, 0-based"},color_name:{type:"string",description:"Human-friendly name of color."},rgba_color:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}},location:{type:"object",description:"Location of shape.",properties:{row:{type:"number",description:"Row of the shape, 0-based."},column:{type:"number",description:"Column of the shape, 0-based."}}}}}},response_time_duration_ms:{type:["number","null"],description:"Milliseconds from when the response configuration of shapes is shown until the user taps a response. Null if trial was skipped."},user_response:{type:["string","null"],enum:["same","different"],description:"User's response to whether the shapes are same colors or different."},user_response_correct:{type:["boolean","null"],description:"Was the user's response correct?"},quit_button_pressed:{type:"boolean",description:"Was the quit button pressed?"}},o={activity_begin_iso8601_timestamp:{type:"string",format:"date-time",description:"ISO 8601 timestamp at the beginning of the game activity."},first_trial_begin_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the beginning of the first trial. Null if no trials were completed."},last_trial_end_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the end of the last trial. Null if no trials were completed."},n_trials:{type:"integer",description:"Number of trials completed."},flag_trials_match_expected:{type:"integer",description:"Does the number of completed and expected trials match? 1 = true, 0 = false."},n_trials_correct:{type:"integer",description:"Number of correct trials."},n_trials_incorrect:{type:"integer",description:"Number of incorrect trials."},participant_score:{type:["number","null"],description:"Participant-facing score, calculated as (number of correct trials / number of trials attempted) * 100. This is a simple metric to provide feedback to the participant. Null if no trials attempted."}},s={name:"Color Shapes",id:"color-shapes",publishUuid:"394cb010-2ccf-4a87-9d23-cda7fb07a960",version:"0.8.32 (d289d12c)",moduleMetadata:{name:"@m2c2kit/assessment-color-shapes",version:"0.8.32",dependencies:{"@m2c2kit/addons":"0.3.33","@m2c2kit/core":"0.3.34"}},translation:{configuration:{baseLocale:"en-US"},"en-US":{localeName:"English",INSTRUCTIONS_TITLE:"Color Shapes",SHORT_INSTRUCTIONS_TEXT_PAGE_1:"Try to remember the color of 3 shapes, because they will soon disappear. When the shapes reappear, answer whether they have the SAME or DIFFERENT colors as they had before",INSTRUCTIONS_TEXT_PAGE_1:"Try to remember the color of 3 shapes, because they will soon disappear.",INSTRUCTIONS_TEXT_PAGE_2:"Next you will see the same shapes reappear.",INSTRUCTIONS_TEXT_PAGE_3:"Answer whether the shapes have the SAME or DIFFERENT colors as they had before.",START_BUTTON_TEXT:"START",NEXT_BUTTON_TEXT:"Next",BACK_BUTTON_TEXT:"Back",GET_READY_COUNTDOWN_TEXT:"GET READY!",SAME_BUTTON_TEXT:"Same",DIFFERENT_BUTTON_TEXT:"Different",TRIALS_COMPLETE_SCENE_TEXT:"This activity is complete.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"},"es-MX":{localeName:"Espa\xF1ol",INSTRUCTIONS_TITLE:"Formas de Color",INSTRUCTIONS_TEXT_PAGE_1:"Intenta recordar el color de las 3 formas, porque pronto desaparecer\xE1n.",INSTRUCTIONS_TEXT_PAGE_2:"Luego ver\xE1s reaparecer las mismas formas.",INSTRUCTIONS_TEXT_PAGE_3:"Responde si las formas tienen el MISMO o DIFERENTE color que antes.",START_BUTTON_TEXT:"COMENZAR",NEXT_BUTTON_TEXT:"Siguiente",BACK_BUTTON_TEXT:"Atr\xE1s",GET_READY_COUNTDOWN_TEXT:"PREP\xC1RESE",SAME_BUTTON_TEXT:"Mismo",DIFFERENT_BUTTON_TEXT:"Diferente",TRIALS_COMPLETE_SCENE_TEXT:"Esta actividad est\xE1 completa.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"},"de-DE":{localeName:"Deutsch",INSTRUCTIONS_TITLE:"Farb-Formen",INSTRUCTIONS_TEXT_PAGE_1:"Oben und unten sehen Sie Symbolpaare.",INSTRUCTIONS_TEXT_PAGE_2:"Ihre Aufgabe wird es sein, auf dasjenige untere Paar zu tippen, welches mit einem der obigen Paare exakt \xFCbereinstimmt.",INSTRUCTIONS_TEXT_PAGE_3:"Versuchen Sie bitte, so schnell und korrekt wie m\xF6glich zu sein.",START_BUTTON_TEXT:"START",NEXT_BUTTON_TEXT:"Weiter",BACK_BUTTON_TEXT:"Vorherige",GET_READY_COUNTDOWN_TEXT:"BEREIT MACHEN",SAME_BUTTON_TEXT:"Gleich",DIFFERENT_BUTTON_TEXT:"Unterschiedlich",TRIALS_COMPLETE_SCENE_TEXT:"Die Aufgabe ist beendet.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"}},shortDescription:"Color Shapes is a visual array change detection task, measuring intra-item feature binding, where participants determine if shapes change color across two sequential presentations of shape stimuli.",longDescription:'Color Shapes is a change detection paradigm used to measure visual short-term memory binding (Parra et al., 2009). Participants are asked to memorize the shapes and colors of three different polygons for 3 seconds. The three polygons are then removed from the screen and re-displayed at different locations, either having the same or different colors. Participants are then asked to decide whether the combination of colors and shapes are the "Same" or "Different" between the study and test phases.',showFps:e.show_fps.default,width:400,height:800,trialSchema:t,scoringSchema:o,parameters:e,fonts:[{fontName:"roboto",url:"fonts/roboto/Roboto-Regular.ttf"}],images:[{imageName:"instructions-1",height:256,width:256,url:"images/cs-instructions-1.png"},{imageName:"instructions-2",height:256,width:256,url:"images/cs-instructions-2.png"},{imageName:"instructions-3",height:350,width:300,url:"images/cs-instructions-3.png",localize:!0},{imageName:"circle-x",height:32,width:32,url:"images/circle-x.svg"}]};super(s)}async initialize(){await super.initialize();const e=this,t=e.getParameter("seed");typeof t=="string"&&v.setSeed(t);const o=96,r=350,s=e.getParameter("number_of_shapes_shown"),n=this.makeShapes(o);if(e.getParameter("show_quit_button")){const u=new me({imageName:"circle-x",position:{x:380,y:20},isUserInteractionEnabled:!0});e.addFreeNode(u),u.onTapDown(d=>{e.removeAllFreeNodes(),d.handled=!0;const g=new B;if(e.addScene(g),e.presentScene(g),e.addTrialData("quit_button_pressed",!0),e.trialComplete(),e.getParameter("scoring")){const C=e.calculateScores([],{numberOfTrials:e.getParameter("number_of_trials")});e.addScoringData(C),e.scoringComplete()}e.cancel()})}let i;e.getParameter("show_locale_picker")&&(i=new _e,e.addFreeNode(i));let a;const l=e.getParameter("instructions");if(l)a=Z.create(l);else switch(e.getParameter("instruction_type")){case"short":{a=Z.create({instructionScenes:[{title:"INSTRUCTIONS_TITLE",text:"SHORT_INSTRUCTIONS_TEXT_PAGE_1",imageName:"instructions-1",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"START_BUTTON_TEXT",nextButtonBackgroundColor:S.Green,nextSceneTransition:$.none()}]});break}case"long":{a=Z.create({instructionScenes:[{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_1",imageName:"instructions-1",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"NEXT_BUTTON_TEXT",backButtonText:"BACK_BUTTON_TEXT"},{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_2",imageName:"instructions-2",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"NEXT_BUTTON_TEXT",backButtonText:"BACK_BUTTON_TEXT"},{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_3",imageName:"instructions-3",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"START_BUTTON_TEXT",nextButtonBackgroundColor:S.Green,backButtonText:"BACK_BUTTON_TEXT"}]});break}default:throw new ne("invalid value for instruction_type")}a[0].onAppear(()=>{e.addTrialData("activity_begin_iso8601_timestamp",this.beginIso8601Timestamp)}),e.addScenes(a);const h=new Te({milliseconds:3e3,text:"GET_READY_COUNTDOWN_TEXT",zeroDwellMilliseconds:1e3,transition:$.none()});e.addScene(h);const m=e.getParameter("cells_per_side"),_=e.getParameter("cells_per_side"),I=e.getParameter("number_of_trials"),j=e.getParameter("shape_colors"),X=[],W=e.getParameter("cells_per_side"),Q=W,ae=e.getParameter("number_of_different_colors_trials"),le=v.fromRangeWithoutReplacement(ae,0,I-1);for(let u=0;u<I;u++){const d=new Array,g=new Array,C=v.fromRangeWithoutReplacement(s,0,n.length-1),P=v.fromRangeWithoutReplacement(s,0,j.length-1),D=p=>!!(p.map(c=>c.row===0&&c.column===0).some(c=>c===!0)&&p.map(c=>c.row===1&&c.column===1).some(c=>c===!0)&&p.map(c=>c.row===2&&c.column===2).some(c=>c===!0)||p.map(c=>c.row===2&&c.column===0).some(c=>c===!0)&&p.map(c=>c.row===1&&c.column===1).some(c=>c===!0)&&p.map(c=>c.row===0&&c.column===2).some(c=>c===!0)),b=p=>{const c=new Set(p.map(k=>k.row)).size,R=new Set(p.map(k=>k.column)).size;return!(c!==1&&R!==1)};let K=!1,V;do V=v.fromGridWithoutReplacement(s,W,Q),!b(V)&&!D(V)?K=!0:K=!1;while(!K);for(let p=0;p<s;p++){const c={shape:n[C[p]],shapeIndex:C[p],color:j[P[p]].rgbaColor,colorName:j[P[p]].colorName,location:V[p]};d.push(c)}let q=!1,G;do G=v.fromGridWithoutReplacement(s,W,Q),!b(G)&&!D(G)?q=!0:q=!1;while(!q);for(let p=0;p<s;p++){const c={shape:d[p].shape,shapeIndex:C[p],color:d[p].color,colorName:j[P[p]].colorName,location:G[p]};g.push(c)}let se=0;if(le.includes(u)){const p=e.getParameter("number_of_shapes_changing_color");if(p>s)throw new ne(`number_of_shapes_changing_color is ${p}, but it must be less than or equal to number_of_shapes_shown (which is ${s}).`);const R=v.fromRangeWithoutReplacement(p,0,s-1).map(O=>g[O]);se=R.length;const k=R[0].color;for(let O=0;O<p;O++){const re=R[O];O+1<p?re.color=R[O+1].color:re.color=k}}X.push({presentShapes:d,responseShapes:g,numberOfShapesWithDifferentColors:se})}const U=new B;e.addScene(U);const ee=new w({rect:{size:{width:r,height:r}},fillColor:S.Transparent,strokeColor:S.Gray,lineWidth:4,position:{x:200,y:300}});U.addChild(ee);const ce=new oe({text:"+",fontSize:32,fontColor:S.Black,localize:!1});ee.addChild(ce),U.onAppear(()=>{e.addTrialData("activity_begin_iso8601_timestamp",this.beginIso8601Timestamp),e.addTrialData("trial_begin_iso8601_timestamp",new Date().toISOString()),U.run(y.sequence([y.wait({duration:e.getParameter("fixation_duration_ms")}),y.custom({callback:()=>{e.presentScene(x)}})]))});const x=new B;e.addScene(x);const pe=new w({rect:{size:{width:r,height:r}},fillColor:S.Transparent,strokeColor:S.Gray,lineWidth:4,position:{x:200,y:300}});x.addChild(pe);const F=new ie({rows:m,columns:_,size:{width:r,height:r},position:{x:200,y:300},backgroundColor:S.Transparent,gridLineColor:S.Transparent});x.addChild(F),x.onAppear(()=>{const u=X[e.trialIndex];for(let d=0;d<u.presentShapes.length;d++){const g=u.presentShapes[d].shape;g.fillColor=u.presentShapes[d].color,g.position={x:0,y:0},F.addAtCell(g,u.presentShapes[d].location.row,u.presentShapes[d].location.column)}x.run(y.sequence([y.wait({duration:e.getParameter("shapes_presented_duration_ms")}),y.custom({callback:()=>{F.removeAllGridChildren()}}),y.wait({duration:e.getParameter("shapes_removed_duration_ms")}),y.custom({callback:()=>{F.removeAllGridChildren(),e.presentScene(N)}})]))});const N=new B;e.addScene(N);const he=new w({rect:{size:{width:r,height:r}},fillColor:S.Transparent,strokeColor:S.Gray,lineWidth:4,position:{x:200,y:300}});N.addChild(he);const J=new ie({rows:m,columns:_,size:{width:r,height:r},position:{x:200,y:300},backgroundColor:S.Transparent,gridLineColor:S.Transparent});N.addChild(J),N.onAppear(()=>{const u=X[e.trialIndex];for(let d=0;d<u.responseShapes.length;d++){const g=u.responseShapes[d].shape;g.fillColor=u.responseShapes[d].color,g.position={x:0,y:0},J.addAtCell(g,u.responseShapes[d].location.row,u.responseShapes[d].location.column)}M.isUserInteractionEnabled=!0,z.isUserInteractionEnabled=!0,H.startNew("rt")});const M=new Y({text:"SAME_BUTTON_TEXT",position:{x:100,y:700},size:{width:150,height:50}});N.addChild(M),M.onTapDown(()=>{M.isUserInteractionEnabled=!1,te(!1)});const z=new Y({text:"DIFFERENT_BUTTON_TEXT",position:{x:300,y:700},size:{width:150,height:50}});N.addChild(z),z.onTapDown(()=>{z.isUserInteractionEnabled=!1,te(!0)});const te=u=>{const d=H.elapsed("rt");H.remove("rt"),J.removeAllGridChildren(),e.addTrialData("trial_end_iso8601_timestamp",new Date().toISOString());const g=X[e.trialIndex];e.addTrialData("response_time_duration_ms",d),e.addTrialData("user_response",u?"different":"same");const C=g.numberOfShapesWithDifferentColors===0&&!u||g.numberOfShapesWithDifferentColors>0&&u;e.addTrialData("user_response_correct",C);const P=g.presentShapes.map(b=>({shape_index:b.shapeIndex,color_name:b.colorName,rgba_color:b.color,location:b.location}));e.addTrialData("present_shapes",P),e.addTrialData("quit_button_pressed",!1);const D=g.responseShapes.map(b=>({shape_index:b.shapeIndex,color_name:b.colorName,rgba_color:b.color,location:b.location}));if(e.addTrialData("response_shapes",D),e.addTrialData("trial_index",e.trialIndex),e.trialComplete(),e.trialIndex<I)e.presentScene(U);else{if(e.getParameter("scoring")){const b=e.calculateScores(e.data.trials,{numberOfTrials:e.getParameter("number_of_trials")});e.addScoringData(b),e.scoringComplete()}e.getParameter("show_trials_complete_scene")?e.presentScene(A,$.slide({direction:ge.Left,duration:500,easing:fe.sinusoidalInOut})):e.end()}},A=new B;e.addScene(A);const ue=new oe({text:"TRIALS_COMPLETE_SCENE_TEXT",position:{x:200,y:400}});A.addChild(ue);const L=new Y({text:"TRIALS_COMPLETE_SCENE_BUTTON_TEXT",position:{x:200,y:650}});L.isUserInteractionEnabled=!0,L.onTapDown(()=>{L.isUserInteractionEnabled=!1,A.removeAllChildren(),e.end()}),A.addChild(L),A.onSetup(()=>{e.removeAllFreeNodes()})}calculateScores(e,t){const o=new f(e);return o.summarize({activity_begin_iso8601_timestamp:this.beginIso8601Timestamp,first_trial_begin_iso8601_timestamp:o.arrange("trial_begin_iso8601_timestamp").slice(0).pull("trial_begin_iso8601_timestamp"),last_trial_end_iso8601_timestamp:o.arrange("-trial_end_iso8601_timestamp").slice(0).pull("trial_end_iso8601_timestamp"),n_trials:o.length,flag_trials_match_expected:o.length===t.numberOfTrials?1:0,n_trials_correct:o.filter(s=>s.user_response_correct===!0).length,n_trials_incorrect:o.filter(s=>s.user_response_correct===!1).length}).mutate({participant_score:s=>s.n_trials>0?s.n_trials_correct/s.n_trials*100:null}).observations}makeShapes(e){const t=new w({path:{pathString:E[0],height:e},lineWidth:0}),o=new w({path:{pathString:E[1],height:e},lineWidth:0}),r=new w({path:{pathString:E[2],height:e*.8},lineWidth:0}),s=new w({path:{pathString:E[3],height:e},lineWidth:0}),n=new w({path:{pathString:E[4],height:e*.8},lineWidth:0}),i=new w({path:{pathString:E[5],height:e},lineWidth:0}),a=new w({path:{pathString:E[6],height:e},lineWidth:0}),l=new w({path:{pathString:E[7],height:e},lineWidth:0});return[t,o,r,s,n,i,a,l]}}const E=["M0 89.94v-2L131.95 0h2v88.7c2.34 1.6 4.47 3.11 6.65 4.55 42.77 28.22 85.54 56.42 128.3 84.63v2c-44.65 29.65-89.3 59.29-133.95 88.94h-1v-90.84C89.44 148.72 44.72 119.33 0 89.94Z","M162 188c-.33 27-.67 54-1 81-26.87-26.18-53.74-52.35-80-77.94V269H0C0 180.83 0 92.67.04 4.5.04 3 .67 1.5 1 0c24.64 29.1 49.15 58.31 73.96 87.26 28.88 33.7 58.01 67.17 87.04 100.74Z","M3 148.86V61.12C41.76 40.75 80.52 20.37 119.28 0h2.91c21.32 20.7 42.64 41.4 63.96 62.11v89.71c-38.44 20.04-76.88 40.09-115.31 60.13h-2.91L3.01 148.86Z","M134 0h2c7.26 22.31 14.38 44.67 21.86 66.9 3.91 11.61 5.47 29.91 13.25 33.27C203 113.94 236.86 123.13 270 134v1L136 269h-1c-11.04-33.58-22.08-67.16-33.21-101.03C67.87 156.98 33.93 145.99 0 135v-1L134 0Z","M107 0h1l108 108v1c-26.67 35.33-53.33 70.66-80 106h-1c-8.82-35.03-17.64-70.07-27-107.28C98.62 145.01 89.81 180 81.01 215h-1C53.33 179.66 26.67 144.33 0 109v-2L107 0Z","M0 1C2.17.67 4.33.05 6.5.04 58.33-.01 110.17 0 162 0v270H2c26.2-22.17 52.41-44.33 78.86-66.71V67.4c-3.85-3.22-7.35-6.2-10.9-9.11C46.64 39.18 23.32 20.09 0 1Z","M95 268.99h-1C62.66 238.66 31.33 208.33 0 178V88C26.67 58.67 53.33 29.33 80 0h1c0 29.45 0 58.89-.01 88.38 35.99 29.57 72 59.09 108.01 88.61v1l-94 91Z","M13 0h67l135 135v1L81 270c-27-.33-54-.67-81-1 11.73-12.51 23.61-24.87 35.16-37.54 33.14-36.35 66.14-72.82 100.23-110.38C94.4 80.52 53.7 40.26 13 0Z"];export{be as ColorShapes};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m2c2kit/assessment-color-shapes",
3
- "version": "0.8.31",
3
+ "version": "0.8.32",
4
4
  "m2c2kit": {
5
5
  "assessmentId": "color-shapes",
6
6
  "locales": [
@@ -43,17 +43,17 @@
43
43
  },
44
44
  "homepage": "https://m2c2-project.github.io/m2c2kit",
45
45
  "dependencies": {
46
- "@m2c2kit/addons": "0.3.32",
47
- "@m2c2kit/core": "0.3.33"
46
+ "@m2c2kit/addons": "0.3.33",
47
+ "@m2c2kit/core": "0.3.34"
48
48
  },
49
49
  "devDependencies": {
50
- "@m2c2kit/build-helpers": "0.3.29",
51
- "@m2c2kit/schema-util": "0.1.23",
52
- "@m2c2kit/session": "0.3.15",
53
- "@rollup/plugin-node-resolve": "16.0.2",
50
+ "@m2c2kit/build-helpers": "0.3.30",
51
+ "@m2c2kit/schema-util": "0.1.24",
52
+ "@m2c2kit/session": "0.3.16",
53
+ "@rollup/plugin-node-resolve": "16.0.3",
54
54
  "concurrently": "9.2.1",
55
55
  "rimraf": "6.0.1",
56
- "rollup": "4.52.4",
56
+ "rollup": "4.52.5",
57
57
  "rollup-plugin-copy": "3.5.0",
58
58
  "rollup-plugin-esbuild": "6.2.1",
59
59
  "typescript": "5.9.3"
package/schemas.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
- "title": "Color Shapes version 0.8.31, 92cfffbe",
3
+ "title": "Color Shapes version 0.8.32, d289d12c",
4
4
  "type": "object",
5
5
  "description": "All game schemas",
6
6
  "properties": {
@@ -168,6 +168,11 @@
168
168
  ],
169
169
  "default": null,
170
170
  "description": "Optional seed for the seeded pseudo-random number generator. When null, the default Math.random() is used."
171
+ },
172
+ "scoring": {
173
+ "type": "boolean",
174
+ "default": false,
175
+ "description": "Should scoring data be generated? Default is false."
171
176
  }
172
177
  }
173
178
  },
@@ -377,6 +382,118 @@
377
382
  "description": "Was the quit button pressed?"
378
383
  }
379
384
  }
385
+ },
386
+ "ScoringSchema": {
387
+ "type": "object",
388
+ "description": "Scoring data schema",
389
+ "properties": {
390
+ "data_type": {
391
+ "type": "string",
392
+ "description": "Type of data."
393
+ },
394
+ "study_id": {
395
+ "type": [
396
+ "string",
397
+ "null"
398
+ ],
399
+ "description": "The short human-readable text ID of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."
400
+ },
401
+ "study_uuid": {
402
+ "type": [
403
+ "string",
404
+ "null"
405
+ ],
406
+ "format": "uuid",
407
+ "description": "Unique identifier of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."
408
+ },
409
+ "document_uuid": {
410
+ "type": "string",
411
+ "format": "uuid",
412
+ "description": "Unique identifier for this data document."
413
+ },
414
+ "session_uuid": {
415
+ "type": "string",
416
+ "format": "uuid",
417
+ "description": "Unique identifier for all activities in this administration of the session. This identifier changes each time a new session starts."
418
+ },
419
+ "activity_uuid": {
420
+ "type": "string",
421
+ "format": "uuid",
422
+ "description": "Unique identifier for all trials in this administration of the activity. This identifier changes each time the activity starts."
423
+ },
424
+ "activity_id": {
425
+ "type": "string",
426
+ "description": "Human-readable identifier of the activity."
427
+ },
428
+ "activity_publish_uuid": {
429
+ "type": "string",
430
+ "format": "uuid",
431
+ "description": "Persistent unique identifier of the activity. This identifier never changes. It can be used to identify the activity across different studies and sessions."
432
+ },
433
+ "activity_version": {
434
+ "type": "string",
435
+ "description": "Version of the activity."
436
+ },
437
+ "device_timezone": {
438
+ "type": "string",
439
+ "description": "Timezone of the device. Calculated from Intl.DateTimeFormat().resolvedOptions().timeZone."
440
+ },
441
+ "device_timezone_offset_minutes": {
442
+ "type": "integer",
443
+ "description": "Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."
444
+ },
445
+ "locale": {
446
+ "type": [
447
+ "string",
448
+ "null"
449
+ ],
450
+ "description": "Locale of the trial. null if the activity does not support localization."
451
+ },
452
+ "activity_begin_iso8601_timestamp": {
453
+ "type": "string",
454
+ "format": "date-time",
455
+ "description": "ISO 8601 timestamp at the beginning of the game activity."
456
+ },
457
+ "first_trial_begin_iso8601_timestamp": {
458
+ "type": [
459
+ "string",
460
+ "null"
461
+ ],
462
+ "format": "date-time",
463
+ "description": "ISO 8601 timestamp at the beginning of the first trial. Null if no trials were completed."
464
+ },
465
+ "last_trial_end_iso8601_timestamp": {
466
+ "type": [
467
+ "string",
468
+ "null"
469
+ ],
470
+ "format": "date-time",
471
+ "description": "ISO 8601 timestamp at the end of the last trial. Null if no trials were completed."
472
+ },
473
+ "n_trials": {
474
+ "type": "integer",
475
+ "description": "Number of trials completed."
476
+ },
477
+ "flag_trials_match_expected": {
478
+ "type": "integer",
479
+ "description": "Does the number of completed and expected trials match? 1 = true, 0 = false."
480
+ },
481
+ "n_trials_correct": {
482
+ "type": "integer",
483
+ "description": "Number of correct trials."
484
+ },
485
+ "n_trials_incorrect": {
486
+ "type": "integer",
487
+ "description": "Number of incorrect trials."
488
+ },
489
+ "participant_score": {
490
+ "type": [
491
+ "number",
492
+ "null"
493
+ ],
494
+ "description": "Participant-facing score, calculated as (number of correct trials / number of trials attempted) * 100. This is a simple metric to provide feedback to the participant. Null if no trials attempted."
495
+ }
496
+ }
380
497
  }
381
498
  }
382
499
  }