Created
October 13, 2021 16:27
-
-
Save AgeOfMarcus/d679f9a66eab40c4044608dfdb773999 to your computer and use it in GitHub Desktop.
Canvas Quiz Savedata
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
// get answers | |
var answers = {} | |
document.querySelectorAll('div.display_question').forEach(function(el, index) { | |
let correct_ans = el.querySelector('input:checked').parentElement.parentElement.children[1].innerText; | |
answers[index] = correct_ans; | |
}) | |
console.log(answers) | |
// enter answers | |
var answers = {} // paste answers in | |
document.querySelectorAll('div.display_question').forEach(function(el, index) { | |
let correct_ans = answers[index]; | |
el.querySelectorAll('input[type=radio]').forEach(function(rad) { | |
let ans_text = rad.parentElement.parentElement.children[1].innerText; | |
if (correct_ans == ans_text) { | |
rad.checked = true; | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment