// 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({
});
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" );
});
var hi2_clicked;
var trophic3_clicked;
//Hijacking the "Zoom to map" button to simulate mouse clicks on items in the right hand menu
$('#ch49-question-1 .map_zoom_button').click(function() {
var c = window.frames[0].frameElement.contentWindow.mccb;
if ($(c).hasClass('btn-default')) {
window.frames[0].frameElement.contentWindow.mccb.click();
}
});
$('#ch49-question-2 button').click(function() {
allButtonsOff();
var c = window.frames[0].frameElement.contentWindow.trophic1;
if ($(c).hasClass('btn-default')) {
c.click();
}
});
$('#ch49-question-3 button').click(function() {
window.frames[0].frameElement.contentWindow.tnc0.click();
});
$('#ch49-question-4 button').click(function() {
allButtonsOff();
window.frames[0].frameElement.contentWindow.tccb.click();
});
$('#ch49-question-5 button').click(function() {
var c = window.frames[0].frameElement.contentWindow.hi1;
if ($(c).hasClass('btn-default')) {
c.click();
}
});
$('#ch49-question-6 button').click(function() {
if (!hi2_clicked) {
window.frames[0].frameElement.contentWindow.hi2.click();
hi2_clicked = 1;
}
});
$('#ch49-question-7 button').click(function() {
if (!hi2_clicked) {
window.frames[0].frameElement.contentWindow.hi2.click();
hi2_clicked = 1;
}
});
$('#ch49-question-8 button').click(function() {
if (!trophic3_clicked) {
window.frames[0].frameElement.contentWindow.trophic3.click();
trophic3_clicked = 1;
}
});
$('#ch49-question-9 button').click(function() {
window.frames[0].frameElement.contentWindow.mapreset.click();
allButtonsOff();
player.map_zoom();
window.frames[0].frameElement.contentWindow.tpcb.click();
window.frames[0].frameElement.contentWindow.mpcb.click();
});
//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();
function allButtonsOff() {
if ($(window.frames[0].frameElement.contentWindow.tccb).hasClass('btn-success')) {
window.frames[0].frameElement.contentWindow.tccb.click();
}
else if ($(window.frames[0].frameElement.contentWindow.mccb).hasClass('btn-success')) {
window.frames[0].frameElement.contentWindow.mccb.click();
}
else if ($(window.frames[0].frameElement.contentWindow.tpcb).hasClass('btn-success')) {
window.frames[0].frameElement.contentWindow.tpcb.click();
}
else if ($(window.frames[0].frameElement.contentWindow.mpcb).hasClass('btn-success')) {
window.frames[0].frameElement.contentWindow.mpcb.click();
}
else if ($(window.frames[0].frameElement.contentWindow.tncb).hasClass('btn-success')) {
window.frames[0].frameElement.contentWindow.tncb.click();
}
else if ($(window.frames[0].frameElement.contentWindow.mncb).hasClass('btn-success')) {
window.frames[0].frameElement.contentWindow.mncb.click();
}
}