var data;
var score;
var questionStatus = {};
- var showReview, threshold, instantReview, logAttempts, displayScore, countQuestions, passedAction, failedAction,
+ var testMode, quizMode, showReview, threshold, instantReview, logAttempts, displayScore, countQuestions,
+ passedAction, failedAction,
logQuestions;
function initApp() {
instantReview = DATA.instantReview;
logAttempts = DATA.logattempts;
displayScore = DATA.display_score;
+ testMode = DATA.type === 'test';
+ quizMode = DATA.type === 'quiz';
threshold = DATA.threshold;
if (threshold > 1) {
$(answer).addClass('active');
$('section:visible').find('.answer:not(.active)').addClass('inactive');
updateScore();
- displayBadge($(answer).attr('data-correct') == 1);
+ if (testMode) {
+ displayBadge(true);
+ } else {
+ displayBadge($(answer).attr('data-correct') == 1);
+ }
resizeContainer();
} else {
$(answer).toggleClass('active');
}
function updateScore() {
+ if (testMode) {
+ return updateTestScore();
+ }
+ if (quizMode) {
+ return updateQuizScore();
+ }
+ }
+
+ function updateTestScore() {
+ score = 0;
+ var answers = [];
+ var qn = 1;
+ logQuestions = [];
+
+
+ $('.question').each(function () {
+ var q = $(this);
+ var a = [];
+ var log = {};
+
+ var qScore = null;
+ if ($(this).data('type') === 'multiple') {
+ $(this).find('.answer.active').each(function () {
+ a.push($(this).data('a'))
+ qScore = DATA.questions[q.data('q') - 1].answers[$(this).data('a')].score;
+ });
+
+ answers.push(a);
+ log.answer = a;
+ } else {
+ log.answer = $(this).find('input,textarea,select').val();
+ }
+
+ questionStatus[qn] = qScore;
+
+ if (qScore !== null) {
+ score += qScore;
+ }
+ log.score = qScore;
+
+ logQuestions[qn] = log;
+ qn++;
+ });
+
+
+ var state = {
+ q: $(".answer.active").last().closest('.question').data('q') + 1, a: answers
+ };
+
+ if (SCORM) {
+ setSCORMLocation(state);
+ }
+ $("#correctanswers").text(score);
+ }
+
+ function updateQuizScore() {
score = 0;
var answers = [];
var qn = 1;
}
$("#correctanswers").text(score);
}
+
+
});
})(typeof window === 'undefined' ? this : window);