A Small Moodle/Blackbaud Integration Example

Here the code we use to pull user name information from Education Edge into the Moodle user profile. This code starts at line 320 of moodle/user/edit.php. The bit about @sfuhs.org allows me to handle Moodle accounts for both AD users (students, faculty) and non-AD users (parents), who login with their personal email addresses.

// pre-fill user information
$user->email = $user->username;
if (!strpos($user->email, '@')) {$user->email .= '@sfuhs.org';}
$query = " SELECT
NUM LIKE '" . $user->email . "' AND

mssql_connect ( "$eesrv", "$eeuser", "$eepass" );
$result = mssql_query ( $query );
if ($row['NICKNAME']) {$row['FIRSTNAME']=$row['NICKNAME'];}
if ($row['FIRSTNAME']) {$user->firstname = $row['FIRSTNAME'];}
if ($row['LASTNAME']) {$user->lastname = $row['LASTNAME'];}


I then modify the edit.html template so that the name fields are not editable, consistent with the idea of our users being fully identified by name within our web intranet. This goes hand in hand with automatically capturing the user login from the environment variables, which is subject matter for a separate post.


  1. Paul Gibbs says:

    Hi Richard,

    I’m really interested in hearing more about your Moodle/EE integration. Would you be able to answer some or all of these burning questions? đŸ™‚

    1. Do you populate classes through queries run against the EE database everytime someone logs in? Or do you do some sort of daily download to update classes with new students and remove students who have been dropped?

    2. Do you link students’ EE accounts to AD account and then have the students log into Moodle with their AD accounts, and handle the listing of what courses they’re enrolled in that way?

    3. Are you running Moodle on Windows or Linux?

  2. Paul Gibbs says:

    I’m really interested in learning more about how your EE/Moodle integration is going. Could I ask you a couple questions…?

    1. How are you handling course rosters? You you query on EE everytime a student logs in so that your list of enrolled students is updated realtime? Or do you do run code each evening to remove dropped students from Moodle and add newly registered students?

    2. For login, are you adding an AD account in EE for each EE record, and then logging users in through Moodle via AD so that the connection between the two is the AD account?

    3. Are you running Moodle on Linux or Windows?

    Thank you so much!

  3. Richard says:

    1. We leave all courses open, so that theoretically any student may enroll in any course. In practice, only the students actually taking the course enroll in it. We see no reason to restrict course enrollment at our school. In fact, we cherish a culture of openness among classes.

    2. Yes, that’s right. We already need the AD account so that each student has mail, file, and web access in general. So binding Moodle to AD was a no-brainer. The link between EE and AD is that we store the AD username in each student’s EE record for cross-reference purposes.

    3. Linux. I did run Moodle on Windows at my previous school, and it ran fine for our user base of about 500 users. See http://k12converge.com for a story of how Moodle on Windows didn’t scale well to a larger, more active user population.

    – Richard