Debug shows error and don't have permission to view courses

Debug shows error and don't have permission to view courses

by Dr. Michael Commini -
Number of replies: 13

First,  I would like to thank @Ken Task and @Colin Fraser who made suggestions on an older post for the 'You don't have permission to view this list of courses' error (https://moodle.org/mod/forum/discuss.php?d=388498#p1636643). Ken suggested I create a newer post so, since I enabled the debugger and generated more info, I thought I'd follow his advice and create this post.

As you can see from the image below, we are encountering the 'You don't have permission to view this list of courses' error. After trying Ken's suggestion unsuccessfully, I turned on debugging via the config.php file and got the error code: cannotviewcategory.

I looked through the config.php file and do not see where to override this error. I've also checked the database via phpMyAdmin and do not see where to reset this. As it stands, we cannot access the site at all. Every attempt to get to the admin sections of the site (managedocs, purge_cache, etc) is met with the same error message.

We're running Moodle version 3.8.

I appreciate any suggestions to overcome this issue and regain access to the site anyone can provide.

Thank you and regards,

Mike

Screenshot of debugging info

Average of ratings: Useful (1)
In reply to Dr. Michael Commini

Re: Debug shows error and don't have permission to view courses

by Ken Task -
Picture of Particularly helpful Moodlers

Dunno really .. but using our PHPMyAdmin run this query:

select * from `mdl_role_capabilities` where `capability` like "%course:view%"

You'll have to track down what role id's etc, is for everyone.  There is a column that shows epoch time stamp modified date.   Use epoch time stamp converter on net to see human date/time.   You might be able to find the row that was modified but then you'd have to track down what the values are in other columns to get back to 'normal'.

Next time you play with this ... do a DB backup first.  If something goes terribly wrong one could then restore that DB backup to keep the site available.

'SoS', Ken


In reply to Ken Task

Re: Debug shows error and don't have permission to view courses

by Dr. Michael Commini -
Yeah, I literally just began rebuilding the site a few days ago so didn't run the db backup yet. As for the tables you suggested I look at (this post and the other), I spent hours looking at each of those yesterday before reaching out (and hours again this a.m.) I finally decided to put the site into debug mode to see what I got. I don't know where to turn the front page capabilities back on - I'm pretty sure that's the first issue I have to tackle.

Thank you for your replies, they're helpful and confirm that I've been looking in the right areas. I didn't try doing the searches the way you've recommended so I'm going to try those next (right after pouring another cup of coffee :P) If you think of anything else, please let me know. In the meantime, I'll post the solution whenever I get one - even if I have to rebuild the database.

Best regards,

Mike
In reply to Dr. Michael Commini

Re: Debug shows error and don't have permission to view courses

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Did you try switching to the standard theme, Boost? If you have no admin access, add this line to config.php:
$CFG->theme = 'boost';
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: Debug shows error and don't have permission to view courses

by Dr. Michael Commini -
Hi smile Yes, I did, thank you for the suggestion. It didn't work. Imagine my surprise when adding $CFG->theme="classic'; did work. I'm in the site now undoing everything I did yesterday. However, every time I comment out the classic theme and go back to the site and refresh with the enlightlite them, I get the you don't have permission message. The enlightlite them was the theme we installed this past Sunday and it was working fine until yesterday.

Unrelated to that, I'm also not able to reset the authenticated user definition back to default, regardless of how many times I click reset. The security overview still shows it's not defined properly. Thus, I'm still exploring and troubleshooting.

Regards,

Mike
In reply to Dr. Michael Commini

Re: Debug shows error and don't have permission to view courses

by Ken Task -
Picture of Particularly helpful Moodlers

@Visvanath - beat me to it! smile.
@Dr Mike - *BEFORE you tinker more, make a backup!!!!*  Once you get something back in working order ... backup again.  Continue that 'extra pre-caution' until finally resolved.

Rate @Visvanath posting as useful.

Almost went down a very deep rabbit hole.  One of these days
Moodle will take a 'page' from Joomla and assure anything /admin/
is set to a stock theme that came with distribution.

Strongly suggest removing enlightlite theme.  Consider cloning site to a dev instance where you can tinker and not worry about total crash.

Nothing is 'unrelated' to theme issues.

And the last part ... reset of authenticated user definition back ...

Me thinks, the only way to know for sure is to find the table related and view changes.

'SoS', Ken

In reply to Ken Task

Re: Debug shows error and don't have permission to view courses

by Dr. Michael Commini -
@Ken,

You actually beat Visvanath to the punch.... it was your post from February that gave me the idea to try the boost theme first. When that didn't work, I followed your advice and tried the classic theme. If I had followed it when I read it yesterday, I would've saved myself many hours of troubleshooting frustration :/

