pushkin-consortium / pushkin

A customizable, scalable ecosystem for massive online psychological experiments
https://pushkin-consortium.github.io/pushkin/
MIT License
24 stars 10 forks source link

Not sure process.env.PUBLIC_URL is still used #236

Closed jkhartshorne closed 10 months ago

jkhartshorne commented 1 year ago

Noticed this when I was reviewing this commit. I think this may be from an older version of create-react-app. Not of the current code seems to use it.

hunterschep commented 1 year ago

I think this page in the react docs is most related to this. According to this, it is still supported in scripts 0.5.0 or higher

They also issue some guidance on the usage of the PUBLIC_URL and folder as opposed to importing things normally

Downsides of using the public folder:

When to use the public folder:

hunterschep commented 11 months ago

See above comment, usage of this feature makes sense for the scope of our project

jessestorbeck commented 11 months ago

I actually found a page in our docs explaining why we use the public folder for image/video stimuli: https://languagelearninglab.gitbook.io/pushkin/advanced/experiment-structure/experiment-web-page-component#assets

Incidentally, I missed updating this page based on https://github.com/pushkin-consortium/pushkin-client/pull/39. Updating it now.

Perhaps though someone ought to check where exactly images used in a jsPsych timeline should go, since these two pages in our docs are actually at odds with respect to where one should put them in their Pushkin site: in the experiment's web page/src/assets folder or the site's pushkin/front-end/public folder

This could probably be added to the list of "easy" tasks we talked about yesterday. @hunterschep or @ayang21, let me know if you want to test this, otherwise I'll do it.

jessestorbeck commented 11 months ago

I've tested this now with images in both experiments/[exp]/web page/src/assets and pushkin/front-end/public. My timeline looks like this:

    const timeline = []

    var trial1 = {
        type: jsPsychImageKeyboardResponse,
        stimulus: process.env.PUBLIC_URL + '/patrick1.svg',
        choices: ['s', 'p'],
        prompt: "<p>Press 's' for Spongebob. Press 'p' for Patrick.</p>",
    }
    timeline.push(trial1);

    var trial2 = {
        type: jsPsychImageKeyboardResponse,
        stimulus: process.env.PUBLIC_URL + '/spongebob1.svg',
        choices: ['s', 'p'],
        prompt: "<p>Press 's' for Spongebob. Press 'p' for Patrick.</p>",
    }
    timeline.push(trial2);

    var trial3 = {
        type: jsPsychImageKeyboardResponse,
        stimulus: process.env.PUBLIC_URL + '/patrick2.svg',
        choices: ['s', 'p'],
        prompt: "<p>Press 's' for Spongebob. Press 'p' for Patrick.</p>",
    }
    timeline.push(trial3);

    var trial4 = {
        type: jsPsychImageKeyboardResponse,
        stimulus: process.env.PUBLIC_URL + '/spongebob2.svg',
        choices: ['s', 'p'],
        prompt: "<p>Press 's' for Spongebob. Press 'p' for Patrick.</p>",
    }
    timeline.push(trial4);

Images in the experiment's assets folder are not available within the jsPsych timeline:

Screen Shot 2023-10-23 at 1 48 14 PM

Images in the site's public folder are available within the jsPsych timeline:

Screen Shot 2023-10-23 at 1 48 41 PM

I guess the good news is we have one way that works for including image/video stimuli in an experiment, although I think requiring image/video stimuli to go in the site's public folder is not ideal for a few reasons:

It might be nice if prep did move files from the experiment's assets folder to the public folder, as this page in the docs currently states.

jkhartshorne commented 11 months ago

It might be nice if prep did move files from the experiment's assets folder to the public folder, as this page in the docs currently states.

I think that's right. But you have to be careful with name spaces. (What happens if two files have the same name?) So I'd try to use subfolders within the public folder.

jessestorbeck commented 10 months ago

Addressed by https://github.com/pushkin-consortium/pushkin-cli/pull/121 d49810d