gjb2048 / moodle-theme_essential

The Essential Moodle Theme
https://gjb2048.github.io/moodle-theme_essential/
GNU General Public License v3.0
91 stars 120 forks source link

Putting a calendar block in the "Admin only" blocks area triggers an error for student users #870

Open tim1mw opened 6 years ago

tim1mw commented 6 years ago

As the title says, I have a site where the calendar block has been placed in the block area labelled "Blocks moved into the area below will only be seen by admins". If you then log in as a student, the following error is generated:

Missing required key in single structure: year Error code: invalidparameter

Moving the calendar block out of the admin only area or hiding the block stops the error. My guess is that some calendar code is still being sent for student users and that includes an Ajax call which triggers the error.

gjb2048 commented 6 years ago

And what, pray chance may it be thy version number?

tim1mw commented 6 years ago

Sorry, forgot that. Moodle 3.5 with Essential V3.5.0.1.

gjb2048 commented 6 years ago

Can reproduce, no idea how to fix or why getCalendarMonthData js is being called via an event when there is no calendar on the page and thus no markup containing the calendar (wrapper) with the data for the AJAX call.

gjb2048 commented 6 years ago

Ok, probably because the block is not 'hidden' with its own settings so expects to be 'displayed' and therefore outputs its JS.

gjb2048 commented 6 years ago

month_mini.mustache rendered with JS but not the markup.

gjb2048 commented 6 years ago

Called from calendar_mini.mustache

gjb2048 commented 6 years ago

moodleblock.class.php ->get_content_for_output ->

if ($this->instance->visible) { $bc->content = $this->formatted_contents($output);

->

block_calendar_month::get_content()

gjb2048 commented 6 years ago

Workaround is to hide the calendar block in the hidden block region.

gjb2048 commented 6 years ago

Not sure I can solve this without removing the functionality.

gjb2048 commented 6 years ago

I don't think this can be solved, going to probably remove the functionality.

marcoblancas commented 6 years ago

Have you removed the functionality? I have placed the block calendar in the "hidden from users" region but the blocks are displayed for everybody and I can't reproduce this issue.

I think the problem is related with https://tracker.moodle.org/browse/MDL-62775 . I'm having the same problems with my custom theme.

gjb2048 commented 6 years ago

"Have you removed the functionality?" = no. "I'm having the same problems with my custom theme." are you asking for support with your theme?

marcoblancas commented 6 years ago

No support required... Thank you. I just thought, this issue could be related with the issue I posted and may be it could help to fix it.

gjb2048 commented 6 years ago

Ok, thanks.