moodle-format_onetopic icon indicating copy to clipboard operation
moodle-format_onetopic copied to clipboard

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

Open sh-csg opened this issue 1 year ago • 3 comments

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

sh-csg avatar Feb 20 '24 18:02 sh-csg

(failing CI is not related to the patch)

sh-csg avatar Feb 21 '24 08:02 sh-csg

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.

sh-csg avatar Feb 21 '24 13:02 sh-csg

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

PhMemmel avatar Feb 21 '24 14:02 PhMemmel

Hi,

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

izendegi avatar May 08 '24 06:05 izendegi

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

davidherney avatar May 09 '24 03:05 davidherney