Well, we fixed it, but the solution is not clear to me.
After searching in the database, which is rather big and complex, our tech just turned on extra logging and found a query happening in an old course. Deleting the course fixed the task issue.
This is what was caught:
SELECT
quba.id AS qubaid,
quba.contextid,
quba.component,
quba.preferredbehaviour,
qa.id AS questionattemptid,
qa.questionusageid,
qa.slot,
qa.behaviour,
qa.questionid,
qa.variant,
qa.maxmark,
qa.minfraction,
qa.maxfraction,
qa.flagged,
qa.questionsummary,
qa.rightanswer,
qa.responsesummary,
qa.timemodified,
qas.id AS attemptstepid,
qas.sequencenumber,
qas.state,
qas.fraction,
qas.timecreated,
qas.userid,
qasd.name,
qasd.value
FROM mdl_question_usages quba
LEFT JOIN mdl_question_attempts qa ON qa.questionusageid = quba.id
LEFT JOIN mdl_question_attempt_steps qas ON qas.questionattemptid = qa.id
LEFT JOIN mdl_question_attempt_step_data qasd ON qasd.attemptstepid = qas.id
WHERE
quba.id = '82898'
ORDER BY
qa.slot,
qas.sequencenumber
*************************** 1. row ***************************
qubaid: 82898
contextid: 58172
component: mod_quiz
preferredbehaviour: adaptive
questionattemptid: NULL
questionusageid: NULL
slot: NULL
behaviour: NULL
questionid: NULL
variant: NULL
maxmark: NULL
minfraction: NULL
maxfraction: NULL
flagged: NULL
questionsummary: NULL
rightanswer: NULL
responsesummary: NULL
timemodified: NULL
attemptstepid: NULL
sequencenumber: NULL
state: NULL
fraction: NULL
timecreated: NULL
userid: NULL
name: NULL
value: NULL