Skip to content

Instantly share code, notes, and snippets.

@PostsDesert
Created May 9, 2023 21:39
Show Gist options
  • Save PostsDesert/c43ded169d939c96be550cab1311cc33 to your computer and use it in GitHub Desktop.
Save PostsDesert/c43ded169d939c96be550cab1311cc33 to your computer and use it in GitHub Desktop.
A simple program that removes all the answer information from a Moodle quiz to allow for easier review without subconsciously thinking you already know it because you can see the answer. To use, just paste in the inspect element console on the Moodle Quiz review page.
var elements = document.querySelectorAll('.qnbutton, .state, .grade, .outcome, .icon');
for (var i = 0; i < elements.length; i++) {
elements[i].style.opacity = '0.0'; // set initial opacity
elements[i].addEventListener('click', function() {
var opacity = parseFloat(this.style.opacity);
this.style.opacity = opacity ? '' : '0.0'; // toggle opacity
});
}
// Get all the checkboxes and radio inputs on the page
const boxInputs = document.querySelectorAll('input[type="checkbox"], input[type="radio"]');
// Loop through each input and uncheck it
boxInputs.forEach(input => {
input.checked = false;
});
// Get all the text inputs on the page
const textInputs = document.querySelectorAll('input[type="text"], input[type="email"], input[type="password"]');
// Loop through each input and clear its value
textInputs.forEach(input => {
input.value = '';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment