Currently for question, Learndash only allow to add an message to the correct answer & a generic message for all of the incorrect answer. How do i write a unique message for each of the incorrect answers.
I tried adding a script to the text editor. It works when I test it in codepen but it doesn't seem to run on the Wordpress.
<div>
<p id="answerMessage">Answer</p>
<div>
<script>
function() {
const answerMessage = document.getElementById('answerMessage');
const labelElement = document.querySelector('li.wpProQuiz_questionListItem label.is-selected');
if (labelElement) {
const inputElement = labelElement.querySelector('input.wpProQuiz_questionInput');
const selectedValue = inputElement.value;
// 3 is the correct answer
const answerMessages = {
"1": "Explanation 1",
"2": "Explanation 2",
"4": "Explanation 3",
};
if (selectedValue in answerMessages) {
answerMessage.innerText = answerMessages[selectedValue];
}
}
};
</script>
</div>
</div>
It would be great if I can add an extra field below each answer on the question page. Unfortunately I'm not too familiar with PHP.