Once in, I ran a config change report and have touched everything it shows I changed yesterday. The last thing I did before my nap - I was tired, y'all - was reset the site policy handler. I changed it to Default (core) yesterday so changed it back to Policies (tool_policy) today. Now I'm going to purge the cache again and see if that does the trick. If not, then as I was waking from said nap, my thought was to either continue with the classic theme or try another. Waking and finding your advice to ditch the enlightlite theme serves only to confirm what my waking my mind was thinking.

As far as the table related to the authenticated user definition, I have looked at many tables since yesterday and have been unable to find it. I even tried your suggestion of looking for the Epoch timestamp. I haven't come across it yet. sad

Thank you and Visvanath again for your support.

Regards,

Mike
In reply to Dr. Michael Commini

Re: Debug shows error and don't have permission to view courses

by Ken Task -
Picture of Particularly helpful Moodlers

Sent to your addy seen in your profile 2 xml exports of authenticated users and authenticated users on front page from a 3.8 instance whose roles are 'stock' ... not changed.  (PM doesn't allow attached files)

You could export yours and download the xml's.  Don't overwrite the ones I sent.   If you have a mac, you could then use a diff command on comparing the 2 xml's ... your xml export and the one I sent ya.

Might help you sort out the issues.

*IF you do try to import my shared xml's into your server, have to warn I've not done this before ... so use at your own risk ... think diff might be safer way to approach.

'SoS', Ken

In reply to Ken Task

Re: Debug shows error and don't have permission to view courses

by Dr. Michael Commini -
@Ken Task, @Visvanath Ratnaweera:

Ken, thanks again for your help. My export and yours were vastly different. However, since I had to download the xml file to compare to your send, I found the missing script I mentioned in my email to you. It was embedded in the config_log. The log showed time I added it and the time it got removed. To add to that, we noticed a significant slowing down of the site. When I checked the cPanel, we had been throttled by our hosting service. My theory was that something in the theme was causing a significant drain on their system resources. I uninstalled that theme and the system went back to normal. By this morning, we are no longer being throttled.

So, there was definitely something going on with that theme. There's still an issue with the authenticated user not being defined properly even after resetting it to default, so I'm going to try to pour through the documentation to see what I can find. In my opinion, the documentation is not great. It needs more screenshots to show us what we should look for. Some of us are more visual - reading only takes us so far. Images help drive the point home smile

Again, thank you to you and to Visvanath for your hanging in there while I re-learned Moodle. It's been years since I've done anything with it and now that I'm nearing retirement from this wonderful company for which I work here in the Middle East and am preparing for my return to the US (permanently? Only God knows....) I decided to re-launch the K-12 academy we had before I came over here. That was way back with version 1.9!

Best regards,

Mike
In reply to Dr. Michael Commini

Re: Debug shows error and don't have permission to view courses

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi all

My contribution was just chance. A bystander sometimes sees things before the people who are involved in a skirmish. ;)

Yes, there is something wrong somewhere. The reference theme is Boost. An unmodified current stable release (3.8) should work with Boost as advertised. Rather than evading the problem with Classic, I would switch to Boost and dig deeper. The starting point is a full debug trace https://docs.moodle.org/38/de/Debugging at DEVELOPER level.
In reply to Dr. Michael Commini

Re: Debug shows error and don't have permission to view courses

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

I think it is a bug with the Enlightlite theme. The same problem was reported on the theme page (see comment dated 2019-11-11) and it is reported in the bug tracker: #40 Login Page Error - moodle 3.7.

It seems to occur when course categories are only visible to users in specific roles. The theme doesn't allow for this and tries to list all categories resulting in the cannotviewcategory error for categories the user is not allowed to view.

Average of ratings: Useful (2)
In reply to Leon Stringer

Re: Debug shows error and don't have permission to view courses

by Wellington José Cunha -

I think it is a bug not fix, yet. I use 3.10 version.

I have the same problem, I change the theme to my access, but don't have the fix it. Do you know if somebody fix it?

Thanks!

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Debug shows error and don't have permission to view courses

by KirK Chapman -
Leon noted,  "I think it is a bug with the Enlightlite theme"

I agree. I was able to get back into my site by:
changing the config.php file for my site by adding: 

$CFG->theme  = 'classic';
(I added it above this line)
$CFG->directorypermissions = 0777;

I logged the issue with lmsace ; the maintainers of the Enlightlite theme here in greater issue detail on GitHub:

I see Leon has posted this as well https://bitbucket.org/lmsace/enlightlite/pull-requests/4 for an immediate fix till lmsace fixes the issue in the plugin!
Thanks Leon!





In reply to Dr. Michael Commini

Re: Debug shows error and don't have permission to view courses

by KirK Chapman -
Thanks for your previous related post!
It got me back into my site so I could resolve the issue temporarily.

$CFG->theme = 'classic';
(I added it above this line)
$CFG->directorypermissions = 0777