var previousUserAnswerIndex = null, userAnswerIndex = null, result = 0;
var userAnswers = [], trial;
var Player_chapter_1 = window.Player_hwyk.extend( {
show_section_animate: function( section_to_show, direction ) {
'use strict';
this._super( section_to_show, direction );
if ( this.sections[section_to_show].md && this.sections[section_to_show].md.sectionid === 'screen3a-2' ) {
var queries = window.player.activity.questions[2].queries;
var answers = [, , , ];
for ( var i = 0; i < 4; i++ ) {
answers[i] = document.querySelector( '#question3_answer_' + (i + 1) );
}
var bold_text = [
' One person or a small group of people who have won the United States Memory Championship You would need to study individuals who have relatively normal memory abilities. By only studying a person or people with exceptional memory, you would not be able to generalize your findings to the larger population.',
' One person or a small group of people who have average memory abilities You were correct to recruit one or more individuals who have average memory abilities. HOWEVER, we would need to study large groups of people in order to generalize the findings to the larger population.',
' One person or a small group of people who have extremely poor memory abilities You would need to study individuals who have relatively normal memory abilities. By only studying a person or people with poor memory abilities, you would not be able to generalize your findings to the larger population.',
' One person or a small group of people with a family history of memory loss Knowing whether people have a family history of memory loss does not give you the information you need. To know whether our memory is accurate, you need to know something about the memory abilities of the actual participants you recruit. '
];
var normal_text = [
'One person or a small group of people who have won the United States Memory Championship You would need to study individuals who have relatively normal memory abilities. By only studying a person or people with exceptional memory, you would not be able to generalize your findings to the larger population.',
' One person or a small group of people who have average memory abilities You were correct to recruit one or more individuals who have average memory abilities. HOWEVER, we would need to study large groups of people in order to generalize the findings to the larger population.',
' One person or a small group of people who have extremely poor memory abilities You would need to study individuals who have relatively normal memory abilities. By only studying a person or people with poor memory abilities, you would not be able to generalize your findings to the larger population.',
' One person or a small group of people with a family history of memory loss Knowing whether people have a family history of memory loss does not give you the information you need. To know whether our memory is accurate, you need to know something about the memory abilities of the actual participants you recruit. '
];
for ( var i = 0; i < 4; i++ ) {
if ( queries[0].user_answer_index == i ) {
answers[i].innerHTML = bold_text[i];
}
else {
answers[i].innerHTML = normal_text[i];
}
}
}
if( this.sections[section_to_show].md && this.sections[section_to_show].md.sectionid === 'screen8' ) {
var queries = window.player.activity.questions[6].queries;
var answers = [,,,,];
for( var i = 0; i < 6; i++ ){
answers[i] = document.querySelector('#answer_' + (i+1));
}
for( var i = 0; i < 6; i++ ){
if (queries[i].user_answer_index == 0){
answers[i].setAttribute('checked','');
}else{
answers[i].checked = false;
}
answers[i].setAttribute('disabled','');
}
}
if ( this.sections[section_to_show].md && this.sections[section_to_show].md.sectionid === 'screen5b' ) {
var section = this.sections[section_to_show];
var $button = section.jq.find( '.go_on_button' );
var words = [
[ 'shirt', 'pants', 'shoes', 'jackets', 'vests' ],
[ 'chair', 'clock', 'belt', 'lamp', 'plate' ]
];
var fakeWords = [ 'pants', 'yellow', 'sun', 'ties', 'shoes', 'vests', 'green', 'socks' ];
$( '#step_button' ).hide();
if ( trial ) {
trial.stop();
}
trial = new Trial( section.jq, words, $button, fakeWords );
$button.show().text( 'I’m ready to see my list' ).unbind().bind( 'click', function() {
trial.startTrial( 0 );
} );
}
if ( this.sections[section_to_show].md && this.sections[section_to_show].md.sectionid === 'screen5c' ) {
var section = this.sections[section_to_show];
var correctAnswers = [ true, false, false, false, true, true, false, false ];
var x = 0;
for ( var i = 0; i < userAnswers.length; i++ ) {
if ( userAnswers[i] === correctAnswers[i] ) {
x++;
}
}
section.jq.find( '[data-block_type=answer] p' ).text( 'You got ' + x + ' out of 8 correct.' );
}
}
} );
var Trial = function( node, words, $button, fakeWords ) {
this.container = node.find( '.word' );
this.controls = node.find( '.controls' );
this.yesBttn = node.find( 'button.yes' );
this.noBttn = node.find( 'button.no' );
this.secondPart = node.find( '.second_part' );
this.next = node.find( '.click_next' );
this.firstPart = node.find( '.first_part' );
this.text = node.find( '.experiment-container .text' );
this.words = words;
this.fakeWords = fakeWords;
this.index = 0;
this.$button = $button;
this.answers = [];
this.isAvailable = true;
this.container.hide();
this.container.hide();
this.firstPart.show();
this.controls.hide();
this.text.hide();
};
Trial.prototype.startTrial = function( part ) {
this.container.show();
this.$button.hide();
if ( this.index < this.words[ part ].length ) {
this.container.text( this.words[ part ][ this.index ] );
setTimeout( function() {
if ( this.isAvailable ) {
this.container.hide();
}
}.bind( this ), 1000 );
setTimeout( function() {
if ( this.isAvailable ) {
this.startTrial( part );
}
}.bind( this ), 1000 );
this.index++;
}
else {
// start second experiment
if ( part ) {
//this.firstPart.hide();
this.secondPart.hide();
this.text.show();
this.container.hide();
this.yesBttn.unbind().bind( 'click', this.addAnswer.bind( this, true ) );
this.noBttn.unbind().bind( 'click', this.addAnswer.bind( this, false ) );
this.$button.show().text( 'I’m ready to start' ).unbind().bind( 'click', function() {
this.index = 0;
this.container.show();
this.controls.show();
this.$button.hide();
this.firstPart.hide();
this.startSecondTrial();
}.bind( this ) );
// start second part of first experiment
}
else {
this.firstPart.hide();
this.secondPart.show();
this.container.hide();
this.$button.show().unbind().bind( 'click', function() {
this.index = 0;
this.startTrial( 1 );
}.bind( this ) );
}
}
};
Trial.prototype.startSecondTrial = function() {
if ( this.index < this.fakeWords.length ) {
this.container.text( this.fakeWords[ this.index ] );
this.index++;
}
else {
this.firstPart.hide();
this.text.hide();
this.next.show();
this.container.hide();
this.controls.hide();
$( '#step_button' ).show();
userAnswers = this.answers;
}
};
Trial.prototype.addAnswer = function( value ) {
this.answers.push( value );
this.startSecondTrial();
};
Trial.prototype.stop = function() {
this.isAvailable = false;
};
window.player = new Player_chapter_1();