#Moodle Tip - Modifying Course Enrollment Keys En Masse

Problem:
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 keys...do you see the problem?


Solution:
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` 
WHERE PASSWORD =  ''

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'
WHERE PASSWORD =''

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 Corner-MGuhlin.org


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

Comments

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!

Popular posts from this blog

#Chromecast Add-Ons to Play Various Video File Formats

Free Professional Learning! Education On Air #googleedu

10 Steps to a Blended Learning Classroom #MIEexpert #MIE #tceamie1