//draw canvas function //copied from official round part //clock stuff over //console.log("testing!!!"); $('.not-clicked').click(function(e) { var elems = document.querySelectorAll(".not-clicked"); //modified here, since I don't know what's length for, and don't know the followwing script //this time my modification starts here for (i = 0; i < elems.length; ++i) { {//console.log(elems[i].id)#} elems[i].classList.remove("not-clicked"); elems[i].classList.add("clicked"); } }); var num_FR = parseInt({{ subsession.num_FR }}); var sender_Mistake = parseFloat({{ subsession.sender_Mistake }}); var solutions = {{ solutions|safe }}; var pass_qsect_1 = false; var pass_qsect_1_2 = false; var pass_qsect_2 = false; function mtopFunction(){ topFunction(); liveSend({"read": 1}) if(sender_Mistake > 0){ if(pass_qsect_1_2){ $('#quiz_sect1').hide(); $('#quiz_sect1-2').hide(); $('#quiz_sect2').show(); } else{ if(pass_qsect_1){ $('#quiz_sect1').hide(); $('#quiz_sect1-2').show(); $('#quiz_sect2').hide(); } else{ $('#quiz_sect1').show(); $('#quiz_sect1-2').hide(); $('#quiz_sect2').hide(); } } } else{ if(pass_qsect_1){ $('#quiz_sect1').hide(); $('#quiz_sect2').show(); } else{ $('#quiz_sect2').hide(); $('#quiz_sect1').show(); } //} } } function liveRecv(data) { if (data.read ==1){ var style = document.querySelector('[data="test"]'); style.innerHTML =".nav{ visibility: visible;}"; } } function nextpage(){ var i, items = $('.nav-link'), pane = $('.tab-pane'); for(i = 0; i < items.length; i++){ if($(items[i]).hasClass('active') == true){ break; } } if(i < items.length - 1){ // for tab $(items[i]).removeClass('active'); $(items[i+1]).addClass('active'); // for pane $(pane[i]).removeClass('show active'); $(pane[i+1]).addClass('show active'); } } if ({{ read }} == 1){ nextpage(); nextpage(); nextpage(); nextpage(); nextpage(); nextpage(); nextpage(); } var coll = document.getElementsByClassName("collapsible"); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { this.classList.toggle("expanded"); var content = this.nextElementSibling; if (content.style.maxHeight){ content.style.maxHeight = null; } else { content.style.maxHeight = content.scrollHeight + "px"; } }); } if (num_FR > 0){ var quiz_Proceed = function(){ //console.log("Using proceed for trt PB"); if ($('input[name=q1]:checked').val() == solutions['q1'] && $('input[name=q2]:checked').val() == solutions['q2'] && $('input[name=q3]:checked').val() == solutions['q3'] && $('input[name=q4]:checked').val() == solutions['q4'] ){ document.getElementById("form").submit(); } else { if($('input[name=q1]:checked').val() != solutions['q1']){ $('input[name=q1]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q1]:checked').parent().css('background-color','#D5F7D6'); } if($('input[name=q2]:checked').val() != solutions['q2']){ $('input[name=q2]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q2]:checked').parent().css('background-color','#D5F7D6'); } if($('input[name=q3]:checked').val() != solutions['q3']){ $('input[name=q3]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q3]:checked').parent().css('background-color','#D5F7D6'); } if($('input[name=q4]:checked').val() != solutions['q4']){ $('input[name=q4]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q4]:checked').parent().css('background-color','#D5F7D6'); } $(".otree-form-errors, .alert, .alert-danger").show(); document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera } } $("label[for='id_q1_0']").eq( 0 ).html("Suppose at the beginning of the 1st official round, your role is assigned to be S. Which of the following statements is true?"); $("label[for='id_q1_0']").eq( 1 ).html("" + "My role will be randomly determined for each of the official rounds. So, I could play the role of True R or False R as well in the later rounds."); $("label[for='id_q1_1']").html(" " + "My role is fixed as S for the rest of the experiment. In each official round, I will be randomly paired with a True R participant who knows that he will receive a message from me."); $("label[for='id_q1_2']").html(" " + "My role is fixed as S for the rest of the experiment. In each official round, I will be paired "+ "with a True R participant who does not know whether s/he is True R or False R."); $("label[for='id_q1_3']").html(" " + "The True R participant in my pair will decide how many grams of herbal extract to put to make an antidote. "+ "But his/her decision does not affect my point."); $("label[for='id_q2_0']").eq(0).html("Suppose at the beginning of the 1st official round, " + "you are informed that your role is R. Which of the following statements is true?"); $("label[for='id_q2_0']").eq(1).html("" + "My role will be randomly determined for each of the official rounds. So, I could play the role of S in the later rounds."); $("label[for='id_q2_1']").html(" " + "My role will be True R for the rest of the experiment. " + "In each round, I will receive a message from S who knows exactly the poison type for me."); $("label[for='id_q2_2']").html(" " + "My role will be False R for the rest of the experiment. " + "In each round, I will receive a message from S who does not know what type of poison I am affected."); $("label[for='id_q2_3']").html(" " + "My role will be fixed but I don’t know if my role is True R or False R. " + "In any case, I will receive a message from S who knows exactly the poison type for me in each round."); $("label[for='id_q2_4']").html(" " + "My role will be fixed but I don’t know if my role is True R or False R. " + "The chances are {{ TR_prob }}-and-{{ FR_prob }} that the message I receive is from S who knows exactly the poison type for me " + "or from S who does not know what type of poison I am affected."); $("label[for='id_q3_0']").eq( 0 ).html("Imagine a participant Albert whose role is False R. "+ "Which of the followings is true?"); $("label[for='id_q3_0']").eq( 1 ).html("" + "No S in the experiment knows the poison type for Albert."); $("label[for='id_q3_1']").html(" " + "Albert is matched with some S who knows the poison type for Albert."); $("label[for='id_q3_2']").html(" " + "The message Albert receives is from some S who knows poison type for Albert."); $("#id_q7_0").prop("checked", true); $("#id_q8_0").prop("checked", true); } else{ if(sender_Mistake == 0){ var quiz_Proceed = function(){ //console.log("Using proceed for trt ST"); if ($('input[name=q1]:checked').val() == solutions['q1'] && $('input[name=q2]:checked').val() == solutions['q2'] && $('input[name=q3]:checked').val() == solutions['q3'] && $('input[name=q4]:checked').val() == solutions['q4'] ){ document.getElementById("form").submit(); } else { //console.log("error message from sect 1!"); if($('input[name=q1]:checked').val() != solutions['q1']){ $('input[name=q1]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q1]:checked').parent().css('background-color','#D5F7D6'); } if($('input[name=q2]:checked').val() != solutions['q2']){ $('input[name=q2]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q2]:checked').parent().css('background-color','#D5F7D6'); } if($('input[name=q3]:checked').val() != solutions['q3']){ $('input[name=q3]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q3]:checked').parent().css('background-color','#D5F7D6'); } if($('input[name=q4]:checked').val() != solutions['q4']){ $('input[name=q4]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q4]:checked').parent().css('background-color','#D5F7D6'); } $(".otree-form-errors, .alert, .alert-danger").show(); document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera } } $("#id_q7_0").prop("checked", true); $("#id_q8_0").prop("checked", true); } else{ //in case sender_Mistake > 0 //console.log("in case sender_Mistake > 0"); var quiz_Proceed = function(){ if ($('input[name=q1]:checked').val() == solutions['q1'] && $('input[name=q2]:checked').val() == solutions['q2'] && $('input[name=q3]:checked').val() == solutions['q3'] && $('input[name=q4]:checked').val() == solutions['q4'] ){ document.getElementById("form").submit(); } else{ //console.log("error message from sect 1!"); if($('input[name=q1]:checked').val() != solutions['q1']){ $('input[name=q1]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q1]:checked').parent().css('background-color','#D5F7D6'); } if($('input[name=q2]:checked').val() != solutions['q2']){ $('input[name=q2]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q2]:checked').parent().css('background-color','#D5F7D6'); } if($('input[name=q3]:checked').val() != solutions['q3']){ $('input[name=q3]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q3]:checked').parent().css('background-color','#D5F7D6'); } if($('input[name=q4]:checked').val() != solutions['q4']){ $('input[name=q4]:checked').parent().css('background-color','#F7D7DA'); } else{ $('input[name=q4]:checked').parent().css('background-color','#D5F7D6'); } $(".otree-form-errors, .alert, .alert-danger").show(); document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera } } } } var typeO_prob = parseInt({{ typeO_prob }}); var typeI_prob = parseInt({{ typeI_prob }}); if(sender_Mistake==0){ $(".form-group, .required").slice(5).css({"display" : "flex", "justify-content": "space-between"}); } else{ $(".form-group, .required").slice(5).css({"display" : "flex", "justify-content": "space-between"}); } if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1){ $('.share_input').attr('size',10); } var Payoffs = {{ payoffs|safe }}; {#console.log(Object.keys(Payoffs).length );#} for (var i = 0; i < Object.keys(Payoffs).length ; i++){ var tr = $(''); if (i == 0){ tr.append("The Actual Amount (grams) of Herbal Extract Taken "); tr.append("" + i + ""); tr.append("" + Payoffs[i]['R0'] + ""); tr.append("  "); tr.append("" + Payoffs[i]['R1'] + ""); tr.append("" + Payoffs[i]['S0'] + ""); tr.append("  "); tr.append("" + Payoffs[i]['S1'] + ""); } else{ tr.append(""); tr.append("" + i + ""); tr.append("" + Payoffs[i]['R0'] + ""); tr.append("  "); tr.append("" + Payoffs[i]['R1'] + ""); tr.append("" + Payoffs[i]['S0'] + ""); tr.append("  "); tr.append("" + Payoffs[i]['S1'] + ""); } $(".ptable").append(tr); } var conflict = parseInt({{ conflict }}); for (var i=0; i<4; i++) { $('.ptable:eq('+i+') tr').eq(2).find('td').eq(2).css({"color": 'dodgerblue', 'font-weight': 'bold'}); $('.ptable:eq('+i+') tr').eq(7).find('td').eq(4).css({"color": 'dodgerblue', 'font-weight': 'bold'}); $('.ptable:eq('+i+') tr').eq(conflict+2).find('td').eq(5).css({"color": 'red', 'font-weight': 'bold'}); $('.ptable:eq('+i+') tr').eq(7).find('td').eq(7).css({"color": 'red', 'font-weight': 'bold'}); }