{"id":273,"date":"2014-04-06T15:59:53","date_gmt":"2014-04-06T15:59:53","guid":{"rendered":"http:\/\/wiki.psychwire.co.uk\/?page_id=273"},"modified":"2014-04-06T18:39:40","modified_gmt":"2014-04-06T18:39:40","slug":"conditional-statements-and-variable-response-accuracy","status":"publish","type":"page","link":"http:\/\/wiki.psychwire.co.uk\/?page_id=273","title":{"rendered":"Conditional Statements and Variable: True\/Correct Response"},"content":{"rendered":"<p>Next, we need to tell Experiment Builder when the answer is correct or incorrect.\u00a0Notice in our\u00a0<em>datasource<\/em>\u00a0we already have a column called \u201cexpected_button\u201d which lets us know which button press is correct for each trial.\u00a0We can use this information to create what is called a \u201cConditional Statement\u201d. Conditionals are common in programming, but they follow the logic of:<\/p>\n<ul>\n<li>IF response is\u00a0<strong>correct<\/strong>\u00a0do something<\/li>\n<li>IF response is\u00a0<strong>incorrect<\/strong>\u00a0do something else<\/li>\n<\/ul>\n<p>In our case, the conditional will appear after the\u00a0<em>KEYBOARD<\/em>\u00a0response but before\u00a0<em>UPDATE_ATTRIBUTE<\/em>. We want to play the error sound only when the response is incorrect.<\/p>\n<p><strong>Conditionals and Feedback<\/strong><\/p>\n<p>To do this, let&#8217;s begin by creating a new variable to record accuracy.\u00a0We do this in the same way we created\u00a0<em>RT<\/em>\u00a0and\u00a0<em>BUTTON_PRESS<\/em>\u00a0earlier:<\/p>\n<ul>\n<li>Create a new variable called RESPONSE_ACCURACY<\/li>\n<li>Set the default value as any number that you won\u2019t use i.e. we will use 0 and 1 for correct and incorrect, so I set the default as 999<\/li>\n<\/ul>\n<p>This process is shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/www.personal.soton.ac.uk\/hg102\/ul\/responseaccuracyvar.gif\" width=\"1125\" height=\"321\" \/><\/p>\n<p>We now need to insert some new actions and triggers. Follow these steps:<\/p>\n<ul>\n<li>Delete the link between\u00a0<em>KEYBOARD<\/em>\u00a0and\u00a0<em>UPDATE_ATTRIBUTE<\/em><\/li>\n<li>Drag a\u00a0<i>CONDITIONAL\u00a0<\/i>Trigger from the<em>\u00a0Trigger<\/em>\u00a0bar<\/li>\n<li>Notice it is shaped like a triangle and the button two points have a cross and a tick<\/li>\n<li>We will give the triangle a conditional statement : this is sketched out below.<\/li>\n<\/ul>\n<p><a href=\"http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/if.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"if\" src=\"http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/if.png\" width=\"842\" height=\"316\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<div>To implement this, first insert a <em>CONDITIONAL<\/em> Trigger from the <em>Trigger<\/em> bar. Then\u00a0Join the <em>KEYBOARD<\/em> response to the top of the triangle as shown below.<\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" alt=\"\" src=\"http:\/\/www.personal.soton.ac.uk\/hg102\/ul\/conditional.gif\" width=\"807\" height=\"667\" \/><\/div>\n<div>\n<div><\/div>\n<div>Click on the new <em>CONDITIONAL<\/em> and look at the <em>Properties<\/em> panel. Instead of what is in there at the moment, we want to say: if the keyboard press is correct, as stated by the column \u201cexpected_button\u201d in the Data Source then the conditions have been met. Or to put it another way,<\/p>\n<p style=\"display: inline !important;\">\u00a0<em>IF\u00a0<\/em><\/p>\n<p><em><span style=\"font-size: 14px; line-height: 1.5em;\">KEYBOARD.TriggeredData.key\u00a0<\/span><\/em><\/p>\n<p style=\"display: inline !important;\"><em>EQUALS\u00a0<\/em><\/p>\n<p><em><span style=\"font-size: 14px; line-height: 1.5em;\">Data Source.expected_button<\/span><\/em><span style=\"font-size: 14px; line-height: 1.5em;\">\u00a0<\/span><em><span style=\"font-size: 14px; line-height: 1.5em;\">THEN [DO SOME ACTIONS].\u00a0<\/span><\/em><span style=\"font-size: 14px; line-height: 1.5em;\">The start of this is shown below.<\/span><\/p>\n<\/div>\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" alt=\"\" src=\"http:\/\/www.personal.soton.ac.uk\/hg102\/ul\/conditional1.gif\" width=\"1001\" height=\"527\" \/><\/p>\n<div>So IF the condition is met and the <em>KEYBOARD<\/em> response is the same as the <em>expected_button<\/em> in the <em>datasource<\/em> then we follow the corner of the <em>CONDITIONAL<\/em> Trigger with the tick on it. Here&#8217;s a diagram showing this:<\/div>\n<div><\/div>\n<div><a href=\"http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/2014-04-06-17_04_34-Developing-Experiments-using-Experiment-Builder-Microsoft-PowerPoint.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-287\" alt=\"2014-04-06 17_04_34-Developing Experiments using Experiment Builder - Microsoft PowerPoint\" src=\"http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/2014-04-06-17_04_34-Developing-Experiments-using-Experiment-Builder-Microsoft-PowerPoint-300x89.png\" width=\"300\" height=\"89\" srcset=\"http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/2014-04-06-17_04_34-Developing-Experiments-using-Experiment-Builder-Microsoft-PowerPoint-300x89.png 300w, http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/2014-04-06-17_04_34-Developing-Experiments-using-Experiment-Builder-Microsoft-PowerPoint.png 549w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/div>\n<div><\/div>\n<p>Next, we need to set up the <em>RESPONSE_ACCURACY<\/em> in <em>UPDATE_ATTRIBUTE.\u00a0<\/em>Here are the steps to follow, with an animation below:<\/p>\n<div>\n<ul>\n<li>Click on <em>UPDATE_ATTRIBUTE<\/em> and in the <em>Properties<\/em> panel click on <em>Attribute-Value List<\/em><\/li>\n<li>Set the <em>Attribute<\/em> as the <em>RESPONSE_ACCURACY<\/em> variable. Remember the <em>Attribute<\/em> is what you want to change<\/li>\n<li>Set the <em>Value<\/em> to 1. Remember the <em>Value<\/em> is what you want the <em>Attribute<\/em> to be changed to. Typically, a value of 0 is used for incorrect and 1 is used for correct, but you can use whatever values you like.<\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" alt=\"\" src=\"http:\/\/www.personal.soton.ac.uk\/hg102\/ul\/updateattirbuteaccuracytrue.gif\" width=\"797\" height=\"559\" \/><\/div>\n<div><\/div>\n<div>Next, join the side of the <em>CONDITIONAL<\/em> with the tick to the <em>UPDATE_ATTRIBUTE<\/em>, as shown below, and then that side is complete!<\/div>\n<div><\/div>\n<div><a href=\"http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/2014-04-06-17_09_06-Developing-Experiments-using-Experiment-Builder-Microsoft-PowerPoint.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-292\" alt=\"2014-04-06 17_09_06-Developing Experiments using Experiment Builder - Microsoft PowerPoint\" src=\"http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/2014-04-06-17_09_06-Developing-Experiments-using-Experiment-Builder-Microsoft-PowerPoint-295x300.png\" width=\"295\" height=\"300\" srcset=\"http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/2014-04-06-17_09_06-Developing-Experiments-using-Experiment-Builder-Microsoft-PowerPoint-295x300.png 295w, http:\/\/wiki.psychwire.co.uk\/wp-content\/uploads\/2014\/04\/2014-04-06-17_09_06-Developing-Experiments-using-Experiment-Builder-Microsoft-PowerPoint.png 348w\" sizes=\"auto, (max-width: 295px) 100vw, 295px\" \/><\/a><\/div>\n<div><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Next, we need to tell Experiment Builder when the answer is correct or incorrect.\u00a0Notice in our\u00a0datasource\u00a0we already have a column called \u201cexpected_button\u201d which lets us know which button press is correct for each trial.\u00a0We can use this information to create what is called a \u201cConditional Statement\u201d. Conditionals are common in programming, but they follow the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":90,"menu_order":1,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-273","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/wiki.psychwire.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wiki.psychwire.co.uk\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/wiki.psychwire.co.uk\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/wiki.psychwire.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/wiki.psychwire.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=273"}],"version-history":[{"count":8,"href":"http:\/\/wiki.psychwire.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/273\/revisions"}],"predecessor-version":[{"id":352,"href":"http:\/\/wiki.psychwire.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/273\/revisions\/352"}],"up":[{"embeddable":true,"href":"http:\/\/wiki.psychwire.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/90"}],"wp:attachment":[{"href":"http:\/\/wiki.psychwire.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}