joyfulwei / Balloon-task-in-Qualtrics

This is the codes which can be deployed directly in Qualtrics
6 stars 10 forks source link

Javascript #1

Open NChaku opened 5 years ago

NChaku commented 5 years ago

I copy-pasted the javascript code into the qualtrics editor but when I try to save the code and move onto the next step, Qualtrics gives me an error called "Unexpected Token: {". Any reason why?

PsychologyRich commented 5 years ago

I was able to track down the coding errors using https://www.webtoolkitonline.com/javascript-tester.html

I've tried to upload the fixed version. It's stored under "Psychologyrich-patch" under the tab

mchiu91 commented 4 years ago

Have followed all the steps but when I preview, all that appears is the balloon image and "flattened" button images that are not functional. Qualtrics gives me error that my Javascript code is not within the Javascript editor, but I've copy/pasted the code within the Editor as they instruct on their help page. Any guidance would be appreciated - I'm new to Javascript and have been grappling with this issue for some time. https://www.qualtrics.com/support/survey-platform/survey-module/question-options/add-javascript/

mchiu91 commented 4 years ago

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor. https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

PsychologyRich commented 4 years ago

I found some broken lines in the java code for the balloon task. I now have a version that works in qualtrics.

I will email the code to you later.

Best wishes,

Richard

On Wed, 20 Nov 2019, 01:38 mchiu91, notifications@github.com wrote:

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor. https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITZPI2EHL2ZFDK6YELQUSIIBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQMIRA#issuecomment-555795524, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOKIIWFBIRT47HE4XQOSI3QUSIIBANCNFSM4JBSSTBA .

mchiu91 commented 4 years ago

That would be amazing, Richard! Thank you very much

On Wed, Nov 20, 2019 at 1:24 AM PsychologyRich notifications@github.com wrote:

I found some broken lines in the java code for the balloon task. I now have a version that works in qualtrics.

I will email the code to you later.

Best wishes,

Richard

On Wed, 20 Nov 2019, 01:38 mchiu91, notifications@github.com wrote:

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor.

https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITZPI2EHL2ZFDK6YELQUSIIBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQMIRA#issuecomment-555795524 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ANOKIIWFBIRT47HE4XQOSI3QUSIIBANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=AHLPOWNNJDLP6QGWQMUKKUTQUTJZJA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ3VXI#issuecomment-555858653, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHLPOWM7RSZ2CYEWLUFCIVDQUTJZJANCNFSM4JBSSTBA .

PsychologyRich commented 4 years ago

Here is the code:

Qualtrics.SurveyEngine.addOnload(function() { /Place your JavaScript here to run when the page loads/ // standard version of the BART

$(document).ready(function() {

// initialize values var round = 0; var start_size = 150; // start value of widht & height of the image; must correspond to the value that is specified for the #ballon id in style.css var increase = 2; // number of pixels by which balloon is increased each pump var size; // start_size incremented by 'increase' var pumps; var thanks; var maximal_pumps=32; var pumpmeup; // number pumps in a given round; is updated each round var number_pumps = []; // arrays for saving number of pumps var total = 0; // money that has been earned in total var explosion; // will an explosion occur? 1 = yes, 0 = no var last_win = 0; // initialize variable that contains the win of the previous round var present_win = 0; //initialize variable of win in present around var rounds_played = 10; var exploded = []; // array for saving whether ballon has exploded //var explode_array = [15, 9, 16, 26, 22, 8, 27, 17, 23, 29,]; var BurstProb; //Random variable that determines whether balloon burst

// initialize language var label_press = 'Inflate balloon'; var label_collect = 'Collect'; var label_balance = 'Total credit:'; var label_last = 'Win last round:'; var label_currency = ' points'; var label_times=' times'; var label_header = 'Balloon Game Round '; var label_gonext1 = 'Start next round'; var label_gonext2 = 'end game'; var msg_explosion1 = '

The balloon is exploded after puming '; var msg_explosion2 = ' times.

Once inflated burst, you did not make any money this round

'; var label_present_time = 'Pumping times:'; var label_present_value = 'Earn this round:';

var msg_collect1 = '

The balloon did not burst! </ p>

You deserve this round '; var msg_collect2 = ' Points. </ p>

The money earned is safe in the bank.

';

var msg_end1 = '

This completes this part of the study. You are in the balloon game '; var msg_end2 = ' points made profit. </ p>

Click Next </ i> to continue the study. </ p>';

// initialize labels $('#press').html(label_press); $('#collect').html(label_collect); $('#total_term').html(label_balance); $('#total_value').html(total+label_currency); $('#last_term').html(label_last); $('#last_value').html(last_win+label_currency); $('#present_value_term').html(label_present_value); $('#present_times_term').html(label_present_time); $('#present_value').html(present_win+label_currency); $('#present_times').html(pumpmeup+label_times); $('#outcomes').html(number_pumps);

// below: create functions that define game functionality

// what happens when a new round starts var new_round = function() { //console.log(number_pumps); //console.log(exploded); $('#gonext').hide(); $('#message').hide(); $('#collect').show(); $('#press').show(); $('#present_times').show(); $('#present_value').show(); round += 1; size = start_size; pumps = 0; present_win =0; show_present(); show_present_earns(); $('#ballon').width(size); $('#ballon').height(size); $('#ballon').show(); $('#round').html('

'+label_header+round+'

'); $('#present_round').show(); $('#outcomes').hide(); $('#NextButton').hide(); };

// what happens when the game ends var end_game = function() { $('#total').remove(); $('#collect').remove(); $('#ballon').remove(); $('#press').remove(); $('#gonext').remove(); $('#round').remove(); $('#last_round').remove(); $('#goOn').show(); $('#message').html(msg_end1+total+msg_end2).show(); $('#outcomes').show(); $('#NextButton').show(); Qualtrics.SurveyEngine.setEmbeddedData('number_pumps',number_pumps); Qualtrics.SurveyEngine.setEmbeddedData('exploded',exploded); Qualtrics.SurveyEngine.setEmbeddedData('total_win',total);

};

// message shown if balloon explodes var explosion_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_explosion1+pumpmeup+msg_explosion2).show(); };

// message shown if balloon does not explode var collected_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_collect1+present_win+msg_collect2).show(); };

// animate explosion using $ UI explosion var balloon_explode = function() { $('#ballon').hide( "explode", {pieces: 100}, 800 ); document.getElementById('explosion_sound').play(); };

// show button that starts next round var gonext_message = function() { $('#ballon').hide(); if (round < rounds_played) { $('#gonext').html(label_gonext1).show(); } else { $('#gonext').html(label_gonext2).show(); } };

// add money to bank var increase_value = function() { $('#total_value').html(total+label_currency); };

var show_last = function() { $('#last_value').html(last_win+label_currency); }; var show_present=function(){ $('#present_times').html(pumps+label_times) } var show_present_earns=function(){ $('#present_value').html(present_win+label_currency) } var show_array=function(){ $('#pump_array').html(number_pumps) }

// button functionalities

// pump button functionality -> 'pressure' in slider bar increases $('#press').click(function() { BurstProb = Math.random(); //generate random number between 0 and 1 if (pumps >= 0 && pumps < maximal_pumps) { // interacts with the collect function, which sets pumps to -1, making the button temporarily unclickable explosion = 0; // is set to one if pumping goes beyond explosion point; see below pumps += 1; present_win +=0.25; //Burst probabilty is 1 / (maximal_pumps-pumps+1) as in Read et al. in 2002, so probability to burst increase with number of pumps, pumping becomes more risky //Because BurstProb is random number between 0 and 1, the propbability that BurstProb > 1/(maximal_pumps-pumps+1) is equal to 1 - 1/(maximal_pumps-pumps+1) //and the probability that BurstProb < 1/(maximal_pumps-pumps+1) is equal to 1/(maximal_pumps-pumps+1) //In other words, the ballon will burst with probability 1/(maximal_pumps-pumps+1), and will not burst with probability 1-1/(maximal_pumps-pumps+1) if (BurstProb > 1/(maximal_pumps-pumps+1)) { size +=increase; $('#ballon').width(size); $('#ballon').height(size); show_present(); show_present_earns(); } else { last_win = 0; pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts explosion = 1; // save that balloon has exploded this round balloon_explode(); exploded.push(explosion); // save whether balloon has exploded or not number_pumps.push(pumpmeup); // save number of pumps $('#ballon').hide(); $('#present_round').hide(); setTimeout(explosion_message, 1200); setTimeout(gonext_message, 1200); setTimeout(show_last, 1200); } } });

// collect button: release pressure and hope for money $('#collect').click(function() { if (pumps === 0) { alert('you can only collect the money once you click "给气球充气”。'); } else if (pumps > 0) { // only works after at least one pump has been made exploded.push(explosion); // save whether balloon has exploded or not document.getElementById('tada_sound').play(); number_pumps.push(pumps); // save number of pumps pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts $('#ballon').hide(); $('#present_round').hide(); collected_message(); gonext_message(); total += present_win; last_win = present_win; increase_value(); show_last(); } });

// click this button to start the next round (or end game when all rounds are played) $('#gonext').click(function() { if (round < rounds_played) { new_round(); } else { end_game(); } });

// start the game! new_round();

});

});

