webpackJsonp([11],{
/***/ 103:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(38);
/***/ }),
/***/ 38:
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(56);
var common = __webpack_require__(2);
var dom = __webpack_require__( 3 );
var platform = __webpack_require__(0).run_on;
var ProjectFigures = __webpack_require__(6);
var ProjectPlayer = __webpack_require__(1);
var ProjectMCQuery = __webpack_require__(4);
var Activity = __webpack_require__(5);
var ASTERISK = '' +
// '' +
'' +
'';
var CHECKMARK = '' +
'';
/* var CHECKMARK_UNCHECKED = '' +
'' +
'' +
''; */
var FiguresExtended = ProjectFigures.extend({
media_finished_callback: function (mmid) {
this._super();
var active_section = window.player.sections[window.player.section_currently_showing];
active_section.videos[mmid] = true;
var cumulative_result = Object.values(active_section.videos).every(function (val) {
return val;
});
if (cumulative_result) {
window.player.completeSectionTask();
$('[data-video-conditional="' + window.player.section_currently_showing + '"]').addClass('active_1');
}
}
});
var ChapterActivity = Activity.extend({
question_submit_button_label: 'Check Your Answer',
question_submit_button: function (q) {
var classList = 'standard_button question_submit_button';
var btnLabel = player.activity.question_submit_button_label;
if (q.queries[0].is_hs_type) {
classList += ' hs_submit_hidden';
btnLabel += 's';
}
// define question_submit_button_label as a variable so it can be overridden
return '';
},
submit_question: function ( question_index ) {
this._super(question_index);
var feedback = player.activity.questions[question_index.data.question_index].jq.find( '.question_feedback_part' );
feedback.attr('tabindex', '-1').focus();
},
show_next_question: function ( question ) {
this._super(question);
if ( question.question_sequence != null ) {
var qs = question.question_sequence;
var next_qs_index = question.question_sequence_index + 1;
var next_question = (next_qs_index === NaN) ? null : qs.questions[next_qs_index];
if (qs.one_at_a_time === true && next_question == null && qs.sequence_complete === 'partial') {
$('.question_sequence_review_button').remove();
qs.sequence_complete = 'complete';
}
}
}
});
var ChapterPlayer = ProjectPlayer.extend({
update_navigation: function () {
this._super();
var nextButtonText = '';
switch (this.section_currently_showing) {
case 0:
nextButtonText = 'Begin';
break;
case 7:
nextButtonText = 'Finish';
break;
default:
nextButtonText = 'Continue';
break;
}
$('#next_button .ui-button-text').text(nextButtonText);
},
initialize: function (isWithoutAccessibleTables) {
this._super(isWithoutAccessibleTables);
this.activity = new ChapterActivity();
},
initialize_sections: function () {
this._super();
var self = this;
var i;
var j;
var jj;
var $id;
var $anim_btn;
var video_list = [];
for (var id in self.init_figures.bcVideo) {
if (self.init_figures.bcVideo.hasOwnProperty(id)) {
video_list.push(id);
}
}
player.currentVideoID = '';
player.videoIsPlaying = false;
for (j = 0; j < this.sections.length; j++) {
var s = this.sections[j];
var $videos = s.jq.find('.outer_outer_outer_video');
if ($videos.length) {
s.videos = {};
s.jq.find('[data-block_type="conditional_1"]').attr('data-video-conditional', j);
$anim_btn = s.jq.find('.anim_ctrl_btn');
if ($anim_btn.length) {
s.animations = {};
$anim_btn.each(function () {
var $video = $($videos.get($(this).data('id'))).find('video');
$id = $video.attr('id');
s.animations[$id] = {
animation: $video,
parent: $video.parent().parent().parent().parent()
};
$(this).click({id: $id, sectionId: j}, function (ev) {
var id = ev.data.id;
var section = player.sections[ev.data.sectionId];
if (!id || !section.animations[id]) {
return;
}
if (id === player.currentVideoID) {
if (player.videoIsPlaying) {
section.animations[player.currentVideoID].animation.get(0).pause();
player.videoIsPlaying = false;
}
else {
section.animations[player.currentVideoID].animation.get(0).play();
player.videoIsPlaying = true;
}
}
else {
for (var key in section.animations) {
if (section.animations.hasOwnProperty(key)) {
var $animation = section.animations[key].animation;
// var $parent = section.animations[key].parent;
var animation = $animation.get(0);
/* $animation.attr('aria-hidden', 'true').addClass('hidden');
$parent.hide(); */
animation.pause();
animation.currentTime = 0;
}
}
section.animations[id].animation.get(0).play();
section.animations[id].parent.show();
player.currentVideoID = id;
player.videoIsPlaying = true;
}
});
});
}
$videos.each(function () {
var $id = $(this).find('video').attr('id');
for (i = 0; i < video_list.length; i++) {
if ($id.indexOf(video_list[i]) > -1) {
s.videos[video_list[i]] = false;
/* if ($anim_btn.length) {
$id =
s.animations[]
} */
break;
}
}
});
}
var $hs_aria = s.jq.find('.question_sequence_closing_material [data-type="metadata"] [key="hs_aria"]');
if ($hs_aria.length) {
var hs_aria = JSON.parse($hs_aria.text());
var ida;
for (i = 0; i < hs_aria.query_hs.length; i++) {
for (jj = 0; jj < hs_aria.query_hs[i].length; jj++) {
ida = hs_aria.regions[i].replace(/\s+/g, '') + jj;
s.jq.append('
' + hs_aria.query_hs[i][jj] + '
');
}
}
$hs_aria.remove();
s.jq.closest('[data-type="box"]')
.find('.question_sequence_closing_material [data-type="metadata"] [key="source_images"]').remove();
s.jq.closest('[data-type="box"]')
.find('.question_sequence_closing_material [data-type="metadata"] [key="hs_choices"]').remove();
}
}
}
});
var ProjectHSQuery = ProjectMCQuery.extend( {
parseSource: function () {
// eslint-disable-next-line
this._super.apply(this, arguments);
var img_layer_src;
var hs_config;
var hs_aria;
var $source_img = this.jq.closest('[data-type="box"]')
.find('.question_sequence_closing_material [data-type="metadata"] [key="source_images"]');
var $hs_choices = this.jq.closest('[data-type="box"]')
.find('.question_sequence_closing_material [data-type="metadata"] [key="hs_choices"]');
var $hs_aria = this.jq.closest('[data-type="box"]')
.find('.question_sequence_closing_material [data-type="metadata"] [key="hs_aria"]');
if ($source_img.length === 1 && $hs_choices.length === 1 && $hs_aria.length === 1) {
img_layer_src = JSON.parse($source_img.text());
hs_config = JSON.parse($hs_choices.text());
hs_aria = JSON.parse($hs_aria.text());
}
else if ('hs_choices' in this.md && 'source_images' in this.md && 'hs_aria' in this.md) {
img_layer_src = JSON.parse(this.md['source_images']);
hs_config = JSON.parse(this.md['hs_choices']);
hs_aria = JSON.parse(this.md['hs_aria']);
}
this.is_hs_type = (typeof img_layer_src !== 'undefined');
if (this.is_hs_type) {
var old_alts = [];
var graph_choices = [''];
var correct_choice = this.choices[this.correct_answer_index];
for (var i = 0; i < img_layer_src.length; i++) {
old_alts = graph_choices.slice(0);
graph_choices = [];
for (var j = 0; j < hs_config[i].length; j++) {
for (var k = 0; k < old_alts.length; k++) {
graph_choices.push(old_alts[k] + j);
}
}
}
this.choices = graph_choices;
this.correct_answer_index = this.choices.indexOf(correct_choice);
this.img_layer_src = img_layer_src;
this.hs_config = hs_config;
this.hs_aria = hs_aria;
}
},
postInit: function () {
var self = this;
var $hsLink = $('[data-query_index="' + self.query_index + '"] .hs_link');
var checkHs = function (event, img_layer_src, query_index) {
var curEls = event.currentTarget.parentNode.childNodes;
var i;
for (i = 0; i < curEls.length; i++) {
curEls[i].setAttribute('class', 'hs_link');
curEls[i].setAttribute('aria-checked', 'false');
}
event.currentTarget.setAttribute('class', 'hs_link active');
event.currentTarget.setAttribute('aria-checked', 'true');
var checked_hs_count = $(event.currentTarget).parents('.hs_query').find('.hs_link.active').length;
var $submitButton = $('#question_submit_button_' + (query_index + 1));
if (checked_hs_count === img_layer_src.length) {
$submitButton.removeClass('hs_submit_hidden');
}
else {
$submitButton.addClass('hs_submit_hidden');
}
};
$hsLink.live('keydown', function (event) {
var isSpace = event.key === ' ' || event.key === 'Spacebar' || event.keyCode == 32;
var isEnter = event.key === 'Enter' || event.keyCode === 13;
var isArrowDown = event.key === 'ArrowDown' || event.keyCode === 40;
var isArrowUp = event.key === 'ArrowUp' || event.keyCode === 38;
var isArrowLeft = event.key === 'ArrowLeft' || event.keyCode === 37;
var isArrowRight = event.key === 'ArrowRight' || event.keyCode === 39;
var $links;
var idx;
if (isSpace || isEnter) {
event.preventDefault();
var is_answered = self.user_answer_index !== null;
if (!is_answered) {
checkHs(event, self.img_layer_src, self.query_index);
}
}
else if (isArrowDown || isArrowRight) {
event.preventDefault();
$links = $(this).closest('[data-question_index]').find('.hs_link');
idx = $links.index($(this));
if (idx < $links.length - 1) {
$links.eq(idx + 1).focus();
}
}
else if (isArrowUp || isArrowLeft) {
event.preventDefault();
$links = $(this).closest('[data-question_index]').find('.hs_link');
idx = $links.index($(this));
if (idx > 0) {
$links.eq(idx - 1).focus();
}
}
}).live('click', function (event) {
event.preventDefault();
//safe_log(event);
var has_touch = 'ontouchstart' in window;
if (has_touch) return false;
//safe_log(self);
var is_answered = self.user_answer_index !== null;
//safe_log('is_answered = ' + is_answered);
if (!is_answered) {
checkHs(event, self.img_layer_src, self.query_index);
}
}).live('touchstart', function (event) {
event.preventDefault();
var has_touch = 'ontouchstart' in window;
if (!has_touch) return false;
var is_answered = self.user_answer_index !== null;
if (!is_answered) {
checkHs(event, self.img_layer_src, self.query_index);
}
});
},
getHTML: function (mode) {
if (this.is_hs_type) {
var html = '';
var i;
var disabled = '';
var j;
var checked_idx;
var needs_mark;
var is_answered = false;
var correct_idx = null;
var queryHtml = this.query_text_html();
var $query = $(queryHtml);
if ($query.is('legend')) {
queryHtml = $query.html();
}
html += '
';
html += '
' + queryHtml + '
';
// img_layer_src is just an array with one element, an object describing
// the brain image. We don't really need the for loop here as there is
// only ever one element in img_layer_src.
for (i = 0; i < this.img_layer_src.length; i++) {
is_answered = (this.user_answer_index !== null);
if (is_answered) {
checked_idx = +this.choices[this.user_answer_index].charAt(i);
correct_idx = +this.choices[this.correct_answer_index].charAt(i);
needs_mark = true;// (this.correct_answer_index !== this.user_answer_index);
}
else {
checked_idx = null;
correct_idx = null;
needs_mark = false;
}
html += '';
}
// Get a possible feedback string for each option
html += this.correct_incorrect_feedback();
html = dom.createHTML( html );
common.parseMathExpresions( html );
return html;
}
else {
return this._super.call(this, mode);
}
},
evaluateAnswer: function () {
if (this.is_hs_type) {
var checkedValue;
var $container = $('.hs_query[data-query_index="' + this.query_index + '"] svg');
var answer = [];
$container.each(function () {
var $el = $(this);
var field_index = $el.attr('data-field_index');
var $answer = $el.find('a.active');
if ($answer.length === 0) {
return false;
}
else {
answer[+field_index] = $answer.attr('data-hs_index');
}
});
if (answer.length === $container.length) {
var choiceIdx = this.choices.indexOf(answer.join(''));
if (choiceIdx > -1) checkedValue = choiceIdx;
}
if (typeof checkedValue !== 'undefined') {
// get the user's selected answer, which will be 0-based
this.user_answer_index = checkedValue * 1;
// set grade accordingly (if this.md.no_correct_answer is true, any answer is correct)
if ( this.user_answer_index === this.correct_answer_index || this.md.no_correct_answer == 'true' ) {
this.setGrade( 100 );
}
else {
this.setGrade( 0 );
}
return true;
}
else {
// if android and mc query, then clear feedback
if (platform.android || platform.ios || platform.mac) {
window.player.updateLiveRegion();
}
var text = this.parent_question.queries.length > 1
? 'Please answer all questions.' : 'Choose one option from the list.';
var textTitle = this.parent_question.queries.length > 1
? 'Please note' : 'Please note';
var $fromInitBtn = $('#question_submit_button_' + (this.query_index + 1) + ':visible'),
$fromElement = $fromInitBtn.length ?
$fromInitBtn :
$('#question_submit_button_' + this.parent_question.index);
window.Local_Dialog.open( '