Affects Version/s: 3.5.13, 3.8.4
Fix Version/s: None
Component/s: Block: Configurable report
Affected Branches:MOODLE_35_STABLE, MOODLE_38_STABLE
Steps to reproduce:
- Export a custom SQL report from the Configurable Reports management page in course A as XML
- Import the report into a different course (course B)
- Edit the report in course B
- Navigate to the Custom SQL tab.
- Note that the course navigation, breadcrumb trail etc places the context in course B
- Make some small change (e.g. add a comment)
- Save changes
- Observe the course navigation, breadcrumb trail etc.
- Expected result: the user remains in the context of course B
- Actual result: the user has been returned to the context of course A
This is happening because the table mdl_block_configurable_reports includes the courseid in two places. One is the courseid field itself. The other is the components field which contains a string of key/value pairs. One of these keys is courseid. When the report XML is imported into the new course, the database field courseid for the new record is correctly set to course B, but the courseid reference embedded within the components field remains at the original value (course A). This value is used by the block in a small number of places, including the redirect after saving changes to a report, resulting in the unexpected navigation path described.
The risk is that the user will get confused about which course they are in, make a purposeful edit to a newly imported report, and accidentally edit the wrong instance of the report in its original course context.
I imagine that the solution would be to update the courseid reference in the components field as part of the report import process, but I can't at present see quite how to make that work with a robust solution.