var Activity_manuscript = Activity.extend({ get_question_number: function(q) { // always use q.index here return q.index; }, submit_question: function(question_index) { this._super(question_index); // if we're on the last page and user has answered all queries, show completion message if (player.showing_last_section() && player.activity.answered_all_queries) { player.show_completion_message(); } }, show_grade_saved_message: function() { this._super(); // if activity is complete, show the completion div // (in addition to doing an alert, which super does) if (player.activity.answered_all_queries) { player.user_has_received_completion_alert = true; $("#grade_submitted_message").show(); } } }); var Player_manuscript = Player.extend({ tab_jq: null, // have to overwrite and simplify show_section here compared to player.js, // to use jquery ui's standard tab functions. show_section: function(section_to_show) { 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; } if (section_to_show == null || isNaN(section_to_show) || section_to_show < 0 || section_to_show >= this.sections.length) { return; } // 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). 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 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 } }, tab_selected: function(event, ui) { // we don't actually use event; // it's just there because it's part of the standard jquery ui fn prototype 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 (player.md.sequenced_sections == "true" && section_to_show > player.last_available_section) { alert(player.md.section_sequence_message); 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.update_section_status(); player.update_navigation(); window.scrollTo(0,0); }, show_navigation: function() { // this._super(); return; var html = "
" + title + "
"; $("h2").each(function(index, element) { if (index == 0) return; $(this).after(html); }); this._super(); // after we call this.super, re-initialize the activity to the custom // activity type for this manuscript this.activity = new Activity_manuscript(); }, initialize2: function() { this._super(); // Get rid of chapter numbers in question numbers // and insert them into the start of the query text // have to do this here, after question has been rendered $("[data-type=question]").each(function(index, element) { $(this).find("h3").hide(); var html = "" + (index+1) + ". "; $(this).find(".query_text").first().prepend(html); }); }, init: function() { this._super(); } }); player = new Player_manuscript();