Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
3.1.10, 3.2.7, 3.3.4, 3.4.1
-
None
-
MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE
Description
THIS IS AN MUA PROJECT PROPOSAL THAT WILL BE OR HAS BEEN SUBMITTED FOR POSSIBLE MUA FUNDING. ANY EXISTING TRACKER ITEMS THAT THIS MIGHT DUPLICATE SHOULD BE LINKED TO BELOW.
Overview
There are several cases, due to business processes and rules out of our control, where the same person may get registered on Moodle several times (twice or more times) with different usernames. This is very annoying for the person, since the person can see only part of the courses and activity from certain Moodle registers.
The community (since 2008) has provided for years scripts that try to address this problem. All they have in common that try to unify two Moodle registers of the same person into a single register, moving all the information from one register to another one. See more at: https://moodle.org/mod/forum/discuss.php?d=103425
admin/tool/mergeusers is available as an administration plugin (https://moodle.org/plugins/tool_mergeusers). This is the evolution of the community effort on addressing the merging users problem. This plugin allows merging an old, unused Moodle user into another up-to-date, active Moodle user, so that the latter profile gathers together all the information (activity, logs, etc.) from both Moodle users, as if it all corresponded to a single Moodle user. This plugin allows you to merge users from the web as an administration or also do it in a cron job.
However, the merging operation of two users affects the whole Moodle instance to unify registries from all Moodle plugins. Therefore, as system maintainence specialists, we believe this plugin should be in the Moodle core.
Summary
- Project size: medium
- Audience: primary schools, universities, work places
- Target users: administrators
Goals
- Administrator users of almost every Moodle instance will get benefitted from having this plugin installed.
- Having such a case of multiple user records for a single person, Administrator users cannot do an equivalent set of actions to reach the same result as this plugin does.
- Automation is possible: Having merging actions defined by this plugin, Moodlers would be able to make merging actions automatically on their Moodle instance. What they need is to implement a CLI provider to get the list of merging actions and activate the plugin's CLI cron.
- Logging and checking the list of mergings: Administrator users can list the merged users and check how these merging actions were performed.
- Events for additional automation and logging: Events are thrown under successfull or wrong merging actions, so that further automation is possible, to react to those events or just log them in. It will also help to collect correctly the learning analytics.
User Stories
User stories should be specific to each requirement and provide a clear view of what you want the improvement/new feature to accomplish.
- I am a site administrator and I have been informed that 2 user accounts actually refer to the same person. I want to merge these two accounts such that the user can log in to one designated 'current' account and access all their content normally, and also appear in site logs as one person.
- I am a site administrator and I have been informed that 4 user accounts actually refer to the same person. I want to be able to merge two user accounts three times to have the designated 'current' account for that person.
- I am a teacher and I realize that I have the same student enrolled in my course twice. After someone with access merges the accounts I want that student to be listed as one student and I want to be able to see all their log activity, submissions, etc. as one student.
- I am a site administrator and I want to customize the merge operation on my site. I want to set up on the plugin settings whether I prevent reusing the user account to be removed after I merge the two accounts into one. If I activate this setting, the merge operation disables the account to be removed after the merge success. This setting is activated by default and higly recommended.
- I am a site administrator and I want to customize the merge operation on my site. I want to set up on the plugin settings whether I only allow transactional merges. If so, this plugin does not work on databases not supporting transactions. This setting is activated by default and highly recommended.
- I am a site administrator and I want to customize the merge operation on my site. I want to set up whether some of the database tables are excluded from being processed by the plugin, like `user_preferences`, `user_private_key` and `user_info_data`. If this setting is activated, all three tables are omitted during the merge. This setting is activated by default and highly recommended. There is another table `my_pages` that is always omitted, otherwise, the user cannot access into `MOODLESITE/my/` URL.
- I am a site administrator and I want to customize the merge operation on quizzes. I want to set up a plugin settings to stet how quizz attempts are merged according to the policies stated below:
- Policy 1: Merge attempts from both user accounts and renumber. All quizz attempts are kept for the user to be kept and all attempts are renumbered by the time they were started and quizz mark updated correspondingly to the quizz mark criteria.
- Policy 2: Keep attempts from the user account to be kept. Attempts from the user to be removed are removed. Attempts from the user to be kepts are kept, since this option considers them as the most important.
- Policy 3: Keep attempts from the user account to be removed. Attempts from the user account to be kept are removed. Attempts from the user account to be removed are kept, since this option considers them as the most important.
- Policy 4: Do nothing: do not merge nor delete (by default). Attempts are not merged nor deleted, remaining related to the user account who made them. This is the most secure action, since merging users from user A to user B or B to A may produce different quiz grades.
- I am a site administrator and I want to customize the merge operation on my site with a fallback criteria. I want to decide which user data is kept if any conflict arises during the merge within a database table. Conflicts may arise when the column related to the user.id is a unique key or part of it and updating the value breaks the table restrictions. The site administrator chooses among (1) only keep data for the user account to be kept (by default), so that records from the user account to be removed are removed or (2) data from both user accounts are kept as they are (without updating the user.id).
- I am a site administrator and I want to customize the merge operation on my site with de definition of field names related to user.id. I want to be able to specify a list of names for table columns that are related to the user.id column as a default set, as well as a list of column names related to user.id column for specific tables. The plugin uses this information to detect in a per table basis, the columns related to user.id column and then the data from both users accounts in every single table.
- I am a site administrator and I want to customize how merge operation is performed in a per table basis. I want to specify on the plugin settings the criteria to apply in general for database tables (the default), and also specific criteria for specific tables (like those related to quizzes or other special cases). By now, the plugin provides 3 different types of merge operations:
- Default, for any table.
- One specific for `user_enrolments`.
- One specific for `quiz_attempts`.
- I am a site administrator and I want to customize how merge operation is performed when composed indexes exist on tables. A composed index is an index formed by several columns. I want that the plugin:
- Detects automatically those unique indexes on tables where some of the columns are related to user.id and which columns are related to user.id.
- Let me specify which other composed indexes that, even though they are not unique, have to be considered as unique by the plugin for guaranteeing data consistency from the user perspective. These composed indexes may be defined on the table definition or may be defined by me manually as site administrator. I am also able to specify which columns are related to user.id.
- Consider all these indexes to process every database table properly to guarantee data consistency. In case of conflict, the plugin applies the "fallback criteria".
- I am a site administrator and have this plugin on my Moodle instance. I want that when I merge operation be idempotent. That is, no matter if I merge a user A into B, or a user B into A, the resulting merged user account should contain the same Moodle data. This general rule can have exceptions, like the information related to the person, like the information contained in the database table user and user_preferences.
- I am a site administrator and have a customized CLI merger suitable for my institution's information system, that provides an ordered list of users to merge. I want to customize the CLI merger on my site so that I can choose my customized CLI merger and run it via cron (placing it at crontab or as a Moodle task).
- I am a site administrator and I have this plugin installed. I want to list the logs of merges already done. In case there are no user merges, I read "There is no merged users. Good for you!". Otherwise, I can see a paginated list of merged users and an option to see the detail of the whole merging operation, including the detail of the two users, the tables not processed and the list of SQL statements performed during the merge, as well as the time started, the time ended and its duration.
- I am a student and I have two user accounts and I have performed some quizz attempt(s) on the same quizz once with the user account to be removed and once with the user account to be kept. After someone with access merges the two accounts I want to see my quizz with the attempt(s) merged accordingly to the configured plugin's policy.
- I am a student and when I enrolled in a course this term, I couldn't see my previous courses and grades, because my school/institution made a new account for me (for any reason). After someone with access merges the accounts I want to be able to see all my courses, participation, log activity, submissions, etc. under the one remaining account.
- I am a student and I had two user accounts in the same course and I completed some activities (A activities) with both user accounts, some other activities (B activities) with the account to be removed and other activities (C activities) with the account to be kept. After someone with access merges the two accounts I am able to see:
- "C activities" are kept "as is" with the same account to be kept.
- "B activities" are updated so that the account to be kept is the owner.
- "A activities" are mixed up together in order not to lose student's activities and the account to be kept is the owner. Examples are:
- Quizzes: Quizzes are a complex case. See its specific use case.
- Assign: All submissions of files are kept in the file repository, but only one selected as submission. Online text submissions are appended one after the other.
- Forum: I can see all posts and contributions made from both user accounts as they were done by the user account to be kept.
- In general: All activity did by the user account to be removed have to appear as if it was performed by the user account to be kept.
- I am a professor or user of any other kind of role and I have two user accounts. After someone with access merges the two accounts I want to see all courses and resources own by either the user account to be removed and the user account to be kept as if they are owned by the user account to be kept.
- I am the CLI cron and I get a list of pairs of usernames to merge. I process every pair of usernames (if any) merging the pairs of username in the same order they were provided. This helps reducing manual actions from Administrators.
Links to existing tracker issues, forum discussions, contrib plugins
- Currently, it is an administration tool: https://moodle.org/plugins/tool_mergeusers
- Repository: https://github.com/ndunand/moodle-tool_mergeusers
- Origin of this plugin: https://moodle.org/mod/forum/discuss.php?d=103425 (2008)
- Merging quiz attempts: https://moodle.org/mod/forum/discuss.php?d=258979 (2014)
- Previously, it was built as a report tool: https://moodle.org/plugins/report_mergeusers
- Moodle tracker: https://tracker.moodle.org/browse/MDL-24443 (2010)
Requirements
- Include https://moodle.org/plugins/tool_mergeusers into the Moodle core.
- (Optional) For this tool's maintainability, it could be improved in this way:
- Even though this plugin provides web settings with some configuration items, most of the configuration is established in a configuration file in PHP. It would be better to have all items available through the web interface for faster and easier access and updating to all settings.
- (Optional) In the current implementation, the tool provides a page with the list of merging actions done. It could be improved by adding pagination of results.
- Several Moodle users refer to the same person. In our institution we had up to 4 Moodle users relating to the same person. This makes difficult for the user to access all their courses. After merging all users into a single one (the correct/valid one), that person can log into Moodle and access all their courses normally.
- Automatic merging. If you set up a Command Line Interface (CLI) provider (a PHP implementation), you can put in the cron a process to automatically merge users. In our institution we use such a CLI provider, reading from a specific external database server and merging users (if any) nightly.
Further reading
Not by now.