Qualtrics.SurveyEngine.addOnReady(function() { /Place your JavaScript here to run when the page is fully displayed/

});

Qualtrics.SurveyEngine.addOnUnload(function() { /Place your JavaScript here to run when the page is unloaded/

});

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 07:25, mchiu91 notifications@github.com wrote:

That would be amazing, Richard! Thank you very much

On Wed, Nov 20, 2019 at 1:24 AM PsychologyRich notifications@github.com wrote:

I found some broken lines in the java code for the balloon task. I now have a version that works in qualtrics.

I will email the code to you later.

Best wishes,

Richard

On Wed, 20 Nov 2019, 01:38 mchiu91, notifications@github.com wrote:

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor.

https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITZPI2EHL2ZFDK6YELQUSIIBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQMIRA#issuecomment-555795524

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ANOKIIWFBIRT47HE4XQOSI3QUSIIBANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=AHLPOWNNJDLP6QGWQMUKKUTQUTJZJA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ3VXI#issuecomment-555858653 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AHLPOWM7RSZ2CYEWLUFCIVDQUTJZJANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW2LPNWSLWKSX3Z7ZTQUTQ7RA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ7SXY#issuecomment-555874655, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOKIIVDZRDDCUDTLGUYFSDQUTQ7RANCNFSM4JBSSTBA .

PsychologyRich commented 4 years ago

If this doesn't work I will share the working version with you in Qualtrics.

Best,

Richard

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 07:25, mchiu91 notifications@github.com wrote:

That would be amazing, Richard! Thank you very much

On Wed, Nov 20, 2019 at 1:24 AM PsychologyRich notifications@github.com wrote:

I found some broken lines in the java code for the balloon task. I now have a version that works in qualtrics.

I will email the code to you later.

Best wishes,

Richard

On Wed, 20 Nov 2019, 01:38 mchiu91, notifications@github.com wrote:

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor.

https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITZPI2EHL2ZFDK6YELQUSIIBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQMIRA#issuecomment-555795524

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ANOKIIWFBIRT47HE4XQOSI3QUSIIBANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=AHLPOWNNJDLP6QGWQMUKKUTQUTJZJA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ3VXI#issuecomment-555858653 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AHLPOWM7RSZ2CYEWLUFCIVDQUTJZJANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW2LPNWSLWKSX3Z7ZTQUTQ7RA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ7SXY#issuecomment-555874655, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOKIIVDZRDDCUDTLGUYFSDQUTQ7RANCNFSM4JBSSTBA .

mchiu91 commented 4 years ago

Thank you!! Just to clarify, this code was pasted directly into the Javascript editor on the Qualtrics question with the html text?

Sent from my iPhone

On Nov 20, 2019, at 4:08 AM, PsychologyRich notifications@github.com wrote:

Here is the code:

Qualtrics.SurveyEngine.addOnload(function() { /Place your JavaScript here to run when the page loads/ // standard version of the BART

$(document).ready(function() {

// initialize values var round = 0; var start_size = 150; // start value of widht & height of the image; must correspond to the value that is specified for the #ballon id in style.css var increase = 2; // number of pixels by which balloon is increased each pump var size; // start_size incremented by 'increase' var pumps; var thanks; var maximal_pumps=32; var pumpmeup; // number pumps in a given round; is updated each round var number_pumps = []; // arrays for saving number of pumps var total = 0; // money that has been earned in total var explosion; // will an explosion occur? 1 = yes, 0 = no var last_win = 0; // initialize variable that contains the win of the previous round var present_win = 0; //initialize variable of win in present around var rounds_played = 10; var exploded = []; // array for saving whether ballon has exploded //var explode_array = [15, 9, 16, 26, 22, 8, 27, 17, 23, 29,]; var BurstProb; //Random variable that determines whether balloon burst

// initialize language var label_press = 'Inflate balloon'; var label_collect = 'Collect'; var label_balance = 'Total credit:'; var label_last = 'Win last round:'; var label_currency = ' points'; var label_times=' times'; var label_header = 'Balloon Game Round '; var label_gonext1 = 'Start next round'; var label_gonext2 = 'end game'; var msg_explosion1 = '

The balloon is exploded after puming '; var msg_explosion2 = ' times.

Once inflated burst, you did not make any money this round

'; var label_present_time = 'Pumping times:'; var label_present_value = 'Earn this round:';

var msg_collect1 = '

The balloon did not burst! </ p>

You deserve this round '; var msg_collect2 = ' Points. </ p>

The money earned is safe in the bank.

';

var msg_end1 = '

This completes this part of the study. You are in the balloon game '; var msg_end2 = ' points made profit. </ p>

Click Next </ i> to continue the study. </ p>';

// initialize labels $('#press').html(label_press); $('#collect').html(label_collect); $('#total_term').html(label_balance); $('#total_value').html(total+label_currency); $('#last_term').html(label_last); $('#last_value').html(last_win+label_currency); $('#present_value_term').html(label_present_value); $('#present_times_term').html(label_present_time); $('#present_value').html(present_win+label_currency); $('#present_times').html(pumpmeup+label_times); $('#outcomes').html(number_pumps);

// below: create functions that define game functionality

// what happens when a new round starts var new_round = function() { //console.log(number_pumps); //console.log(exploded); $('#gonext').hide(); $('#message').hide(); $('#collect').show(); $('#press').show(); $('#present_times').show(); $('#present_value').show(); round += 1; size = start_size; pumps = 0; present_win =0; show_present(); show_present_earns(); $('#ballon').width(size); $('#ballon').height(size); $('#ballon').show(); $('#round').html('

'+label_header+round+'

'); $('#present_round').show(); $('#outcomes').hide(); $('#NextButton').hide(); };

// what happens when the game ends var end_game = function() { $('#total').remove(); $('#collect').remove(); $('#ballon').remove(); $('#press').remove(); $('#gonext').remove(); $('#round').remove(); $('#last_round').remove(); $('#goOn').show(); $('#message').html(msg_end1+total+msg_end2).show(); $('#outcomes').show(); $('#NextButton').show(); Qualtrics.SurveyEngine.setEmbeddedData('number_pumps',number_pumps); Qualtrics.SurveyEngine.setEmbeddedData('exploded',exploded); Qualtrics.SurveyEngine.setEmbeddedData('total_win',total);

};

// message shown if balloon explodes var explosion_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_explosion1+pumpmeup+msg_explosion2).show(); };

// message shown if balloon does not explode var collected_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_collect1+present_win+msg_collect2).show(); };

// animate explosion using $ UI explosion var balloon_explode = function() { $('#ballon').hide( "explode", {pieces: 100}, 800 ); document.getElementById('explosion_sound').play(); };

// show button that starts next round var gonext_message = function() { $('#ballon').hide(); if (round < rounds_played) { $('#gonext').html(label_gonext1).show(); } else { $('#gonext').html(label_gonext2).show(); } };

// add money to bank var increase_value = function() { $('#total_value').html(total+label_currency); };

var show_last = function() { $('#last_value').html(last_win+label_currency); }; var show_present=function(){ $('#present_times').html(pumps+label_times) } var show_present_earns=function(){ $('#present_value').html(present_win+label_currency) } var show_array=function(){ $('#pump_array').html(number_pumps) }

// button functionalities

// pump button functionality -> 'pressure' in slider bar increases $('#press').click(function() { BurstProb = Math.random(); //generate random number between 0 and 1 if (pumps >= 0 && pumps < maximal_pumps) { // interacts with the collect function, which sets pumps to -1, making the button temporarily unclickable explosion = 0; // is set to one if pumping goes beyond explosion point; see below pumps += 1; present_win +=0.25; //Burst probabilty is 1 / (maximal_pumps-pumps+1) as in Read et al. in 2002, so probability to burst increase with number of pumps, pumping becomes more risky //Because BurstProb is random number between 0 and 1, the propbability that BurstProb > 1/(maximal_pumps-pumps+1) is equal to 1 - 1/(maximal_pumps-pumps+1) //and the probability that BurstProb < 1/(maximal_pumps-pumps+1) is equal to 1/(maximal_pumps-pumps+1) //In other words, the ballon will burst with probability 1/(maximal_pumps-pumps+1), and will not burst with probability 1-1/(maximal_pumps-pumps+1) if (BurstProb > 1/(maximal_pumps-pumps+1)) { size +=increase; $('#ballon').width(size); $('#ballon').height(size); show_present(); show_present_earns(); } else { last_win = 0; pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts explosion = 1; // save that balloon has exploded this round balloon_explode(); exploded.push(explosion); // save whether balloon has exploded or not number_pumps.push(pumpmeup); // save number of pumps $('#ballon').hide(); $('#present_round').hide(); setTimeout(explosion_message, 1200); setTimeout(gonext_message, 1200); setTimeout(show_last, 1200); } } });

// collect button: release pressure and hope for money $('#collect').click(function() { if (pumps === 0) { alert('you can only collect the money once you click "给气球充气”。'); } else if (pumps > 0) { // only works after at least one pump has been made exploded.push(explosion); // save whether balloon has exploded or not document.getElementById('tada_sound').play(); number_pumps.push(pumps); // save number of pumps pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts $('#ballon').hide(); $('#present_round').hide(); collected_message(); gonext_message(); total += present_win; last_win = present_win; increase_value(); show_last(); } });

// click this button to start the next round (or end game when all rounds are played) $('#gonext').click(function() { if (round < rounds_played) { new_round(); } else { end_game(); } });

// start the game! new_round();

});

});

