Skip to content

Instantly share code, notes, and snippets.

@YazeedAlKhalaf
Last active April 21, 2024 12:25
Show Gist options
  • Save YazeedAlKhalaf/75e57f313fcc872adda309378c419d65 to your computer and use it in GitHub Desktop.
Save YazeedAlKhalaf/75e57f313fcc872adda309378c419d65 to your computer and use it in GitHub Desktop.
edugate auto rate
(function () {
let feedbackType = "r"; // Change to 'l' for left side, since sometimes negative and positive are switched :)
let rows = Array.from(document.querySelectorAll("table tr"));
rows.forEach((row) => {
let radios = Array.from(row.querySelectorAll('input[type="radio"]'));
if (radios.length > 0) {
let selection;
if (feedbackType === "r") {
selection = radios.slice(-3);
} else {
selection = radios.slice(0, 2);
}
let chosenOption =
selection[Math.floor(Math.random() * selection.length)];
chosenOption.checked = true;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment