var DD_Query = DD_Query.extend({
getQueryTextForARGA: function(query_num) {
var q_stems = ['While preparing for giving a speech, I feel tense and nervous.',
'I feel tense when I see the words SPEECH and PUBLIC SPEECH on a course outline when studying.',
'My thoughts become confused and jumbled when I am giving a speech.',
'Just after giving a speech I feel that I have had a pleasant experience.',
'I get anxious when I think about a speech coming up.',
'I have no fear of giving a speech.',
'Although I am nervous just before starting a speech, I soon settle down after getting started and feel calm and comfortable.',
'I look forward to giving a speech.',
'When the instructor announces a speaking assignment in class, I can feel myself getting tense.',
'My hands tremble when I am giving a speech.',
'I feel relaxed while giving a speech.',
'I enjoy preparing for a speech.',
'I am in constant fear of forgetting what I prepared to say.',
'I get anxious if someone asks me something about my topic that I do not know.',
'I face the prospect of giving a speech with confidence.',
'I feel that I am in complete possession of myself while speaking.',
'My mind is clear when giving a speech.',
'I do not dread giving a speech.',
'I perspire just before starting a speech.',
'My heart beats very fast just as I start a speech.',
'I experience considerable anxiety while sitting in the room just before my speech starts.',
'Certain parts of my body feel tense and rigid while I am giving a speech.',
'Realizing that only a little time remains in a speech makes me very tense and anxious.',
'While giving a speech I can control my feelings of tension and stress.',
'I breathe faster just before starting a speech.',
'I feel comfortable and relaxed the hour or so before giving a speech.',
'I do poorly on speeches because I am anxious.',
'I feel anxious when the teacher announces the date of a speaking assignment.',
'When I make a mistake while giving a speech, I find it hard to concentrate on the parts that follow.',
'During an important speech I experience a feeling of helplessness building up inside me.',
'I have trouble falling asleep the night before a speech.',
'My heart beats very fast while I present a speech.',
'I feel anxious while waiting to give my speech.',
'While giving a speech I get so nervous I forget facts I really know.'
];
if (q_stems[query_num] !== undefined) {
return q_stems[query_num];
}
if (this.query_text_for_ARGA != null && this.query_text_for_ARGA != "") {
return this.query_text_for_ARGA;
} else if (this.query_text != null && this.query_text != "") {
return this.query_text;
} else {
return "see page for question context";
}
}
});
var Activity_subtype = Activity_manuscript_type.extend({
// brb: Fixes bug for questions with more than 30 queries. Previously,
// only the first 30 queries would be restored.
brb_get_query_number: function(question, query_index) {
var n = this.get_question_number(question);
// if the question has more than one query, add a sub-index
if (question.queries.length > 1) {
if (query_index < 31) {
n += String.fromCharCode(97 + query_index); // 97 is "a"
}
else {
n += "%" + (97 + query_index).toString(16).toUpperCase();
}
}
return n;
},
ARGA_Initialize_Questions: function() {
for (var j = 0; j < this.questions.length; ++j) {
var question = this.questions[j];
// if md.question_report_text is set, we will submit the question as a whole, rather than as individual queries
var query_correct_answers = "";
// for each query in the question...
for (var i = 0; i < question.queries.length; ++i) {
var query = question.queries[i];
// establish a question number to use
var query_number = this.get_query_number(question, i);
// get a query weight
var query_weight = question.get_weight();
// if the question has more than one query, divide weight accordingly
if (question.queries.length > 1) {
query_weight = Math.round(query_weight / question.queries.length);
}
// initialize the ARGA response, unless we're saving one response for the whole question
if (!question.md_set("question_report_text")) {
Set_ARGA_Question_Response({
questionNum:'' + query_number,
questionType:query.getQueryTypeForARGA(),
questionText:this.encode_for_ARGA(query.getQueryTextForARGA(i)),
correctAnswer:this.encode_for_ARGA(query.getCorrectAnswerForARGA()),
learnerResponse:'',
questionGrade:0,
questionWeight:query_weight
});
// otherwise compose query roll-ups
} else {
if (query_correct_answers != "") {
query_correct_answers += " / ";
}
query_correct_answers += query.getCorrectAnswerForARGA();
}
}
// if we're initializing one response for the whole question, do so here
if (question.md_set("question_report_text")) {
var number = this.get_question_number(question);
var type = question.md_set("question_type") ? question.md.question_type : this.mixed_question_type_label;
var text = question.md.question_report_text; // we wouldn't get to here if this wasn't set
Set_ARGA_Question_Response({
questionNum:'' + number,
questionType: type,
questionText:this.encode_for_ARGA(text),
correctAnswer:this.encode_for_ARGA(query_correct_answers),
learnerResponse:'',
questionGrade:0,
questionWeight:question.get_weight()
});
}
}
},
ARGA_set_query_response: function(q, query_number, query_weight) {
// return if ARGA isn't running
if (!player.ARGA_running) return;
// set arga response
// note that we send the original grade in questionData so we can get it back when the user returns
Set_ARGA_Question_Response({
questionNum:'' + query_number,
questionType:q.getQueryTypeForARGA(),
questionText:this.encode_for_ARGA(q.getQueryTextForARGA(q.query_index)),
correctAnswer:this.encode_for_ARGA(q.getCorrectAnswerForARGA()),
learnerResponse:this.encode_for_ARGA(q.getUserAnswerForARGA()),
questionGrade:q.getGradeForARGA(),
questionWeight:query_weight,
questionData:q.getOriginalGrade()
});
},
submit_question: function (question_index) {
// the arg may be a number or an event object; in the latter case...
if (typeof question_index == "object") {
// extract the question_index from the object
question_index = question_index.data.question_index;
}
//force all queries to be answered before doing anything.
var allQueriesAnswered = true;
for (var i = 0; i < player.activity.questions[question_index].queries.length; i++) {
var x = player.activity.questions[question_index].queries[i].user_has_answered();
if (!x) {
allQueriesAnswered = false;
}
}
if (!allQueriesAnswered) {
$("
Please answer all of the questions before submitting.
").dialog({
buttons: [{
text: "OK",
click: function () {
$(this).dialog("close");
}
}]
});
//alert("answer all questions!");
return false;
}
var answer;
var key;
player.model["score"] = 0;
//player.model["val1"] = 0;
//player.model["val2"] = 0;
for (var i = 0; i < player.activity.questions[question_index].queries.length; i++) {
answer = $("#query_answer_" + i).val();
if (answer !== "-1") {
player.model["score"] += (parseInt(answer) + 1);
console.log("#query_answer_" + i + ": " + player.model["score"]);
}
}
/*
for (var i = 0; i < player.activity.questions[question_index].queries.length; i++) {
answer = $('input:radio[name=query_answer_' + i + ']:checked').val();
//key = "val" + answer;
player.model["score"] += answer;
console.log("tallying score: " + player.model["score"]);
}
*/
console.log("computed score: " + player.model["score"]);
this._super(question_index);
// the arg may be a number or an event object; in the latter case...
if (typeof question_index == "object") {
// extract the question_index from the object
question_index = question_index.data.question_index;
}
player.activity.questions[question_index].checkModelUpdateConditionals(question_index);
//var executedNextStep = player.activity.questions[question_index].checkNextStepConditionals(question_index);
//player.sendModelToServer();
//check if we need to show the next button
//safe_log(player.get_current_section_jq().find(".next_section_button").attr("role"));
player.get_current_section_jq().find(".next_section_button").show();
//STG set focus on continue butotn, so 'continue' button shows up in the window, not below
$('button.next_section_button').focus();
//insert any variables that may be newly displayed in the question feedback
player.show_variables();
//move the feedback into a nice popup
$("[data-question_index=" + question_index + "]").find(".query_mc_feedback_correct_incorrect").dialog({
buttons: [{
text: "OK",
click: function () {
$(this).dialog("close");
}
}]
});
//look for any advanced answer choice feedback and show it as a dialog
// player.process_question_feedback_conditional_display();
$("#next_button2").show();
player.show_section(1);
return false;
},
show_grade_saved_message: function() {
// if the user has answered all queries AND the user hasn't been told this already,
// tell them now
if (player.activity.answered_all_queries && !player.user_has_received_completion_alert) {
setTimeout('Standard_Dialog.alert("You have completed the activity, and your grade has been submitted.");', 20);
player.user_has_received_completion_alert = true;
}
},
restore_saved_answers: function() {
// skip page queries (questions[0])
for (var i = 1; i < this.questions.length; ++i) {
var question = this.questions[i];
// prepare for question_report_text questions
var query_responses;
if (question.md_set("question_report_text")) {
query_responses = "" + Get_ARGA_QuestionData(this.get_question_number(question))
query_responses = query_responses.split(this.query_responses_separator);
}
var restored_all_answers = true;
var all_answers_correct = true;
for (var j = 0; j < question.queries.length; ++j) {
var query = question.queries[j];
var saved_answer, saved_grade;
// get saved answer and grade out of the questionData for question_report_text questions
if (question.md_set("question_report_text")) {
if (query_responses[j] != null) {
var arr = query_responses[j].split(this.query_responses_grade_separator);
saved_answer = arr[0];
saved_grade = arr[1];
} else {
saved_grade = saved_answer = "";
}
// or out of learnerResponse / questionData for single-query questions
} else {
var ARGA_question_number = this.brb_get_query_number(question, j);
saved_answer = Get_ARGA_LearnerResponse(ARGA_question_number);
// we stored the original grade in questionData
saved_grade = Get_ARGA_QuestionData(ARGA_question_number)
}
// if we found a grade...
if (saved_grade !== "" && saved_grade >= 0) {
// restore the answer
query.restoreAnswerFromARGA(saved_answer);
query.setGrade(saved_grade);
// then re-render the query in review mode
query.jq.html(query.getHTML("review"));
if (query.isCorrect() == false) {
all_answers_correct = false;
}
} else {
restored_all_answers = false;
}
}
if (restored_all_answers) {
// update the submit div for the question
this.update_question_action_div(i);
// Show appropriate feedback. If the question responses were submitted,
// the student must have finished the question, so we don't have to worry
// about hints.
this.show_question_feedback(question, all_answers_correct, false);
// if the item is in a sequence, show the next question
this.show_next_question(question);
// NEED TO CHECK TO MAKE SURE THIS IS WORKING PROPERLY
// If the question is in a sequence and the sequence is complete, call show_closing_material
var qs = question.question_sequence;
if (qs != null && qs.sequence_complete == "partial") {
this.show_closing_material(qs.index);
}
// update section status
player.update_section_status();
player.activity.calculate_score();
}
}
},
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();
var due_date_passed = (Get_ARGA_Data("due_date_has_passed") == "1");
var msg = "";
var buttons;
due_date_passed = false;
if (grade != "" && grade != null && 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 the activity, and your 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});
} else {
player.activity.ARGA_initialization_final();
}
},
calculate_score: function () {
var question_index = $('[data-type="question"]').attr('data-question_index');
var answer;
var key;
player.model["score"] = 0;
for (var i = 0; i < player.activity.questions[question_index].queries.length; i++) {
answer = $("#query_answer_" + i).val();
if (answer !== "-1") {
player.model["score"] += (parseInt(answer) + 1);
console.log("#query_answer_" + i + ": " + player.model["score"]);
}
}
console.log("computed score: " + player.model["score"]);
player.show_variables();
}
});
var Player_custom = Player_subtype.extend({
show_variables: function () {
//look through all the p nodes
var section = this.get_current_section_jq();
var regex = new RegExp("{(.+?)}", "gmi");
$(section).find("p, label, option, table").each(function (index, element) {
var text = $(element).html();
text = text.replace(regex, function (a, b) {
return eval("player." + b);
});
$(element).html(text);
});
var div_score = 0;
// display the appropriate results
if (player.model['score'] > 0) {
console.log("displaying score");
$('[data-block_type="score"]').text(player.model['score']);
if (player.model["score"] <= 98) {
div_score = 98;
}
else if (player.model["score"] <= 131) {
div_score = 131;
}
else {
div_score = 170;
}
console.log("div score: " + div_score);
var block_type = "[data-block_type='results_val" + div_score + "']";
console.log("results block_type: " + block_type);
$(block_type).addClass('show_result');
}
}, // end show_variables function
});
player = new Player_custom();