psychopy.org | Reference | Downloads | Github

Self-paced reading experiment freezes after instructions

URL of experiment: https://gitlab.pavlovia.org/smithle9/06-04-2020

Sourcecode

Description of the problem: Hello! I am novice having some issues with a mini self-paced reading task I created to see whether PsychoPy has the functionality I need for future projects. The question I have is regarding this part of the experiment:

I added the following Python code into the “Every Frames” window of the code component in the practicetrial Routine.

Screenshot 2020-06-09 10.21.37

Below is the JS:

 // Task- Each Frame (JS)
    var _pj;
    function _pj_snippets(container) {
        function in_es6(left, right) {
            if (((right instanceof Array) || ((typeof right) === "string"))) {
                return (right.indexOf(left) > (- 1));
            } else {
                if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
                    return right.has(left);
                } else {
                    return (left in right);
                }
            }
        }
        container["in_es6"] = in_es6;
        return container;
    }
    _pj = {};
    _pj_snippets(_pj);
    while (continueRoutine) {
        let kb = psychoJS.eventManager.getKeys({"timeStamped": true});
        if ((kb.length > 0)) {
            if (_pj.in_es6("space", kb[0])) {
                try {
                    nextWord = word_list.pop();
                    practicetext.setText(nextWord);
                } catch(e) {
                    if ((e instanceof IndexError)) {
                        continueRoutine = false;
                        rtList.append(kb[0][1]);
                        break;
                    } else {
                        throw e;
                    }
                }
            }

From looking at other topics, it seems like the problem is the While loop, which works when running the experiment through PsychoPy, but not running it online. But, I honestly have no idea.

Again, I’m very much a novice, so any help would be greatly appreciated!

Hi,

Have you come across my crib sheet? You have a .append which will only work if you’ve added the relevant code to my suggested code_JS.

I think you can lose the whole “while continueRoutine” wrapper. Things in Each Frame are automatically executed each frame while the routine is running.

Best wishes,

Wakefield

Hi, thanks for this incredibly useful doc! I’ll work through it and troubleshoot anything else that does not automatically convert and take out the while wrapper, and see if that works. :slight_smile:

1 Like