Hi @barnabythebear - good questions…
Is there a way to import a list of users with roles at the start of each academic year and also to remove the old cohort?
farmOS does not provide a CSV importer for users. The idea has come up in our farmOS 2.x development conversations, but there hasn’t been a demand for it (you’re the first to ask!) so it isn’t going to be an immediate priority. That said, it might not be hard to add in the future…
As for right now, adding them manually one-at-a-time may be the easiest (assuming it’s not a LOT of people each year). This can be done via the “People” menu item.
At the end of the year, rather than deleting all the old accounts, you can “Block” them. This keeps the association with any logs/assets that those students created, which is valuable for historical context IMO.
could it be done at database level with the Load Data Infile command?
As a rule of thumb, you should always avoid making changes directly to the database. farmOS has a database abstraction layer with PHP functions for common tasks, which ensure that any code that should run on inserts/deletes/updates does.
One other option that might be worth considering, if the manual one-at-a-time approach is too onerous, is to use the farmOS API. I know that it’s possible to create users via the 2.x API, however I’m not sure if it is possible via the 1.x API. So this too may be a “future” feature for your purposes.
Hope that helps provide some context on what’s possible!