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

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

Open tim1mw opened this issue 6 years ago • 14 comments

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

  • line 315 of /lib/externallib.php: invalid_parameter_exception thrown
  • line 223 of /lib/externallib.php: call to external_api::validate_parameters()
  • line 59 of /lib/ajax/service.php: call to external_api::call_external_function()

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.

tim1mw avatar Jun 04 '18 17:06 tim1mw

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

gjb2048 avatar Jun 04 '18 17:06 gjb2048

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

tim1mw avatar Jun 04 '18 17:06 tim1mw

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 avatar Jun 04 '18 19:06 gjb2048

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

gjb2048 avatar Jun 04 '18 19:06 gjb2048

month_mini.mustache rendered with JS but not the markup.

gjb2048 avatar Jun 04 '18 20:06 gjb2048

Called from calendar_mini.mustache

gjb2048 avatar Jun 04 '18 21:06 gjb2048

moodleblock.class.php ->get_content_for_output ->

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

->

block_calendar_month::get_content()

gjb2048 avatar Jun 04 '18 21:06 gjb2048

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

gjb2048 avatar Jun 04 '18 21:06 gjb2048

Not sure I can solve this without removing the functionality.

gjb2048 avatar Jun 12 '18 10:06 gjb2048

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

gjb2048 avatar Jul 17 '18 12:07 gjb2048

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.

marcoblancas avatar Oct 01 '18 12:10 marcoblancas

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

gjb2048 avatar Oct 01 '18 14:10 gjb2048

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.

marcoblancas avatar Oct 04 '18 19:10 marcoblancas

Ok, thanks.

gjb2048 avatar Oct 04 '18 21:10 gjb2048