Skip to content

Instantly share code, notes, and snippets.

@SwapnilSoni1999
Created May 30, 2020 07:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SwapnilSoni1999/f820f780fae750910ab673a07e00214b to your computer and use it in GitHub Desktop.
Save SwapnilSoni1999/f820f780fae750910ab673a07e00214b to your computer and use it in GitHub Desktop.
google form auto filling script for MCQ.
  • paste in dev console
  • call autofillAnswers function
  • pass answer string eg. "DBCCBDBCADCBADBADABC"
  • eg.
autofillAnswers("DBCCBDBCADCBADBADABC")
function getIntFromMCQ(optionStr) {
const OptEnum = { 'A': 0, 'B': 1, 'C': 2, 'D': 3 }
return OptEnum[optionStr]
}
function autofillAnswers(answerSeriesStr) {
let answers = answerSeriesStr.match(/\w/gm)
for (let i=0; i<answers.length; i++) {
let currQues = i
let answer = answers[i]
document.querySelectorAll('.freebirdFormviewerViewItemsItemItem')[currQues].children[1].children[0].children[0].children[0].children[getIntFromMCQ(answer)].querySelector('label').click()
}
}
// usage: autofillAnswers("DBCCBDBCADCBADBADABC")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment