// add SAVI video player stylesheet
// This is taken care of now in https://digitalfirst.bfwpub.com/savi_bc_df/asset/prod_1_0.js
/*
(function () {
var video_head = document.getElementsByTagName('head')[0];
var video_style = document.createElement('link');
video_style.href = 'https://savi-cdn.macmillantech.com/fonts/SourceSansPro/sourceSansPro.css';
video_style.type = 'text/css';
video_style.rel = 'stylesheet';
video_head.append(video_style);
})();
*/
// add custom SAVI CSS overrides to make responsive
// Doing this in initialize2 so it loads after main SAVI CSS file.
/*
(function () {
var video_head = document.getElementsByTagName('head')[0];
var video_style = document.createElement('link');
video_style.href = 'asset/css/savi_video_local.css';
video_style.type = 'text/css';
video_style.rel = 'stylesheet';
video_head.append(video_style);
})();
*/
/* brb: New code for HTML5 brightcove video player. Processing of videos
in DF takes place in the Figures.process_media method. So we need to
rewrite it to use the new player markup and methods. */
var FiguresOld = Figures.extend({
bcVideo: {}, // holds all of the video players (by ID)
bcPlayerData: { 'accountId': '1500315202001', 'playerId': 'B1AhVYg4l' },
process_media: function() {
var context = this;
// Process each video
$("[data-mmtype='mov']").each(function() {
var $this = $(this);
var $parent = $this.parent("[data-type='figure']");
var video_mmsrc = $this.attr("data-mmsrc");
//var video_id = "vidPlayerID";
var video_id = $parent.attr("data-figure-id");
var caption = "";
var $caption = $parent.find("[data-type='caption']");
if ($caption.length == 1) {
caption = "
" + $caption.html() + "
";
}
// Replace the current figure HTML with the new HTML5 video HTML
playerHTML = '
' + caption + '
';
$parent.before(playerHTML);
$parent.remove();
// instantiate the player
bc(document.getElementById(video_id));
// create player instance and set up cuepoints
//safe_log("creating video player");
videojs(video_id).ready(function() {
context.bcVideo[video_id] = this;
// reset the video to the beginning after it ends
context.bcVideo[video_id].on("ended", function() {
context.bcVideo[video_id].currentTime(0);
context.bcVideo[video_id].pause();
//$("#" + video_id).removeClass("vjs-has-started");
// update the LASX if needed
if (player.ARGA_running) {
var las = Number(Get_ARGA_Data("LASX"));
//safe_log("video ended");
//safe_log("LASX = " + las);
//safe_log("curr sec = " + player.section_currently_showing);
if (las <= player.section_currently_showing) {
Set_ARGA_Data("LVSX", player.section_currently_showing);
Set_ARGA_Data("LASX", (las+1));
player.activity.ARGA_submit_data(false);
}
}
$(".next_button").show();
$(".next_button").focus();
});
context.bcVideo[video_id].on("play", function() {
//$("#" + video_id).addClass("vjs-has-started");
});
}); //end ready
});
} // end process_media
});
var Activity_ays = Activity_manuscript.extend({
congratulations_msg: undefined,
// override method to get rid of grade percentage in completed pop-up
ARGA_initialization_alert: function() {
// This overrides the standard ARGA initialization message, which doesn't
// tell the user he/she can resubmit (or tell him his grade)
var grade = Get_ARGA_Grade();
var due_date_passed = (Get_ARGA_Data("due_date_has_passed") == "1");
var msg = "";
var buttons;
due_date_passed = false;
if (grade != "" && grade != null && grade >= 0) {
// if resubmissions are allowed...
if (player.md.allow_resubmission == "true") {
// if due date has not passed, give the student the option of resubmitting or reviewing
if (!due_date_passed) {
msg = "
You have completed this activity, and your grade (" + grade + "%) has been submitted. Would you like to:
"
+ "
Keep your current grade and review your previous answers
"
+ "
Or reset your submission and try the activity again?
You have completed this activity, and your grade (" + grade + "%) has been submitted. Since the due date for the activity has now passed, you cannot re-submit answers to the activity questions.
You have completed this activity, and your grade has been submitted.
"
;
buttons = [ {text:"OK", click: player.activity.ARGA_initialization_final} ];
}
// grade has not been submitted
} else {
// if due date has passed, tell the user "tough luck". Otherwise show nothing.
if (due_date_passed) {
msg = "
The due date for this activity has passed. You can still review the activity, but no answers will be submitted and no grade will be recorded.
"
;
buttons = [ {text:"OK", click: player.activity.ARGA_initialization_final} ];
}
}
// if we need a message, show it in a jquery UI dialog
if (msg != "") {
msg = "
" + msg + "
";
$("body").append(msg);
$("#arga_init_dialog").dialog({title:"Please Note", width:450, modal:true, buttons: buttons});
} else {
player.activity.ARGA_initialization_final();
}
},
show_grade_saved_message: function() {
//safe_log("show_grade_saved_message: enter");
//safe_log("show_grade_saved_message: congratulations msg = " + this.congratulations_msg);
// if the user has answered all queries AND the user hasn't been told this already,
// tell them now
if (player.activity.answered_all_queries && !player.user_has_received_completion_alert) {
var msg = "You have completed the activity, and your grade has been submitted.";
if (this.congratulations_msg !== undefined) {
msg = this.congratulations_msg;
}
function show_message() {
Standard_Dialog.alert(msg);
}
setTimeout(show_message, 20);
player.user_has_received_completion_alert = true;
}
},
ARGA_initialization_final: function(decision) {
//safe_log("ARGA_initialization_final: enter (" + decision + ")");
//safe_log("ARGA_initialization_final: metadata");
//safe_log(player.md);
// close dialog if open
$("#arga_init_dialog").dialog('close');
// if user chose to reset the activity, reset all submitted answers and grade
if (decision == "reset") {
// PW: ARGA should really provide a function for resetting all data; for now I'll hack it
ARGA_API.data = new Array();
Set_ARGA_Grade(-1);
player.user_has_received_completion_alert = false;
Save_ARGA_Data({"show_progress":false});
// start on section 0
player.show_section(0);
// else if user is here for the first time...
} else if (player.ARGA_submission_initialized == false) {
//safe_log("ARGA_initialization_final: ARGA_submission_initialized == false");
// initialize the questions
player.activity.ARGA_Initialize_Questions();
// and show the first questions
player.show_section(0);
// otherwise normal re-initialization
} else {
//safe_log("ARGA_initialization_final: normal re-initialization");
// if md.restore_previous_submissions is "true" (this is the default value),
// restore all saved answers
if (player.md.restore_previous_submissions == "true") {
//safe_log("ARGA_initialization_final: retstoring saved answers");
player.activity.restore_saved_answers();
}
// grade the activity
//safe_log("ARGA_initialization_final: grade activity");
player.activity.grade_activity();
// set user_has_received_completion_alert to true
// if the user has already completed the activity
if (Get_ARGA_Data("complete") == "yes") {
player.user_has_received_completion_alert = true;
}
// restore to previously-viewed section if appropriate
if (player.md.restore_last_viewed_section == "true") {
//safe_log("ARGA_initialization_final: restoring last viewed section");
player.restore_section();
// otherwise show section 0
} else {
player.show_section(0);
}
}
},
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("
Please answer all of the questions before submitting.
",{
from: this,
modal: true,
buttons: [{
text: "OK",
click: function () {
Standard_Dialog.close();
}
}]
});
return false;
}
//safe_log("submit_question: calling super with question_index = " + question_index);
this._super(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;
}
*/
player.activity.questions[question_index].checkModelUpdateConditionals(question_index);
//check if we need to show the next button
//safe_log(player.get_current_section_jq().find(".next_section_button").attr("role"));
player.get_current_section_jq().find(".next_section_button").show();
// show text after submitting
var curSection = player.get_current_section();
var lastSectionIndex = player.sections.length - 1;
var submitMessageDiv = document.createElement('div');
submitMessageDiv.setAttribute('class','submit_message');
if( curSection.index != lastSectionIndex ) {
Standard_Dialog.open("
Your answers have been submitted. Please click NEXT to move to the next screen.
", {
from: player.sections[player.section_currently_showing].jq.find('.next_button'),
modal: true,
buttons: [{
text: "OK",
click: function () {
Standard_Dialog.close();
}
}]
});
}
//STG set focus on continue button, so 'continue' button shows up in the window, not below
$('button.next_section_button').focus();
//insert any variables that may be newly displayed in the question feedback
player.show_variables();
// calculate score
player.activity.calculate_score(curSection, question_index);
$(".next_button").show();
//return false;
},
calculate_score: function(curSection, question_index) {
//move the feedback into a nice popup
$("[data-question_index=" + question_index + "]").find(".query_mc_feedback_correct_incorrect").dialog({
buttons: [{
text: "OK",
click: function () {
$(this).dialog("close");
}
}]
});
var feedback = document.querySelector(".question_feedback_part");
if( feedback ) {
feedback.setAttribute("tabindex", "0");
var feedbackAriaLabel = feedback.textContent;
feedback.setAttribute("aria-label", feedbackAriaLabel);
}
var finalQuestionIndex = player.activity.questions.length - 1;
var curQuestion = player.activity.questions[finalQuestionIndex];
var numOfQuestions = curQuestion.queries.length;
if( curSection.all_questions_answered && question_index == finalQuestionIndex ) {
var userAnswer, correctAnswer, curQuery, boldAnswer;
var score = 0;
for( i = 0; i < numOfQuestions; i++ ) {
if( curQuestion.queries[i].answerType == "string" ) {
userAnswer = curQuestion.queries[i].user_answer;
correctAnswer = curQuestion.queries[i].correct_answer;
if ( userAnswer.toLowerCase() == correctAnswer.toLowerCase() ) {
score++;
}
} else {
userAnswer = curQuestion.queries[i].user_answer_index;
correctAnswer = curQuestion.queries[i].correct_answer_index;
if (userAnswer == correctAnswer) {
score++;
}
curQuery = curSection.jq.find('[data-type=query]')[i];
boldAnswer = curQuery.querySelectorAll('label')[correctAnswer];
boldAnswer.style.fontWeight = "bold";
}
}
var activityName = player.md.activity_type_title;
// brb: remove percentage from message
var conString = "Congratulations! You have completed the activity \"" +
activityName + ",\" and your grade has been submitted.";
this.congratulations_msg = conString;
/*
var conDialog = "
" + conString + "
";
Standard_Dialog.open(conDialog,{
modal: true,
buttons: [{
text: "OK",
click: function () {
Standard_Dialog.close();
feedback.focus();
}
}]
});
*/
return false;
}
},
is_instructor: function() {
return ( player.ARGA_running && Get_ARGA_Data('user_rights') == '3_instructor' || player.instructor );
}
});
var completeVideo = false;
var Player_ays = Player_manuscript.extend({
model: {},
initialize2: function() {
this._super();
// add custom SAVI CSS overrides to make responsive
(function () {
var video_head = document.getElementsByTagName('head')[0];
var video_style = document.createElement('link');
video_style.href = 'asset/css/savi_video_local.css';
video_style.type = 'text/css';
video_style.rel = 'stylesheet';
video_head.append(video_style);
})();
// load savi brightcove library
// we have to load this here because there is an issue in Variables.init
// in which the entire html in the manuscript div is replaced and we have
// to wait for that to happen before activiating the savi-brightcove library
$.getScript("https://savi-cdn.macmillantech.com/brightcove/savi-brightcove-player.js", function (data, textStatus, jqxhr) {
});
// brb: Need to set allowfullscreen to true on parent iframe so videos
// can go to full screen
/*
$('#document-body-iframe', window.parent.document).attr('allowfullscreen', 'true').attr('mozallowfullscreen', 'true').attr('webkitallowfullscreen', 'true');
*/
},
tab_selected: function (event, ui){
var las;
if (player.ARGA_running) {
las = Get_ARGA_Data("LASX");
}
else {
las = 0;
}
//safe_log("tab_selected: entered function");
//safe_log("tab_selected: player.section_currently_showing = " + player.section_currently_showing);
//safe_log("tab_selected: lvs = " + lvs + ", las = " + las);
// we don't actually use event;
// it's just there because it's part of the standard jquery ui fn prototype
$('[data-type=chapter]').attr('tabindex', '-1');
$('[data-type=chapter]').attr('aria-label', '');
var current_section = null;
if (player.section_currently_showing !== null) {
current_section = window.player.sections[player.section_currently_showing];
}
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 ( section_to_show > player.last_available_section ) {
// Let pass through
if ( player.activity.is_instructor() || player.md.sequenced_sections !== "true" ) {
Standard_Dialog.open("Please note: Students need to read and complete each section of the activity before moving on to the next section. " +
"Instructors, however, can skip around between sections as they choose.");
}
else {
Standard_Dialog.open(player.md.section_sequence_message);
return false;
}
}
var videoSection = player.get_current_section_jq().find("[data-block_type=video-container]").length > 0;
// Bruce: The video has been completed if the last available section (LASX) is
// greater than 0.
if (!completeVideo && las > 0) {
completeVideo = true;
}
if ( videoSection && !completeVideo ) {
if ( player.activity.is_instructor() || player.md.sequenced_sections !== "true" ) {
Standard_Dialog.open("Please note: Students need to read and complete each section of the activity before moving on to the next section. " +
"Instructors, however, can skip around between sections as they choose.");
}
else {
Standard_Dialog.open("You will be able to move to the next screen after you have watched the video!");
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.hide_section(current_section);
player.show_section_animate(section_to_show);
player.update_section_status();
player.update_navigation();
/*
if( videoSection ) {
var figureId = $( '#digfir_section_0 [data-type="figure"]' ).data( 'figure-id' );
var videoPlayer = brightcove.api.getExperience( figureId );
var playerModule = videoPlayer.getModule( brightcove.api.modules.APIModules.VIDEO_PLAYER );
playerModule.pause();
}
*/
window.scrollTo(0, 0);
},
hide_section: function (section) {
'use strict';
if (section && section.md.section_type && window.mheAYS[section.md.section_type]) {
if (window.mheAYS[section.md.section_type].hide) {
window.mheAYS[section.md.section_type].hide(section);
}
}
},
show_navigation: function () {
// this._super(); return;
var title = "
Assess Your Strengths
";
var html = "
"
+ "
" + title + "
" + this.md.activity_type_title + "
"
+ "
"
;
for (var i = 0; i < this.sections.length; ++i) {
var s = this.sections[i];
html += "
"
;
// also insert a "next" button at the bottom of each section, unless it's the last one
if (i < this.sections.length - 1) {
s.jq.append("
");
}
}
html += "
";
var self = this;
$("[data-type=chapter]").prepend(html).tabs({
select: self.tab_selected,
fx: {opacity: 'toggle', duration: 100}
});
var LEFT_ARROW_KEY = 37;
var RIGHT_ARROW_KEY = 39;
var CustomTabs = function( $jq ) {
this.$jq = $jq;
this.$li = $jq.find('li a');
this.index = 0;
// Disable all tabindex attr on $jq
this._disableAll();
this.$jq.attr('role', 'tablist');
this.$li.attr('role', 'tab');
// Attach listeners
var cTabs = this;
this.$li.click( function(){
if ( cTabs.stopEvents ) {
return false;
}
cTabs._disableAll();
// Get index of node was clicked by
var index = cTabs.$li.index( this );
cTabs.setMenuActive( index, true );
});
this.$li.keydown( function( event ){
var key = event.keyCode;
var l = cTabs.$li.length;
var newIndex = cTabs.index;
var changes = false;
if ( key === LEFT_ARROW_KEY && cTabs.index >= 1 ) {
--newIndex;
changes = true;
}
if ( key === RIGHT_ARROW_KEY && cTabs.index < l - 1 ) {
++newIndex;
changes = true;
}
if ( changes ) {
cTabs.setMenuActive( newIndex );
}
});
$(".next_button").click( function() {
var newIndex = cTabs.index;
++newIndex;
cTabs.setMenuActive( newIndex );
});
// Set first menu as active element
this.setMenuActive( 0 );
};
CustomTabs.prototype.setMenuActive = function( index, fake ) {
var cTabs = this;
this.stopEvents = true;
this.prevIndex = this.index;
this.index = index;
this.$li[this.prevIndex].setAttribute('tabindex', '-1');
this.$li[this.index].setAttribute('tabindex', '0');
this.$li[this.prevIndex].setAttribute('aria-selected', 'false');
this.$li[this.index].setAttribute('aria-selected', 'true');
if ( !fake ) {
this.$li[this.index].click();
}
if ( this.index <= player.last_available_section && completeVideo ) {
this.$li[this.index].focus();
} else {
Standard_Dialog.onceCallback = function(){
cTabs.setMenuActive( cTabs.prevIndex, true );
}
}
this.stopEvents = false;
};
CustomTabs.prototype._disableAll = function(){
$.each( this.$li, function( index, node ) {
node.setAttribute('tabindex', '-1');
node.setAttribute('aria-selected', 'false');
} );
};
//var $tabs = $("li.ui-state-default a");
var $tabs = $("#activity_top ul");
new CustomTabs( $tabs );
player.tab_jq = $("[data-type=chapter]");
},
show_section: function (section_to_show) {
//safe_log("show_section: section_to_show = " + section_to_show);
//safe_log("show_section: section_currently_showing = " + this.section_currently_showing);
if (section_to_show == "previous") {
section_to_show = this.section_currently_showing - 1;
} else if (section_to_show == "next") {
section_to_show = this.section_currently_showing + 1;
}
//safe_log("show_section: this.sections.length = " + this.sections.length);
if (section_to_show == null || isNaN(section_to_show) || section_to_show < 0 || section_to_show >= this.sections.length) {
//safe_log("show_section: section_to_show >= this.sections.length, returning");
return;
}
// but for some reason tab_selected isn't running properly when we first start,
// so make sure player.section_currently_showing got updated
//safe_log("show_section: updating player.section_currently_showing");
if (player.section_currently_showing != section_to_show) {
player.section_currently_showing = section_to_show;
// and call update_section_status in this case too
player.update_section_status();
}
// callling jquery ui's tabs() here will call tab_selected below,
// which will take care of calling update_section_status and updating
// the navigation (in this case, showing the right tab).
//safe_log("show_section: calling tabs()");
player.tab_jq.tabs("select", section_to_show);
// but for some reason tab_selected isn't running properly when we first start,
// so make sure player.section_currently_showing got updated
/* Bruce: moving this above the call to tabs() because it depends on
player.section_currently_showing being correct */
/*
safe_log("show_section: updating player.section_currently_showing");
if (player.section_currently_showing != section_to_show) {
player.section_currently_showing = section_to_show;
// and call update_section_status in this case too
player.update_section_status();
}
*/
// process iframes for the section, unless all were preloaded
if (player.md.preload_all_iframes != "true") {
this.figures.process_iframes(this.get_current_section().jq); // iframes
}
var videoSection = player.get_current_section_jq().find("[data-block_type=video-container]");
var videoPlayer, playerModule;
/*
if( videoSection.length > 0 && !completeVideo ) {
var figureId = $( '#digfir_section_0 [data-type="figure"]' ).data( 'figure-id' );
var ready = false;
var timerId = setInterval( function() {
var refreshIntervalId = setInterval( function() {
if( brightcove.api.getExperience(figureId) ) {
videoPlayer = brightcove.api.getExperience(figureId);
ready = true;
clearInterval(refreshIntervalId);
}
}, 1000);
if( ready ) {
playerModule = videoPlayer.getModule( brightcove.api.modules.APIModules.VIDEO_PLAYER );
playerModule.addEventListener( brightcove.api.events.MediaEvent.COMPLETE, function() {
completeVideo = true;
$(".next_button").show();
$(".next_button").focus();
} );
clearInterval(timerId);
}
}, 1000 );
}
*/
/*
if( !videoSection ) {
var figureId = $( '#digfir_section_0 [data-type="figure"]' ).data( 'figure-id' );
videoPlayer = brightcove.api.getExperience( figureId );
playerModule = videoPlayer.getModule( brightcove.api.modules.APIModules.VIDEO_PLAYER );
playerModule.pause();
}
*/
var ddSelect = player.sections[section_to_show].jq.find('.query_dd_select');
var isTable = player.sections[section_to_show].jq.find('table');
if( ddSelect.length > 0) {
$('.query_dd_select').each( function() {
var $p, pID, pText;
if ( isTable.length > 0 ) {
$p = $(this).parent().parent().prev('td').find('p')
} else {
$p = $(this).parent().parent().find('p');
}
pID = $p.attr('id');
pText = $p.text();
//$(this).attr('aria-describedby', pID);
$(this).attr('aria-label', pText);
$(this).attr('role', 'combobox')
} );
}
},
// Bruce: This function should be overridden in chapter-specific JS files
// as needed.
set_my_score: function() {
//safe_log("set_my_score: default");
var total = 0;
$('#digfir_section_1').find(':selected').each(function() {
var $this = $(this);
total += (parseInt($this.val()) + 1);
});
//safe_log("set_my_score: my score = " + total);
if (total > 0) {
$('[data-block_type="my_score"]').text(total);
}
},
update_section_status: function () {
// Bruce: We need to get the total score of the previous section if it doesn't
// already exist
if (player.ARGA_running) {
var lvs = Get_ARGA_Data("LVSX");
var las = Get_ARGA_Data("LASX");
if (this.section_currently_showing === null) {
//safe_log("update_section_status: setting section_currently_showing to " + lvs);
this.section_currently_showing = lvs;
}
// Bruce: The video has been completed if the last available
// section (LASX) is greater than 0.
if (!completeVideo && las > 0) {
completeVideo = true;
}
}
//safe_log("update_section_status: enter");
//safe_log("update_section_status: section_currently_showing = " + player.section_currently_showing);
//safe_log("update_section_status: this.get_current_section_jq =");
//safe_log(this.get_current_section_jq());
this._super();
//safe_log("update_section_status: post super");
//safe_log("update_section_status: this.get_current_section_jq =");
//safe_log(this.get_current_section_jq());
//safe_log("update_section_status: section_currently_showing = " + player.section_currently_showing);
player.show_variables();
if (this.get_current_section_jq() !== null) {
//handle the next button;
var section = this.get_current_section_jq();
var curSection = player.get_current_section();
// if we are looking at the third tab then get the score from the
// second tab and insert it into results
if (player.section_currently_showing == 2) {
this.set_my_score();
}
if ( section.find("[data-type=question]").length > 0 ) {
$(section).find(".next_button").hide();
} else if( section.find(".next_screen_button").length == 0 ) {
//make sure its not the last section
$(section).find(".next_button").show();
}
if( curSection.all_questions_answered
&& section.find(".next_screen_button").length == 0) {
$(section).find(".next_button").show();
}
if( section.find("[data-type=question]").length > 0 ) {
var messageNode = document.querySelector(".submit_message_text");
var parent = document.querySelector("#question_action_div_1");
if(messageNode) {
parent.removeChild(messageNode);
}
}
if ( section.find("[data-block_type=video-container]").length > 0 && !completeVideo ) {
$(".next_button").hide();
}
}
player.process_conditional_display(section);
},
show_section_animate: function (section_to_show) {
'use strict';
// Hide currently showing section
if (this.section_currently_showing !== null) {
this.sections[this.section_currently_showing].jq.hide();
}
this.section_currently_showing = section_to_show;
var section = this.sections[section_to_show];
section.jq.show();
if (section_to_show === 0 && !this.show_in_first_time) {
this.show_in_first_time = true;
$('[data-type=chapter]').focus();
}
else {
section.jq.focus();
}
$('.slide_title').html(section.title);
// Update slide number
$('#slide_number').html('slide ' + ( section_to_show + 1 ) + ' of ' + this.sections.length);
// If this is the first/last section, disabled the previous/next button
if (this.section_currently_showing === 0) {
$('.prev_button').attr('disabled', 'disabled');
}
else {
$('.prev_button').attr('disabled', '');
}
if (section.md.section_type && window.mheAYS[section.md.section_type]) {
if (window.mheAYS[section.md.section_type].show) {
window.mheAYS[section.md.section_type].show(section);
}
}
},
//show_navigation: function(){
// this._super();
//
// var $activity_title = $('#activity_type');
//
// $activity_title.attr('tabindex', '0')
// .attr('aria-label', $activity_title.text());
//
// /*var navHtml = UI_Elements.get_button_html({
// id: "next_button2",
// extra_class: "toolbar_button prev_next_buttons",
// label: "Next",
// fn: 'player.show_section("next")'
// });
// */
//
// //$("[data-type=chapter]").append(navHtml);
// //$("#next_button2").button();
//},
show_variables: function () {
//look through all the p nodes
var section = this.get_current_section_jq();
var regex = new RegExp("{(.+?)}", "gmi");
// old parsed tags is [p, label, option, table]
$(section).find("p, label").each(function (index, element) {
var oldText = $(element).html();
var newText = oldText.replace(regex, function (a, b) {
return eval("player." + b );
});
if ( oldText.localeCompare(newText) !== 0 ) {
var attr = element.getAttribute("aria-label");
if ( attr ) {
attr = attr.replace(regex, function (a, b) {
return eval("player." + b);
});
element.setAttribute("aria-label", attr);
}
$(element).html(newText);
}
});
},
process_conditional_display: function (section_to_show) {
//safe_log("process_conditional_display: enter, section_to_show = " + section_to_show);
var h = section_to_show;
player.get_current_section_jq().find("[data-block_type=conditional_display]").each(function (index, element) {
var md = new Metadata({jq: $(element).children("[data-type=box_inner]").children("[data-type=metadata]")});
var condition = md["display_conditional"];
// alert("condition: " + condition);
if (typeof condition != 'undefined') {
condition = condition.replace(/model/g, "player.model");
condition = condition.replace(/&/g, "\&");
var div = document.createElement('div');
div.innerHTML = condition;
condition = div.firstChild.nodeValue;
if (eval(condition)) {
//if this displayed box has questions, make sure any next_section_button boxes are hidden
if ($(element).children().children("[data-type=question]").length > 0) {
player.get_current_section_jq().find(".next_section_button").hide();
}
$(element).show();
//now run the model updates in the block
// player.initialize_explain(element);
//safe_log("condition met");
}
}
});
},
processNextStepConditionals: function (s) {
for (var i = 0; i < s.md["next_step_conditional"].length; ++i) {
var c = s.md.next_step_conditional[i];
if (c.search(/\{(.*)\}\s*\{(.*)\}/) > -1) {
// extract condition, section to show if it's met
c = new Object();
c.condition = RegExp.$1;
c.section_to_show = RegExp.$2;
c.message = $.trim(RegExp.$3);
c.condition = this.processCondition(c.condition);
s.md.next_step_conditional[i] = c;
} else {
//safe_log("bad conditional step: " + c);
s.md.next_step_conditional[i] = {condition: "false"};
}
}
},
processModelUpdateConditionals: function (s) {
for (var i = 0; i < s.md["model_update_conditional"].length; ++i) {
var c = s.md.model_update_conditional[i];
if (c.search(/\{(.*)\}\s*(.*)/) > -1) {
// extract condition, section to show if it's met, and optional message
c = {};
c.condition = RegExp.$1;
c.updateStatement = RegExp.$2;
c.updateStatement = this.processCondition(c.updateStatement);
c.condition = this.processCondition(c.condition);
s.md.model_update_conditional[i] = c;
} else {
//safe_log("bad conditional step: " + c);
s.md.model_update_conditional[i] = {condition: "false"};
}
}
},
processCondition: function (condition) {
// < > in condition
condition = condition.replace(//g, ">");
var div = document.createElement('div');
div.innerHTML = condition;
var condition = div.firstChild.nodeValue;
// substitute for queries in condition...
// query is correct or incorrect
condition = condition.replace(/qq(\d+)\s*==\s*true/g, "qq.queries[$1-1].isCorrect()");
condition = condition.replace(/qq(\d+)\s*==\s*false/g, "!qq.queries[$1-1].isCorrect()");
//check for a certain MC answer
condition = condition.replace(/qqMC(\d+)/g, "qq.queries[$1-1].user_answer_index");
// otherwise assume it's something about query.user_answer
condition = condition.replace(/qq(\d+)/g, "qq.queries[$1-1].user_answer");
// note that everything is going to be a string compare unless the condition includes "*1",
// i.e. qq1*1 < 4
//for update statements, get string value of a MC or DD
condition = condition.replace(/qqMCValue(\d+)/g, "qq.queries[$1-1].choices[qq.queries[$1-1].user_answer_index]");
// now conditions on the entire question -- just allow correct and incorrect
condition = condition.replace(/qq\s*==\s*true/g, "qq.is_correct()");
condition = condition.replace(/qq\s*==\s*false/g, "!qq.is_correct()");
return condition;
},
setModel: function (key, value, loadOnInit) {
//console.log(key, value );
if (key.match(/^userAvatar\./)) {
var newkey = key.substring(11, key.length);
player.model.userAvatar[newkey] = value;
} else if (key.match(/^partnerAvatar\./)) {
var newkey = key.substring(14, key.length);
player.model.partnerAvatar[newkey] = value;
} else if (key.match(/^avatar\./)) {
var newkey = key.substring(7, key.length);
player.model.avatar[newkey] = value;
} else {
player.model[key] = value;
}
},
initialize: function () {
//safe_log("Version 1001");
this._super();
this.activity = new Activity_ays();
//this.figures = new AYS_Figures();
if( window.location.search ){
var p = window.location.search.substr( 1 ).split( "=", 2 );
var b = {};
if( p.length === 1 ){
b[p[0]] = "";
} else {
p[1] = p[1].toLowerCase();
b[p[0]] = decodeURIComponent( p[1].replace( /\+/g, " " ) );
}
this.instructor = ( b["role"] === "instructor" );
}
// Manuscript
//var $manuscript = $('#manuscript');
//$manuscript.attr('role', 'application');
// Chapter
var $chapter = $('[data-type=chapter]');
var main_title = $("[key=activity_type_title]").html();
$chapter.attr('tabindex', '0')
.attr('aria-label', 'You are taking test in the course Concept Practice. ' +
'You need to read each section and answer all questions to pass the activity ' + main_title);
this.silentElement = $('');
$chapter.append(this.silentElement);
// Section
$('[data-type="section"]').attr('tabindex', '0');
$('[data-type="section"]').attr('aria-label', '');
//$('[data-type="section"]').attr('role', 'tabpanel');
var videoSection = $('[data-type="section"]')[0];
var video = $('[data-block_type="video-container"]').find('[data-type="figure"]');
var videoText = videoSection.querySelector("p").innerText;
videoSection.setAttribute('tabindex', '-1');
video.attr("aria-label", videoText);
// Images
$('[data-block_type="figure_text"]').attr('aria-hidden', 'true');
$('img').attr('aria-hidden', 'true');
$('img').attr('alt', '');
$('img').before('1');
// Tables
$('table').attr('role', 'document');
// Video
var $video = $('[data-block_type="video-container"]').find('[data-type="figure"]');
$video.attr('role', 'application');
//var $question = $('[data-block_type="question-container"]');
//var $query = $question.find('[data-type="query"]');
//$query.attr('role', 'application');
// Source
$('[data-block_type="reference"]').attr('tabindex', '0');
// Lists
$('li').each( function(i, value) {
$(value).html('• ' + $(value).html());
});
player.show_source_buttons();
},
show_source_buttons: function() {
//Show source buttons
var referenceBlock = $('[data-block_type="references"]');
referenceBlock.each( function( i, v ) {
var sourceBtn = document.createElement("button");
sourceBtn.setAttribute("class", "source-btn");
if( $(v).find('p').length > 1 ) {
sourceBtn.innerHTML = "Sources";
} else {
sourceBtn.innerHTML = "Source";
}
var referenceButton = $(v).find('[data-block_type="references_button"]');
referenceButton.append(sourceBtn);
} );
$('.source-btn').click( function() {
var referenceList = $(this).parent().parent().find('[data-block_type="references_list"]');
var curSection = player.get_current_section_jq();
var nextButton = curSection.find('.next_button');
if ( referenceList.is(":visible") ) {
referenceList.hide();
nextButton.css('margin-top', '-38px');
} else {
referenceList.show();
referenceList.attr('tabindex','0');
referenceList.focus();
var top = -referenceList.css('height').match(/\d+/g) - 58;
nextButton.css('margin-top', top + 'px');
//setTimeout( function(){ this.focus(); }, 500 );
}
} );
},
initialize_sections: function () {
var player = this; // define this so it's available inside the below function
var self = this;
$("[data-type='section']").each(function (index, element) {
var jq = $(element);
// establish the section in the sections array; store its jq
var s = player.sections[player.sections.length] = {};
s.jq = jq;
// set the section's index
s.index = index;
jq.attr("data-section-index", index).attr("id", "digfir_section_" + index);
// extract the section's title and number
s.number = jq.find("h2").find("[data-type=number]").html();
s.title = jq.find("h2").find("[data-type=title]").html();
// process page queries for the section
player.activity.process_page_queries_for_section(jq);
++player.section_count;
s.md = new window.Metadata({lowercase_keys: true});
s.md.add_from_jq(s.jq.children('[data-type=metadata]'));
if (s.md.section_type && window.mheAYS[s.md.section_type]) {
var initialize = window.mheAYS[s.md.section_type].initialize;
if (initialize) {
initialize(s);
}
}
});
// we need to do this here because the ids on the sections are not set
// until super() is called
this.savi_bc_videos = new SaviBcVideoCollection();
}
});
Question = Question.extend({
extract_metadata: function () {
if (this.jq == null) {
return;
}
this.md.add_from_jq(this.jq.children("[data-type=metadata]"));
player.processNextStepConditionals(this);
player.processModelUpdateConditionals(this);
},
checkModelUpdateConditionals: function (question_index) {
var q_string = "player.activity.questions[" + question_index + "]";
for (var i = 0; i < player.activity.questions[question_index].md.model_update_conditional.length; ++i) {
var c = player.activity.questions[question_index].md.model_update_conditional[i];
var condition = c.condition.replace(/qq/g, q_string);
condition = condition.replace(/model/g, "player.model");
var updateStatement = c.updateStatement.replace(/setModel/g, "player.setModel");
updateStatement = updateStatement.replace(/model/g, "player.model");
updateStatement = updateStatement.replace(/qq/g, q_string);
updateStatement = unescape(updateStatement);
condition = unescape(condition);
condition = condition.replace(/&/g, '&');
if (condition == "else" || eval(condition) == true) {
// if section_to_show is "done", we're done!
//safe_log("triggering model update from question");
eval(updateStatement);
}
}
return null;
}
});
DD_Query = DD_Query.extend({
user_has_answered: function () {
var x = $('#query_answer_' + this.query_index).val();
return x != -1;
},
getHTML: function (mode) {
var html = this.query_text_html();
var ariaLabel = $(html).text();
if (this.userHasAnswered() || mode == 'review' || mode == 'review_correct_incorrect' || mode == 'preview') {
ariaLabel += ' You already answered this question.';
}
else {
ariaLabel += ' Answer the question and click Submit button.';
}
ariaLabel = ariaLabel.replace(/\"/g, '');
html = html.replace('>', 'aria-label="' + ariaLabel + '" tabindex="0"> ');
// if we're in preview mode or
// (a student answer has been given and we're not in review_correct_incorrect mode),
// or the student got it correct
// disable the select
var disabled = "";
if (mode == 'preview' || (mode != 'review_correct_incorrect' && this.user_answer_index != null) || this.isCorrect()) {
disabled = "disabled";
}
html = this.query_text_html();
ariaLabel = $(html).text();
if (this.userHasAnswered() || mode == 'review' || mode == 'review_correct_incorrect' || mode == 'preview') {
ariaLabel += ' You already answered this question.';
}
else {
ariaLabel += ' Answer the question and click Submit button.';
}
ariaLabel = ariaLabel.replace(/\"/g, '');
html = html.replace('>', 'aria-label="' + ariaLabel + '" tabindex="0"> ');
html += '';
html += this.finish_inline_query(this.choices[this.correct_answer_index], mode);
// Close off the nobr tag for the item
html += '';
return html;
}
});
MC_Query = MC_Query.extend({
user_has_answered: function () {
if (typeof $('input:radio[name=query_answer_' + this.query_index + ']:checked').val() != "undefined") {
return true;
} else {
return false;
}
},
getHTML: function (mode) {
// initialize imagemap elements
if (this.imagemap_initialized === false) {
var question_jq = this.jq.parent();
this.im_init(question_jq);
this.imagemap_initialized = true;
}
// start with the query text, if there
var html = this.query_text_html();
var oldAriaString = html.match(/_{2,20}/g);
if( oldAriaString ) {
$(oldAriaString).each( function(i, value) {
var newAriaString = '' + value + 'blank';
html = html.replace(value, newAriaString);
} );
}
var ariaLabel = $(html).text();
ariaLabel = ariaLabel.replace(/_{2,20}/g, '');
if (this.userHasAnswered() || mode == 'review' || mode == 'review_correct_incorrect' || mode == 'preview') {
ariaLabel += ' You already answered this question.';
}
else {
ariaLabel += ' Answer the question and click Submit button.';
}
ariaLabel = ariaLabel.replace(/\"/g, '');
html = html.replace('>', 'aria-label="' + ariaLabel + '" tabindex="0"> ');
// wrap answers in a p tag
html += "
";
// Build answer selection
var is_correct = false;
for (var z = 0; z < this.choices.length; z++) {
var index = this.choice_order[z];
// if this is review mode...
var checked = "";
var disabled = "";
var radio_style = "query_mc_other_choice";
if (mode == 'review' || mode == 'review_correct_incorrect' || mode == 'preview') {
// if it's the correct choice, it should be marked in green
if (index == this.correct_answer_index) {
// but only if we're *not* in review_correct_incorrect mode or this is the user's choice
if (mode != 'review_correct_incorrect' || index == this.user_answer_index) {
//radio_style = "query_mc_correct_choice";
}
// if this is what the user chose, he got it correct
if (index == this.user_answer_index) {
is_correct = true;
}
// else if it's the user's choice (and this.md.no_correct_answer is not true), it should be marked in red
} else if (index == this.user_answer_index && this.md.no_correct_answer != "true") {
// radio_style = "query_mc_incorrect_user_choice";
}
// and the input should be disabled, unless we're in review_correct_incorrect mode
if (mode != "review_correct_incorrect") {
disabled = "disabled";
}
}
// if this is the choice the user clicked, it's checked (regardless of mode)
if (index == this.user_answer_index) {
checked = "checked";
}
// Create radio button input plus label
// html += "
"
// + "
"
// + "
"
// + "
" + this.choice_ids[z] + ".
"
// + "
"
// + "
";
html += ""
+ ""
+ ""
+ " ";
}
// get a possible feedback string; this fn will take account of mode
html += this.correct_incorrect_feedback(mode, is_correct);
html += "
";
// $('.query_mc_choice_radio').each(function (i) {
// $(this).attr('aria-label', $(this).find('label').text());
// });
return html;
},
correct_incorrect_feedback: function (mode, is_correct) {
var html = "";
// get correct answer as presented to user
for (var i = 0; i < this.choices.length; ++i) {
if (this.choice_order[i] == this.correct_answer_index) {
break;
}
}
// if the question explicitly defines feedback for the user's answer, use it as the feedback
if (this.user_answer_index != null && this.choices_fb[this.user_answer_index] != null) {
html += this.choices_fb[this.user_answer_index];
}
// the correct answer will be highlighted in green, so there's no reason to say anything more.
// now, if we got any feedback, enclose it in a div
if (html != "") {
html = "
" + html + "
";
}
return html;
}
});
/* brb: We aren't using this class any more. We are using the new
HTML video player which is defined at the top of this file. */
var AYS_Figures = Figures.extend({
process_media: function() {
// we're not currently using this (jwplayer is not being included)
$("[data-mmtype='mp3']").each(function(index, element) {
var jq = $(element);
var id = jq.attr("data-figure-id");
var mmsrc = jq.attr("data-mmsrc");
// http://www.longtailvideo.com/jw/upload/bunny.mp3
// http://www.youtube.com/embed/CsGYh8AacgY
var src = jq.attr("src");
var attr = jq.attr("data-attr");
if (attr == null) attr = "";
attr = attr.split(/\s*,\s*/);
var params = new Object();
params.width = jq.width();
params.height = jq.height() + 24; // 24 is for the controler at the bottom
params.file = mmsrc;
params.image = src;
params.controlbar = "bottom";
params.screencolor = "ffffff";
params["viral.allowmenu"] = "false";
params["viral.onpause"] = "false";
params["viral.oncomplete"] = "false";
// determine url of flashplayer based on whether we're published or not
if (UI_Elements.in_preview_mode()) {
params.flashplayer = "/js/preview/player.swf";
} else {
params.flashplayer = "js/player.swf";
}
//safe_log(params.flashplayer);
for (var i = 0; i < attr.length; ++i) {
var a = attr[i].split(/\s*=\s*/);
params[a[0]] = a[1];
}
jwplayer(id).setup(params);
});
//AF: this is less than ideal, but i had to make this a global variable so it can be accessed by the video players when they fire the templateloaded event.
// we should look into changing it.
videos.templateReady = function (figureObjectID) {
var KEY_CODES = {
SPACE: 32,
ENTER: 13
};
var vidplayer = brightcove.api.getExperience(figureObjectID);
var experienceModule = vidplayer.getModule(brightcove.api.modules.APIModules.EXPERIENCE);
var playerModule = vidplayer.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
var el = document.querySelector("[data-figure-id="+ figureObjectID +"]");
el.setAttribute( "tabindex", "0" );
el.addEventListener( "keydown", (function( isPlay ) {
return function( evt ) {
var keyCode = evt.keyCode || evt.which;
if( keyCode === KEY_CODES.SPACE || keyCode === KEY_CODES.ENTER ){
if( isPlay ){
playerModule.pause();
isPlay = false;
return;
}
playerModule.play();
isPlay = true;
}
}
})( false ));
var questionSequence = $("#" + figureObjectID).closest('[data-type="figure"]').nextAll('[data-block_type="question_sequence"], [data-block_type="question_sequence_one_at_a_time"]');
questionSequence.each(function (index, element) {
if ($(element).attr("data-block_type") == "figure") {
if ($(element).find(".BrightcoveExperience").size() > 0) { //we have found another video following the current one, so stop
return false;
}
}
var questionSequenceIndex = $(element).attr("question_sequence_index");
var questionSequenceMetaData = $(element).find('[data-type="box_inner"]').children('[data-type="metadata"]').find('[key="cuepoint"]').html();
$(element).hide();
if (questionSequenceMetaData != null) {
var cuePointsModule = vidplayer.getModule(brightcove.api.modules.APIModules.CUE_POINTS);
var CuePointType = brightcove.api.modules.CuePointsModule.CuePointType;
var cuePoints = [{ name: figureObjectID, metadata: questionSequenceIndex, time: questionSequenceMetaData, type: CuePointType.CODE }];
cuePointsModule.addCuePoints(videos[figureObjectID], cuePoints);
videos.question_sequence_to_video_map[questionSequenceIndex] = figureObjectID;
}
});
playerModule.addEventListener(brightcove.api.events.CuePointEvent.CUE, videos.cuePointEvent);
};
videos.cuePointEvent = function (e) {
//get the player - the name property of the cuePoint is set to the ID of the Brightcove experience
//so we can find the player here.
var vidplayer = brightcove.api.getExperience(e.cuePoint.name);
globalPlayer = brightcove.api.getExperience(e.cuePoint.name);
//safe_log("got vid player");
var playerModule = vidplayer.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
//safe_log("got module");
playerModule.pause(true);
//safe_log("paused");
player.show_question_sequence(e.cuePoint.metadata, false);
};
$("[data-mmtype='mov']").each(function(index, element) {
var jq = $(element);
var id = jq.attr("data-figure-id");
var mmsrc = jq.attr("data-mmsrc");
var src = jq.attr("src");
var attr = jq.attr("data-attr");
if (attr == null) attr = "";
attr = attr.split(/\s*,\s*/);
var params = new Object();
for (var i = 0; i < attr.length; ++i) {
var a = attr[i].split(/\s*=\s*/);
params[a[0]] = a[1];
//safe_log("added param " + a[0] + ": " + a[1]);
}
params.autoStart = jq.attr("data-autoplay");
var videoPlayerID = "";
var videoPlayerKey = "";
//if(params.showVideoControls == 'true'){
//AF: This is the video player with playback controls. We are only using this one for right now.
videoPlayerID = "1513003547001";
if(jq.attr("data-playerid")){
videoPlayerID = jq.attr("data-playerid");
}
videoPlayerKey = "AQ~~,AAABXVHBMdE~,bnY9CM55Z1MLPZuidy4KYEC_16wi-U8Q";
//}else{
// videoPlayerID = "1504927982001";
// videoPlayerKey = "AQ~~,AAABXVHBMdE~,bnY9CM55Z1PiqOYprq-NHmUPG2yKZ4U-";
//}
videos[id] = mmsrc;
var BCL = {};
BCL.markup = function (html, data) {
var m;
var i = 0;
var match = html.match(data instanceof Array ? /{{\d+}}/g : /{{\w+}}/g) || [];
while (m = match[i++]) {
html = html.replace(m, data[m.substr(2, m.length-4)]);
}
return html;
};
videos.templateLoad = function(e){
//AF: For now, we are not using captions.
var vidplayer = brightcove.api.getExperience(e);
var CuePointType = brightcove.api.modules.CuePointsModule.CuePointType;
var modExp = vidplayer.getModule(brightcove.api.modules.APIModules.EXPERIENCE);
modExp.addEventListener(brightcove.api.events.ExperienceEvent.TEMPLATE_READY, function (evt) { videos.templateReady(e); });
//captionsModule.loadDFXP(player.md.video_caption_url + videos[e] + ".xml", videos[e]);
//if needed, we can use these events to trigger code upon the success or error of loading captions.
//if there is an error, it fails silently and just doesn't show captions.
//captionsModule.addEventListener(brightcove.api.events.CaptionsEvent.DFXP_LOAD_SUCCESS, onDFXPLoadSuccess);
//captionsModule.addEventListener(brightcove.api.events.CaptionsEvent.DFXP_LOAD_ERROR, onDFXPLoadError);
};
BCL.playerData = { "playerID" : videoPlayerID,
"playerKey" : videoPlayerKey,
"width" : jq.width(),
"height" : jq.height(),
"videoID" : mmsrc,
"autoStart" : params.autoStart};
BCL.playerTemplate = "";
console.log( BCL.playerTemplate );
var playerHTML = "";
playerHTML = BCL.markup(BCL.playerTemplate, BCL.playerData); //replaces placeholders with values
jq.replaceWith(playerHTML);
brightcove.createExperiences();
});
}
});
Essay_Query = Essay_Query.extend({
user_has_answered: function () {
if ($.trim($("#query_answer_" + this.query_index).val() != "")) {
return true;
} else {
return false;
}
}
});
FB_Query = FB_Query.extend({
user_has_answered: function () {
var x = jQuery.trim($("#query_answer" +
"" +
"_" + this.query_index).val());
if (jQuery.trim($("#query_answer_" + this.query_index).val()) != "") {
return true;
} else {
return false;
}
},
getHTML: function(mode) {
var html = "";
// start with the query text, if there is any
html += this.query_text_html();
// determine how big the response blank should be, unless one was specified
var blank_size = this.md.blank_size;
if (blank_size == "" || blank_size == null || isNaN(blank_size * 1)) {
var s = "" + this.correct_answer;
blank_size = (s.length + 2);
}
// if student hasn't answered or we're in preview mode, use an empty string for the input value
var val, disabled;
var fb_string = "";
if (!this.userHasAnswered() || mode == 'preview') {
val = "";
disabled = "";
// otherwise we have an answer, so fill it in
} else {
// make sure we convert double quotes to " for placement in 'value="xxx"' attributes
val = this.user_answer.replace(/\"/g, """);
// also disable the input in this case, if we're not in review_correct_incorrect mode
// or if the user got it right
if (mode != "review_correct_incorrect" || this.isCorrect()) {
disabled = "disabled";
}
}
html += ''
+ ''
;
html += this.finish_inline_query(this.correct_answer, mode);
html += '';
$('.query_fb_input').keypress(function(e) {
if ( !( e.charCode >= 65 && e.charCode <= 90 || e.charCode >= 97 && e.charCode <= 122 )
&& e.charCode ){
return false;
}
});
return html;
}
});
CB_Query = CB_Query.extend({
user_has_answered: function () {
return (jQuery.trim($("#query_answer_" + this.query_index).val()) != "");
},
getHTML: function(mode) {
var html = "";
// CB's never have query text
// if we're in preview mode or
// (a student answer has been given and we're not in review_correct_incorrect mode),
// or the student got it correct
// disable the checkbox
var disabled = "";
if (mode == 'preview' || (mode != 'review_correct_incorrect' && this.user_answer_index != null) || this.isCorrect()) {
disabled = "disabled";
}
// if user has answered with choice 0, it should be checked, unless we're in preview mode
var checked = "";
if (this.user_answer_index === 0 && mode != 'preview') {
checked = "checked"
}
html += '';
html += this.finish_inline_query(this.choices[this.correct_answer_index], mode);
return html;
}
});
var preventTab = function (dialog, e) {
e = e || window.event;
e.stopPropagation();
if (e.keyCode === 9) { // Tab key
e.preventDefault();
if (e.shiftKey) { // Shift + Tab key
dialog.focus();
}
}
};
var preventShiftTab = function (e) {
e = e || window.event;
if (e.shiftKey && e.keyCode === 9) { // Shift + Tab key
e.preventDefault();
}
};
window.Standard_Dialog.open = function (html, options) {
if (options == null) {
options = {};
}
if (options.width == "auto") {
options.width = null;
}
else if (options.width == null) {
options.width = 400;
}
if (options.modal == null) {
options.modal = true;
}
if (options.resizable == null) {
options.resizable = false;
}
if (options.buttons == "none") {
options.buttons = null;
}
else if (options.buttons == "OK" || options.buttons == null) {
options.buttons = [{text: "OK", click: Standard_Dialog.close}];
}
options.closeOnEscape = false;
options.dialogClass = "noclose";
options.draggable = false;
$("#standard_dialog_div").dialog("close");
$("#standard_dialog_div").remove();
html = "
" + html + "
";
$('body').append(html);
var $dialog = $('#standard_dialog_div');
$dialog.dialog(options);
var dialog = $dialog.parent();
dialog.attr('aria-label', $dialog.text());
dialog.attr('role', 'window');
dialog.removeAttr('aria-labelledby');
dialog.focus();
var $lastBtn = $('.ui-dialog-buttonset button:last-child');
$lastBtn.attr('aria-label', 'Close dialog');
$lastBtn.click( function(){
if ( window.Standard_Dialog.onceCallback ) {
if ( options.from && options.from !== $(".next_button") ) {
window.Standard_Dialog.onceCallback = null;
} else {
var f = window.Standard_Dialog.onceCallback;
window.Standard_Dialog.onceCallback = null;
f();
}
}
if ( options.from && options.from != "next" ) {
options.from.focus();
}
});
$lastBtn.bind('keydown', preventTab.bind(this, dialog));
dialog.bind('keydown', preventShiftTab);
};
window.Standard_Dialog.close = function () {
'use strict';
$("#standard_dialog_div").remove();
};
player = new Player_ays();
var SaviBcHandlers = SaviBcHandlers || {};
SaviBcHandlers.ended_default = function (video_obj) {
completeVideo = true;
$(".next_button").show();
if (player.ARGA_running && Get_ARGA_Data('LASX') < 1) {
Set_ARGA_Data("LASX", 1);
player.activity.ARGA_submit_data(false);
}
};