// insert Lato font definition
// Note: we need to use the fontsquirrel version so that it works in IE
document.write("
");
var Activity_subtype = Activity_manuscript_type.extend({
/*
restore_saved_answers: function() {
// don't restore saved answers for instructors
// brb: Not sure why this was here but the want the instructors
// to be able to review their answers
// if (!player.activity.is_instructor()) {
// this._super();
// }
safe_log("restore_saved_answers");
this._super();
}
*/
/* 20190415: The change below was made a few years ago in order to allow instructors to view their saved answers. For whatever reason, instructors are prevented from saving their answers in js/basic_activity.js (see restore_saved_answers). We need to add the
asset/hlw22_sim_only to production and don't want to spend the time
testing this change right now. If instructors complain in
the future about not being able to save their answers then re-enable
the following and test to make sure it works.
*/
/*
restore_saved_answers: function() {
safe_log("restore_saved_answers");
safe_log(this.questions);
// skip page queries (questions[0])
for (var i = 1; i < this.questions.length; ++i) {
var question = this.questions[i];
// prepare for question_report_text questions
var query_responses;
if (question.md_set("question_report_text")) {
query_responses = "" + Get_ARGA_QuestionData(this.get_question_number(question))
query_responses = query_responses.split(this.query_responses_separator);
}
var restored_all_answers = true;
var all_answers_correct = true;
for (var j = 0; j < question.queries.length; ++j) {
var query = question.queries[j];
var saved_answer, saved_grade;
// get saved answer and grade out of the questionData for question_report_text questions
if (question.md_set("question_report_text")) {
if (query_responses[j] != null) {
var arr = query_responses[j].split(this.query_responses_grade_separator);
saved_answer = arr[0];
saved_grade = arr[1];
} else {
saved_grade = saved_answer = "";
}
// or out of learnerResponse / questionData for single-query questions
} else {
var ARGA_question_number = this.get_query_number(question, j);
saved_answer = Get_ARGA_LearnerResponse(ARGA_question_number);
// we stored the original grade in questionData
saved_grade = Get_ARGA_QuestionData(ARGA_question_number)
}
// if we found a grade...
if (saved_grade !== "" && saved_grade >= 0) {
// restore the answer
query.restoreAnswerFromARGA(saved_answer);
query.setGrade(saved_grade);
// then re-render the query in review mode
query.jq.html(query.getHTML("review"));
if (query.isCorrect() == false) {
all_answers_correct = false;
}
} else {
restored_all_answers = false;
}
}
if (restored_all_answers) {
// update the submit div for the question
this.update_question_action_div(i);
// Show appropriate feedback. If the question responses were submitted,
// the student must have finished the question, so we don't have to worry
// about hints.
this.show_question_feedback(question, all_answers_correct, false);
// if the item is in a sequence, show the next question
this.show_next_question(question);
// NEED TO CHECK TO MAKE SURE THIS IS WORKING PROPERLY
// If the question is in a sequence and the sequence is complete, call show_closing_material
var qs = question.question_sequence;
if (qs != null && qs.sequence_complete == "partial") {
this.show_closing_material(qs.index);
}
// update section status
player.update_section_status();
}
}
}
*/
});
var Player_subtype = Player_manuscript_type.extend({
opened_from_portal: true,
start_quiz: function() {
this._super();
},
// see note below
map_zoom: function() {
// get current question
var q = this.activity.questions[this.activity.current_question];
// then get zoom_to value from metadata
var zoom_to = q.md.zoom_to;
if (zoom_to != null) {
var zta = zoom_to.split(/\s*,\s*/);
if (zta.length != 3) {
console.log("Incorrect zoom_to values: " + zoom_to);
return;
} else {
var zoomlevel = zta[0];
var latlng = new this.iframe.L.LatLng(zta[1], zta[2]);
this.iframe.main_map.setView(latlng, zoomlevel);
$.scrollTo($('[data-type="figure"]').first());
}
} else {
console.log("No zoom_to value specified for this question");
}
},
show_guidance: function(el) {
var jq = $(el).next();
jq.slideToggle('fast');
$('html, body').animate({
scrollTop: $(document).height()
},
1500);
},
full_screen: function() {
var src = $("[data-type=figure]").find("iframe").first().attr("src");
// get height and width of window
var fsw = window.open(src, "synthesis_full_screen", "height=" + screen.height + ",width=" + screen.width + ",top=0,left=0,resizable=yes");
},
map_locate_test: function() {
},
show_activity_notes: function() {
var text = "The questions included below have been written to test students' understanding of the material presented in the animation. If you assign the Visual Synthesis Map Activity, students will get two chances to answer each question correct (except for true/false questions).
Note that many questions include a button that \"zooms\" the Map to the relevant place in the Map for that question. Thus requiring students to answer the questions also serves to ensure that students have visited most of the important portions of the Map.";
Standard_Dialog.alert(text, {title:"Instructor Notes"});
},
initialize: function() {
this._super();
// after we call this.super, re-initialize the activity to the custom
// activity type for this subtype
this.activity = new Activity_subtype();
},
initialize2: function() {
this._super();
// instructor notes at the top
if (player.activity.is_instructor()) {
var html = UI_Elements.get_button_html({
"label": "Instructor Notes"
, "fn": 'player.show_activity_notes()'
, "extra_class": "instructor_guidance_button"
});
$("[data-type=section]").prepend(html);
}
var html = UI_Elements.get_button_html({
"label": "Full Screen Mode"
, "fn": 'player.full_screen()'
, "extra_class": "instructor_guidance_button"
});
$("#activity_instructions").before(html);
// process instructor_guidance boxes for questions
$("[data-block_type=instructor_guidance]").each(function(index, element) {
// PW: this isn't getting located quite right yet; leave out for now
return;
var jq = $(this);
// if the user is a student, don't show this box at all
if (player.activity.is_instructor() != true) {
jq.remove();
return;
}
// prepend an element to show the content
var html = UI_Elements.get_button_html({
"label": "Instructor Notes"
, "fn": 'player.show_guidance(this)'
, "extra_class": "instructor_guidance_button"
})
jq.before(html);
});
// to use the map_zoom function, a question should include a metadata tag like this:
// _zoom_to: 5, 29.59257, -139.96582
// where the parameters are level, latitude, longitude
// if a question should *not* have a zoom_to button, it should be marked
// with block_type "no_zoom"
var html = UI_Elements.get_button_html({
"label": "Zoom To Map"
, "fn": 'player.map_zoom()'
, "extra_class": "map_zoom_button"
})
$("[data-type=question]").not("[data-block_type=no_zoom]").prepend(html);
UI_Elements.activate_buttons();
// get reference to the iframe
this.iframe = $("[data-type=figure]").find("iframe")[0].contentWindow;
// anything that you want to do after *everything* has been set up
// should be done here.
//assign id to box element that contains questions and wrap anchor tag on tooltip to jump to section
var qbox = "[data-type='box']";
var startbtn = "#start_quiz_button";
$(qbox).attr('id','qbox');
$("#start_quiz_button").wrap('');
//debugging REMOVE in PROD
$("#start_quiz_button").click(function() {
console.log( "clicked" );
});
//check if start comprehension quiz button is on screen
var box_location;
$.fn.isOnScreen = function(){
var win = $(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
var bounds = this.offset();
bounds.right = bounds.left + this.outerWidth();
//debugging REMOVE in PROD
if( !$.browser.webkit){
console.log("not webkit");
}else{
console.log("webkit")
}
bounds.bottom = bounds.top + this.outerHeight();
return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
};
//if not on screen add tooltip class and wrap the anchor tag + slight delay on the bounce animation
if($(startbtn).isOnScreen() === false ){
$("body").prepend('Answer Questions Below
');
$(".tooltip").css("bottom", "10px");
$(".tooltip").wrap('');
$(".tooltip").delay(500).queue(function(next){
$(this).addClass('bounce');
});
}else{
return;
}
//click makes tooltip go away
$(".tooltip").click(function(){
$(this).css("display","none");
});
//listening to scroll and removing tooltip after threshold unless class exists
var lastFixPos = 0;
var threshold = 50;
$(window).scroll(function(){
if($(".tooltip").hasClass("fader fadedOut")){
return;
}else{
var diff = Math.abs($(window).scrollTop() - lastFixPos);
if(diff > threshold){
lastFixPos = $(window).scrollTop();
$(".tooltip").addClass("fader fadedOut");
}else{
return;
}
}
});
}
});
player = new Player_subtype();