Changed Student Roles and now Admin can't assign roles, add course content, etc

Changed Student Roles and now Admin can't assign roles, add course content, etc

by Martha Beck -
Number of replies: 22

Help!  I made changes to the Student's roles so they could edit their own profile and not have access to the other partisipants profiles.  I also went through the list to make sure the Student roles did not have edit/delete capabilties.  When I selected update, I got an error message (did not copy it) telling me that I have to add a comand line because of this error.

I backed out of the screen in hopes of resetting some of the premissions and removing the error.  The page refreshed and now the administrator can't assign roles, edit anything (except Block sections on main page) or add course content.

Is there a way to revert to the previous roles?

Moodle applicaiton:  release = '1.9.2+ (Build: 20080723)

Please reply with quesitons or suggesitons.

Thank You

Chris Castillo

Average of ratings: -
In reply to Martha Beck

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You *must* have changed something other than the student role settings. At least I hope so, or this is very weird.

The first thing to try is (if you can) go to all the roles editing screens (Site Administration > Users > Permissions > Define Roles) and look for the "Reset Defaults" buttons. Try and get all the roles back to default.

Also, have a careful think if you can remember changing any other settings.

Let us know how you get on. It should be sort-able, so don't panic just yet.
In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Martha Beck -

Hello Howard,

Thanks for your time on this.  I am close to certain that I was in the student section of the roles editing.  I did get a error message when I tried to save the changes and it advised that I add some command line to the s/w to continue.  When I backed out, that is when the change occured and I lost the ability to adminster the site.  I will attach the image I see when I (who had admin ability) logs in.

That is the issue, the site does not have an admin with roles that can make changes to the site.

Attachment Moodle_mainscreen.jpg
In reply to Martha Beck

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ok.... use this at your own risk!!! I suggest a database backup just in case.

Add the attached script to your moodle installation in the root of the install (the same place as config.php, version.php, file.php etc).

Run it from the browser, ie.

http://your.moodle.url/adminfix.php

What this does is to reset your admin role to the default, tell you the name of the primary admin user, reset their password to 'moodle' and add them (back) to the administrator role.

You can then log on as that user and you should (at least) have admin rights again.

WARNING: This script is the biggest security hole known to man. You *must* delete it again once you have used it smile

Let me know if it helps.
In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Peggy Murrah -
Hi Howard,

Thanks so much for your help on this. I'm working with Chris on trying to get these Roles sorted out.

I added the adminfix script and ran it - it shows that the main account is reset to admin status, however when I log in, there is no difference in what I can do.

I found a rolesdebug script and ran it - this is what I entered and the results I got back:

capability (I put admin)
context type NONESystemUserCourse categoryCourseModuleBlock (I selected system)
context id (I put 1)
user = admin (Steve T.)
capability = admin ("[[]]")
context = System1 (System)
-
R1 = Administrator
R5 = Student
System
R1(N), R5(N)
Calculated permission = P
Can do anything = false
Can do this = false
-
Role for visitors = Guest
Role for guest = Guest
Default role for all users = Student
Default role for users in a course= Student
Creators role in a new course = Instructor
Default front page role = ?

It looks like the Admin and Student roles are somehow competing with each other?

Any ideas on this?

Also, this is a fairly new moodle - would it be better to just reinstall and start over? We do have a backup, so the forum entries and everything we've added would be recoverable, yes?

Thanks much,
Peggy Murrah
In reply to Peggy Murrah

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Martha Beck -

Hi Peggy & Howard:

Thanks so much for the effort on this.  I did try to login after the script ran and the site is the same.  Same main screen, no admin privilages. 

I did notice that my user name does not appear in the "Block Admin" roles list.  All the other students seem to be there, but not the admin accts.

Hopefully that helps.

Thank you again for your time.

In reply to Martha Beck

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ok, second attempt!

This now unasigns your primary admin from all roles other than Administrator. It also sets a number of roles related configuration options back to their default.

See if this helps - let me know.
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Peggy Murrah -
Success!

It looks like all the admin options are back in place - Chris will go through it more thoroughly, but so far, so good!

Thanks so much for all your help.

Best regards,
Peggy Murrah
In reply to Peggy Murrah

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hey - I've done something useful this week. Universal roles fixer big grin
In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Jairo Serrano -
Hello!

Thanks for the script but don't work for me sad

i have a similar problem, i cant access to edit, view or nothing with role in my moodle site...

showme a blank page when try to access to this spaces...

admin/roles/assign.php?contextid=1
admin/roles/manage.php
admin/user/user_bulk.php

Debug mode dont show nothing too...

any ideas?
In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Aleš Kocourek -

Howard, you are a GOD! You saved my life! Many many many thanks.

BTW: I did exactly what has been descibed above! I was changing (especially disabling) some of the STUDENT's rights. I confirmed the changes... and got the error/admin/section errorr (http://docs.moodle.org/en/error/admin/sectionerror). Since I didn't have a clue what to do with it, I backed up and lost all my admin rights.

P.S. One minor thing I've found out right now. After I log out of my moodle profile, a warning shows right above the login text-field saying something like: "Your session has expired, please login again." [I have a Czech mutation so I don't know the exact formulation in English.] Any ideas?

In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Debbie McDonald -
Hi Howard,

I too locked myself out of my site. I used the fix but can not seem to log back in. I keep getting an invalid password error on the "You must change your password to proceed." screen. Help?

Debbie
In reply to Peggy Murrah

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ok... I'll modify my script to reset some more stuff and, if you have time, we'll try again. The only thing I noticed in the roles information is that the admin user seems to have been made a student in the system context and that the default role for users should be Authenticated User - I'm surprised that changing this to student would break stuff though. I would never change those options - I don't really understand the implications (and I don't think anybody else does either tongueout )

I'm quite keen to make this work because problems like yours turn up relatively frequently.

Get back to you in a couple of hours!
In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Jack Briner -
I have taken this script and made it a little more fool proof. It removes itself after it has run. It requires the admin to reset his/her password.

Thank you for your work, Howard.
In reply to Jack Briner

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Debbie McDonald -
THANK YOU HOWARD.... You saved me too!!!! I was able to get password reset.
In reply to Jack Briner

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Jamie Tinley -
Howard and Jack: I ran this file and successfully changed admin password but still NO ADMIN settings available for me! I can't do anything! I have 3 admins - two are mine which both don't work and the third is for a secretary who was just assigning mentees for me and she has lost it too now. Please help, I need to manage our site! Thanks
- I used your sept. version Jack and Howard's instructions. James
In reply to Jack Briner

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by vishakha mujoo -

I tried it but this is the error I am getting - in my case administrator and student are two roles to same user id and I happened to override another role emp which was based on student role

resetting default roles

reloading context

primary admin is '',login with this

authentication plugin not found

In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Viviane Cantaluppi -
THANK YOU Howard (& Jack)!

I made the same 'mistake' (changing role-permissions) and all of a sudden, my admin-rights where gone... überrascht



Having installed and executed your file, my Moodle works perfectly fine now!
You saved my day, thanks. zwinkernd

Viviane C.
In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Stephane stephane -

Hello,

I have this role permission problem, so i tried to use your script adminfix and i have a http 500 error ... this si the only page that give me this error ...

do you have a solution/explanation ?

thanks in advance !

Stephane.

In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by António Gonçalves -
I have run your script and I get the message that I attached. I think I have lost my moodle... I will start over again! smile
Attachment AdminFailure.JPG
In reply to Howard Miller

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Patrick Burns -


This does not work for me. I run the script and it reports the following...

RESETING DEFAULT ROLES

RELOADING CONTEXT


That's all I see. I go to log in using the reset password and it never reset, it's still the same as it was and no roles are fixed. It shouldn't matter that my backend is postgresql should it?


Also, if I run it on the command line I get a segfault.


php adminfix.php
<p>RESETING DEFAULT ROLES</p><p>RELOADING CONTEXT</p>zsh: segmentation fault php adminfix.php



Thanks,
Patrick
In reply to Martha Beck

Re: Changed Student Roles and now Admin can't assign roles, add course content, etc

by Christophe Leville -
Hi Chris!

I have the same problem as you (as far as I can see in your screnshot). I created a user directly in the DB and gave him administrator´s permissions. But it didn´t help. The new administrator gets to see the same administration bloc as before with too little options (only Grades, Front pages and Reports) and now permssions to change user´s permissions. I´ve checked in the DB in the tables role, role_allow_assign and role_capabilities and everything seems to be the same as in another test-moodle of mine.
You may have a look at my screenshot. That´s the new administrator that I created. HE doesn´t have any more options as the other administrators.

What else could I change in the DB ?

thanks.
Attachment screenshot.3.jpeg