From 6c65bee3f63a97da48b2a5da49d7ec0a20da0c8b Mon Sep 17 00:00:00 2001 From: Francis Devine Date: Wed, 6 Sep 2023 16:00:30 +1200 Subject: [PATCH] MDL-79274 assignfeedback_editpdf: Fix permission error in conversion This was causing the adhoc task to fail with a nopermission error, when a user was unenrolled from a course before their assignment submission could be converted into a pdf. Comments from MDL-56810 indicate the correct approach is to not attempt a conversion in those cases. --- .../feedback/editpdf/classes/task/convert_submission.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mod/assign/feedback/editpdf/classes/task/convert_submission.php b/mod/assign/feedback/editpdf/classes/task/convert_submission.php index e9bb5682e4265..c577edc383e39 100644 --- a/mod/assign/feedback/editpdf/classes/task/convert_submission.php +++ b/mod/assign/feedback/editpdf/classes/task/convert_submission.php @@ -65,6 +65,15 @@ public function execute() { foreach ($users as $userid) { mtrace('Converting submission for user id ' . $userid); + // If the assignment is not vieweable, we should not try to convert the documents + // for this submission, as it will cause the adhoc task to fail with a permission + // error. + // + // Comments on MDL-56810 indicate that submission conversion should not be attempted + // if the submission is not viewable due to the user not being enrolled. + if (!$assign->can_view_submission($userid)) { + continue; + } // Note: Before MDL-71468, the scheduled task version of this // task would stop attempting to poll the conversion after a // configured number of attempts were made to poll it, see: