(Balanced) Latin square design with multiple studies

URL of experiment: n/a - general enquiry

I have a series of 4 experiments that I need to combine into 1 session for online delivery. IN the post linked below, @wakecarter and @jon provide a solution for passing participant details from one experiment to the next, and for how to send the participant to the next element of the study after completing one part:

My follow-on question to the above is this:
What is the best way to create a (balanced) latin square design to counterbalance order of tasks between subjects?
My default approach would be to use the 4 different orders as specified by a balanced Latin square, and consequently have 4 different recruitment URLs (with mutual exclusion so that participants can only participate in one), pointing to 4 different elements of the study. But that would require creating 4 different versions of each task on Pavlovia, with the only difference being the parameters in the online tab of the experiment settings box.
That not only sound clunky, but a recipe for disaster.

Is there a better way to do this?

As always, thanks!

I think you need to experiment with redirecting the URL in code based on an order expInfo parameter that gets passed from one experiment to the next.

You could allocate participants to the different orders using my survey tool. https://moryscarter.com/vespr/survey.php

Best wishes,

Wakefield

Thanks so much @wakecarter. I will give both solutions a try!

HI @wakecarter and @jon,

so I tried the following, but get a reference error
ReferenceError: setRedirectUrls is not defined

if ((expInfo["Group"] === 1)) {
    nextExp = "https://run.pavlovia.org/MJB/b";
} else {
    if ((expInfo["Group"] === 2)) {
        nextExp = "https://run.pavlovia.org/MJB/c";
    } else {
        if ((expInfo["Group"] === 3)) {
            nextExp = "http://www.google.com";
        } else {
            if ((expInfo["Group"] === 4)) {
                nextExp = "https://run.pavlovia.org/MJB/d";
            }
        }
    }
}

setRedirectUrls(nextExp, 'www.google.com');

I also tried the last line as

PsychoJS.setRedirectURLs(nextExp, 'www.google.com');

and that gets a different error.

I suspect it is something utterly trivial that I am doing wrong – what is it?

The info I have is

So long as you have URLs set in the experiment options, it may be possible to change them using the following command: PsychoJS.setRedirectUrls(myCompletedURL, myCancelledURL)
CompletedURL / IncompleteURL - #23 by jon

Have you set URLs in the experiment options? What was the error you got the second time?

HI @wakecarter.

SO I figured out one part of the problem:

it is

PsychoJS.setRedirectUrls and not PsychoJS.setRedirectURLs

So now I don’t get an error, but the code still does not work.

I do have URLs set in the experiment options, and when I remove the last line

PsychoJS.setRedirectUrls(nextExp, 'www.google.com');

then the redirect works to the default specified here.
But with that line, the experiment simply ends on a grey screen

@wakecarter, @jon – I have amended the above code so it now includes the html directory but that does not seem to be the problem either.

This still ends up just on a grey screen when the experiment ends

if ((expInfo["Group"] === 1)) {
    nextExp = 'https://run.pavlovia.org/MJB/b/html';
} else {
    if ((expInfo["Group"] === 2)) {
        nextExp = 'https://run.pavlovia.org/MJB/c/html';
    } else {
        if ((expInfo["Group"] === 3)) {
            nextExp = 'http://www.google.com';
        } else {
            if ((expInfo["Group"] === 4)) {
                nextExp = 'https://run.pavlovia.org/MJB/d/html';
            }
        }
    }
}

psychoJS.setRedirectUrls(nextExp, 'www.google.com');

Argh – feeling slightly silly here!
I figured it out. The error was that the expInfo[‘Group’] variable is of course a string so the conditional needs to read

if ((expInfo["Group"] === '1')) {
    nextExp = 'https://run.pavlovia.org/MJB/b/html';
} else {

etc.

i.e. have quotation marks around the ‘1’ etc

2 Likes