Skip to content

Instantly share code, notes, and snippets.

@alashow
Created November 15, 2019 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alashow/fe9096004e9a0848cd0a88661b4be8b0 to your computer and use it in GitHub Desktop.
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.
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