Qualtrics.SurveyEngine.addOnReady(function() { /Place your JavaScript here to run when the page is fully displayed/

});

Qualtrics.SurveyEngine.addOnUnload(function() { /Place your JavaScript here to run when the page is unloaded/

});

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 07:25, mchiu91 notifications@github.com wrote:

That would be amazing, Richard! Thank you very much

On Wed, Nov 20, 2019 at 1:24 AM PsychologyRich notifications@github.com wrote:

I found some broken lines in the java code for the balloon task. I now have a version that works in qualtrics.

I will email the code to you later.

Best wishes,

Richard

On Wed, 20 Nov 2019, 01:38 mchiu91, notifications@github.com wrote:

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor.

https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITZPI2EHL2ZFDK6YELQUSIIBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQMIRA#issuecomment-555795524

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ANOKIIWFBIRT47HE4XQOSI3QUSIIBANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=AHLPOWNNJDLP6QGWQMUKKUTQUTJZJA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ3VXI#issuecomment-555858653 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AHLPOWM7RSZ2CYEWLUFCIVDQUTJZJANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW2LPNWSLWKSX3Z7ZTQUTQ7RA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ7SXY#issuecomment-555874655, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOKIIVDZRDDCUDTLGUYFSDQUTQ7RANCNFSM4JBSSTBA .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

PsychologyRich commented 4 years ago

Yes that's right

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 13:10, mchiu91 notifications@github.com wrote:

Thank you!! Just to clarify, this code was pasted directly into the Javascript editor on the Qualtrics question with the html text?

Sent from my iPhone

On Nov 20, 2019, at 4:08 AM, PsychologyRich notifications@github.com wrote:

Here is the code:

Qualtrics.SurveyEngine.addOnload(function() { /Place your JavaScript here to run when the page loads/ // standard version of the BART

$(document).ready(function() {

// initialize values var round = 0; var start_size = 150; // start value of widht & height of the image; must correspond to the value that is specified for the #ballon id in style.css var increase = 2; // number of pixels by which balloon is increased each pump var size; // start_size incremented by 'increase' var pumps; var thanks; var maximal_pumps=32; var pumpmeup; // number pumps in a given round; is updated each round var number_pumps = []; // arrays for saving number of pumps var total = 0; // money that has been earned in total var explosion; // will an explosion occur? 1 = yes, 0 = no var last_win = 0; // initialize variable that contains the win of the previous round var present_win = 0; //initialize variable of win in present around var rounds_played = 10; var exploded = []; // array for saving whether ballon has exploded //var explode_array = [15, 9, 16, 26, 22, 8, 27, 17, 23, 29,]; var BurstProb; //Random variable that determines whether balloon burst

// initialize language var label_press = 'Inflate balloon'; var label_collect = 'Collect'; var label_balance = 'Total credit:'; var label_last = 'Win last round:'; var label_currency = ' points'; var label_times=' times'; var label_header = 'Balloon Game Round '; var label_gonext1 = 'Start next round'; var label_gonext2 = 'end game'; var msg_explosion1 = '

The balloon is exploded after puming '; var msg_explosion2 = ' times.

Once inflated burst, you did not make any money this round

'; var label_present_time = 'Pumping times:'; var label_present_value = 'Earn this round:';

var msg_collect1 = '

The balloon did not burst! </ p>

You deserve this round '; var msg_collect2 = ' Points. </ p>

The money earned is safe in the bank.

';

var msg_end1 = '

This completes this part of the study. You are in the balloon game '; var msg_end2 = ' points made profit. </ p>

Click Next </ i> to continue the study. </ p>';

// initialize labels $('#press').html(label_press); $('#collect').html(label_collect); $('#total_term').html(label_balance); $('#total_value').html(total+label_currency); $('#last_term').html(label_last); $('#last_value').html(last_win+label_currency); $('#present_value_term').html(label_present_value); $('#present_times_term').html(label_present_time); $('#present_value').html(present_win+label_currency); $('#present_times').html(pumpmeup+label_times); $('#outcomes').html(number_pumps);

// below: create functions that define game functionality

// what happens when a new round starts var new_round = function() { //console.log(number_pumps); //console.log(exploded); $('#gonext').hide(); $('#message').hide(); $('#collect').show(); $('#press').show(); $('#present_times').show(); $('#present_value').show(); round += 1; size = start_size; pumps = 0; present_win =0; show_present(); show_present_earns(); $('#ballon').width(size); $('#ballon').height(size); $('#ballon').show(); $('#round').html('

'+label_header+round+'

'); $('#present_round').show(); $('#outcomes').hide(); $('#NextButton').hide(); };

// what happens when the game ends var end_game = function() { $('#total').remove(); $('#collect').remove(); $('#ballon').remove(); $('#press').remove(); $('#gonext').remove(); $('#round').remove(); $('#last_round').remove(); $('#goOn').show(); $('#message').html(msg_end1+total+msg_end2).show(); $('#outcomes').show(); $('#NextButton').show(); Qualtrics.SurveyEngine.setEmbeddedData('number_pumps',number_pumps); Qualtrics.SurveyEngine.setEmbeddedData('exploded',exploded); Qualtrics.SurveyEngine.setEmbeddedData('total_win',total);

};

// message shown if balloon explodes var explosion_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_explosion1+pumpmeup+msg_explosion2).show(); };

// message shown if balloon does not explode var collected_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_collect1+present_win+msg_collect2).show(); };

// animate explosion using $ UI explosion var balloon_explode = function() { $('#ballon').hide( "explode", {pieces: 100}, 800 ); document.getElementById('explosion_sound').play(); };

// show button that starts next round var gonext_message = function() { $('#ballon').hide(); if (round < rounds_played) { $('#gonext').html(label_gonext1).show(); } else { $('#gonext').html(label_gonext2).show(); } };

// add money to bank var increase_value = function() { $('#total_value').html(total+label_currency); };

var show_last = function() { $('#last_value').html(last_win+label_currency); }; var show_present=function(){ $('#present_times').html(pumps+label_times) } var show_present_earns=function(){ $('#present_value').html(present_win+label_currency) } var show_array=function(){ $('#pump_array').html(number_pumps) }

// button functionalities

// pump button functionality -> 'pressure' in slider bar increases $('#press').click(function() { BurstProb = Math.random(); //generate random number between 0 and 1 if (pumps >= 0 && pumps < maximal_pumps) { // interacts with the collect function, which sets pumps to -1, making the button temporarily unclickable explosion = 0; // is set to one if pumping goes beyond explosion point; see below pumps += 1; present_win +=0.25; //Burst probabilty is 1 / (maximal_pumps-pumps+1) as in Read et al. in 2002, so probability to burst increase with number of pumps, pumping becomes more risky //Because BurstProb is random number between 0 and 1, the propbability that BurstProb > 1/(maximal_pumps-pumps+1) is equal to 1 - 1/(maximal_pumps-pumps+1) //and the probability that BurstProb < 1/(maximal_pumps-pumps+1) is equal to 1/(maximal_pumps-pumps+1) //In other words, the ballon will burst with probability 1/(maximal_pumps-pumps+1), and will not burst with probability 1-1/(maximal_pumps-pumps+1) if (BurstProb > 1/(maximal_pumps-pumps+1)) { size +=increase; $('#ballon').width(size); $('#ballon').height(size); show_present(); show_present_earns(); } else { last_win = 0; pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts explosion = 1; // save that balloon has exploded this round balloon_explode(); exploded.push(explosion); // save whether balloon has exploded or not number_pumps.push(pumpmeup); // save number of pumps $('#ballon').hide(); $('#present_round').hide(); setTimeout(explosion_message, 1200); setTimeout(gonext_message, 1200); setTimeout(show_last, 1200); } } });

// collect button: release pressure and hope for money $('#collect').click(function() { if (pumps === 0) { alert('you can only collect the money once you click "给气球充气”。'); } else if (pumps > 0) { // only works after at least one pump has been made exploded.push(explosion); // save whether balloon has exploded or not document.getElementById('tada_sound').play(); number_pumps.push(pumps); // save number of pumps pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts $('#ballon').hide(); $('#present_round').hide(); collected_message(); gonext_message(); total += present_win; last_win = present_win; increase_value(); show_last(); } });

// click this button to start the next round (or end game when all rounds are played) $('#gonext').click(function() { if (round < rounds_played) { new_round(); } else { end_game(); } });

// start the game! new_round();

});

});

