Thursday, January 8, 2015

Steps to correct external DB to moodle synch error

I call these php files with each cron execution in my moodle.

I created a bat file that sits in the webroot on the server that calls both of the php scripts needed to synch account authentication and enrollment from external DB.

systempath/www/sync_enrollments_genius.bat file
c:\wamp\bin\php\php5.3.13\php.exe -f c:\wamp\www\student\auth\db\cli\sync_users.php
c:\wamp\bin\php\php5.3.13\php.exe -f c:\wamp\www\student\enrol\database\cli\sync.php

Occasionally - the call to auth\db\cli\sync_users.php generates an error
!!! Error writing to database !!!
!! Duplicate entry 'username' for key 'mdl_user_mneuse_uix'
'' account details below...
.
.
"
The error is caused when moodle is trying to create new accounts but finds an existing lastname (account) whose Authentication type is manual.  Changing that from manual to DB should correct the problem.

Steps to diagnose and correct the error
  1. turn on developer level debugging in moodle - show it to the screen
  2. run the cron script again
  3. Look at the cron output - notice the username of the account failing(trying to create in moodle)
  4. Look for the account in moodle - search for the lastname
  5. edit the account and change its authentication type from manual to external
That should take care of this error - once moodle knows its an externally created account - it *synches with the account in the external DB.

No comments:

Post a Comment