Renamed myDom -> to reflect it being a jQuery object
parent
748412e206
commit
8bb04c69b7
|
@ -126,7 +126,7 @@ H5P.QuestionSet = function (options) {
|
||||||
var currentQuestion = 0;
|
var currentQuestion = 0;
|
||||||
var questionInstances = new Array();
|
var questionInstances = new Array();
|
||||||
var allQuestionsAnswered = false;
|
var allQuestionsAnswered = false;
|
||||||
var myDom;
|
var $myDom;
|
||||||
|
|
||||||
if (params.randomOrder) {
|
if (params.randomOrder) {
|
||||||
// TODO: Randomize order of questions
|
// TODO: Randomize order of questions
|
||||||
|
@ -147,7 +147,7 @@ H5P.QuestionSet = function (options) {
|
||||||
for (var i = questionInstances.length - 1; i >= 0; i--) {
|
for (var i = questionInstances.length - 1; i >= 0; i--) {
|
||||||
answered = answered && (questionInstances[i]).getAnswerGiven();
|
answered = answered && (questionInstances[i]).getAnswerGiven();
|
||||||
}
|
}
|
||||||
$('.finish.button', myDom).attr({'disabled': !answered});
|
$('.finish.button', $myDom).attr({'disabled': !answered});
|
||||||
};
|
};
|
||||||
|
|
||||||
var _showQuestion = function (questionNumber) {
|
var _showQuestion = function (questionNumber) {
|
||||||
|
@ -155,24 +155,24 @@ H5P.QuestionSet = function (options) {
|
||||||
if (questionNumber < 0) { questionNumber = 0; }
|
if (questionNumber < 0) { questionNumber = 0; }
|
||||||
if (questionNumber >= params.questions.length) { questionNumber = params.questions.length - 1; }
|
if (questionNumber >= params.questions.length) { questionNumber = params.questions.length - 1; }
|
||||||
|
|
||||||
$('.prev.button', myDom).attr({'disabled': (questionNumber === 0)});
|
$('.prev.button', $myDom).attr({'disabled': (questionNumber === 0)});
|
||||||
$('.next.button', myDom).attr({'disabled': (questionNumber == params.questions.length-1)});
|
$('.next.button', $myDom).attr({'disabled': (questionNumber == params.questions.length-1)});
|
||||||
|
|
||||||
|
|
||||||
// Hide all questions
|
// Hide all questions
|
||||||
$('.question-container', myDom).hide();
|
$('.question-container', $myDom).hide();
|
||||||
|
|
||||||
// Reshow the requested question
|
// Reshow the requested question
|
||||||
$('#q-' + questionNumber, myDom).show();
|
$('#q-' + questionNumber, $myDom).show();
|
||||||
|
|
||||||
// Update progress indicator
|
// Update progress indicator
|
||||||
// Test if current has been answered.
|
// Test if current has been answered.
|
||||||
if (params.progressType == 'textual') {
|
if (params.progressType == 'textual') {
|
||||||
$('.progress-text', myDom).text(params.texts.textualProgress.replace("@current", questionNumber+1).replace("@total", params.questions.length));
|
$('.progress-text', $myDom).text(params.texts.textualProgress.replace("@current", questionNumber+1).replace("@total", params.questions.length));
|
||||||
} else {
|
} else {
|
||||||
// Set currentNess
|
// Set currentNess
|
||||||
$('.progress-dot.current', myDom).removeClass('current');
|
$('.progress-dot.current', $myDom).removeClass('current');
|
||||||
$('#qdot-' + questionNumber, myDom).addClass('current');
|
$('#qdot-' + questionNumber, $myDom).addClass('current');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember where we are
|
// Remember where we are
|
||||||
|
@ -184,7 +184,9 @@ H5P.QuestionSet = function (options) {
|
||||||
var attach = function (targetId) {
|
var attach = function (targetId) {
|
||||||
// Render own DOM into target.
|
// Render own DOM into target.
|
||||||
template.update(targetId, params);
|
template.update(targetId, params);
|
||||||
myDom = $('#' + targetId);
|
$myDom = $('#' + targetId);
|
||||||
|
|
||||||
|
$myDom.find(".questionset").css({backgroundImage: 'url(' + params.backgroundImage + ')'});
|
||||||
|
|
||||||
// Attach questions
|
// Attach questions
|
||||||
for (var i=0; i<questionInstances.length; i++) {
|
for (var i=0; i<questionInstances.length; i++) {
|
||||||
|
@ -192,19 +194,19 @@ H5P.QuestionSet = function (options) {
|
||||||
// TODO: Render on init, inject in template.
|
// TODO: Render on init, inject in template.
|
||||||
quest.attach('q-' + i);
|
quest.attach('q-' + i);
|
||||||
$(quest).on('h5pQuestionAnswered', function (ev) {
|
$(quest).on('h5pQuestionAnswered', function (ev) {
|
||||||
$('#qdot-' + currentQuestion, myDom).removeClass('unanswered').addClass('answered');
|
$('#qdot-' + currentQuestion, $myDom).removeClass('unanswered').addClass('answered');
|
||||||
_updateFinishButton();
|
_updateFinishButton();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set event listeners.
|
// Set event listeners.
|
||||||
$('.next.button', myDom).click(function (ev) {
|
$('.next.button', $myDom).click(function (ev) {
|
||||||
_showQuestion(currentQuestion + 1);
|
_showQuestion(currentQuestion + 1);
|
||||||
});
|
});
|
||||||
$('.prev.button', myDom).click(function (ev) {
|
$('.prev.button', $myDom).click(function (ev) {
|
||||||
_showQuestion(currentQuestion - 1);
|
_showQuestion(currentQuestion - 1);
|
||||||
});
|
});
|
||||||
$('.finish.button', myDom).click(function (ev) {
|
$('.finish.button', $myDom).click(function (ev) {
|
||||||
// Get total score.
|
// Get total score.
|
||||||
var finals = getScore();
|
var finals = getScore();
|
||||||
var totals = totalScore();
|
var totals = totalScore();
|
||||||
|
|
Loading…
Reference in New Issue