there's a tracker issue with a patch that covers this here:
https://tracker.moodle.org/browse/MDL-49673
I'm currently planning to tidy that up and submit it for possible inclusion in Moodle 3.7 - if you have internal development staff they might be able to apply that patch to your local site (don't try this unless you have internal development capabilities - it's not "easy")