var DUE_DATE_MESG_SHOWN = false;
/* 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. */
Figures = Figures.extend({
bcVideo: {}, // holds all of the video players (by ID)
bcPlayerData: { 'accountId': '1500315202001', 'playerId': 'B1AhVYg4l' },
process_media: function() {
var context = this; // safe off '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 = $parent.attr("data-figure-id");
// Replace the current figure HTML with the new HTML5 video HTML
playerHTML = '
';
$parent.before(playerHTML);
$parent.remove();
// instantiate the player
bc(document.getElementById(video_id));
// create player instance and set up cuepoints
videojs(video_id).ready(function() {
context.bcVideo[video_id] = this;
var textTrack = [];
var allTextTracks;
var attLength;
var tt;
// 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");
//safe_log("video_id " + video_id + " has ended");
// opening video
if (video_id == "id1396153") {
$('body').removeClass('no_next_button');
}
// ending video
else {
$('#finished_mesg').show();
$('#back_to_home_mesg').show();
}
}); // end 'ended'
}); //end ready
});
}
});
var BCLS = (function () {
var player,
APIModules,
videoPlayer;
var onComplete = function() {
//console.log("BCLS: onComplete");
$('body').removeClass('no_next_button');
};
return {
onTemplateLoad: function(experienceID) {
//console.log("BCLS: template loaded");
// get a reference to the player and API Modules and Events
player = brightcove.api.getExperience(experienceID);
APIModules = brightcove.api.modules.APIModules;
},
onTemplateReady: function(evt) {
//console.log("BCLS: template ready");
// get references to modules
videoPlayer = player.getModule(APIModules.VIDEO_PLAYER);
videoPlayer.addEventListener( brightcove.api.events.MediaEvent.COMPLETE, onComplete);
},
}
}());
var BCLS2 = (function () {
var player,
APIModules,
videoPlayer;
var onComplete = function() {
//console.log("BCLS2: onComplete");
// See if we can find the Home button for the course. If so then show a link
// for Back to Home which will trigger a click on the button. Otherwise just
// show a message.
/* Couldn't seem to trigger a click on the Home button. Just show message for
both. */
var found_home_button = false;
var $home_button;
/*
try {
var $outer_doc = $(window.parent.document);
$home_button = $outer_doc.find('#fne-header-view').children("a.faceplate-fne-home-icon");
if ($home_button.length > 0) {
safe_log("found Home button");
found_home_button = true;
}
else {
safe_log("couldn't find Home button");
}
}
catch(err) {
safe_log("couldn't find Home button");
}
*/
$('#finished_mesg').show();
if (!found_home_button) {
$('#back_to_home_mesg').show();
}
else {
$('#back_to_home_link').show();
$('#back_to_home_link').click(function(event) {
if (event !== undefined) {
event.stopImmediatePropagation();
}
//safe_log("clicking Home button: " + $home_button);
//safe_log($home_button);
$home_button.click();
return false;
});
}
};
return {
onTemplateLoad: function(experienceID) {
//console.log("BCLS2: template loaded");
// get a reference to the player and API Modules and Events
player = brightcove.api.getExperience(experienceID);
APIModules = brightcove.api.modules.APIModules;
},
onTemplateReady: function(evt) {
//console.log("BCLS2: template ready");
// get references to modules
videoPlayer = player.getModule(APIModules.VIDEO_PLAYER);
videoPlayer.addEventListener( brightcove.api.events.MediaEvent.COMPLETE, onComplete);
}
}
}());
var BCLS3 = (function () {
var player,
APIModules,
videoPlayer;
var onComplete = function() {
//console.log("BCLS3: onComplete");
$('#finished_mesg').show();
$('#back_to_home_mesg').show();
};
return {
onTemplateLoad: function(experienceID) {
//console.log("BCLS3: template loaded");
// get a reference to the player and API Modules and Events
player = brightcove.api.getExperience(experienceID);
APIModules = brightcove.api.modules.APIModules;
},
onTemplateReady: function(evt) {
//console.log("BCLS3: template ready");
// get references to modules
videoPlayer = player.getModule(APIModules.VIDEO_PLAYER);
videoPlayer.addEventListener( brightcove.api.events.MediaEvent.COMPLETE, onComplete);
}
}
}());
var xBookUtils = {};
var noopDSApi = {
initializeClass : function(){
var dfd = jQuery.Deferred();
setTimeout(function(){
dfd.resolve(null);
}, Math.floor(100 + Math.random() * 500));
return dfd.promise();
},
initializeUser: function(){
var dfd = jQuery.Deferred();
setTimeout(function(){
dfd.resolve(null);
}, Math.floor(100 + Math.random() * 500));
return dfd.promise();},
loadClassData: function(){
var dfd = jQuery.Deferred();
setTimeout(function(){
dfd.resolve([]);
}, Math.floor(100 + Math.random() * 500));
return dfd.promise();},
loadGlobalClassData: function(){
var dfd = jQuery.Deferred();
setTimeout(function(){
dfd.resolve(null);
}, Math.floor(100 + Math.random() * 500));
return dfd.promise();},
setData: function(){},
setGlobalData: function(){
var dfd = jQuery.Deferred();
setTimeout(function(){
dfd.resolve(null);
}, Math.floor(100 + Math.random() * 500));
return dfd.promise();},
};
var Activity_coach = Activity_manuscript_type.extend({
add_question: function(index, element) {
var a = player.activity; // this fn gets called within the scope of a jquery each, so we can't refer to "this"
var jq = $(element);
// see if we're in a question_pool or question_sequence block
var qs_parent = jq.parents("[data-block_type=question_sequence], [data-block_type=question_sequence_one_at_a_time]");
var q = a.questions[a.questions.length] = new Question({
"index": a.questions.length
, "number": jQuery.trim($("[data-type='number']", jq).html())
, "title": jQuery.trim($("[data-type='title']", jq).html())
, "jq": jq
, "points_possible": 0
});
// store the question index in the DOM too
jq.attr("data-question_index", q.index);
// get question queries
a.question_being_initialized = q;
$("[data-type='query']", jq).each(a.add_query);
// if the question has queries, add bling to the bottom
if (q.queries.length > 0) {
var html = "
";
var submit_handler;
// add a submit button if we're supposed to have one
// (image map and matching questions, which should contain one and only one query, don't have submit buttons)
if (q.queries[0].hasSubmitButton === true) {
// "answer_one" pool mode (yet to be fully implemented...)
if (q.pool_mode == 'answer_one') {
html += "";
submit_handler = player.activity.Show_Submit;
} else {
html += a.question_submit_button(q);
/*
brb - 20160202: use our own submit_question handler
so we can get info from data services before we save
the question
*/
//submit_handler = player.activity.submit_question;
submit_handler = player.activity.coach_submit_question;
}
}
// add a "give up" button if we're supposed to have one
// (image map questions, which should contain one and only one query, should have this button)
if (q.queries[0].hasGiveUpButton === true) {
html += "";
submit_handler = player.activity.give_up_question;
}
html += "
";
jq.append(html);
// bind the submit_handler function to the button, passing in the question_index
$("#question_submit_button_" + q.index).click({question_index:q.index}, submit_handler);
// float instructor controls to right of action button
jq.prepend(a.instructor_question_controls(q));
// also, determine question points and weight at this time
for (var i = 0; i < q.queries.length; ++i) {
q.points_possible += q.queries[i].getPointsPossible();
}
// round to two decimal places, in case there are decimals
q.points_possible = Math.round(q.points_possible * 100) / 100;
}
// now that the question has been created, deal with sequences and pools
if (qs_parent.length > 0) {
// get sequence index and item
var qs_index = qs_parent.attr("question_sequence_index") * 1;
var qs = a.question_sequences[qs_index];
// place in sequence
var sequence_num = qs.questions.length;
qs.questions[sequence_num] = q;
// place reference to sequence in question
q.question_sequence = qs;
q.question_sequence_index = sequence_num;
// if this isn't #1, hide the question
if (sequence_num > 0) {
jq.hide();
}
// update the sequence navigator if it's there
$("#question_sequence_max_index_" + qs.index).html(sequence_num+1);
}
},
get_total_points: function() {
var points_awarded = 0;
//safe_log(this.questions);
for (var i = 1; i < 4; i++) {
//safe_log("get_total_points: i = " + i);
var question = this.questions[i];
//safe_log(question);
// go through each query in the question and get points
for (var j = 0; j < question.queries.length; ++j) {
var query = question.queries[j];
// getPointsForQuery is a special function created just for this
// activity that will return 0 if the question hasn't been answered yet
// otherwise will return 0 or 1.
points_awarded += query.getPointsForQuery();
}
}
//safe_log("get_total_points: returning " + points_awarded);
return points_awarded;
},
parseScores: function(str) {
var scoreObject = {};
var score_arr = str.split(/::/);
for (var i=0; i 1) {
query_weight = Math.round(query_weight / question.queries.length);
}
// if credit_after_max_tries is set, give at least that credit now, as long as the student tried
if (question.md.credit_after_max_tries != null) {
var query_grade = query.getGradeForARGA();
if (query_grade >= 0 && query_grade < question.md.credit_after_max_tries) {
query.overrideGrade(question.md.credit_after_max_tries * 1);
}
}
// set the ARGA response, unless we're saving one response for the whole question
if (!question.md_set("question_report_text")) {
// we need to call a DS version of this function
//t.ARGA_set_query_response(query, query_number, query_weight);
t.ARGA_set_query_response_DS(query, query_number, query_weight);
// otherwise compose query roll-ups
} else {
if (query_correct_answers != "") {
query_correct_answers += " / ";
query_responses += " / ";
query_responses_for_questionData += t.query_responses_separator;
}
query_correct_answers += query.getCorrectAnswerForARGA();
query_responses += query.getUserAnswerForARGA();
// see restore_saved_answers for how this is used later
query_responses_for_questionData += query.getUserAnswerForARGA()
+ t.query_responses_grade_separator
+ query.getOriginalGrade();
query_grade_sum += query.getGradeForARGA() * 1;
}
// show in review mode, unless question metadata says not to show correct answers
if (question.md.show_correct_answers != "false") {
query.jq.html(query.getHTML("review"));
}
} // end for
// Fix all queries in all questions so they have 100% and don't show the correct answer
// We have three questions in the activity (1-3)
for (var j = 1; j < 4; j++) {
var question_fix = t.questions[j];
for (var k = 0; k < question_fix.queries.length; ++k) {
var query_fix = question_fix.queries[k];
var query_number_fix = t.get_query_number(question_fix, k);
var query_weight_fix = question_fix.get_weight();
//safe_log("fixing query " + query_number_fix);
t.ARGA_set_query_response_DS(query_fix, query_number_fix, query_weight_fix);
}
}
// if we're saving one response for the whole question, save here
if (question.md_set("question_report_text")) {
var question_grade = Math.round(query_grade_sum / question.queries.length);
t.ARGA_set_question_response(question, query_correct_answers, query_responses, question_grade, query_responses_for_questionData);
}
// grade the activity
t.grade_activity();
// Make sure the grade is always 100
t.grade_percent = 100;
// then if ARGA is running, submit data; show_grade_saved_message will be called on completion.
if (player.ARGA_running) {
t.ARGA_submit_data();
}
// update the question_action_div
t.update_question_action_div(question_index);
// if the item is in a sequence, show the next question
t.show_next_question(question);
// update section status
player.update_section_status();
UI_Elements.toggle_button("step_button", true);
},
ARGA_set_query_response_DS: function(q, query_number, query_weight) {
// return if ARGA isn't running
if (!player.ARGA_running) return;
// set arga response
// note that we send the original grade in questionData so we can get it back when the user returns
Set_ARGA_Question_Response({
questionNum:'' + query_number,
questionType:q.getQueryTypeForARGA(),
questionText:this.encode_for_ARGA(q.getQueryTextForARGA()),
correctAnswer:this.encode_for_ARGA(""),
learnerResponse:this.encode_for_ARGA(q.getUserAnswerForARGA()),
questionGrade:100,
questionWeight:query_weight,
questionData:100
});
},
displayError: function(err_str) {
$("
" + err_str + "
").dialog({
modal: true,
buttons: [{
text: "OK",
click: function () {
$(this).dialog("close");
}
}]
});
},
allQueriesAnswered: 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 allQueriesAnswered = true;
for (var i = 0; i < player.activity.questions[question_index].queries.length; i++) {
var x = player.activity.questions[question_index].queries[i].user_has_answered();
if (!x) {
allQueriesAnswered = false;
break;
}
}
if (!allQueriesAnswered) {
$("
Please answer all of the questions before submitting.
").dialog({
modal: true,
buttons: [{
text: "OK",
click: function () {
$(this).dialog("close");
}
}]
});
return false;
}
return true;
},
submit_question_old: 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;
}
if (!player.activity.allQueriesAnswered(question_index)) {
return false;
}
this._super(question_index);
$("#auto_answer").hide();
var total_points = player.activity.get_total_points();
//safe_log("Total points: " + total_points);
//safe_log("question_index: " + question_index);
if (question_index == 4) {
$("
= 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.
"
buttons = [ {text:"OK", click: player.activity.ARGA_initialization_final} ];
}
// resubmissions are not allowed
} else {
msg = "
You have completed this activity.
";
buttons = [ {text:"OK", click: player.activity.ARGA_initialization_final} ];
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();
}
}
}); // end Activity_coach
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;
}
}
/*
// mode should be "delivery" or "review"; "delivery" is assumed
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();
// 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] + ".
"
+ "
"
+ "
";
}
// get a possible feedback string; this fn will take account of mode
html += this.correct_incorrect_feedback(mode, is_correct);
html += "";
return html;
}
*/
});
var Player_coach = Player_manuscript_type.extend({
ACTIVITY_COMPLETED: false,
DUE_DATE_HAS_PASSED: false,
fne_jq: null,
scrolling_window_jq: null,
highLearnerStatusCutoff: 23,
ds : {
isInitialized : false,
api : ( typeof ((((window.parent || {}).PX || {}).API || {}).DataService) != "undefined") ? window.parent.PX.API.DataService : noopDSApi,
userData: {},
classData: {},
initialize: function(callback){
this.initializeUser();
},
initializeUser: function(){
this.api.initializeUser("coach").then(function(a){
// We don't need to initialize any userData here since the
// user only takes this quiz once
/*
if (a !== null && a!== undefined){
for(var i = 0; i < a.length; i++){
player.ds.userData[a[i].Key] = (JSON.parse(a[i].Value.val));
}
}
*/
});
},
// group is either "low" or "high"
/*
initializeClass: function(group) {
this.api.initializeClass(group).then(function(a){
// current_checkpoint is signifies whether the last person who completed
// the quiz was assigned to the checkpoint group (1) or not (0)
var current_checkpoint = 0;
safe_log("initializeClass");
safe_log(a);
if (a !== null && a!== undefined){
current_checkpoint = a[0].Value.checkpoint;
if (current_checkpoint === undefined) {
current_checkpoint = 0;
}
}
safe_log("current_checkpoint = " + current_checkpoint);
});
},
*/
generateDataRecord: function(datasetID, key, value, loadOnUserInit, loadOnClassInit, loadOnSchoolInit){
//safe_log("generateDataRecord");
//safe_log(value);
var course_id = "1001";
var user_id = "5001";
if (xBookUtils.inPX()) {
course_id = parent.PxPage.Context.Course.EntityId;
user_id = parent.PxPage.Context.User.CurrentUserId;
}
var r = {
CourseId: course_id,
InstitutionId: null,
UserId: user_id,
Key: key,
Value: value, // this is string now, no need to stringify
DataSetId: datasetID,
LoadOnUserInit: loadOnUserInit,
LoadOnClassInit: loadOnClassInit,
LoadOnSchoolInit: loadOnSchoolInit
};
//safe_log("returning r");
//safe_log(r);
return r;
} // end generateDataRecord
}, // end ds
// learner_group is either "low" or "high"
// Return 1 if user should get checkpoint questions based on their learner group,
// otherwise return 0.
nextCheckpoint: false,
_get_checkpoint: function(learner_group) {
var return_value = 0;
// we can't use initializeClass because sooner or later it will be
// restricted to instructors only
/*
this.ds.api.initializeClass("coach").then(function(a){
if(a !== null && a !== undefined){
safe_log("initializeClass");
safe_log(a);
}
else {
safe_log("initializeClass returned undefined");
}
return 999;
//callback();
//this.isInitialized = true;
});
*/
this.nextCheckpoint = !this.nextCheckpoint
return Number(this.nextCheckpoint);
},
save_student_data: function(){
var scoreObject = ""; // this will actually be a string for now
// create an object that stores points for each individual question and
// also total points scored
// Change that. Create a string with separators that we can parse to retrieve
// the scores because there is a bug with Data Services right now (CTC-5433).
// The format will be: query1,score::query2,score:: ... ::total,score
var ques_num = 1;
var total_points = 0;
for (var i = 1; i < 4; i++) {
var question = player.activity.questions[i];
// store points for each individual question
for (var j = 0; j < question.queries.length; ++j) {
var query = question.queries[j];
// we won't save results for each questions unless they need it
//scoreObject += "query" + ques_num + "," + query.getPointsAwarded() + "::";
total_points += query.getPointsForQuery();
//ques_num++;
}
}
// store total points scored
scoreObject += "total," + total_points + "::";
/*
// are they a low (0) or high (1) learner?
var status = 0;
if (total_points >= this.highLearnerStatusCutoff) {
status = 1;
}
*/
scoreObject += "learnerstatus," + learnerstatus + "::";
// do they get the checkpoint questions?
// Create method for checking whether student should get checkpoint questions.
// For now just hardcode it
//var checkpoint = _get_checkpoint();
//var checkpoint = 1;
//var checkpoint = this._get_checkpoint("low");
scoreObject += "checkpoint," + checkpoint;
//safe_log("scoreObject");
//safe_log(scoreObject);
this.send_student_data_to_ARGA(scoreObject);
}, // end save_student_data
send_student_data_to_ARGA: function(scoreObject){
var dataObject = {};
if(player.ARGA_running){
//data services
// I don't think we need to store the user name
//dataObject.name = Get_ARGA_Data("learner_name");
dataObject.scores = scoreObject; // this is a string now, not a JS object
//safe_log("dataObject");
//safe_log(dataObject);
var record = player.ds.generateDataRecord("coach", "scores", dataObject, "true", "true", "false");
//safe_log("record");
//safe_log([record]);
player.ds.api.setData([record]);
}
else {
dataObject.name = "Rebecca%20Merrill";
dataObject.scores = scoreObject;
//safe_log("dataObject");
//safe_log(dataObject);
//safe_log("dataObject stringified");
//var stringified_data = JSON.stringify(dataObject);
//safe_log(stringified_data);
var record = player.ds.generateDataRecord("coach", "scores", dataObject, "true", "true", "false");
//safe_log("record");
//safe_log([record]);
}
}, // end send_student_data_to_ARGA
/* brb: We are overriding this method in order to keep the activity from
updating ARGA if the activity has been completed so that it doesn't
overwrite a manual grade change in the grade book (see JIRA LP-127) */
update_section_status: function() {
if (this.section_currently_showing != null && this.last_available_section <= this.section_currently_showing) {
var s = this.get_current_section();
s.all_questions_answered = true;
// if the current section has any questions, see if they've all been answered
var qs_to_check = [];
s.jq.find("[data-type=question]").each(function(index, element) {
var q_index = $(element).attr("data-question_index");
var question = player.activity.questions[q_index];
s.all_questions_answered = s.all_questions_answered && question.is_complete();
if (question.question_sequence != null) {
for (var i = 0; i < qs_to_check.length; ++i) {
if (qs_to_check[i] == question.question_sequence) break;
}
if (i == qs_to_check.length) {
qs_to_check.push(question.question_sequence);
}
}
});
// now check question sequences to make sure they're done too
s.all_question_sequences_completed = true;
for (var i = 0; i < qs_to_check.length; ++i) {
s.all_question_sequences_completed = s.all_question_sequences_completed && (qs_to_check[i].sequence_complete == "complete");
}
if (s.all_questions_answered && s.all_question_sequences_completed) {
this.last_available_section = this.section_currently_showing + 1;
}
}
this.fill_in_previous_query_responses();
// if ARGA is initialized and we need to restore the user to his last position when he returns,
if (this.ARGA_running && player.md.restore_last_viewed_section == "true") {
// if we're viewing a page other than the one currently saved as LVS (last-viewed section)
var lvs = Get_ARGA_Data("LVSX");
if (this.section_currently_showing != null && this.section_currently_showing != lvs) {
// store LVS/LAS to register the last-viewed/last-available page,
// and save ARGA so it gets registered
Set_ARGA_Data("LVSX", this.section_currently_showing);
Set_ARGA_Data("LASX", this.last_available_section);
/* brb: If the activity has not been completed then save LVSX,
but if it has been completed then do not save LVSX because
that will also send the grade to the PX grade book again,
overwriting any manual grade changes the instructor may
have made. */
/* brb: also don't want to do this if the due date has passed */
if (!this.ACTIVITY_COMPLETED && !this.DUE_DATE_HAS_PASSED) {
this.activity.ARGA_submit_data(false);
}
}
}
},
show_section_animate: function(section_to_show, direction) {
// make sure modal window is closed
$("#toc_dialog").dialog("close");
// hide currently showing section
if (this.section_currently_showing != null) {
this.get_current_section_jq().hide();
}
this.section_currently_showing = section_to_show;
this.get_current_section_jq().fadeIn(300);
if (this.section_currently_showing == 0) {
$('body').addClass('no_next_button');
$('#step_button .ui-button-text').text('Start Now');
}
else if (this.section_currently_showing == 1) {
$('body').removeClass('no_next_button');
$('#step_button .ui-button-text').text('Begin Diagnostic');
}
else {
$('body').removeClass('no_next_button');
$('#step_button .ui-button-text').text('Next');
}
// update slide_number and title
$("#slide_title").html(this.get_current_section().title);
UI_Elements.update_button_label("slide_number", (section_to_show+1) + " of " + this.sections.length + " ");
// if this is the first/last section, dim the previous/next button
if (this.section_currently_showing == 0) {
$("#previous_button").addClass("button_dimmed");
} else {
$("#previous_button").removeClass("button_dimmed");
}
if (this.section_currently_showing == (this.sections.length - 1)) {
$("#next_button").addClass("button_dimmed");
} else {
$("#next_button").removeClass("button_dimmed");
}
// scroll to top
window.scrollTo(0,0);
if (xBookUtils.inPX()) {
//safe_log("scrolling window to top");
player.scrolling_window_jq.scrollTop(0);
}
var $curr_sec = player.get_current_section_jq();
var curr_sec_id = $curr_sec.attr('id');
//safe_log("curr_sec_id = " + curr_sec_id);
// For testing purposes, display the results for this student.
if (curr_sec_id === "digfir_section_8") {
$("#step_button").remove();
if (this.ACTIVITY_COMPLETED) {
$('#finished_mesg').show();
$('#back_to_home_mesg').show();
}
player.ds.api.initializeUser("coach").then(function(a){
if (a !== null && a!== undefined){
var scoreObject;
for(var i = 0; i < a.length; i++){
scoreObject = player.activity.parseScores(a[i].Value.scores);
}
//safe_log(scoreObject);
//$("#coach_diag_ch1_010-results").html("
" // toolbar
;
}
$("[data-type=chapter]").prepend(html);
// button at the bottom of the manuscript to go on to the next step
$("[data-type=chapter]").append(UI_Elements.get_button_html({
id: "step_button",
label: "Next",
fn: 'player.show_section("next")'
}));
// icons for toolbar and next buttons...
$('#previous_button').button({
icons: {
primary: "ui-icon-circle-triangle-w"
}
});
$('#next_button').button({
icons: {
secondary: "ui-icon-circle-triangle-e"
}
});
$('#slide_number').button({
icons: {
secondary: "ui-icon-circle-triangle-s"
}
});
$('#step_button').button({
icons: {
secondary: "ui-icon-circle-triangle-e"
}
});
// activate all other buttons
UI_Elements.activate_buttons();
},
initialize2: function() {
this._super();
if (player.ARGA_running) {
if (Get_ARGA_Data("due_date_has_passed") == 1) {
this.DUE_DATE_HAS_PASSED = true;
}
try {
var dejs_arr = ARGA_API.dejs_data;
for (var i=0; iPlease note: The due date for this assignment has passed. You will not be able to complete this assignment at this time. Please contact your instructor to request a due date extension.");
}
});
// disable all questions
$('[data-type="question"]').each(function() {
var $this = $(this);
$this.find('input[type="radio"]').attr("disabled",true);
$this.find('textarea').attr("disabled",true);
$this.find('input').attr("disabled",true);
});
if (!DUE_DATE_MESG_SHOWN) {
DUE_DATE_MESG_SHOWN = true;
//safe_log("DUE_DATE_MESG_SHOWN = " + DUE_DATE_MESG_SHOWN);
//alert("The due date for this assignment has passed. You will not be able to complete this assignment at this time. Please contact your instructor to request a due date extension.");
var buttons = [ {text:"OK", click: player.activity.ARGA_initialization_final} ];
var alert_msg = "
" + "The due date for this assignment has passed. You will not be able to complete this assignment at this time. Please contact your instructor to request a due date extension." + "
");
$("#checkpoint").click(function() {
safe_log("set checkpoint");
$("#manuscript").loadingOverlay();
});
}
*/
},
initialize: function() {
//safe_log("player.initialize()");
this._super();
this.activity = new Activity_coach();
//safe_log("initialize (5)");
player.ds.initialize(function(){
//safe_log("data services initializing");
//show individual report
player.get_user_data_from_ARGA();
//player.get_class_data_from_ARGA();
/*
if(player.isInstructor){
player.generate_instructor_report_data();
}
*/
//player.generate_student_report($("[data-block_type='individual_student_results']")[0]);
});
this.scrolling_window_jq = $(window);
try {
this.fne_jq = $("#fne-content",window.parent.document);
if (this.fne_jq.length == 0) {
this.fne_jq = null;
} else {
this.scrolling_window_jq = this.fne_jq;
}
} catch(e) {}
}
}); // end Player_coach
player = new Player_coach();
/*
inPX: Return true if the page is being viewed in PX, otherwise return false.
*/
xBookUtils.inPX = function() {
if (xBookUtils.inPXFrame()) {
return true;
}
// We could still be in a supp window in PX, so check the URL.
// P.S. Not sure if this is the most reliable way to check this?
if (/dlap\.bfwpub\.com/.test(window.location.href)) {
return true;
}
if (/macmillanhighered\.com\/brainhoney/.test(window.location.href)) {
return true;
}
return false;
}
/*
inPXFrame: Return true if the page is being viewed in the main PX content frame,
otherwise return false.
*/
xBookUtils.inPXFrame = function() {
try {
if (top.PxPage) {
return true;
}
}
catch(err) { }
return false;
}
MC_Query = MC_Query.extend({
/*
This function returns 0 if the query has not been answered yet,
otherwise it returns 0 or 1. We need this function because it executes
before the ARGA submit function has been called and so the queries
have not been officially graded yet and thus we can't use getPointsAwarded.
*/
getPointsForQuery: function() {
// get the user's answer (zero based)
//safe_log("getPointsForQuery: query_index = " + this.query_index);
var $answer = $('input:radio[name=query_answer_' + this.query_index + ']:checked');
if ($answer.length < 1) {
//safe_log("no answer checked, returning 0");
return 0;
}
var user_answer = $answer.val();
//safe_log("getPointsForQuery: user_answer = " + user_answer);
if (Number(user_answer) == this.correct_answer_index) {
//safe_log("correct");
return 1;
}
else {
//safe_log("incorrect");
return 0;
}
} // end getPointsForQuery
});