var Activity_manuscript = Activity.extend({
current_question: null,
show_next_question: function() {
if (this.current_question == null) {
this.current_question = 1;
} else {
this.questions[this.current_question].jq.hide();
++this.current_question;
}
if (this.current_question >= this.questions.length) {
this.complete_quiz();
return;
}
$("[data-question_index=" + this.current_question + "]").fadeIn(500, function() {
window.scrollTo(0,1000);
});
//this.questions[this.current_question].jq.fadeIn(500, function() {
// window.scrollTo(0,1000);
//});
},
submit_question: function(question_index) {
this._super(question_index);
},
complete_quiz: function() {
// show questions and calculate total score
var total_score = 0;
for (var i = 1; i < this.questions.length; ++i) {
this.questions[i].jq.show();
if (this.questions[i].queries[0].isCorrect()) {
++total_score;
}
}
// show total score at bottom of questions block
var total_questions = this.questions.length - 1;
var percentage = Math.round(total_score / total_questions * 100);
var html = "
"
+ "Total Score: " + total_score
+ " out of " + total_questions
+ ", " + percentage + "%"
+ "
"
;
$("[data-block_type=questions]").append(html);
// scroll to bottom of screen
window.scroll(0, 1000);
}
});
var Player_manuscript = Player.extend({
// this will be set to true when the user is allowed to take the quiz
quiz_enabled: false,
// we'll do our own ARGA initialization alert
ARGA_custom_initialization_alert: true,
// this will be set to true when the quiz starts, so it can't be restarted
quiz_started: false,
// This shouldn't be necessary at all, since we only have one section per activity
show_section_animate: function(section_to_show, direction) {
// hide currently showing section
if (this.section_currently_showing != null) {
this.get_current_section_jq().hide();
}
this.section_currently_showing = section_to_show;
this.get_current_section_jq().show(300);
// scroll to top
window.scrollTo(0,0);
},
toggle_long_description: function() {
var jq = $("#expand_link").find("a");
if (jq.html() == "expand") {
jq.html("collapse");
$("[data-block_type=short_description]").hide();
$("[data-block_type=long_description]").slideDown(200);
} else {
jq.html("expand");
$("[data-block_type=long_description]").slideUp(200, function() {
$("[data-block_type=short_description]").show();
});
}
},
// no navigation to show, since we only have one section per activity
show_navigation: function() {
var html;
// Show activity title and "expand" link to show the long description
html = ""
+ ""
+ this.sections[0].title
+ "
"
+ "" ;
// insert this before the short_description block
$("[data-block_type=short_description]").before(html);
// Show "Begin the Video Assessment Quiz" link and instructions
html = "
"
+ "After you've watched the video, click the link below to answer questions about what you've learned."
+ ""
+ ""
// insert this after the long description block
$("[data-block_type=long_description]").after(html);
// Show title for questions at start of questions block
html = "";
$("[data-block_type=questions]").prepend(html);
},
enable_quiz: function() {
this.quiz_enabled = true;
},
start_quiz: function() {
if (this.quiz_started) {
return;
}
// if the quiz is not yet enabled...
if (!this.quiz_enabled) {
// if user has instructor-level access, tell them students won't see it
// but let them through
if (player.activity.is_instructor() == true) {
alert("Please note: Students will not be able to view these questions until they have watched the entire video. Instructors, however, can view the questions at any time.");
// otherwise don't let them start the quiz!
} else {
alert("You must watch the entire video before completing the Video Assessment Quiz.");
return;
}
}
$("[data-block_type=questions]").show();
this.activity.show_next_question();
this.quiz_started = true;
},
extract_activity_metadata: function() {
this._super();
// optional metadata val: activity_type_title
this.required_metadata_val("enable_quiz_time", 30);
// if enable_quiz_time is > 2000, it's almost certainly specified in milliseconds, so convert to seconds
if (this.md.enable_quiz_time > 2000) {
this.md.enable_quiz_time = Math.round(this.md.enable_quiz_time / 1000);
}
},
initialize: function() {
this._super();
// first call this.super, then re-initialize the activity to the custom
// activity type for this manuscript
this.activity = new Activity_manuscript();
// start a timer that determines when the user is allowed to take the quiz
setTimeout("player.enable_quiz()", (this.md.enable_quiz_time * 1000));
},
initialize2: function() {
this._super();
},
init: function() {
this._super();
}
});
player = new Player_manuscript();