var Activity_info_graphic = window.Activity_manuscript_type.extend({ update_question_action_div: function(question_index) { 'use strict'; var question = this.questions[question_index]; // calculate points_awarded and points_possible var points_awarded = 0; var points_possible = 0; var points_provisional = false; for (var i = 0; i < question.queries.length; ++i) { var query = question.queries[i]; points_awarded += query.getPointsAwarded(); points_possible += query.getPointsPossible(); if ( query.pointsAreProvisional() == true ) { points_provisional = true; } } // round to at most two decimal places points_awarded = Math.round(points_awarded * 100) / 100; points_possible = Math.round(points_possible * 100) / 100; // hide submit button (and any other similar buttons that might be added by subtypes), but show points earned var jq = $("#question_action_div_" + question.index); jq.find(".question_submit_button").hide(); var text = ''; var provisional = jq.parent().find('.essay_question_evaulation_feedback'); if ( provisional.length ) { text = provisional.text() + ' '; provisional.text(''); } var ariaLabel = text + "Points awarded: " + points_awarded + " out of " + points_possible; if ( points_provisional ) { ariaLabel += " (provisional)"; } var points_html = "
" + html + "
"); }, 2500); }, show_section_animate: function(section_to_show) { 'use strict'; // Hide currently showing section if ( this.section_currently_showing !== null ) { this.sections[this.section_currently_showing].jq.hide(); } this.section_currently_showing = section_to_show; var section = this.sections[section_to_show]; section.jq.show(); if ( section_to_show === 0 && !this.show_in_first_time ) { this.show_in_first_time = true; $('[data-type=chapter]').focus(); } else { section.jq.focus(); } $('.slide_title').html(section.title); // Update slide number $('#slide_number').html('slide ' + ( section_to_show + 1 ) + ' of ' + this.sections.length); // If this is the first/last section, disabled the previous/next button if ( this.section_currently_showing === 0 ) { $('.prev_button').attr('disabled', 'disabled'); } else { $('.prev_button').attr('disabled', ''); } if ( this.section_currently_showing === ( this.sections.length - 1 ) ) { $('.next_button').attr('disabled', 'disabled'); } else { $('.next_button').attr('disabled', ''); } }, show_navigation: function() { 'use strict'; var $chapter = $("[data-type=chapter]"); var main_title = $("[key=activity_type_title]").html(); if (main_title == null) { main_title = 'Concept Practice'; }; // Header var html = " "; $chapter.prepend(html); // Footer html = " "; $chapter.append(html); // Activate all other buttons UI_Elements.activate_buttons(); }, show_section: function(section_to_show) { //window.alert(section_to_show); var direction = "right"; if ( section_to_show == "previous" ) { section_to_show = this.section_currently_showing - 1; direction = "left"; } 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; } // if user has to view sections in sequence and hasn't gotten up to this one, don't allow it if ( this.md.sequenced_sections == "true" && section_to_show > this.last_available_section ) { Standard_Dialog.alert('You need to read and complete each section of the activity before moving on to the next section.
', { buttons: [{ text: "OK", click: function() { Standard_Dialog.close(); this.get_current_section().jq.find("[data-type=question] .query_text").focus(); }.bind(this) }] }); return; } this.show_section_animate(section_to_show, direction); // 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 } this.update_section_status(); this.update_navigation(); }, initialize: function() { 'use strict'; this._super(); // Re-init activity this.activity = new Activity_info_graphic(); // Manuscript var $manuscript = $('#manuscript'); $manuscript.attr('role', 'application'); // Chapter var $chapter = $('[data-type=chapter]'); $chapter.attr('tabindex', '-1') .attr('aria-label', 'You are taking test in the course Concept Practice. ' + 'You need to read each section and answer all questions to pass the activity ' + this.activity_title); this.silentElement = $(''); $chapter.append(this.silentElement); // Section $('[data-type="section"]').attr('tabindex', '0') .attr('aria-labelledby', 'slide_number'); // Paragraphs $('[data-type="section"]').find('p').each(function(i) { $(this).attr('tabindex', '0'); $(this).attr('aria-label', $(this).text()); }); // Images $('[data-type="section"]').find('img').attr('tabindex', '0'); } }); var MC_Query = MC_Query.extend({ // Mode should be "delivery" or "review"; "delivery" is assumed getHTML: function(mode) { // start with the query text, if there var html = this.query_text_html(); var ariaLabel = $(html).text(); if ( this.userHasAnswered() || mode == 'review' || mode == 'review_correct_incorrect' || mode == 'preview' ) { ariaLabel += ' You already answered this question.'; } else { ariaLabel += ' Answer the question and click Submit button.'; } ariaLabel = ariaLabel.replace(/\"/g, ''); html = html.replace('>', 'aria-label="'+ariaLabel+'" tabindex="0">QUESTION: '); // 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 += ""
+ " | "
+ "" + " |
You must answer the question before proceeding.
", { buttons: [{ text: "OK", click: function() { Standard_Dialog.close(); $('[data-question_index="' + (this.query_index + 1) + '"] .query_text').focus(); }.bind(this) }] }); return false; } } }); var Essay_Query = Essay_Query.extend({ // mode should be "delivery" or "review" or "review_correct_incorrect"; "delivery" is assumed getHTML: function(mode) { // start with the query text, if there var html = this.query_text_html(); var ariaLabel = $(html).text(); if ( this.userHasAnswered() || mode == 'review' || mode == 'review_correct_incorrect' || mode == 'preview' ) { ariaLabel += ' You already answered this question.'; } else { ariaLabel += ' Answer the question and click Submit button.'; } ariaLabel = ariaLabel.replace(/\"/g, ''); html = html.replace('>', 'aria-label="'+ariaLabel+'" tabindex="0">QUESTION: '); var val, disabled; if ( !this.userHasAnswered() || mode == 'preview' ) { val = ""; disabled = ""; // otherwise we have an answer, so fill it in } else { // make sure we convert double quotes to " for placement in 'value="xxx"' attributes val = this.user_answer; // convert breaks to newlines val = val.replace(/