Qualtrics.SurveyEngine.addOnReady(function() { /Place your JavaScript here to run when the page is fully displayed/

});

Qualtrics.SurveyEngine.addOnUnload(function() { /Place your JavaScript here to run when the page is unloaded/

});

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 07:25, mchiu91 notifications@github.com wrote:

That would be amazing, Richard! Thank you very much

On Wed, Nov 20, 2019 at 1:24 AM PsychologyRich < notifications@github.com> wrote:

I found some broken lines in the java code for the balloon task. I now have a version that works in qualtrics.

I will email the code to you later.

Best wishes,

Richard

On Wed, 20 Nov 2019, 01:38 mchiu91, notifications@github.com wrote:

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor.

https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITZPI2EHL2ZFDK6YELQUSIIBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQMIRA#issuecomment-555795524

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ANOKIIWFBIRT47HE4XQOSI3QUSIIBANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=AHLPOWNNJDLP6QGWQMUKKUTQUTJZJA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ3VXI#issuecomment-555858653

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AHLPOWM7RSZ2CYEWLUFCIVDQUTJZJANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW2LPNWSLWKSX3Z7ZTQUTQ7RA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ7SXY#issuecomment-555874655 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ANOKIIVDZRDDCUDTLGUYFSDQUTQ7RANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW4HFSXHAPRMW3KSP3QUUZNXA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEER5N4I#issuecomment-555996913, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOKIIWCGZBFXTIGRAOMIHTQUUZNXANCNFSM4JBSSTBA .

mchiu91 commented 4 years ago

Unfortunately I still get the same error message that Javascript code should be in Javascript Editor. Would you happen to know why that might be?

Sent from my iPhone

On Nov 20, 2019, at 8:14 AM, PsychologyRich notifications@github.com wrote:

Yes that's right

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 13:10, mchiu91 notifications@github.com wrote:

Thank you!! Just to clarify, this code was pasted directly into the Javascript editor on the Qualtrics question with the html text?

Sent from my iPhone

On Nov 20, 2019, at 4:08 AM, PsychologyRich notifications@github.com wrote:

Here is the code:

Qualtrics.SurveyEngine.addOnload(function() { /Place your JavaScript here to run when the page loads/ // standard version of the BART

$(document).ready(function() {

// initialize values var round = 0; var start_size = 150; // start value of widht & height of the image; must correspond to the value that is specified for the #ballon id in style.css var increase = 2; // number of pixels by which balloon is increased each pump var size; // start_size incremented by 'increase' var pumps; var thanks; var maximal_pumps=32; var pumpmeup; // number pumps in a given round; is updated each round var number_pumps = []; // arrays for saving number of pumps var total = 0; // money that has been earned in total var explosion; // will an explosion occur? 1 = yes, 0 = no var last_win = 0; // initialize variable that contains the win of the previous round var present_win = 0; //initialize variable of win in present around var rounds_played = 10; var exploded = []; // array for saving whether ballon has exploded //var explode_array = [15, 9, 16, 26, 22, 8, 27, 17, 23, 29,]; var BurstProb; //Random variable that determines whether balloon burst

// initialize language var label_press = 'Inflate balloon'; var label_collect = 'Collect'; var label_balance = 'Total credit:'; var label_last = 'Win last round:'; var label_currency = ' points'; var label_times=' times'; var label_header = 'Balloon Game Round '; var label_gonext1 = 'Start next round'; var label_gonext2 = 'end game'; var msg_explosion1 = '

The balloon is exploded after puming '; var msg_explosion2 = ' times.

Once inflated burst, you did not make any money this round

'; var label_present_time = 'Pumping times:'; var label_present_value = 'Earn this round:';

var msg_collect1 = '

The balloon did not burst! </ p>

You deserve this round '; var msg_collect2 = ' Points. </ p>

The money earned is safe in the bank.

';

var msg_end1 = '

This completes this part of the study. You are in the balloon game '; var msg_end2 = ' points made profit. </ p>

Click Next </ i> to continue the study. </ p>';

// initialize labels $('#press').html(label_press); $('#collect').html(label_collect); $('#total_term').html(label_balance); $('#total_value').html(total+label_currency); $('#last_term').html(label_last); $('#last_value').html(last_win+label_currency); $('#present_value_term').html(label_present_value); $('#present_times_term').html(label_present_time); $('#present_value').html(present_win+label_currency); $('#present_times').html(pumpmeup+label_times); $('#outcomes').html(number_pumps);

// below: create functions that define game functionality

// what happens when a new round starts var new_round = function() { //console.log(number_pumps); //console.log(exploded); $('#gonext').hide(); $('#message').hide(); $('#collect').show(); $('#press').show(); $('#present_times').show(); $('#present_value').show(); round += 1; size = start_size; pumps = 0; present_win =0; show_present(); show_present_earns(); $('#ballon').width(size); $('#ballon').height(size); $('#ballon').show(); $('#round').html('

'+label_header+round+'

'); $('#present_round').show(); $('#outcomes').hide(); $('#NextButton').hide(); };

// what happens when the game ends var end_game = function() { $('#total').remove(); $('#collect').remove(); $('#ballon').remove(); $('#press').remove(); $('#gonext').remove(); $('#round').remove(); $('#last_round').remove(); $('#goOn').show(); $('#message').html(msg_end1+total+msg_end2).show(); $('#outcomes').show(); $('#NextButton').show(); Qualtrics.SurveyEngine.setEmbeddedData('number_pumps',number_pumps); Qualtrics.SurveyEngine.setEmbeddedData('exploded',exploded); Qualtrics.SurveyEngine.setEmbeddedData('total_win',total);

};

// message shown if balloon explodes var explosion_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_explosion1+pumpmeup+msg_explosion2).show(); };

// message shown if balloon does not explode var collected_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_collect1+present_win+msg_collect2).show(); };

// animate explosion using $ UI explosion var balloon_explode = function() { $('#ballon').hide( "explode", {pieces: 100}, 800 ); document.getElementById('explosion_sound').play(); };

// show button that starts next round var gonext_message = function() { $('#ballon').hide(); if (round < rounds_played) { $('#gonext').html(label_gonext1).show(); } else { $('#gonext').html(label_gonext2).show(); } };

// add money to bank var increase_value = function() { $('#total_value').html(total+label_currency); };

var show_last = function() { $('#last_value').html(last_win+label_currency); }; var show_present=function(){ $('#present_times').html(pumps+label_times) } var show_present_earns=function(){ $('#present_value').html(present_win+label_currency) } var show_array=function(){ $('#pump_array').html(number_pumps) }

// button functionalities

// pump button functionality -> 'pressure' in slider bar increases $('#press').click(function() { BurstProb = Math.random(); //generate random number between 0 and 1 if (pumps >= 0 && pumps < maximal_pumps) { // interacts with the collect function, which sets pumps to -1, making the button temporarily unclickable explosion = 0; // is set to one if pumping goes beyond explosion point; see below pumps += 1; present_win +=0.25; //Burst probabilty is 1 / (maximal_pumps-pumps+1) as in Read et al. in 2002, so probability to burst increase with number of pumps, pumping becomes more risky //Because BurstProb is random number between 0 and 1, the propbability that BurstProb > 1/(maximal_pumps-pumps+1) is equal to 1 - 1/(maximal_pumps-pumps+1) //and the probability that BurstProb < 1/(maximal_pumps-pumps+1) is equal to 1/(maximal_pumps-pumps+1) //In other words, the ballon will burst with probability 1/(maximal_pumps-pumps+1), and will not burst with probability 1-1/(maximal_pumps-pumps+1) if (BurstProb > 1/(maximal_pumps-pumps+1)) { size +=increase; $('#ballon').width(size); $('#ballon').height(size); show_present(); show_present_earns(); } else { last_win = 0; pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts explosion = 1; // save that balloon has exploded this round balloon_explode(); exploded.push(explosion); // save whether balloon has exploded or not number_pumps.push(pumpmeup); // save number of pumps $('#ballon').hide(); $('#present_round').hide(); setTimeout(explosion_message, 1200); setTimeout(gonext_message, 1200); setTimeout(show_last, 1200); } } });

// collect button: release pressure and hope for money $('#collect').click(function() { if (pumps === 0) { alert('you can only collect the money once you click "给气球充气”。'); } else if (pumps > 0) { // only works after at least one pump has been made exploded.push(explosion); // save whether balloon has exploded or not document.getElementById('tada_sound').play(); number_pumps.push(pumps); // save number of pumps pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts $('#ballon').hide(); $('#present_round').hide(); collected_message(); gonext_message(); total += present_win; last_win = present_win; increase_value(); show_last(); } });

// click this button to start the next round (or end game when all rounds are played) $('#gonext').click(function() { if (round < rounds_played) { new_round(); } else { end_game(); } });

// start the game! new_round();

});

});

