Created
November 15, 2019 02:50
-
-
Save alashow/fe9096004e9a0848cd0a88661b4be8b0 to your computer and use it in GitHub Desktop.
Solves multiple choice question parts of webtexts/soomo learning. Just run this code on browser's console.
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
prepareAnswers(); | |
setTimeout(resetQuestions, 1500); | |
setTimeout(solveQuestions, 3000); | |
function prepareAnswers() { | |
$.each($.find('.multiple-choice-question-element'), function(i, wrapper) { | |
wrapper = $(wrapper); | |
var button = wrapper.find('.save-answers'); | |
var choice = $(wrapper.find('.question-choice')[0]).find('input'); | |
choice.prop("checked", true).trigger("click"); | |
button.trigger('click'); | |
}); | |
} | |
function resetQuestions() { | |
var resetButton = $('#reset-mc-answers').find('button'); | |
resetButton.trigger('click'); | |
} | |
function solveQuestions() { | |
$.each($.find('.multiple-choice-question-element'), function(i, wrapper) { | |
wrapper = $(wrapper); | |
var button = wrapper.find('.save-answers'); | |
var choices = wrapper.find('.question-choice'); | |
var found = false; | |
$.each(choices, function(index, choice) { | |
if (!found) { | |
var choice = $(choice) | |
choice.find('input').prop("checked", true).trigger("click"); | |
if (wrapper.find('.correct').length == 1) { | |
found = true; | |
button.trigger('click'); | |
} | |
} | |
}) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment