psychopy.org | Reference | Downloads | Github

Feedback in online experiments issue

URL of experiment: https://pavlovia.org/agleontyev/newest_proj

Description of the problem:

In my experiment, after reading the instructions, participants are supposed to select the difficulty level by clicking on polygons coded as ez, nrm and hrd. This click should define where the cutoff line crossing which will end the trial (e.g. y = 0, so crossing half a screen with a mouse cursor). Moreover, difficulty level is supposed to influence the amount of points awarded for correct performance. In python everything works. In Pavlovia, I cannot set the cutoff line, nor can I make accumulate points.

here is the custom code I am using. On the selection routine (choice_1, end routine):

if mouse_3.clicked_name == ['ez']:
    difflevel = 0.25
    salary_inc = 1
elif mouse_3.clicked_name == ['nrm']:
    difflevel = 0
    salary_inc = 2
elif mouse_3.clicked_name == ['hrd']:
    difflevel = -0.25
    salary_inc = 3

it is automatically translated into:

if ((mouse_3.clicked_name === ["ez"])) {
    difflevel = 0.25;
    salary_inc = 1;
} else {
    if ((mouse_3.clicked_name === ["nrm"])) {
        difflevel = 0;
        salary_inc = 2;
    } else {
        if ((mouse_3.clicked_name === ["hrd"])) {
            difflevel = (- 0.25);
            salary_inc = 3;
        }
    }
}

In the trials loop (end of routine, supposed to pass on to feedback routine):

if vol == 0:
    if mouse.clicked_name != []:
        salary = salary + salary_inc
        msg = 'Correct'+ "\n Your points: " + str(salary) 
    if mouse.clicked_name == []:
        salary = salary - salary_inc
        if salary <0:
            salary = 0
        msg = 'Incorrect. You waited too long to respond' + "\n Your points: " + str(salary) 
if vol == 1:
    if correct_stop == 0:
        salary = salary-salary_inc
        if salary <0:
            salary = 0
        msg = 'Incorrect. It was a stop trial; do not move mouse'+"\n Your points: " + str(salary)
    else:
        salary = salary + salary_inc
        msg = 'Correct'+"\n Your points: " + str(salary)
    

In JS:

if ((vol === 0)) {
    if ((mouse.clicked_name !== [])) {
        salary = (salary + salary_inc);
        msg = (("Correct" + "\n Your points: ") + salary.toString());
    }
    if ((mouse.clicked_name === [])) {
        salary = (salary - salary_inc);
        if ((salary < 0)) {
            salary = 0;
        }
        msg = (("Incorrect. You waited too long to respond" + "\n Your points: ") + salary.toString());
    }
}
if ((vol === 1)) {
    if ((correct_stop === 0)) {
        salary = (salary - salary_inc);
        if ((salary < 0)) {
            salary = 0;
        }
        msg = (("Incorrect. It was a stop trial; do not move mouse" + "\n Your points: ") + salary.toString());
    } else {
        salary = (salary + salary_inc);
        msg = (("Correct" + "\n Your points: ") + salary.toString());
    }
}

1 Like

Hi @agleontyev,

Don’t know if you managed to solve this but I spent 1 day cause I had a similar issue like yours. What did the trick for me was that instead of using == or ===, I used .includes and making some minor changes in the JS code. So in your case would be something like this:

if (mouse_3.clicked_name.includes('ez')){
    difflevel = 0.25
    salary_inc = 1}
else if (mouse_3.clicked_name.includes('nrm')){
    difflevel = 0
    salary_inc = 2}
else if (mouse_3.clicked_name.includes('hrd')){
    difflevel = -0.25
    salary_inc = 3}

Let me know if this helped.