Created
March 21, 2016 22:47
-
-
Save k4kfh/09225c205dcb044d5918 to your computer and use it in GitHub Desktop.
Simple script for getting the answers from a Canvas quiz and pasting them into the input of another attempt. Only useful if your teachers allow multiple attempts on a quiz, and it doesn't cheat, it's just a time saver.
This file contains 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
//OLD ATTEMPT CODE | |
//run this on the old attempt page to spit out all your answers in an array. | |
//copy the array to your clipboard | |
var answerList = []; | |
$(".question_input").each(function() { | |
answerList.push($(this).val()) | |
}) | |
//NEW ATTEMPT CODE | |
//put in your answers in global variable answerList | |
answerList = //paste in the answers from your clipboard here | |
//Then just paste the code below. | |
inputs = $(".question_input") | |
for(i=0;i<answerList.length;i++) { | |
console.log("Question " + (i+1) + ":" + answerList[i]) | |
console.log("DOM ELEMENT FOR THIS QUESTION:"); | |
console.log(inputs[i]) | |
var currentInput = inputs[i] | |
$(inputs[i]).val(answerList[i]) | |
} | |
/* | |
Note: Canvas will tell you that you've got a bunch of | |
unanswered questions when you go to submit the quiz. It's lying; | |
it's just not noticing the changes since they're from the script and not the user. | |
If you just submit it anyway, it will still grade correctly. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment