var Activity_manuscript_type = Activity.extend({
current_question: null,
// this needs to be updated in player.js. Remove it from here once that update has occurred
ARGA_initialization_alert: function() {
// This overrides the standard ARGA initialization message, which doesn't
// tell the user he/she can resubmit (or tell him his grade)
var grade = Get_ARGA_Grade();
// treat empty grade as -2
if (grade == "") {
grade = -2;
}
var due_date_passed = (Get_ARGA_Data("due_date_has_passed") == "1");
var msg = "";
var buttons;
// PW: this must have been in for testing purposes
//due_date_passed = false;
// no alert for instructors
if (player.activity.is_student()) {
if (grade >= 0) {
// if resubmissions are allowed...
if (player.md.allow_resubmission == "true") {
// if due date has not passed, give the student the option of resubmitting or reviewing
if (!due_date_passed) {
msg = "
You have completed this activity, and your grade (" + grade + "%) has been submitted. Would you like to:
"
+ "- Keep your current grade and review your previous answers
"
+ "- Or reset your submission and try the activity again?
"
+ "
"
;
buttons = [ {text:"Keep current grade", click: player.activity.ARGA_initialization_final}
, {text: "Try Activity Again", click: function() {player.activity.ARGA_initialization_final("reset")}}
];
} else {
msg = "You have completed this activity, and your grade (" + grade + "%) has been submitted. Since the due date for the activity has now passed, you cannot re-submit answers to the activity questions.
"
buttons = [ {text:"OK", click: player.activity.ARGA_initialization_final} ];
}
// resubmissions are not allowed
} else {
msg = "You have completed this activity, and your grade (" + grade + "%) has been submitted.
"
;
buttons = [ {text:"OK", click: player.activity.ARGA_initialization_final} ];
}
// grade has not been submitted
} else {
// if due date has passed, tell the user "tough luck". Otherwise show nothing.
if (due_date_passed) {
msg = "The due date for this activity has passed. You can still review the activity, but no answers will be submitted and no grade will be recorded.
"
;
buttons = [ {text:"OK", click: player.activity.ARGA_initialization_final} ];
}
}
}
// if we need a message, show it in a jquery UI dialog
if (msg != "") {
msg = "" + msg + "
";
$("body").append(msg);
$("#arga_init_dialog").dialog({title:"Please Note", width:450, modal:true, buttons: buttons, dialogClass:"arga_init_dialog", closeOnEscape: false}); // player.activity.ARGA_initialization_final
} else {
player.activity.ARGA_initialization_final();
}
},
restore_saved_answers: function() {
// don't restore saved answers for instructors
if (!player.activity.is_instructor()) {
this._super();
// now show stuff...
}
},
get_question_number: function(q) {
// always use q.index here
return q.index;
},
show_next_question: function(question) {
if (this.current_question >= this.questions.length - 1) {
this.complete_quiz();
return;
}
this._super(this.questions[this.current_question++]);
},
complete_quiz: function() {
// make sure question_submit_button's are hidden
$(".question_submit_button").hide();
// also question_sequence_navigator should be hidden
$(".question_sequence_navigator").hide();
// show questions
for (var i = 1; i < this.questions.length; ++i) {
this.questions[i].jq.show();
}
var html = ""
+ "Total Score: " + player.activity.total_points_earned
+ " out of " + player.activity.total_points_possible
+ " points (" + player.activity.grade_percent + "%)"
+ "
"
;
player.question_block.append(html);
// scroll to bottom of screen
$(window).scrollTo(5000, {
duration:200
, axis:'y'
});
}
});
var Player_manuscript_type = Player.extend({
activity_title: null,
// this will be initialized with the jquery of the question block,
// which might be a question_sequence or question_sequence_one_at_a_time
question_block: null,
// this will be set to true when the user is allowed to take the quiz
quiz_enabled: false,
// this will be set to true when the quiz starts, so it can't be restarted
quiz_started: false,
// metadata
md: new Object(),
// no navigation to show, since we only have one section per activity
show_navigation: function() {
var html = "";
// find the question_block
this.question_block = $("[data-block_type=question_sequence]");
if (this.question_block.length == 0) {
this.question_block = $("[data-block_type=question_sequence_one_at_a_time]");
}
if (this.question_block.length == 0) {
this.question_block = $("[data-block_type=questions]");
}
this.question_block.hide();
// Show activity type and title, unless activity data says to hide it
html += "";
if (this.md.activity_type_title != null) {
html += "
" + this.md.activity_type_title + "
";
}
html += this.activity_title
+ "
"
;
// insert this at the top of the (only) section
$("[data-type=section]").first().prepend(html);
// Instructions for starting the quiz
if (this.md.activity_instructions != null) {
html = ""
+ this.md.activity_instructions
+ "
"
;
// insert this before the first figure block
$("[data-type=figure]").first().before(html);
}
// button for starting the quiz -- after the figure block
html = ""
+ UI_Elements.get_button_html({
id: "start_quiz_button"
, label: this.md.quiz_start_button_label
, fn: "player.start_quiz()"
})
+ "
"
$("[data-type=figure]").first().after(html);
UI_Elements.activate_buttons();
// Show title for questions at start of questions block
html = "";
this.question_block.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 completed the activity. Instructors, however, can view the questions at any time.");
// otherwise don't let them start the quiz!
} else {
alert(this.md.quiz_premature_warning);
return;
}
}
$("#activity_instructions").css("visibility","hidden");
$("#start_quiz_link").hide();
this.question_block.show();
this.activity.current_question = 1;
this.activity.questions[this.activity.current_question].jq.show();
this.quiz_started = true;
// scroll to bottom of screen
$(window).scrollTo(2000, {
duration:200
, axis:'y'
});
},
extract_activity_metadata: function() {
this._super();
// optional metadata val: activity_type_title
this.required_metadata_val("enable_quiz_time", 30);
this.required_metadata_val("activity_instructions", "After you've completed the activity, click the button below to answer questions about what you've learned.");
this.required_metadata_val("quiz_title", "Activity Comprehension Quiz");
this.required_metadata_val("quiz_start_button_label", "Begin the " + this.md.quiz_title);
this.required_metadata_val("quiz_premature_warning", "You must complete the activity before you can take the " + this.md.quiz_title + ".");
// 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() {
// extract metadata
this.extract_activity_metadata();
// activity title is data-type="title" inside h1
this.activity_title = $("h1").find("[data-type=title]").html();
this._super();
// first call this.super, then re-initialize the activity to the custom
// activity type for this manuscript
this.activity = new Activity_manuscript_type();
// 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();
$("#manuscript").show();
},
init: function() {
this._super();
}
});
player = new Player_manuscript_type();