Qualtrics.SurveyEngine.addOnReady(function() { /Place your JavaScript here to run when the page is fully displayed/

});

Qualtrics.SurveyEngine.addOnUnload(function() { /Place your JavaScript here to run when the page is unloaded/

});

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 07:25, mchiu91 notifications@github.com wrote:

That would be amazing, Richard! Thank you very much

On Wed, Nov 20, 2019 at 1:24 AM PsychologyRich < notifications@github.com> wrote:

I found some broken lines in the java code for the balloon task. I now have a version that works in qualtrics.

I will email the code to you later.

Best wishes,

Richard

On Wed, 20 Nov 2019, 01:38 mchiu91, notifications@github.com wrote:

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor.

https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITZPI2EHL2ZFDK6YELQUSIIBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQMIRA#issuecomment-555795524

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ANOKIIWFBIRT47HE4XQOSI3QUSIIBANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=AHLPOWNNJDLP6QGWQMUKKUTQUTJZJA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ3VXI#issuecomment-555858653

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AHLPOWM7RSZ2CYEWLUFCIVDQUTJZJANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW2LPNWSLWKSX3Z7ZTQUTQ7RA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ7SXY#issuecomment-555874655 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ANOKIIVDZRDDCUDTLGUYFSDQUTQ7RANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW4HFSXHAPRMW3KSP3QUUZNXA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEER5N4I#issuecomment-555996913, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOKIIWCGZBFXTIGRAOMIHTQUUZNXANCNFSM4JBSSTBA .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

PsychologyRich commented 4 years ago

Hi

Can I suggest you send me your qualtrics user name (pls email direct to r.stephens@keele.ac.uk) and I will send you, within qualtrics, a copy of the functioning survey containing this version of the BART.

Best wishes,

Richard

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 23:44, mchiu91 notifications@github.com wrote:

Unfortunately I still get the same error message that Javascript code should be in Javascript Editor. Would you happen to know why that might be?

Sent from my iPhone

On Nov 20, 2019, at 8:14 AM, PsychologyRich notifications@github.com wrote:

Yes that's right

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 13:10, mchiu91 notifications@github.com wrote:

Thank you!! Just to clarify, this code was pasted directly into the Javascript editor on the Qualtrics question with the html text?

Sent from my iPhone

On Nov 20, 2019, at 4:08 AM, PsychologyRich < notifications@github.com> wrote:

Here is the code:

Qualtrics.SurveyEngine.addOnload(function() { /Place your JavaScript here to run when the page loads/ // standard version of the BART

$(document).ready(function() {

// initialize values var round = 0; var start_size = 150; // start value of widht & height of the image; must correspond to the value that is specified for the #ballon id in style.css var increase = 2; // number of pixels by which balloon is increased each pump var size; // start_size incremented by 'increase' var pumps; var thanks; var maximal_pumps=32; var pumpmeup; // number pumps in a given round; is updated each round var number_pumps = []; // arrays for saving number of pumps var total = 0; // money that has been earned in total var explosion; // will an explosion occur? 1 = yes, 0 = no var last_win = 0; // initialize variable that contains the win of the previous round var present_win = 0; //initialize variable of win in present around var rounds_played = 10; var exploded = []; // array for saving whether ballon has exploded //var explode_array = [15, 9, 16, 26, 22, 8, 27, 17, 23, 29,]; var BurstProb; //Random variable that determines whether balloon burst

// initialize language var label_press = 'Inflate balloon'; var label_collect = 'Collect'; var label_balance = 'Total credit:'; var label_last = 'Win last round:'; var label_currency = ' points'; var label_times=' times'; var label_header = 'Balloon Game Round '; var label_gonext1 = 'Start next round'; var label_gonext2 = 'end game'; var msg_explosion1 = '

The balloon is exploded after puming '; var msg_explosion2 = ' times.

Once inflated burst, you did not make any money this round

'; var label_present_time = 'Pumping times:'; var label_present_value = 'Earn this round:';

var msg_collect1 = '

The balloon did not burst! </ p>

You deserve this round '; var msg_collect2 = ' Points. </ p>

The money earned is safe in the bank.

';

var msg_end1 = '

This completes this part of the study. You are in the balloon game '; var msg_end2 = ' points made profit. </ p>

Click Next </ i> to continue the study. </ p>';

// initialize labels $('#press').html(label_press); $('#collect').html(label_collect); $('#total_term').html(label_balance); $('#total_value').html(total+label_currency); $('#last_term').html(label_last); $('#last_value').html(last_win+label_currency); $('#present_value_term').html(label_present_value); $('#present_times_term').html(label_present_time); $('#present_value').html(present_win+label_currency); $('#present_times').html(pumpmeup+label_times); $('#outcomes').html(number_pumps);

// below: create functions that define game functionality

// what happens when a new round starts var new_round = function() { //console.log(number_pumps); //console.log(exploded); $('#gonext').hide(); $('#message').hide(); $('#collect').show(); $('#press').show(); $('#present_times').show(); $('#present_value').show(); round += 1; size = start_size; pumps = 0; present_win =0; show_present(); show_present_earns(); $('#ballon').width(size); $('#ballon').height(size); $('#ballon').show(); $('#round').html('

'+label_header+round+'

'); $('#present_round').show(); $('#outcomes').hide(); $('#NextButton').hide(); };

// what happens when the game ends var end_game = function() { $('#total').remove(); $('#collect').remove(); $('#ballon').remove(); $('#press').remove(); $('#gonext').remove(); $('#round').remove(); $('#last_round').remove(); $('#goOn').show(); $('#message').html(msg_end1+total+msg_end2).show(); $('#outcomes').show(); $('#NextButton').show(); Qualtrics.SurveyEngine.setEmbeddedData('number_pumps',number_pumps); Qualtrics.SurveyEngine.setEmbeddedData('exploded',exploded); Qualtrics.SurveyEngine.setEmbeddedData('total_win',total);

};

// message shown if balloon explodes var explosion_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_explosion1+pumpmeup+msg_explosion2).show(); };

// message shown if balloon does not explode var collected_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_collect1+present_win+msg_collect2).show(); };

// animate explosion using $ UI explosion var balloon_explode = function() { $('#ballon').hide( "explode", {pieces: 100}, 800 ); document.getElementById('explosion_sound').play(); };

// show button that starts next round var gonext_message = function() { $('#ballon').hide(); if (round < rounds_played) { $('#gonext').html(label_gonext1).show(); } else { $('#gonext').html(label_gonext2).show(); } };

// add money to bank var increase_value = function() { $('#total_value').html(total+label_currency); };

var show_last = function() { $('#last_value').html(last_win+label_currency); }; var show_present=function(){ $('#present_times').html(pumps+label_times) } var show_present_earns=function(){ $('#present_value').html(present_win+label_currency) } var show_array=function(){ $('#pump_array').html(number_pumps) }

// button functionalities

// pump button functionality -> 'pressure' in slider bar increases $('#press').click(function() { BurstProb = Math.random(); //generate random number between 0 and 1 if (pumps >= 0 && pumps < maximal_pumps) { // interacts with the collect function, which sets pumps to -1, making the button temporarily unclickable explosion = 0; // is set to one if pumping goes beyond explosion point; see below pumps += 1; present_win +=0.25; //Burst probabilty is 1 / (maximal_pumps-pumps+1) as in Read et al. in 2002, so probability to burst increase with number of pumps, pumping becomes more risky //Because BurstProb is random number between 0 and 1, the propbability that BurstProb > 1/(maximal_pumps-pumps+1) is equal to 1 - 1/(maximal_pumps-pumps+1) //and the probability that BurstProb < 1/(maximal_pumps-pumps+1) is equal to 1/(maximal_pumps-pumps+1) //In other words, the ballon will burst with probability 1/(maximal_pumps-pumps+1), and will not burst with probability 1-1/(maximal_pumps-pumps+1) if (BurstProb > 1/(maximal_pumps-pumps+1)) { size +=increase; $('#ballon').width(size); $('#ballon').height(size); show_present(); show_present_earns(); } else { last_win = 0; pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts explosion = 1; // save that balloon has exploded this round balloon_explode(); exploded.push(explosion); // save whether balloon has exploded or not number_pumps.push(pumpmeup); // save number of pumps $('#ballon').hide(); $('#present_round').hide(); setTimeout(explosion_message, 1200); setTimeout(gonext_message, 1200); setTimeout(show_last, 1200); } } });

// collect button: release pressure and hope for money $('#collect').click(function() { if (pumps === 0) { alert('you can only collect the money once you click "给气球充气”。'); } else if (pumps > 0) { // only works after at least one pump has been made exploded.push(explosion); // save whether balloon has exploded or not document.getElementById('tada_sound').play(); number_pumps.push(pumps); // save number of pumps pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts $('#ballon').hide(); $('#present_round').hide(); collected_message(); gonext_message(); total += present_win; last_win = present_win; increase_value(); show_last(); } });

// click this button to start the next round (or end game when all rounds are played) $('#gonext').click(function() { if (round < rounds_played) { new_round(); } else { end_game(); } });

// start the game! new_round();

});

});

Qualtrics.SurveyEngine.addOnReady(function() { /Place your JavaScript here to run when the page is fully displayed/

});

Qualtrics.SurveyEngine.addOnUnload(function() { /Place your JavaScript here to run when the page is unloaded/

});

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 07:25, mchiu91 notifications@github.com wrote:

That would be amazing, Richard! Thank you very much

On Wed, Nov 20, 2019 at 1:24 AM PsychologyRich < notifications@github.com> wrote:

I found some broken lines in the java code for the balloon task. I now have a version that works in qualtrics.

I will email the code to you later.

Best wishes,

Richard

On Wed, 20 Nov 2019, 01:38 mchiu91, notifications@github.com wrote:

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor.

https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITZPI2EHL2ZFDK6YELQUSIIBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQMIRA#issuecomment-555795524

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ANOKIIWFBIRT47HE4XQOSI3QUSIIBANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=AHLPOWNNJDLP6QGWQMUKKUTQUTJZJA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ3VXI#issuecomment-555858653

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AHLPOWM7RSZ2CYEWLUFCIVDQUTJZJANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW2LPNWSLWKSX3Z7ZTQUTQ7RA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ7SXY#issuecomment-555874655

,

or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ANOKIIVDZRDDCUDTLGUYFSDQUTQ7RANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW4HFSXHAPRMW3KSP3QUUZNXA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEER5N4I#issuecomment-555996913 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ANOKIIWCGZBFXTIGRAOMIHTQUUZNXANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITIDNU3HRSW57VWJHLQUXDUBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEWE5PY#issuecomment-556551871, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOKIIWQ7QRWPVIINVDSUZDQUXDUBANCNFSM4JBSSTBA .

mchiu91 commented 4 years ago

That would be great - I will email you now. Thank you Dr. Stephens!

Sent from my iPhone

On Nov 21, 2019, at 5:23 AM, PsychologyRich notifications@github.com wrote:

Hi

Can I suggest you send me your qualtrics user name (pls email direct to r.stephens@keele.ac.uk) and I will send you, within qualtrics, a copy of the functioning survey containing this version of the BART.

Best wishes,

Richard

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 23:44, mchiu91 notifications@github.com wrote:

Unfortunately I still get the same error message that Javascript code should be in Javascript Editor. Would you happen to know why that might be?

Sent from my iPhone

On Nov 20, 2019, at 8:14 AM, PsychologyRich notifications@github.com wrote:

Yes that's right

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 13:10, mchiu91 notifications@github.com wrote:

Thank you!! Just to clarify, this code was pasted directly into the Javascript editor on the Qualtrics question with the html text?

Sent from my iPhone

On Nov 20, 2019, at 4:08 AM, PsychologyRich < notifications@github.com> wrote:

Here is the code:

Qualtrics.SurveyEngine.addOnload(function() { /Place your JavaScript here to run when the page loads/ // standard version of the BART

$(document).ready(function() {

// initialize values var round = 0; var start_size = 150; // start value of widht & height of the image; must correspond to the value that is specified for the #ballon id in style.css var increase = 2; // number of pixels by which balloon is increased each pump var size; // start_size incremented by 'increase' var pumps; var thanks; var maximal_pumps=32; var pumpmeup; // number pumps in a given round; is updated each round var number_pumps = []; // arrays for saving number of pumps var total = 0; // money that has been earned in total var explosion; // will an explosion occur? 1 = yes, 0 = no var last_win = 0; // initialize variable that contains the win of the previous round var present_win = 0; //initialize variable of win in present around var rounds_played = 10; var exploded = []; // array for saving whether ballon has exploded //var explode_array = [15, 9, 16, 26, 22, 8, 27, 17, 23, 29,]; var BurstProb; //Random variable that determines whether balloon burst

// initialize language var label_press = 'Inflate balloon'; var label_collect = 'Collect'; var label_balance = 'Total credit:'; var label_last = 'Win last round:'; var label_currency = ' points'; var label_times=' times'; var label_header = 'Balloon Game Round '; var label_gonext1 = 'Start next round'; var label_gonext2 = 'end game'; var msg_explosion1 = '

The balloon is exploded after puming '; var msg_explosion2 = ' times.

Once inflated burst, you did not make any money this round

'; var label_present_time = 'Pumping times:'; var label_present_value = 'Earn this round:';

var msg_collect1 = '

The balloon did not burst! </ p>

You deserve this round '; var msg_collect2 = ' Points. </ p>

The money earned is safe in the bank.

';

var msg_end1 = '

This completes this part of the study. You are in the balloon game '; var msg_end2 = ' points made profit. </ p>

Click Next </ i> to continue the study. </ p>';

// initialize labels $('#press').html(label_press); $('#collect').html(label_collect); $('#total_term').html(label_balance); $('#total_value').html(total+label_currency); $('#last_term').html(label_last); $('#last_value').html(last_win+label_currency); $('#present_value_term').html(label_present_value); $('#present_times_term').html(label_present_time); $('#present_value').html(present_win+label_currency); $('#present_times').html(pumpmeup+label_times); $('#outcomes').html(number_pumps);

// below: create functions that define game functionality

// what happens when a new round starts var new_round = function() { //console.log(number_pumps); //console.log(exploded); $('#gonext').hide(); $('#message').hide(); $('#collect').show(); $('#press').show(); $('#present_times').show(); $('#present_value').show(); round += 1; size = start_size; pumps = 0; present_win =0; show_present(); show_present_earns(); $('#ballon').width(size); $('#ballon').height(size); $('#ballon').show(); $('#round').html('

'+label_header+round+'

'); $('#present_round').show(); $('#outcomes').hide(); $('#NextButton').hide(); };

// what happens when the game ends var end_game = function() { $('#total').remove(); $('#collect').remove(); $('#ballon').remove(); $('#press').remove(); $('#gonext').remove(); $('#round').remove(); $('#last_round').remove(); $('#goOn').show(); $('#message').html(msg_end1+total+msg_end2).show(); $('#outcomes').show(); $('#NextButton').show(); Qualtrics.SurveyEngine.setEmbeddedData('number_pumps',number_pumps); Qualtrics.SurveyEngine.setEmbeddedData('exploded',exploded); Qualtrics.SurveyEngine.setEmbeddedData('total_win',total);

};

// message shown if balloon explodes var explosion_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_explosion1+pumpmeup+msg_explosion2).show(); };

// message shown if balloon does not explode var collected_message = function() { $('#collect').hide(); $('#press').hide(); $('#message').html(msg_collect1+present_win+msg_collect2).show(); };

// animate explosion using $ UI explosion var balloon_explode = function() { $('#ballon').hide( "explode", {pieces: 100}, 800 ); document.getElementById('explosion_sound').play(); };

// show button that starts next round var gonext_message = function() { $('#ballon').hide(); if (round < rounds_played) { $('#gonext').html(label_gonext1).show(); } else { $('#gonext').html(label_gonext2).show(); } };

// add money to bank var increase_value = function() { $('#total_value').html(total+label_currency); };

var show_last = function() { $('#last_value').html(last_win+label_currency); }; var show_present=function(){ $('#present_times').html(pumps+label_times) } var show_present_earns=function(){ $('#present_value').html(present_win+label_currency) } var show_array=function(){ $('#pump_array').html(number_pumps) }

// button functionalities

// pump button functionality -> 'pressure' in slider bar increases $('#press').click(function() { BurstProb = Math.random(); //generate random number between 0 and 1 if (pumps >= 0 && pumps < maximal_pumps) { // interacts with the collect function, which sets pumps to -1, making the button temporarily unclickable explosion = 0; // is set to one if pumping goes beyond explosion point; see below pumps += 1; present_win +=0.25; //Burst probabilty is 1 / (maximal_pumps-pumps+1) as in Read et al. in 2002, so probability to burst increase with number of pumps, pumping becomes more risky //Because BurstProb is random number between 0 and 1, the propbability that BurstProb > 1/(maximal_pumps-pumps+1) is equal to 1 - 1/(maximal_pumps-pumps+1) //and the probability that BurstProb < 1/(maximal_pumps-pumps+1) is equal to 1/(maximal_pumps-pumps+1) //In other words, the ballon will burst with probability 1/(maximal_pumps-pumps+1), and will not burst with probability 1-1/(maximal_pumps-pumps+1) if (BurstProb > 1/(maximal_pumps-pumps+1)) { size +=increase; $('#ballon').width(size); $('#ballon').height(size); show_present(); show_present_earns(); } else { last_win = 0; pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts explosion = 1; // save that balloon has exploded this round balloon_explode(); exploded.push(explosion); // save whether balloon has exploded or not number_pumps.push(pumpmeup); // save number of pumps $('#ballon').hide(); $('#present_round').hide(); setTimeout(explosion_message, 1200); setTimeout(gonext_message, 1200); setTimeout(show_last, 1200); } } });

// collect button: release pressure and hope for money $('#collect').click(function() { if (pumps === 0) { alert('you can only collect the money once you click "给气球充气”。'); } else if (pumps > 0) { // only works after at least one pump has been made exploded.push(explosion); // save whether balloon has exploded or not document.getElementById('tada_sound').play(); number_pumps.push(pumps); // save number of pumps pumpmeup = pumps; pumps = -1; // makes pumping button unclickable until new round starts $('#ballon').hide(); $('#present_round').hide(); collected_message(); gonext_message(); total += present_win; last_win = present_win; increase_value(); show_last(); } });

// click this button to start the next round (or end game when all rounds are played) $('#gonext').click(function() { if (round < rounds_played) { new_round(); } else { end_game(); } });

// start the game! new_round();

});

});

Qualtrics.SurveyEngine.addOnReady(function() { /Place your JavaScript here to run when the page is fully displayed/

});

Qualtrics.SurveyEngine.addOnUnload(function() { /Place your JavaScript here to run when the page is unloaded/

});

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk web: www.keele.ac.uk/psychology/people/richardstephens/ twitter: @psychologyrich https://twitter.com/@psychologyrich orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975 youtube: bit.ly/2ipjlM0

On Wed, 20 Nov 2019 at 07:25, mchiu91 notifications@github.com wrote:

That would be amazing, Richard! Thank you very much

On Wed, Nov 20, 2019 at 1:24 AM PsychologyRich < notifications@github.com> wrote:

I found some broken lines in the java code for the balloon task. I now have a version that works in qualtrics.

I will email the code to you later.

Best wishes,

Richard

On Wed, 20 Nov 2019, 01:38 mchiu91, notifications@github.com wrote:

update, I found this recent thread (Nov 11 2019) by Qualtrics, which makes it seem like there's been a permanent change such that javascript is no longer allowed in HTML editor.

https://www.qualtrics.com/community/discussion/7053/javascript-no-longer-allowed-in-html-editor-workaround

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITZPI2EHL2ZFDK6YELQUSIIBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQMIRA#issuecomment-555795524

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ANOKIIWFBIRT47HE4XQOSI3QUSIIBANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=AHLPOWNNJDLP6QGWQMUKKUTQUTJZJA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ3VXI#issuecomment-555858653

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AHLPOWM7RSZ2CYEWLUFCIVDQUTJZJANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW2LPNWSLWKSX3Z7ZTQUTQ7RA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEQ7SXY#issuecomment-555874655

,

or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ANOKIIVDZRDDCUDTLGUYFSDQUTQ7RANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIIW4HFSXHAPRMW3KSP3QUUZNXA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEER5N4I#issuecomment-555996913 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ANOKIIWCGZBFXTIGRAOMIHTQUUZNXANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1?email_source=notifications&email_token=ANOKIITIDNU3HRSW57VWJHLQUXDUBA5CNFSM4JBSSTBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEWE5PY#issuecomment-556551871, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOKIIWQ7QRWPVIINVDSUZDQUXDUBANCNFSM4JBSSTBA .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

annewuwu commented 4 years ago

Hello all,

Was this issue ever resolved? I am having the same issue. Thanks!

mchiu91 commented 4 years ago

Hello all,

Was this issue ever resolved? I am having the same issue. Thanks!

@annewuwu just adding to the thread that the Qualtrics BART game that @PsychologyRich shared worked very well for me; Dr Stephens was really helpful throughout (I just made minor tweaks like wording to fit my specific purposes)

NChaku commented 4 years ago

Hello all,

This new code works for me and I can execute the task as is. I have a follow-up question. The third step is:

3.Download the balloon picture and upload the Balloon.png to your Qualtrics library, and change the related link address of the picture. After you upload the image successfully, you could find the concerned link address in your Qualtrics library. And find the code you need to revise: Ballon, which you could find this in the HTML.

I have downloaded the balloon picture and uploaded it to my qualtrics, but don't understand how to change the link address, where the code I need to revise is, or how to place my own image into the BART task. Any advice or code would be helpful! Thanks!

PsychologyRich commented 4 years ago

It's the html link to the location where the image is stored in Qualtrics.

Ask a friend or tutor that knows a little about computers if you're not sure.

Dr Richard Stephens Senior Lecturer in Psychology

BSc Psychology Programme Director, Keele University

e-mail: r.stephens@keele.ac.uk skype: live:richardstephens_1 https://www.skype.com/en/ twitter: @psychologyrich https://twitter.com/@psychologyrich web: www.keele.ac.uk/psychology/people/richardstephens/ orcid: 0000-0002-5851-8975 http://orcid.org/0000-0002-5851-8975

On Fri, 3 Apr 2020 at 18:24, NChaku notifications@github.com wrote:

