gjbarnard / moodle-format_grid

Grid course format contributed by Gareth J Barnard originally created by Paul Krix
GNU General Public License v3.0
21 stars 55 forks source link

Moodle running on an ipaddress rather than a domain #128

Closed sharpchi closed 11 months ago

sharpchi commented 3 years ago

This is something that has cropped up in testing where we're testing a Moodle (3.9.4+) Boost theme, and Grid (3.9.1.0 - 2020070701) running on an ip address rather than a domain name. We found that when you click on "Participants" in the NavDrawer that a section opened rather than going to the users/index.php page. Participants Click

Following the code in module.js, the navdrawerclick function doesn't handle href.indexOf correctly. https://github.com/gjb2048/moodle-format_grid/blob/06e0e02b458ad1ade3064defc9745983bdee1f5b/module.js#L170

When indexOf can't find the string it returns -1, but this isn't checked for, so it continues on to try to parseInt. When the href is a domain name, this just fails with NaN, but if it's an ipaddress the first numbers are returned. Our ip address started with a 10 and we found that grid was making section-10 appear when clicking on Participants.

Here are a couple of examples from the console log in Firefox mimicing what the function is doing, hopefully you can reproduce these: Normal domain name example Normal domain name example

Ip address example: IP address example

I think line 171 should read: if (sectionref <= 0) { https://github.com/gjb2048/moodle-format_grid/blob/06e0e02b458ad1ade3064defc9745983bdee1f5b/module.js#L171

Happy to do a pull request, if you think that's the fix. thanks Mark

gjb2048 commented 3 years ago

@sharpchi Thanks, will look when I get time.

gjb2048 commented 11 months ago

M4.0- versions no longer supported and this code does not exist in M4.0+ versions.