var isPassed = false,
currentIndex;
var chapter_7 = window.Player_manuscript.extend({
initialize_sections: function(){
this._super();
//image
var $bigImage = $('#idp-bigimage');
$bigImage.unbind();
$bigImage.click(onClickImage.bind($bigImage));
//shuffle blocks
var questions = $("[data-type=question]");
for(var i = 0; i<50;i++) {
var rndA = (Math.random()*(questions.length-2)+1).toFixed(0);
$(questions[rndA]).insertBefore(questions[0]);
}
var isAnswered;
var typeAnswer = [
'authoritative',
'authoritarian',
'permissive',
'rejecting/neglecting'
];
var typeList = [
'authoritative',
'authoritative',
'authoritative',
'authoritative',
'authoritarian',
'authoritarian',
'authoritarian',
'authoritarian',
'permissive',
'permissive',
'permissive',
'permissive',
'rejecting/neglecting',
'rejecting/neglecting',
'rejecting/neglecting',
'rejecting/neglecting'
];
var answer = [
'an authoritative',
'an authoritarian',
'a permissive',
'a rejecting/neglecting'
];
var counterTypeAnswer = [];
counterTypeAnswer[typeAnswer[0]] = 0;
counterTypeAnswer[typeAnswer[1]] = 0;
counterTypeAnswer[typeAnswer[2]] = 0;
counterTypeAnswer[typeAnswer[3]] = 0;
$('#digfir_section_1 .question_submit_button ' ).remove();
$('.query_mc_choice_radio').click(function(){
var currentId = this.getAttribute('id');
//get quest index
currentIndex = (parseInt(currentId[currentId.length-4])) ? (currentId[currentId.length-4]) : '';
currentIndex += currentId[currentId.length-3];
currentIndex = parseInt(currentIndex);
//answer
// 0 - yes, 1 - no... O_o
var isYes =currentId[ currentId.length-1];
if(isYes==0){
counterTypeAnswer[typeList[currentIndex]]++;
}
player.activity.submit_question(currentIndex+1);
player.show_question_feedback( player.activity.queries[ currentIndex ], false ,false);
isAnswered = player.sections[1].all_questions_answered;
if( isAnswered ){
$('#digfir_section_1 .next_button').show();
isPassed = true;
var maxAnswerIndex=0;
var maxCount=-1;
typeAnswer.forEach(function(count,i){
if(counterTypeAnswer[count]>maxCount) {
maxCount = counterTypeAnswer[count];
maxAnswerIndex = i;
}
});
$('
').insertBefore('#digfir_section_1 .next_button');
var html = ""
+ "
Feedback
";
html += "
";
$('.query_mc_feedback_correct_incorrect').append(html);
var feedbackText = "You just completed a brief questionnaire assessing parenting styles that was adapted from Robinson and colleagues (1995).
";
feedbackText+="Your responses indicated that your primary caregiver had ";
var countWords=0;
typeAnswer.forEach(function(item,i){
var count = counterTypeAnswer[item];
if(maxCount==count){
if(countWords>0) {
console.log(item + ' = ' + count);
feedbackText += countWords>1 ? ',' : '';
feedbackText += ' and ';
feedbackText += answer[i];
// feedbackText += countWords > 0 ? ',' : '';
}
else{
feedbackText += answer[i];
}
countWords++;
}
});
// feedbackText+=answer[maxAnswerIndex];
feedbackText+=countWords>1 ? " parenting styles.
" : " parenting style.
";
// feedbackText+=" parenting style.
";
feedbackText+="Please note that the intent of this assessment is to provide you with something to consider regarding the parenting style of your primary caregiver. It is not definite. If you find this assessment interesting please refer to the references for this activity.";
$('#question_feedback_99').append(feedbackText);
}
});
},
show_section: function( section_to_show ) {
this._super( section_to_show );
if( !isPassed ) {
$('#digfir_section_1 .next_button').hide();
}
},
tab_selected: function(event, ui){
// we don't actually use event;
// it's just there because it's part of the standard jquery ui fn prototype
var section_to_show = ui.index;
// if user has to view sections in sequence and hasn't gotten up to this one, don't allow it
if (player.md.sequenced_sections == "true" && section_to_show > player.last_available_section) {
alert(player.md.section_sequence_message);
return false;
}
player.section_currently_showing = section_to_show;
// process iframes for the section, unless all were preloaded
if (player.md.preload_all_iframes != "true") {
player.figures.process_iframes(player.get_current_section().jq); // iframes
}
player.update_section_status();
player.update_navigation();
window.scrollTo(0,0);
},
show_question_feedback: function( question ) {
var checkInputDiv = $("[ data-question_index = " + (parseInt(currentIndex) + 1) + " ] .query_mc_other_choice [checked]").parent();
// checkInputDiv.removeAttr( 'data-state' );
// checkInputDiv.attr( 'data-state', 'true' );
currentIndex=currentIndex+1;
var html = ""
+ "
Feedback
";
html += "
";
// append the div, then fade it in
$("[ data-question_index = " + currentIndex + " ] .query_mc_feedback_correct_incorrect").prepend(html);
//You just completed a brief questionnaire assessing parenting styles that was adapted from Robinson and colleagues (1995).
//Your responses indicated that your primary caregiver had a(n) [….] parenting style.
//Please note that the intent of this assessment is to provide you with something to consider regarding the parenting style of your primary caregiver. It is not definite. If you find this assessment interesting please refer to the references for this activity.
}
});
window.player = new chapter_7();