Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

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

Open
tim1mw opened this issue Jun 4, 2018 · 14 comments

Comments

@tim1mw
Copy link

tim1mw commented Jun 4, 2018

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.

@gjb2048
Copy link
Owner

gjb2048 commented Jun 4, 2018

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

@tim1mw
Copy link
Author

tim1mw commented Jun 4, 2018

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

@gjb2048 gjb2048 added the Bug label Jun 4, 2018
@gjb2048
Copy link
Owner

gjb2048 commented Jun 4, 2018

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
Copy link
Owner

gjb2048 commented Jun 4, 2018

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

@gjb2048
Copy link
Owner

gjb2048 commented Jun 4, 2018

month_mini.mustache rendered with JS but not the markup.

@gjb2048
Copy link
Owner

gjb2048 commented Jun 4, 2018

Called from calendar_mini.mustache

@gjb2048
Copy link
Owner

gjb2048 commented Jun 4, 2018

moodleblock.class.php ->get_content_for_output ->

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

->

block_calendar_month::get_content()

@gjb2048
Copy link
Owner

gjb2048 commented Jun 4, 2018

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

@gjb2048
Copy link
Owner

gjb2048 commented Jun 12, 2018

Not sure I can solve this without removing the functionality.

@gjb2048
Copy link
Owner

gjb2048 commented Jul 17, 2018

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

@marcoblancas
Copy link

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
Copy link
Owner

gjb2048 commented Oct 1, 2018

"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
Copy link

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
Copy link
Owner

gjb2048 commented Oct 4, 2018

Ok, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants