Latin square design with JavaScript
in OSWeb
Hello,
I am attempting to implement a latin-square randomized design, and I have created a quick template in OpenSesame to figure out how it would work. I am referencing a previous post by sebastiaan from 2017 (https://forum.cogsci.nl/discussion/2401/selecting-randomization-lists-in-latin-squared-designs). I have created a template with 4 blocks, as shown in the images below:
When I try to run the experiment, I get the error message "ReferenceError: items is not defined". Any ideas on how I can successfully implement this design using JavaScript instead of Python, so that I may run it online?
Thank you!
Daniel
Comments
** Sorry for the duplicate post **
I solved this problem by using the "slice" command in the block_loop, after creating two variables at the top of the experiment, as so:
vars.slice_top = (vars.subject_nr * 4);
vars.slice_bot = (vars.slice_top + 4);
In the block_loop script, I put:
slice "[slice_top]" "[slice_bot]"
Hello,
I am having trouble implementing this solution in OSWeb, yet on OpenSesame it works flawlessly. I have several blocks of trials, all under the loop "block_loop". The block_loop contains every condition, with a variable called counterbalancing assigned to it. I then calculate which order of blocks the participant will see using the code above in an inline_javascript item.
Again, this works in OpenSesame but not in OSWeb. I initially thought it was a problem of OSWeb not having access to any subject number, since it does not query for one at the beginning of the experiment. So, per @Daniel post here: (https://forum.cogsci.nl/discussion/5930/jatos-how-to-assign-or-collect-participant-number), I left the "Possible subject numbers" field empty, uploaded the experiment to the Cortex test server, but still, the experiment never gets into the loop.
If I place a sketchpad before and after the loop, for instance a welcome and ending screen, those appear sequentially, but the loop is skipped.
Could this be an issue with the "slice" command in the block_loop script? Or any other ideas?
Thank you!
Daniel
Hi @Daniel_513
It seems as if each of your posts in this thread asks a different question, or actually tries to solve a different problem. So to answer a few of your questions in order:
When I try to run the experiment, I get the error message "ReferenceError: items is not defined". Any ideas on how I can successfully implement this design using JavaScript instead of Python, so that I may run it online?
This is hard to tell if we don't know where or how in your experiment
itemsis referred to. Did you compose this experiment purely of OpenSesame items, or did you also use inline_javascript items? If ther former, then this may well be a bug. If the latter, then it helps if you also post the contents of your script here.Could this be an issue with the "slice" command in the block_loop script? Or any other ideas?
This is really hard to tell from the information provided. Given that it works in OpenSesame and not in Osweb usually does indicate a bug in Osweb. Have you tried not encapsulating the slice values in quotes? Thus
becomes
Otherwise you can post your experiment here and I can have a look.
Hello @Daniel,
Sorry for my confusion with my posts. My first post, where I mentioned the ReferenceError, no longer applies, as I took a different approach to solving this problem by using the slice command in the outer block loop script. I will attach below the project I have been working on to test how to accomplish this randomization in OSWeb. The idea is there are four blocks of trials (in this template every block is simply a number being shown on the screen corresponding to which block is being shown [i.e. 1, 2, 3 or 4]), and based on the subject number, the four numbers are displayed in the order determined by the outer block loop. I have created this template to isolate this issue, so that I don't have to deal with actual blocks of trials and so forth.
Thank you very much for your help with this!
Hi @Daniel_513
I think this is indeed a bug in osweb. If I hardcode something like `slice 2 5` the experiment does work in the browser, but if I use variables like you did, it doesn't. I have created an issue for it in osweb's issue tracker: https://github.com/smathot/osweb/issues/18 and we will add a fix for this in the next patch release of osweb. Thanks for reporting it, and apologies for the inconvenience.
Hi @Daniel
Thank you very much for your support with this. I suspected this was the case, as it worked fine in OpenSesame. Would you by chance be able to provide an estimate of when you think the next patch release of osweb will be released? If it would be a matter of weeks, or months, just to have an idea?
Thanks again!
Hi @Daniel_513
Though this should be a relatively easy and quick fix, I cannot make any promises. I am quite swamped with other tasks at the moment, and since this is a project on the side I cannot give it currently much priority. I hopefully will get around to this next week, but I cannot make any promises. If I get it done then you will have to update osweb inside opensesame manually, as there just has been a new 3.3.2 release, and I have no idea when 3.3.3 will be released.
Hi @Daniel
Sorry for my late response. Thank you very much for your help with this!
Hi @Daniel
I was wondering if you've been able to make any headway with fixing this bug. If not then no worries, as I know you've been really busy with other things. Thanks again for your help!
--Daniel
Hi @Daniel_513.
I just issued a fix: https://github.com/smathot/osweb/pull/21. It still needs to be reviewed by @sebastiaan though, so I don't know when a patch release of osweb will happen, but this shouldn't take too long. After this, you should be able to upgrade osweb from inside OpenSesame by following the instructions on: https://osdoc.cogsci.nl/3.3/manual/environment/