Friday, August 20, 2010

#Moodle Tip - Modifying Course Enrollment Keys En Masse

We've just activated student logins via LDAP authentication. Unfortunately, our Moodle instance has courses that do not have enrollment keys. This means students could login to ANY Moodle without an enrollment key. We've just created 70 courses without enrollment you see the problem?

One solution is to go through each course and update the settings to include an enrollment key. This would be time-consuming.

Another solution is to assign a uniform enrollment key to ALL courses that lack an enrollment key. But how?

In the "mdl_course" table, there is a field by the name of "password." This password is the enrollment key for a course. But how to change the password for all?

One way is to use a SQL statement that updates all blank enrollment key settings. Here is the statement that FINDS courses with blank enrollment keys:

SELECT fullname,password 
FROM  `mdl_course` 

Before updating ALL the courses at once, you might want to check to see if it will work. Try this:

update mdl_course
set password='clef'
where fullname='Music Technology'

Verify that the change took place with this command:

SELECT fullname,password 
FROM  `mdl_course`
where fullname='Music Technology'

The results of the query should reveal that the password is now "clef" without quotes.

To update the "password" field for ALL courses en masse, use the following SQL commands:

update mdl_course
set password='clef'

Another way to verify this is to login to the course and check the AVAILABILITY settings:

So, that's all there is to it. Easier than I suspected.

Subscribe to Around the

Everything posted on Miguel Guhlin's blogs/wikis are his personal opinion and do not necessarily represent the views of his employer(s) or its clients. Read Full Disclosure

1 comment:

Kent Villard said...

We use Postgres with our Moodle install. We needed to set the enrolment key to a random four digit number if there was no enrolment key currently. This is the SQL that we use:

UPDATE mdl_course SET password=ltrim(to_char(round(random()*8999+1000),'9999')) WHERE password='';

I just run this periodically, it saves a lot of time and effort!

The Courage to Lead