Admin tools: Merge user accounts

tool_mergeusers
Maintained by Picture of Nicolas Dunand Nicolas Dunand, Picture of Jordi Pujol-Ahulló Jordi Pujol-Ahulló
This administration tool will merge two Moodle user accounts into one.
848 sites
905 downloads
42 fans

The intent is to assign all activity & records from user A to user B. This will give the effect of user B seeming to have done everything both users have ever done in Moodle.

This tool replaces the old report_mergeusers, which is now obsolete.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3

Contributors

Picture of Nicolas Dunand
Nicolas Dunand (Lead maintainer): author
Picture of Jordi Pujol-Ahulló
Jordi Pujol-Ahulló: author
Picture of Forrest Gaston
Forrest Gaston: contributor
Mike Holzer
Mike Holzer: contributor
Picture of RISET Université de Lausanne
RISET Université de Lausanne: Supporting institution
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Bruno Tavares
    Wed, 11 Oct 2017, 8:48 PM
    Greetings.

    On Moodle 2.6.11+ (build 20150619), either using v1.14.1 and v1.12 of the plugin, I'm getting the following error:

    Coding error detected, it must be fixed by a programmer: level must be specified in init() method of each method

    Debug info:
    Error code: codingerror
    Stack trace:
    line 427 of /lib/classes/event/base.php: coding_exception thrown
    line 489 of /lib/classes/event/base.php: call to core\event\base->validate_before_trigger()
    line 231 of /admin/tool/mergeusers/lib/mergeusertool.php: call to core\event\base->trigger()
    line 135 of /admin/tool/mergeusers/index.php: call to MergeUserTool->merge()

    What other information can I provide, to help getting to the problem's origin?

    Thanks in advance.

    Bruno Tavares
  • Picture of Roland Sherwood
    Fri, 24 Nov 2017, 10:36 AM
    Hi,

    Many thanks for this plugin (which really should be in Moodle core, imo). Unfortunately, we've just tried to merge two users and have hit this error:

    Exception thrown when merging: 'Can not find workshop activity with id 23".

    Trace:
    #0 /var/www/html/moodle/admin/tool/mergeusers/lib/mergeusertool.php(291): MergeUserTool->updateGrades('14592', '5162')
    #1 /var/www/html/moodle/admin/tool/mergeusers/lib/mergeusertool.php(216): MergeUserTool->_merge('14592', '5162')
    #2 /var/www/html/moodle/admin/tool/mergeusers/index.php(135): MergeUserTool->merge('14592', '5162')
    #3 {main}


    ×
    Merge failed!
    Your database engine supports transactions. Therefore, the whole current transaction has been rolled back and no modification has been made to your database.

    I've checked within the database and the message is correct about there being no workshop activity with ID 23 (presumably it was deleted at some stage). Do you have any ideas on on how we can proceed?
  • Picture of Jordi Pujol-Ahulló
    Fri, 24 Nov 2017, 3:33 PM
    Hi!

    Thanks for the comments and for giving us feedback.

    The case you show is a bit weird. It's like the course module was deleted but not its related grades (from tables grade_grades and grade_items). This is why the process hangs up.

    Did you proceed the workshop deletion properly?

    Meanhile, if you want to try it out and pass through this incongruence, you could change the line at admin/tool/mergeusers/lib/mergeusertool.php, lines 486 and 489 where there is a "throw new \Exception(...);" for a "continue;", to just omit this grade item.

    Better if you can test in a test instance, prior to run it in production.

    Let us know!

    Jordi
  • Picture of Jordi Pujol-Ahulló
    Tue, 27 Feb 2018, 2:05 AM
    Hi! Several rounds ago, and also for the round of January-July 2018 we are proposing this issue as a MUA project here: https://tracker.moodle.org/browse/MDL-61542

    Looking to see you there and also voting!
  • Picture of Beto de Oliveira
    Tue, 13 Mar 2018, 4:48 AM
    Hi,

    Does the plugin works with external db accounts?
  • Picture of Constance Horne
    Tue, 13 Mar 2018, 4:50 AM
    It merges two users in a moodle database.
  • Picture of Jordi Pujol-Ahulló
    Tue, 13 Mar 2018, 4:06 PM
    Hi!

    Thanks Constance for the reply.

    Hi Beto. This plugin is a Moodle plugin. As such, it only operates on the Moodle database, and not on external databases.

    Thanks to all of you.
  • Renaat
    Wed, 23 May 2018, 9:26 PM
    Moodle 3.5 compatible and no privacy provider?

    As a result the phpunit tests fail:

    provider_testcase::test_all_providers_compliant with data set "tool_mergeusers" ('tool_mergeusers', 'tool_mergeusers\privacy\provider')
    Failed asserting that false is true.

    privacy/tests/provider_test.php:178
    ips/lib/phpunit/classes/advanced_testcase.php:80

    To re-run:
    vendor/bin/phpunit provider_testcase privacy/tests/provider_test.php
  • Picture of Jordi Pujol-Ahulló
    Wed, 23 May 2018, 11:12 PM
    You're right. Sorry about that. We will check it.
  • Picture of Zackary Bennett
    Tue, 3 Jul 2018, 11:46 PM
    I used your tool to try to combine two accounts. However, an error is returned, and I was hoping to get some input on what it means.

    Exception thrown when merging: 'Error reading from database"
    Table 'moodle.mdl_ast_access1095' doesn't exist

    I looked through the tables listed on moodle's site (for reference) and the ones I can see in MySQL workbench, and that table doesn't exist.

    Does that mean that the tool is looking for that table, can't find it, and is throwing an error? Is there anything I can do to work around this issue?
  • Picture of Jordi Pujol-Ahulló
    Wed, 4 Jul 2018, 12:11 AM
    Hi Zackary!

    Thanks for reporting.

    It is very very weird that this plugin tries to look for a table that actually does not exist. Most of all because it looks for all tables in runtime and then iterates for all of them.

    However, if this is the case (we should take a look why it is happenning), you can take a turnaround and let the plugin prevent processing that table. Let's see:

    Taking a look at what we talk about here: https://github.com/ndunand/moodle-tool_mergeusers we can add ad-hoc configuration for every Moodle instance independently.

    I recommend you to place the file "admin/tool/mergeusers/config/config.local.php" with the following content:

    ========================= <?php

    return array(
    'exceptions' => array(
    'ast_access1095', //don't place the table prefix on the table name
    ),
    );
    =========================

    If you have this file already created, for whatever reason, you should have to merge the content. Otherwise, you just create the file with the above content.

    Just tell us what it's going on!

    Jordi

  • Picture of Jordi Pujol-Ahulló
    Wed, 4 Jul 2018, 12:12 AM
    Sorry, the content should be this (without the "=" strings):

    =========================

    <?php

    return array(
    'exceptions' => array(
    'ast_access1095', //don't place the table prefix on the table name
    ),
    );

    =========================

    Hope that helps!
  • Picture of Zackary Bennett
    Sat, 7 Jul 2018, 12:33 AM
    Thank you Jordi! Adding that exception did the trick. So simple and effective.
  • Picture of Evan Abbey
    Thu, 12 Jul 2018, 11:35 PM
    Jordi, we have used the merge users plugin for a while (since it was a report). We just noticed that it is not merging grades within a gradebook when both of the student accounts were enrolled. We are on Moodle version 3.5.0. There are no errors or anything within debugging to indicate that something is wrong that I can see.

    • Is this the intended outcome? I might have missed that the plugin always did this in the past, and just thought it was merging them. I attempted to rollback the plugin, and that made no difference.

    • Right now, our log output for a merge shows these two lines related to grades:
    DELETE FROM mdl_grade_grades WHERE id IN (38548, 38547, 38549)
    UPDATE mdl_grade_grades_history SET userid = '9232' WHERE id IN (137943, 137944, 137945, 137946)

    Do I have a setting incorrect? I have been leaving the default settings for the plugin, as they have worked for me in the past.

    Thank you
1 2 3 4 5 6 7 8
Please login to post comments