Piloting error message (variable is not define)

Description of the problem:
When I run my experiment I get back an error.

col is my variable that I simply specified in the “code” component in the builder. That is if ‘l’ is pressed then col = 1, if ‘s’ is pressed then col = 2. It appears when tranfering experiment to online plaform the ‘code’ component from the builder is ignored. Is there any way to avoid such issue? Or does it require manual specification after the experiment is transfered online?
best Yev.

Hi @Yev, would you mind sharing the URL so we can take a look? It may be that you have not translated your Python to JavaScript, or if you have, then there may be an issue with the translation.

Hi.
Of course. https://run.pavlovia.org/Damanskyy/free-choise/html/
Though now I am having another issue with this error. Not sure how to solve it.
When i run it from Pavlovia dashboard it works. But the link introduces this error.

@Yev, the current error is because you are currently piloting your study. Pilot runs can only be done from Pavlovia, because Pavlovia creates a time-limited token in order to run your study - after 1 hour the current token runs out and you have to generate another one by clicking the pilot button. Piloting does not cost any credits, which is why it is time limited instead. The URL above is probably either generated from Builder, or given as your testing URL on Pavlovia. Either way, this is enough for me to take a look at your task.

@Yev, the error is because you have a code component with custom Python code, which for now needs manual translation to JavaScript - in your code component, set your code type to both so you have Python on the left, and JS on the right. JS code is similar to Python, so not too hard to translate. Here is a translation for you, provided by the new PsychoPy autotranslate feature that will be released very soon. Paste this in the relevant tabs:

// Begin Experiment
col = "";

// Begin Routine
if ((free_resp.rt < 0.5)) {
    stimuli2 = "You responded too early. Please, consentrate.";
    col = "white";
} else {
    if ((free_resp.rt > 3)) {
        stimuli2 = "You responded too slowly. Please, consentrate.";
        col = "white";
    } else {
        if ((free_resp.keys === "s")) {
            col = "green";
        }
        if ((free_resp.keys === "l")) {
            col = "red";
        }
    }
}

@dvbridges Thank you for translating that code. I’ll implemented that change and checked, it is also implemented in the main file js file in html folder now. It helped.
It seems now that the conditioning file xlsx is ignored. Do you know what might be the problem? Does it have to be manually specified in js code?

No, the conditions file should be automatically transferred to the HTML > Resources folder in your project. What is happening , that it is being ignored?

In my condition file I have two stimuli ‘x’ and ‘y’ that are specified in ‘text_2’ and ‘feedb’ text components. Those stimuli aren’t displayed during the experiment.

Is anything displayed in place of ‘x’ and ‘y’? If the text from your code is being displayed in place of ‘x’ and ‘y’, then I believe this is because your conditions file variable stimuli2 is being overwritten by your code component.

The strange thing is, when I run it on my pc, it works as it is supposed. But when run it online nothing is displayed isntead of x or y. This variable stimuli2 seems is set to ‘None’ somewhy.

Ok, the reason you are not seeing X or Y is because your feedback variable is the same as your stimulus variable (X or Y), so feedback is overwriting the stimulus variable. You need to change the feedback variable to something different, e.g., fbText.

Also, your text is oversized, change your feedback and other oversized text to .05, or whatever is good for you.

There are some issues with the code, I would use the following instead:

Python

fbText = ''  # Reset feedback variable on each trial
if free_resp.rt < 0.5: 
    fbText = 'You responded too early. Please, consentrate.'
    col = 'white'
elif free_resp.rt > 3: 
    fbText = 'You responded too slowly. Please, consentrate.'
    col = 'white'
else:
    fbText = 'You responded in good time'
        
    if free_resp.keys == 's':
        col = 'green'

    if free_resp.keys == 'l': 
        col = 'red'

JavaScript

fbText = "";  // Reset feedback variable on each trial
if ((free_resp.rt < 0.5)) {
    fbText = "You responded too early. Please, consentrate.";
    col = "white";
} else {
    if ((free_resp.rt > 3)) {
        fbText = "You responded too slowly. Please, consentrate.";
        col = "white";
    } else {
        fbText = "You responded in good time";
        if ((free_resp.keys === "s")) {
            col = "green";
        }
        if ((free_resp.keys === "l")) {
            col = "red";
        }
    }
}

Remember to change the feedback variable in your feedback text component.

@dvbridges Thank you so much for help. Now it works as it should. Now I know how to make it work. Can I ask you one more thing? Running experiments locally we often use the command name.addData(‘block’, ‘practice’) to add some additional variable to output file. Will it work online as well?