# Assignment: Stroop ## Introduction This experiment is an adapted version of the [Stroop demo](https://gitlab.pavlovia.org/demos/stroop) that serves as a JavaScript (JS) debugging exercise. To get started, please go through the three tutorials below. Each tutorial illustrates a different type of JS error, each of which will have your experiment misbehave in different ways: 1. Experiment is stuck on “initialising the experiment...”. See [tutorial_js_syntax_error](https://gitlab.pavlovia.org/tpronk/tutorial_js_syntax_error) 2. PsychoJS shows a dialog with an error message. See the [tutorial_js_semantic_error](https://gitlab.pavlovia.org/tpronk/tutorial_js_semantic_error) 3. PsychoJS shows a dialog with “unknown resource” message. See [tutorial_js_network_error](https://gitlab.pavlovia.org/tpronk/tutorial_js_network_error) Besides that, we've got two tutorials with more debugging and development tricks: 1. To get additional info about what is happening in the code of your experiment, see [tutorial_js_console_log](https://gitlab.pavlovia.org/tpronk/tutorial_js_console_log) 2. To find out how your to expose PsychoJS objects to the web browser, so that you can access them via the browser console, and try things out in order to see what works (or not), see [tutorial_js_expose_psychojs](https://gitlab.pavlovia.org/tpronk/tutorial_js_expose_psychojs). ## Assignments This experiment has three errors, as outlined below. As you find and fix each error, the next one will appear. Once you've fixed all three, the whole experiment will run! ### 1. Syntax error The first routine of the experiment is called `welcome_participant`, which contains a code component called `welcome_code`. Note that "Code Type" of this code component is set to "Both", so any modifications to the Python or JS are done separately from each other; they are not auto-translated. At the "Begin Routine" tab is a bit of JS that aims to set the text of `welcome_text` to "Welcome (participant)", where (participant) is the value entered for participant in the loading dialog box. However, the JS has a syntax error, so the experiment is stuck in "initialising the experiment...". Please find and fix the error. For some guidance on how to achieve this, search online for "JavaScript String concatenation" or see [this page](https://medium.com/javascript-in-plain-english/how-to-append-concatenate-strings-in-javascript-a-few-different-ways-e1d5a97f4503). ## 2. Semantic error The second routine of the experiment is called `announce_session`, which contains a code component called `announce_code`. Note that "Code Type" of this code component is set to "Auto -> JS", so any modifications to the Python are automatically translated to JS. At the "Begin Routine" tab is a bit of JS that aims to set the text of `announce_text` to "This is session: (session)", where (session) is the value entered for session in the loading dialog box. However, the JS has a semantic error, so when you arrive at this routine, you get an error message saying "ReferenceError: session is not defined". Please find and fix the error. For some guidance on how to achieve this, take a peek at how the value for participant was obtained from the loading dialog box. ### 3. Network error The experiment contains a loop called `trials`, which refers to a Conditions file called `trialTypes.xls`. The first trial of this loop goes well, but on the second trial you'll get an error saying "unknown resource". Please find and fix this error.