Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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