Created
December 11, 2013 23:27
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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