Eloy - I was taking a look at this issue of how to mass upload user roles. I think for maximum flexibility, I would require that the context level be specified in the text file. Here is what I am thinking for an initial step.
User (username or idnumber), Context Level (system, user, category, course), Context name/identifier, Role (shortname) For example,
admin1, system,, admin
teacher1, course, Math101, editingteacher
student1, course, Math101, student
student2, course, Science101, student
parent1, user, student1, parent
parent2, user, student2, parent
mathdean, category, Math, coursecreator
sciencedean, category, Science, coursecreator
ta1, course, Math101, teacher
This brings out what will likely be one source of confusion. Namely that a normal teacher has the shortname editingteacher whereas the non-editing teacher has the shortname teacher. I know there will be questions about this and personally think that teacher should have the shortname teacher and non-editing teacher should have the shortname noneditingteacher (IMO). I'm not sure of the implications of changing that at this point so we may just have to live with it.
For context levels we are excluding (for the time being) the options of group, module, and block since these would each require an additional course identifier (name or idnumber).
I believe (but would have to verify) that the context name/identifier for system is the front page (course.id=1 in most cases). The name/identifiers for the user context could be either username or idnumber. The name/identifier for category would be the course category name. However, we may want to omit this initially and give some consideration to how best to handle course categories. The problem I see is that the name is not a unique identifier of the course category and the user does not have a way of setting an idnumber that could uniquely identify it. Technically speaking, the user and course idnumber fields are not guaranteed to be a unique identifier which is something perhaps that we should begin to enforce if we are going to continue to develop the capability for folks to do mass operations by importing text files (which I think is very helpful for system administrators) and goes a long way in helping to import data from other systems. I'll create a tracker issue to create an idnumber field in course categories as I think it could be useful for folks. Similarly, we may want to consider an idnumber field for the groups table. Yet again, we should probably enforce the uniqueness of groups.courseid, groups.name if we implement this mass role assignment for groups. I see the idnumber field being less useful or necessary for the module and block context levels. The name/identifier for course could be shortname or idnumber.
So to summarize,
10 - SYSTEM - course.id (frontpage/site) - no context name/identifier required (can be anything (preferably blank) as it is ignored)
30 - USER - user.username or user.idnumber
40 - CATEGORY - course_categories.name
50 - COURSE - course.shortname or course.idnumber
60 - GROUP - groups.courseid, groups.name
70 - MODULE - course_modules.course, course_modules.module (looked up from modules.name)
80 - BLOCK - block_instance.courseid, block_instance.blockid (looked up from block.name)
I do not see as part of this bug allowing to create roles from CSV files so if a role name is not found it should be ignored with a warning/status message to the user indicating that that record was not processed.
Does this seem like a reasonable approach to setting up how the CSV file should be used? Does it provoke any comments, questions or concerns? Once we are agreed on the file we can begin looking at how to implement it so that we can handle the heavy checking and any reversions.
Peace - Anthony
If you read the discussion, you will see that we discussed enhancing Upload users to allow assignment of roles in ANY context (not just System). This can be done by specifying Context type, context instance, and role short name. System would fall out as a special case.