-
Bug
-
Resolution: Fixed
-
Minor
-
4.1.6, 4.2.3, 4.3
Steps to reproduce:
- Ensure you have at least two admins for your Moodle site, and that you are not the main admin.
- Edit the main admin account, and set it to auth: nologin.
- Log in as a student, and attempt any quiz.
- Submit your quiz attempt.
Expected result: it works
Actual result:
Exception encountered in event observer '\quiz_statistics\event\observer\attempt_submitted::process': Suspended account
line 223 of /lib/classes/task/manager.php: call to core_user::require_active_user()
line 45 of /mod/quiz/report/statistics/classes/event/observer/attempt_submitted.php: call to core\task\manager::queue_adhoc_task()
line ? of unknownfile: call to quiz_statistics\event\observer\attempt_submitted::process()
line 155 of /lib/classes/event/manager.php: call to call_user_func()
line 75 of /lib/classes/event/manager.php: call to core\event\manager::process_buffers()
line 795 of /lib/classes/event/base.php: call to core\event\manager::dispatch()
line 1907 of /mod/quiz/classes/quiz_attempt.php: call to core\event\base->trigger()
line 1777 of /mod/quiz/classes/quiz_attempt.php: call to mod_quiz\quiz_attempt->fire_state_transition_event()
line 2088 of /mod/quiz/classes/quiz_attempt.php: call to mod_quiz\quiz_attempt->process_finish()
line 96 of /mod/quiz/processattempt.php: call to mod_quiz\quiz_attempt->process_attempt()
Analysis: \quiz_statistics\task\recalculate is doing $task->set_userid(get_admin()->id);, but this is wrong. If you want the task to run as admin, you just just leave userid set to null.
(As far as I can see, in core, $task->set_userid is only ever used to set userid to a real user who the task is running for, e.g. the user doing a backup.)
Patch coming up.