davidherney / moodle-format_onetopic

Course format Onetopic to LMS Moodle
GNU General Public License v3.0
19 stars 45 forks source link

MBS-8819: Show action menu when loading course modules via ajax #171

Closed sh-csg closed 6 months ago

sh-csg commented 9 months ago

This shows action menu when course module is rendered again after changing sth (e.g. indentation). This closes #169 .

sh-csg commented 9 months ago

(failing CI is not related to the patch)

sh-csg commented 9 months ago

Some details about the patch:

The problem arises as $PAGE->_pagetype is not set when the constructor is called for the handling of the get_fragment() call. When $PAGE->pagetype is accessed the first time (lib.php, L140), moodle_page::magic_get_pagetype() calls moodle_page::initialise_default_pagetype() where pagetype is set to "lib-ajax-service" (out of "/lib/ajax/service.php"): https://github.com/davidherney/moodle-format_onetopic/blob/6c6950b531df56fc8fafc43176f05ffc996c5d86/lib.php#L140

Other course formats don't access $PAGE->pagetype that early, so they get to L408 in /lib/external/externallib.php:

https://github.com/moodle/moodle/blob/d3ad77e4762ee5b96a3fecb51158c6039202f39e/lib/external/externallib.php#L408

$PAGE->set_url() sets the pagetype to "site-index" in this case.

PhMemmel commented 9 months ago

Can confirm this patch works, but the issue described by @sh-csg should be fixed in the course format in a cleaner way.

izendegi commented 6 months ago

Hi,

We've applied this patch and it fixes the issue.

davidherney commented 6 months ago

Hi...

Thanks @sh-csg, I've integrated the fix.

@PhMemmel If you have an idea on how to do it better, tell me and I'll review it.

Saludos