Hello all,

This new code works for me and I can execute the task as is. I have a follow-up question. The third step is:

3.Download the balloon picture and upload the Balloon.png to your Qualtrics library, and change the related link address of the picture. After you upload the image successfully, you could find the concerned link address in your Qualtrics library. And find the code you need to revise: <img src= https://erasmusuniversity.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_e40vZ7nffgjMnul id="ballon" alt="Ballon">, which you could find this in the HTML.

I have downloaded the balloon picture and uploaded it to my qualtrics, but don't understand how to change the link address, where the code I need to revise is, or how to place my own image into the BART task. Any advice or code would be helpful! Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1#issuecomment-608563731, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOKIITLIDAEHTNC6LSJOOTRKYLVVANCNFSM4JBSSTBA .

annewuwu commented 4 years ago

I figured out what happened! @NChaku and @SidHatfield, this may address your issue as well.

Make sure when you copy the revised code posted above that you remove breaks inserted in the middle of some comments. I think when code is posted into the comment section format, some lengthier comments get bumped to the next line, and rogue, uncommented words would be registered as invalid commands. I suggest you go through your code and remove 10-15 line breaks in the code, if you copy & pasted the revised code in the comments.

Hope this makes sense. Thank you for all your help and the original code!

NChaku commented 4 years ago

Thanks for responding! I was able to change the balloon image in the html. The problem was that I was looking for that line of code in javascript.

I'm currently trying to make this version of the task available in the offline qualtrics app and will update you all when I get it to work

YaelSF24 commented 4 years ago

Dear Dr. Stephens I saw in the code that there is an array called 'explode_array'. I saw it's in the comments because you use a random function. If I want to use the array (so that for all participants the explosions will be identical), how do I pull the value from the array on each round? Thank you! Yael

PsychologyRich commented 4 years ago

Sorry but I didn't write the program and don't have programming skills - I just got it back working. You will need to find a programmer to help with this.

Best wishes,

Richard

Dr Richard Stephens Senior Lecturer in Psychology Keele University

e-mail: r.stephens@keele.ac.ukmailto:r.stephens@keele.ac.uk twitter: @psychologyrichhttps://twitter.com/@psychologyrich web: www.keele.ac.uk/psychology/people/richardstephens/http://www.keele.ac.uk/psychology/people/richardstephens/ orcid: 0000-0002-5851-8975http://orcid.org/0000-0002-5851-8975


From: YaelSF24 notifications@github.com Sent: 20 September 2020 20:21 To: joyfulwei/Balloon-task-in-Qualtrics Balloon-task-in-Qualtrics@noreply.github.com Cc: Richard Stephens r.stephens@keele.ac.uk; Mention mention@noreply.github.com Subject: Re: [joyfulwei/Balloon-task-in-Qualtrics] Javascript (#1)

Dear Dr. Stephens I saw in the code that there is an array called 'explode_array'. I saw it's in the comments because you use a random function. If I want to use the array (so that for all participants the explosions will be identical), how do I pull the value from the array on each round? Thank you! Yael

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1#issuecomment-695825203, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANOKIIQ52EQPFDWND7K3EGDSGZIZ5ANCNFSM4JBSSTBA.

YaelSF24 commented 4 years ago

Dear Dr. Stephens I managed to find a way to do that. Thank you for your quick response! Yael

On Mon, Sep 21, 2020 at 11:06 AM PsychologyRich notifications@github.com wrote:

Sorry but I didn't write the program and don't have programming skills - I just got it back working. You will need to find a programmer to help with this.

Best wishes,

Richard

Dr Richard Stephens

Senior Lecturer in Psychology

Keele University

e-mail: r.stephens@keele.ac.ukmailto:r.stephens@keele.ac.uk

twitter: @psychologyrichhttps://twitter.com/@psychologyrich

web: www.keele.ac.uk/psychology/people/richardstephens/< http://www.keele.ac.uk/psychology/people/richardstephens/>

orcid: 0000-0002-5851-8975http://orcid.org/0000-0002-5851-8975


From: YaelSF24 notifications@github.com

Sent: 20 September 2020 20:21

To: joyfulwei/Balloon-task-in-Qualtrics < Balloon-task-in-Qualtrics@noreply.github.com>

Cc: Richard Stephens r.stephens@keele.ac.uk; Mention < mention@noreply.github.com>

Subject: Re: [joyfulwei/Balloon-task-in-Qualtrics] Javascript (#1)

Dear Dr. Stephens

I saw in the code that there is an array called 'explode_array'. I saw it's in the comments because you use a random function. If I want to use the array (so that for all participants the explosions will be identical), how do I pull the value from the array on each round?

Thank you!

Yael

You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub< https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1#issuecomment-695825203>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ANOKIIQ52EQPFDWND7K3EGDSGZIZ5ANCNFSM4JBSSTBA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1#issuecomment-695965738, or unsubscribe https://github.com/notifications/unsubscribe-auth/APDPUO7PSERC5VG2Z2K7UDTSG4CRHANCNFSM4JBSSTBA .

-- Yael Shani-Feinstein PhD Student 054-2501743

-- Yael Shani-Feinstein PhD Student 054-2501743

worthyda commented 3 years ago

I had a javascript error initially as well. I was able to figure out that the error is a missing ")" on line 172 of the code (by pasting it into esprima, it told me where the error was). This line was missing a second closed parentheses following "+1: if (BurstProb > 1/(maximal_pumps-pumps+1)) {

The incorrect code was: if (BurstProb > 1/(maximal_pumps-pumps+1) {

CogSciLing commented 2 years ago

@annewuwu @mchiu91 I know that this has been inactive for a while, but I was wondering if you remember how the issue of the flattened buttons (and the buttons not working)? It displays fine for me and most other participants in my study, but recently I had had a select few participants mention this issue. I looked at my code and the one provided by @PsychologyRich and everything seemed to match up, but maybe I am missing something.

connectome16 commented 2 years ago

Dear Dr. Stephens I saw in the code that there is an array called 'explode_array'. I saw it's in the comments because you use a random function. If I want to use the array (so that for all participants the explosions will be identical), how do I pull the value from the array on each round? Thank you! Yael

I was going through the exact same problem. Could you share how you managed to design the codes so that all explosions will be identical for the participants? Thank you for your help!

PsychologyRich commented 2 years ago

I didn't write this code so I can't help, sorry.

Best wishes,

Richard

Dr Richard Stephens Senior Lecturer in Psychology Keele University


From: connectome16 @.> Sent: 27 May 2022 06:53 To: joyfulwei/Balloon-task-in-Qualtrics @.> Cc: Richard Stephens @.>; Mention @.> Subject: Re: [joyfulwei/Balloon-task-in-Qualtrics] Javascript (#1)

Dear Dr. Stephens I saw in the code that there is an array called 'explode_array'. I saw it's in the comments because you use a random function. If I want to use the array (so that for all participants the explosions will be identical), how do I pull the value from the array on each round? Thank you! Yael

I was going through the exact same problem. Could you share how you managed to design the codes so that all explosions will be identical for the participants? Thank you for your help!

— Reply to this email directly, view it on GitHubhttps://github.com/joyfulwei/Balloon-task-in-Qualtrics/issues/1#issuecomment-1139304928, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANOKIIWNGV67ACH4TPNXDRTVMBPPDANCNFSM4JBSSTBA. You are receiving this because you were mentioned.Message ID: @.***>


Please consider the environment before printing this email.This email and its contents may be legally privileged and /or confidential.If it has come to you in error you should not copy or show it to anyone; nor should you take any action based on it, other than to reply to the sender to notify them of the error immediately and to then delete the email from your inbox and deleted items. Keele University staff and students are required to abide by the University's IT Policies when sending and receiving email. Keele University email is hosted by a cloud provider and may be stored outside of the UK.

DuncanMccollum25 commented 2 years ago

@CogSciLing I believe you have the same issue I was having. I believe I found a solution (although I dont know javascript but I was able to get it to work for me). I noticed a file was loading very slowly and it looks like the html code calls jquery-ui.js but the version is no longer supported so if a participant is loading the task for the first time it spends a few minutes trying to find a working version (if you let it sit there it will eventually load the ui). After that I assume it saves the modern version to cookies and will load faster than next time. If you make the changes below to the html code it should load the modern version the first time much faster!

Code to Replace:

New Code:

Best,

Duncan McCollum GTA Psychology University of Oklahoma