Batch disabling of users

Batch disabling of users

by Neil Lindholm -
Number of replies: 13

I am managing a Moodle with about 1100 students. About half of the students have not paid their software user fee so I have been told to disable their accounts until they show proof of payment. I know how to disable one user at a time but have been having no luck figuring out how to batch disable users. The ideal method would be a flag I could add to the Excel file I used to enroll the users but even a method of selecting the users that need to be disabled in the bach actions would be useful. 

Any suggestions?

Average of ratings: -
In reply to Neil Lindholm

Re: Batch disabling of users

by Derek Chirnside -

Neil:

It does not look like it is possible according to here: http://docs.moodle.org/24/en/Upload_users#Fields_that_can_be_included with the CSV option.

What about changing the enrolment period, which can be done with CSV?

You can't change their password (since they can get a new ne emailed to them)

I actualy wonder if the suspend user may be doable, just not documented.

This is a pain.  You can of course have ONE course, Say course 1, inside your moodle with informaion n how to access courses 2-X.  Then merely control access to course 1.

-Derek

 

In reply to Derek Chirnside

Re: Batch disabling of users

by Neil Lindholm -

I like the idea of having one course where I enrol everyone and I am going to look into that for next year. The enrolment period might work but I don't think it iwll disable their accounts. All they would have to do is re-enrol into the courses they want. I could put in keys and time restrictions but it is too late for this term. (I have lots of plans for next term, in September). 

I wish there was a simple way to enable or disable. They have so many things you can do with batch functions or by CSV files but for some reason, disabling users is not one of them. I always wonder if I am the only person with these problems, especially since I can never find other people asking the same questions. I wonder what other admins do when users don't pay fees or are temporarly refused access to Moodle. 

I am going to play with the enrol period though, on my test Moodle site. Maybe I can get it to work. Thanks for the suggestion. 

In reply to Derek Chirnside

Re: Batch disabling of users

by Neil Lindholm -

Reading the link you sent me, I wonder if deleting the user then enroling them again would work. If I delete a user, do all their files in Moodle vanish or if I delete then enrol with all the same information, will their work survive?

In reply to Neil Lindholm

Re: Batch disabling of users

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Do not un-enrol or delete users if you expect the re-enrol them later. That does delete the data about their actions in the course.

You really need to suspent the enrolment, and so you need to find the most efficient way to do that. Sorry, I don't have any ideas.

In reply to Neil Lindholm

Re: Batch disabling of users

by Rachel Fransen -

I would say you need to suspend their account, if you intend for them to use the site again in the future. Suspending their account simply prevents them from logging in -- it doesn't unenroll them from any courses.

Go to the user's profile, as admin, and set their authentication as "No Login." Make sure this option is also enabled in the admin panel -> plugins ->authentication.

I know of a way to display a message on the login screen, if a user tries to login with "No login" status - but I hade to modify core moodle code to do it (usually not recommended). 

In reply to Rachel Fransen

Re: Batch disabling of users

by Neil Lindholm -

The problem is that I need to do this for about 500 students. I really don't want to spend hours doing it individually. 

In reply to Neil Lindholm

Re: Batch disabling of users

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well, worst-case scenario, you can use a tool like Adminer (https://moodle.org/plugins/view.php?plugin=local_adminer ) or phpMyAdmin. You need to update the user table, in the 'auth' column change 'manual' ) (or whatever) to 'nologin' for the students you want to block. Later, once they have paid, change it back.

It clearly would be possible to add 'Change enrolment method' to the list of actions that are possible on the bulk user actions page, but someone would have to write the code.

In reply to Neil Lindholm

Re: Batch disabling of users

by Ken Task -
Picture of Particularly helpful Moodlers

How about ...

Create a New Role - Archtype: Student
Context types where this role may be assigned: System and Course
Role name: student non-paid

In the settings for this role, prohibit all (there is no select all so one will have to click each item as 'prohibited')

Assign student that have not paid the student non-paid at system level.
They are not un-enrolled from courses they are in, they are not deleted from the system, they can login, BUT ….

They see no navigation block on front page.  They see a course listing and can access whatever course to which they have been enrolled but cannot enroll themselves in any.  They can see resources from Section 0 of the front page, however, any click on those resources takes them to a page where it says: 'Sorry, but you do not currently have permissions to do that (View URL)' (or whatever the resource was).  They cannot see any forums.

Finding students in Potential Users search is method of seeing students:
if one uses a single letter, say 's' in the Search box, Moodle 2.3> will list, in the potential users box, all accounts whose First or Last name begin with that letter.

Select each students name that hasn't paid.  Then click add.

Ok, that's not ideal and as clean as a bulk user action, but … you're not hacking any code or doing any other funny business (global mysql command) that might turn around and bite ya later.

Think one could set up the Moodle (next year) where the default role could be set to 'student non-paid'.

'spirit of sharing', Ken

In reply to Ken Task

Re: Batch disabling of users

by Ken Task -
Picture of Particularly helpful Moodlers

Forgot to add ... since the students are already enrolled in courses, at present, setting the roles of students that have not paid to 'non-paid' role at the sysetm level may not have desired outcome (those students now have two roles - student and non-paid student).   If they are already in a course, their role is 'student'.  

However, teachers should be able to re-assign students in their courses from student to non-paid student.   They do need, however, some way to get a pdf file from the student that shows they paid (or something like that).

Yes, I know that means work, but one is having to un-do what has been done and know of no 'magic bullet' at this point.

Once having setup this role and having that role as default (rather than student), then next years process will change somewhat, but you won't be where you are at right now ... having to un-do then re-do - staying with core/non-hacked Moodle code.  This would also be true of any new courses (I think!).

Setting up a guest course - "Having Troubles?" - or some sort of title that fits, even non-paid student roles can see a label.  In that label one could provide information about how to correct their role and gain access to courses for which they've paid.

'spirit of sharing', Ken

In reply to Ken Task

Re: Batch disabling of users

by Neil Lindholm -

Thanks for all the help. I discovered the easiest way to deal with this issue. I work at a school in China and there are a lot of people who are hired here but don't really do anything. I gave them temporary Manager accounts and a spreadsheet with all the names of students needing to be disabled and they are hard at work at the task. smile

I will use some of the ideas mentioned in these posts for next year. Thanks everyone. 

In reply to Ken Task

Re: Batch disabling of users

by Neil Lindholm -

Thanks for all the help. I discovered the easiest way to deal with this issue. I work at a school in China and there are a lot of people who are hired here but don't really do anything. I gave them temporary Manager accounts and a spreadsheet with all the names of students needing to be disabled and they are hard at work at the task. smile

I will use some of the ideas mentioned in these posts for next year. Thanks everyone. 

In reply to Neil Lindholm

Re: Batch disabling of users

by Peter Bowen -

If you have all the user names in a CSV, then you can do some manipulation to produce SQL script. I do this on a weekly basis, and produce something similar to:

UPDATE mdl_user SET suspended=1 WHERE
username=jackross
OR username=johnstone
OR username=garyjones

You then run this directly on the SQL server, and the list of users is now suspended.

I would suggest that if you do not know how to run SQL against your database, than the above is not for you... :D

Kind Regards
Peter

 

In reply to Peter Bowen

Re: Batch disabling of users

by Neil Lindholm -

I'm not even going to touch SQL. On my list of things to learn but that list is getting longer and longer each day.