catalyst / moodle-mod_subcourse

Subcourse module for Moodle
https://moodle.org/plugins/mod_subcourse
GNU General Public License v3.0
24 stars 41 forks source link

External database enrolment sync fails in courses with subcourse modules with empty course reference #95

Closed KepaUrzelai closed 2 months ago

KepaUrzelai commented 2 months ago

When trying to enrol a student to a course, where any subcourse module with no referenced course configured exists, scheduled task to synchronise external database enrolments will fail do to an "Empty referenced course id" coding error.

Backtrace:
* line 430 of /mod/subcourse/lib.php: call to subcourse_fetch_refgrades()
* line 1423 of /lib/gradelib.php: call to subcourse_update_grades()
* line 1393 of /lib/gradelib.php: call to grade_update_mod_grades()
* line 1144 of /lib/gradelib.php: call to grade_grab_course_grades()
* line 2177 of /lib/enrollib.php: call to grade_recover_history_grades()
* line 560 of /enrol/database/lib.php: call to enrol_plugin->enrol_user()
* line 62 of /enrol/database/classes/task/sync_enrolments.php: call to enrol_database_plugin->sync_enrolments()
* line 410 of /lib/classes/cron.php: call to enrol_database\task\sync_enrolments->execute()
* line 194 of /admin/cli/scheduled_task.php: call to core\cron::run_inner_scheduled_task()

Task execution stops and no user is enrolled to the course. However, being possible to set as None the Fetch grades from setting, this shouldn't be a blocking error.

danmarsden commented 2 months ago

Thanks for the report! - I note you have a patch on your local branch but haven't sent through a PR - if you've tested that and it fixes the issue please send it through for review and we'll take a look!

KepaUrzelai commented 2 months ago

Hi Dan,

You're right, I forgot to send the PR. I just did it now :)