Quick fix
This commit is contained in:
parent
87fdf0885f
commit
5568bc4925
2 changed files with 17 additions and 3 deletions
14
server.py
14
server.py
|
@ -45,6 +45,8 @@ def resolve_logs(tries = 3, backup = True):
|
|||
incorrect = {}
|
||||
for l in logs:
|
||||
for a in l['answers']:
|
||||
if a == "dummy":
|
||||
continue
|
||||
if a[0] in correct:
|
||||
if a[2] == correct[a[0]]:
|
||||
l['correct'] -= 1
|
||||
|
@ -55,12 +57,16 @@ def resolve_logs(tries = 3, backup = True):
|
|||
l['answers'] = list(filter(lambda a: a[0] != '-', l['answers']))
|
||||
if len(l['answers']) == l['correct']:
|
||||
for a in l['answers']:
|
||||
if a == "dummy":
|
||||
continue
|
||||
correct[a[0]] = a[2]
|
||||
if a[0] in incorrect:
|
||||
incorrect.pop(a[0])
|
||||
l['answers'] = []
|
||||
elif l['correct'] == 0:
|
||||
for a in l['answers']:
|
||||
if a == "dummy":
|
||||
continue
|
||||
if a[0] not in incorrect:
|
||||
incorrect[a[0]] = []
|
||||
incorrect[a[0]] = list(set(incorrect[a[0]] + [a[2]]))
|
||||
|
@ -74,7 +80,7 @@ def resolve_logs(tries = 3, backup = True):
|
|||
break
|
||||
incorrect.pop(a[0])
|
||||
l['answers'] = []
|
||||
logs = list(filter(lambda l: len(l['answers']) != 0, logs))
|
||||
logs = list(filter(lambda l: (len(l['answers']) != l['answers'].count("dummy")), logs))
|
||||
new_logs = db.read(f"tests.{test}.logs")
|
||||
if new_logs is None:
|
||||
new_logs = []
|
||||
|
@ -95,8 +101,12 @@ def parse_request(r):
|
|||
return
|
||||
match (rtype):
|
||||
case "test_results":
|
||||
answers = results['answers']
|
||||
all_answ = int(results['all'])
|
||||
while (len(answers) != all_answ):
|
||||
answers.append("dummy")
|
||||
log = {
|
||||
'answers': results['answers'],
|
||||
'answers': answers,
|
||||
'correct': int(results['correct']),
|
||||
}
|
||||
logs = db.read(f'tests.{test_id}.logs', [])
|
||||
|
|
6
user.js
6
user.js
|
@ -2,7 +2,7 @@
|
|||
// @name Sorryops
|
||||
// @name:ru Сориупс
|
||||
// @namespace https://git.disroot.org/electromagneticcyclone/sorryops
|
||||
// @version 20240429.1
|
||||
// @version 20240429.2
|
||||
// @description Collect and reuse ORIOKS test answers
|
||||
// @description:ru Скрипт для сбора и переиспользования ответов на тесты ОРИОКС
|
||||
// @icon https://orioks.miet.ru/favicon.ico
|
||||
|
@ -662,7 +662,10 @@ function test_form_handler(server_data) {
|
|||
function result_page_handler() {
|
||||
var i;
|
||||
var correct = variant.slice(variant.indexOf("Число верных ответов: ") + 22);
|
||||
var all = variant.slice(variant.indexOf("Число неверных ответов: ") + 24);
|
||||
correct = correct.slice(0, correct.indexOf("\n")).trim();
|
||||
all = all.slice(0, all.indexOf("\n")).trim();
|
||||
all = (parseInt(all) + parseInt(correct)).toString();
|
||||
var test = GM_getValue('tests', new Object())[testID];
|
||||
if (test === undefined) {
|
||||
return;
|
||||
|
@ -709,6 +712,7 @@ function result_page_handler() {
|
|||
id: testID,
|
||||
answers: sorted_test,
|
||||
correct: correct,
|
||||
all: all,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue