That's the thing though, the code comments do say what set_url should be used for, but it doesn't seem to actually do that in most cases.
Looking at the code some more I think perhaps I should be adding my extra params into get_view_url, which is used in course_get_url, which in turn seems to be used in a lot of activities to set the base for the return url - indeed this seems to be the case with /course/modedit.php. By the looks of it I can recreate get_vew_url() in my course format's class.
Like the comments in the code say however, the return url is hardcoded in a lot of modules unfortunately...
348 /** 349 * The URL to use for the specified course (with section) 350 * 351 * Please note that course view page /course/view.php?id=COURSEID is hardcoded in many 352 * places in core and contributed modules. If course format wants to change the location 353 * of the view script, it is not enough to change just this function. Do not forget 354 * to add proper redirection. 355 * 356 * @param int|stdClass $section Section object from database or just field course_sections.section 357 * if null the course view page is returned 358 * @param array $options options for view URL. At the moment core uses: 359 * 'navigation' (bool) if true and section has no separate page, the function returns null 360 * 'sr' (int) used by multipage formats to specify to which section to return 361 * @return null|moodle_url 362 */
I'm really interested to know if anyone can think of a better way of doing this, maybe something I've missed?