(function(){ var Activity_ch05 = Activity_manuscript.extend({ congratulations_msg: undefined, submit_question: function (question_index) { // the arg may be a number or an event object; in the latter case... if (typeof question_index == "object") { // extract the question_index from the object question_index = question_index.data.question_index; } //force all queries to be answered before doing anything. var queries = player.activity.questions[question_index].queries; var allQueriesAnswered = true; for ( var i = 0; i < queries.length; i++ ) { if ( !queries[i].user_has_answered() ){ allQueriesAnswered = false; } } if (!allQueriesAnswered) { Standard_Dialog.open("
You have already completed the test on this slide but may do so again without affecting your grade.
"; buttons = [ { text: "OK", click: function () { Standard_Dialog.close(); } } ]; } else if (player.section_currently_showing == 2) { /* message = "A score cannot be calcualated for this slide until you redo the test on the previous slide. You may do so without affecting your grade.
"; buttons = [ { text: "OK", click: function () { Standard_Dialog.close(); } } ]; */ this.brb_mesg = true; if (!this.test_completed) { this.toggle_your_score(false); } } if (message !== "" && !this.brb_mesg) { this.brb_mesg = true; this.toggle_your_score(false); message = "A score cannot be calcualated for this slide until you redo the test on the previous slide. You may do so without affecting your grade.
"); } else { $('#digfir_section_2 #brb_message').remove(); $('#digfir_section_2 p').css('display', 'block'); $('#digfir_section_2 [data-block_type="results-container"]').css('display', 'block'); } } }); player = new Player_ch05(); var MAX_COUNT = 50; var FEEDBACK = { MAIN_PART: "You correctly guessed", LESS_THAN_15: "You have not demonstrated ESP. Your score falls within the range of what we would expect based on chance guessing.", MORE_THAN_15: " which is above the range we might expect by chance. So, do you have ESP, or is this the sort of very occasional chance result that we expect a few times in every hundred? You might want to retake the test another few times to see if you can consistently replicate this performance level." }; var espAria = "For each of the 50 predictions, select one of these cards by pressing Spacebar: hollow circle, Greek cross, three vertical wavy lines, hollow square, hollow five pointed star. Use arrows to move between the cards."; var url = [ "asset/ch05/circle.gif", "asset/ch05/cross.gif", "asset/ch05/waves.gif", "asset/ch05/square.gif", "asset/ch05/star.gif" ]; var LEFT_ARROW_KEY = 37; var RIGHT_ARROW_KEY = 39; var currentScore = 0; function Activity( section ){ this.isPassed = false; this.section = section; this.sectionNode = section.jq[0]; this.espNode = this.sectionNode.querySelector(".esp_container"); this.espNode.setAttribute("role", "application"); this.espNode.setAttribute("tabindex", "0"); this.espNode.setAttribute("aria-label", espAria); this.symbols = this.sectionNode.querySelectorAll( ".choice-img-item" ); this.cmpChoiceNode = this.sectionNode.querySelector( "#cmpChoice" ); this.userChoiceNode = this.sectionNode.querySelector( "#userChoice" ); this.hiddenImagesNode = this.sectionNode.querySelector(".hidden-img"); this.countNode = this.sectionNode.querySelector(".count-text"); //this.countNode.innerHTML = "You have completed
0 of 50
predictions.
"; this.countText = $(this.countNode).find('strong'); this.scoreNode = this.sectionNode.querySelector(".score-text"); //this.scoreNode.innerHTML = "Successful predictions:
0
"; this.scoreText = $(this.scoreNode).find('strong'); //this.hiddenUserImage = document.createElement("div"); //this.hiddenUserImage.classList.add("hidden-aria"); //this.espNode.appendChild(this.hiddenUserImage); this.hiddenCmpImage = document.createElement("div"); this.hiddenCmpImage.classList.add("hidden-aria"); this.hiddenImagesNode.appendChild(this.hiddenCmpImage); this.countNode.setAttribute("aria-live", "polite"); this.countNode.setAttribute("aria-atomic", "true"); this.scoreNode.setAttribute("aria-live", "polite"); this.scoreNode.setAttribute("aria-atomic", "true"); this.hiddenCmpImage.setAttribute("aria-live", "assertive"); this.hiddenCmpImage.setAttribute("aria-atomic", "true"); //this.hiddenUserImage.setAttribute("aria-live", "assertive"); //this.hiddenUserImage.setAttribute("aria-atomic", "true"); var i; for( i = 0; i < this.symbols.length; i++ ) { var th = this; this.symbols[i].setAttribute("tabindex", "-1"); this.symbols[i].setAttribute("aria-hidden", "false"); this.symbols[i].style.backgroundImage = 'url(' + url[i] + ')' ; this.symbols[i].addEventListener( "click", this.userChoice.bind( this, i ) ); this.symbols[i].addEventListener( "keydown", function (e) { th.userKeyChoice(e); } ); } this.score = 0; this.counter = 0; this.index = 0; this.setFocus(this.index); } Activity.prototype.randomChoice = function(){ var randIndex = Math.floor( Math.random() * this.symbols.length ); var cmpBackground = this.symbols[randIndex].style.backgroundImage; this.cmpChoiceNode.style.backgroundImage = cmpBackground; this.cmpChoiceNode.aria = this.symbols[randIndex].getAttribute("aria-label"); //var cmpNode = this.symbols[randIndex].cloneNode(true); //this.cmpChoiceNode.innerHTML = ""; //this.cmpChoiceNode.appendChild(cmpNode); this.cmpIndex = randIndex; }; Activity.prototype.userImage = function (e) { var i; for( i = 0; i < this.symbols.length; i++ ) { if (e.target === this.symbols[i] ) { return i; } } }; Activity.prototype.setFocus = function(index) { this.prevIndex = this.index; this.index = index; this.symbols[this.prevIndex].setAttribute("tabindex", "-1"); this.symbols[this.index].setAttribute("tabindex", "0"); this.symbols[this.index].focus(); }; Activity.prototype.userKeyChoice = function(e) { var index = this.userImage(e); var length = this.symbols.length - 1; if( e.keyCode == 32 || e.keyCode == 13 ) { this.userChoice(index); } if( e.keyCode == LEFT_ARROW_KEY && index > 0 && !this.isPassed ) { this.setFocus(index - 1); } if( e.keyCode == RIGHT_ARROW_KEY && index < length && !this.isPassed ) { this.setFocus(index + 1); } }; Activity.prototype.userChoice = function( index ){ if( this.isPassed ) return; var userBackground = this.symbols[index].style.backgroundImage; this.userChoiceNode.style.backgroundImage = userBackground; //this.userChoiceNode.aria = this.symbols[index].getAttribute("aria-label"); //var userNode = this.symbols[index].cloneNode(true); // //this.userChoiceNode.innerHTML = ""; //this.userChoiceNode.appendChild(userNode); this.userIndex = index; this.setFocus(index); this.randomChoice(); this.checkChoice(); this.liveImages(); }; Activity.prototype.liveImages = function() { //var cmpChoiceImage = this.cmpChoiceNode.querySelector("img"); var cmpChoiceAlt = this.cmpChoiceNode.aria; var cmpChoiceText = "Computer selected "; this.hiddenCmpImage.innerHTML = cmpChoiceText + cmpChoiceAlt; }; Activity.prototype.checkChoice = function(){ this.counter++; this.countText.html(this.counter); if( this.userIndex === this.cmpIndex ) { this.score++; this.scoreText.html(this.score); } if( this.counter == MAX_COUNT ) { player.test_completed = true; player.toggle_your_score(true); Standard_Dialog.open("