Skip to content

Instantly share code, notes, and snippets.

@Zulcom
Created October 7, 2017 12:27
Show Gist options
  • Save Zulcom/25f9125b45b76381beeaa4dcfb60b1ff to your computer and use it in GitHub Desktop.
Save Zulcom/25f9125b45b76381beeaa4dcfb60b1ff to your computer and use it in GitHub Desktop.
Tampermonkey random quiz solver
// ==UserScript==
// @name Пройти тест заново, если оценка меньше 8
// @namespace http://tampermonkey.net/
// @version 0.1
// @description жмёт "пройти тест заново", если ответ на тест "Тест не пройден"
// @author Zulcom
// @match https://e.sfu-kras.ru
// @include https://*/mod/quiz/view.php?id=*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
$(function() {
// if($('.quizgradefeedback')[0].innerHTML.search("Тест не пройден")>0)
if( $('#feedback h3')[0].innerHTML.search("Высшая оценка: 8,"))
$('input[value="Пройти тест заново"').click();});
// ==UserScript==
// @name Пройти тестирование
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Расставляет радиобоксы в случайном порядке, чекбоксы заполняет все
// @author Zulcom
// @match https://e.sfu-kras.ru
// @include https://*/mod/quiz/attempt.php?attempt=*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
//$('img').each(function() { $(this)[0].after("("+$(this)[0].src.replace(/^.*[\\\/]/, '')+")");}); если надо, чтобы на всех страницах теста показывались имена картинок
$(function() {
// выбор случайного
if($("input:radio").length > 0)
$("input:radio")[Math.floor(Math.random()*$("input:radio").length)].checked = true;
else
$("input:checkbox").each(function(){
var checkboxes = $(this).closest('form').find(':checkbox');
$(this).prop('checked', true);
});
// переход вперёд
if($("input:submit")[1]) $("input:submit")[1].click();
else $("input:submit")[0].click();
});
// ==UserScript==
// @name Отправить всё и завершить тест
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Отправляет результаты и завершает тест
// @author Zulcom
// @match https://e.sfu-kras.ru
// @include https://*/mod/quiz/summary.php?attempt=*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
function checkContainer () {
if($('.moodle-dialogue-wrap').is(':visible')){ //if the container is visible on the page
$('input[value="Отправить всё и завершить тест"]')[1].click();
} else {
setTimeout(checkContainer, 50); //wait 50 ms, then try again
}
}
$(function() {
$("input:submit")[1].click();
checkContainer();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment