Skip to content

Instantly share code, notes, and snippets.

@Trott
Created December 11, 2013 23:27
Show Gist options
  • Save Trott/7920434 to your computer and use it in GitHub Desktop.
Save Trott/7920434 to your computer and use it in GitHub Desktop.
Quick and dirty prototype for cross-off functionality in Moodle quizzes. Plenty of limitations to this and lots of suboptimal coding practices. But good enough for a quick demo and "something like this?" questions.
var answers = document.querySelectorAll('.multichoice .answer div');
for (var i=0, l=answers.length; i<l; i++) {
answers[i].appendChild(document.createTextNode('\u2717'));
answers[i].addEventListener('click', function( e ) {
if (e.target===this) {
if (this.getAttribute('style') === 'text-decoration: line-through') {
this.setAttribute('style', '');
} else {
this.setAttribute('style','text-decoration: line-through');
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment