Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -
Number of replies: 16

Hello

I've got two installations of moodle on the same windows SQL server with separate databases on that server and they are working perfectly. One is Moodle version 2.7, the other is the latest 2.9 development release. Both have ldap authentication working. Both have the external database plugin activated for user enrolment and they both connect to the data source OK when the settings are tested via the Moodle admin panel.

The 2.7 has a windows scheduled task running the main admin cron and then a cli/sync.php enrolment cron to a user enrolment table in an external SQL Server database. This is working fine. As soon as someone logs in with a valid network account, they get a Moodle account and see their correct enrolments.

I have a copy of that enrolment table in the same external database and an identical scheduled task doing exactly the same things for the 2.9 Moodle. The admin cron runs perfectly and the cli/sync.php step also runs correctly giving a 0x0 result that it has been "successfully completed". The problem is that the actual enrolment data does NOT get synchronised and appear in moodle 2.9 and I have spent several days tearing what's left of my hair out.

I have only run one task at a time and not tried to do them simultaneously. The formatting of the columns and the setup of the mapping is identical as is the data. Has anyone got any ideas or suggestions or similar experience with this version?

Any help would be very welcome.

Best Wishes,

Richard


Average of ratings: -
In reply to Richard Whitfield

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Are you sure that you not syncing the 2.7 by mistake?  I know its a stupid question but one of those things I would discover after many days of frustration!

So you are running ldap authentication and then external database enrolment or ldap enrolment?

...ldap authentication works on both sites?  Just the enrolment part that is missing?




In reply to Emma Richardson

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -

Hello Emma,

Thanks for the quick reply. As far as I can tell I'm not synching the 2.7 because all the code in the task relates to the 2.9 database (moodledb29 as opposed to the original moodledb). Authentication is via leap, yes, and the enrolment is via external db synch.

The task was a copy of the original 2.7 but has had the code in each step changed. As mentioned, it runs the 2.9 cron perfectly, it is just the enrolment cron that fails to do anything. Weird, huh?

Richard

In reply to Richard Whitfield

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Have you looked directly at the 2.9 database and is nothing in there?

You have two issues - which one is failing?  LDAP or External DB?  Do you have users?  Are you running LDAP auth sync?  And then database enrol sync? 
In reply to Emma Richardson

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -

Hello-I will check it out but the ldap authentication is fine. If I look at the enrolment tables in the database no data is there unfortunately. Cheers, Richard 

In reply to Richard Whitfield

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Run the sync from terminal. It should detail wha t it is or is not doing.

In reply to Emma Richardson

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -

Hello Emma,

How do you do that in Windows? I have tried  php-win.exe -f "c:\inetpub\wwwroot\moodle29dev\admin\tool\scheduled_task.php --list"but to no avail

Cheers,

Richard.

In reply to Richard Whitfield

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -

Hello again, Emma.

I've done a little bit more digging and have got some info for you. I can list options, etc but not find individual tasks and then run them. Have you any idea what the syntax is for doing this, please?

Using this a reference: https://docs.moodle.org/28/en/Administration_via_command_line#Running_cron_via_command_line

This command for Windows servers:

php-win.exe -f "c:\inetpub\wwwroot\moodle29dev\admin\tool\cli\schedule_task.php" -list

errors  and the file size for php-win.exe in the installation is 0kb

However, this runs

php.exe -f "c:\inetpub\wwwroot\moodle29dev\admin\tool\cli\schedule_task.php" -list

and produces a list of commands for running php but nothing about the list of tasks and how to run them.

Thanks a lot,

Richard



In reply to Richard Whitfield

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hmm - unfortunately I run on Linux - here's a php page that might help.

http://php.net/manual/en/install.windows.commandline.php

If you can't figure that one out try running cron manually from the web interface /admin/cron.php.  It might give you an idea of what is going on too.

In reply to Emma Richardson

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -

Cheers - I'll give it a go and see what happens. I'm getting somewhere having set up an environment variable for php on the server which seems to be letting me do some more stuff and I'll keep you posted.


Thanks again,

Richard

In reply to Richard Whitfield

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -

Hello Emma,

When I run it, no mention is mentioned of the enrol_database sync, just cohorts/self enrolment/manual, etc. Any ideas why it is avoiding calling this specific sync even when the plugin is activated?


Cheers,

Richard

In reply to Richard Whitfield

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Oh, I think you have to manually add it to cron so maybe it won't show up in the general moodle cron running. 

In reply to Emma Richardson

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -

Ahhh - I think I see. I take it that means editing  admin/cli/cron.php to call  enrol/database/cli/sync.php?

Or is it a case of adding something like \$sudo -u www-data /usr/bin/php enrol/database/cli/sync.php to the general cron file?

Cheers,

Richard

In reply to Richard Whitfield

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

The second part but you said that cron was saying it had run successfully - how have you been running the sync or is it that you haven't?

In reply to Emma Richardson

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -

Hello Emma,

I had been calling the sync,php for enrol_database via the following code in a basic scheduled task:

start program

"C:\Program Files (x86)\PHP\v5.5\php.exe" with arguments of -f c:\inetpub\wwwroot\moodle29dev\enrol\database\cli\sync.php -a

This runs the sync.php and gives a successfully completed result. Maybe it is because the cron was not calling the file?

If not, where do I put the code and what would it be?

Cheers,

Richard

Initially, I got a summary of what to do from here: http://james-moodle.blogspot.co.uk/2014/04/the-many-things-i-learned-setting-up.html.)



In reply to Richard Whitfield

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

No, that should work - but you are not getting a course by course output?  When I run the ldap enrolment sync, it will detail by each course what it does and tell me if it can't find users etc...

There has to be some very simple error somewhere - do you have the classes identified correctly in the database?  Do you have everything set correctly on your moodle site.  What field are you using to identify the courses?  Is it correctly set in Moodle..?

In reply to Emma Richardson

Re: Moodle 2.9 external database enrolment - the sync.php runs successfully but NO data comes across

by Richard Whitfield -

Hello Emma,


When you say "classes" what exactly do you mean? I'm using the course id number field (not id) which is populated from our MIS system. It is a unique id number (e.g.12500) for every course occurrence. As stated at the outset, the data is the same as that for the other moodle 2.7 installation which works fine. When I test the settings for the connection in Moodle admin it works fine for the enrolments table (no table is used for the courses (as per the working installation)).

How are you running the enrolment sync exactly - could you send me a copy of the code from your cron file? That would be a real help.

Thanks for all the time you are putting into this for me.

Cheers,

Richard