// dynamic position of graph
(function() {
var graphOffsetTop, view = 'prev', lastView = 'desktop', mobileView = '', lastMobileView = '';
var updateScroll = function() {
if( !graphOffsetTop) {
graphOffsetTop = $( ".section-title" ).height() + 24;
}
// graph
$( "[data-block_type='visualization_activity']" ).css( {
top: Math.max( graphOffsetTop, $( this ).scrollTop() - graphOffsetTop + graphOffsetTop )
} );
};
var update = function( ){
if( lastView !== view ){
$( 'div[data-type=chapter]' ).removeClass( lastView );
$( 'div[data-type=chapter]' ).addClass( view );
updateScroll();
}
};
var updateForMobile = function( ){
if( lastMobileView !== mobileView ){
$( 'div[data-type=chapter]' ).removeClass( lastMobileView );
$( 'div[data-type=chapter]' ).addClass( mobileView );
}
};
var resize = function() {
if ( window.innerWidth < 1470 || window.innerHeight < 805 ) {
lastView = view;
view = 'tablet';
} else {
lastView = view;
view = 'desktop';
}
if ( window.innerWidth < 1040 ) {
lastMobileView = mobileView;
mobileView = 'mobile';
} else {
lastMobileView = mobileView;
mobileView = '';
}
update();
updateForMobile();
};
$( window ).resize( resize );
resize();
$( window ).scroll( updateScroll );
})();
var Activity_datavis1 = Activity_manuscript_type.extend( {
submit_question: function(question_index) {
this._super(question_index);
var s = player.get_current_section();
// if all questions are answered and all sequences are complete
// (these are set by _super)
if (s.all_questions_answered && s.all_question_sequences_completed) {
// if we're not on the final step
if (s.index < player.sections.length - 1) {
// otherwise we're done!
} else {
player.show_completion_message();
}
}
},
show_question_feedback: function(question, is_correct, try_again) {
// remove prior feedback if there
$("#question_feedback_" + question.index).remove();
// if we don't have any feedback at all, return
if (question.md.feedback == null && question.md.feedback_correct == null && question.md.feedback_incorrect == null && question.md.feedback_hint == null) {
return;
}
var hint_fdb = $( question.jq ).find( '.query_mc_feedback_correct_incorrect' );
var hint_fdb_text = $( hint_fdb ).text();
$( hint_fdb ).html('');
var html = "
"
+ "
" + this.feedbackTitle + "
";
// include general feedback if there
if (question.md.feedback != null) {
html += "
" + question.md.feedback + "
";
}
// include correct feedback if there and the answer is correct
if (is_correct && question.md.feedback_correct != null) {
html += "
" + question.md.feedback_correct + "
";
}
// include incorrect or hint feedback if there and the answer is incorrect
if (!is_correct) {
var found_feedback_string = false;
// if user gets to try again...
if (try_again) {
// check for feedback_conditional's
if (question.md.feedback_conditional.length > 0) {
for (var i in question.md.feedback_conditional) {
var fbc = question.check_conditional(question.md.feedback_conditional[i]);
if (fbc != "") {
html += "
" + fbc + "
";
found_feedback_string = true;
break;
}
}
}
// if we didn't find a feedback string to use above, check for feedback_hint
if (!found_feedback_string && question.md.feedback_hint != null) {
html += "
" + question.md.feedback_hint + "
";
found_feedback_string = true;
}
}
// if we didn't find a feedback string to use above, check for feedback_incorrect
if (!found_feedback_string && question.md.feedback_incorrect != null) {
html += "
";
// append the div, then fade it in
$("#question_action_div_" + question.index).prepend(html);
$("#question_feedback_" + question.index).fadeIn("fast", function() {
// What I'd like to do here is check to make sure the feedback is all showing on the screen,
// and scroll if necessary so that the feedback is all visible. But just doing "scrollTo"
// isn't working properly in all situations.
// $(window).scrollTo($(this), 0);
});
},
} );
var Player_datavis1 = Player.extend( {
initialize: function() {
var title = $('h1.section-title');
var newTitle = title.find('[data-type=title]');
this.activity_title= newTitle.text();
this._super();
this.activity = new Activity_datavis1();
},
initialize2: function(){
this._super();
},
show_completion_message: function () {
// player.activity.grade_activity will always have been called before this fn
// so we'll have access to the properly-calculated activity properties below
var html = "
Congratulations! You have completed this activity."
+ "