in ArticleTemplates/assets/js/modules/quiz.js [391:431]
function onPersonalityAnswerClick(answer, question) {
initPositionPoller();
let highlightedAnswer;
let answerBuckets;
let highlightedAnswerBuckets;
// if the question has been answered already
// and the the new answer selected is not the highlighted answer
// remove answer from highlighted answer buckets
if (question.classList.contains('answered') &&
!(answer.classList.contains('highlight-answer') || questionCount === numAnswered)) {
highlightedAnswer = question.getElementsByClassName('highlight-answer')[0];
highlightedAnswer.classList.remove('highlight-answer');
highlightedAnswerBuckets = highlightedAnswer.dataset.buckets.split(',');
highlightedAnswerBuckets.forEach(bucketId => {
bucketId = bucketId.trim();
if (personalityQuizBuckets[bucketId]) {
personalityQuizBuckets[bucketId].count--;
}
});
numAnswered--;
}
// update answer buckets
answerBuckets = answer.dataset.buckets.split(',');
answerBuckets.forEach(bucketId => {
bucketId = bucketId.trim();
if (personalityQuizBuckets[bucketId]) {
personalityQuizBuckets[bucketId].count++;
}
});
// mark question as answered
question.classList.add('answered');
answer.classList.add('highlight-answer');
numAnswered++;
// If all questions have been answered display the score
if (questionCount === numAnswered) {
showResult();
}
}