Browse files

update enrol/database to use roles.

Credit: Alastair Pharo <>


1) This plugin previously only worked for students.  I have made it so
that you can _optionally_ specify a third column in your external
database that contains some kind of role information (similar to the
other two fields, you can choose any column in the mdl_role table
to map to).  If you do this, then the code loops over for each different
kind of role and queries the external database.

2) There is a *slight* problem to be aware of, if a moodle
configuration was upgraded to use the new role columns, then downgraded
again, some roles might get left behind in the database when the
large-scale sync thing goes through (that is, record pruning doesn't
scale back quite properly). These would be cleaned away by
setup_enrolments at login time, however, and the scenario was unlikely
enough for me to decide to leave it for now.

3) If you don't have role columns there is a 'default role' setting
that you can set (made by Martin D).  This will only be obeyed when no
role columns are specified.  If this is set to 'default', then the
course default role is used, on a per-course basis (which usually
means student apparently).

4) From (3), my understanding is that if no config settings are
changed, and the default role for all upgraded courses is student, that
a smooth upgrade to 1.7 will occur for users of the database enrolment
  • Loading branch information...
1 parent 7d49253 commit 7ccf89f50a08f66091d7b6ba2b66a4a7aebecce8 mjollnir_ committed Sep 26, 2006
Showing with 271 additions and 122 deletions.
  1. +20 −0 enrol/database/config.html
  2. +238 −118 enrol/database/enrol.php
  3. +13 −4 enrol/database/enrol_database_sync.php
@@ -102,6 +102,16 @@
<tr valign="top">
+ <td align="right">enrol_db_localrolefield:</td>
+ <td>
+ <input size="15" type="text" name="enrol_db_localrolefield" value="<?php echo $frm->enrol_db_localrolefield ?>" />
+ </td>
+ <td>
+ <?php print_string("localrolefield","enrol_database") ?>
+ </td>
+<tr valign="top">
<td align="right">enrol_remotecoursefield:</td>
<input size="15" type="text" name="enrol_remotecoursefield" value="<?php echo $frm->enrol_remotecoursefield ?>" />
@@ -121,6 +131,16 @@
+<tr valign="top">
+ <td align="right">enrol_db_remoterolefield:</td>
+ <td>
+ <input size="15" type="text" name="enrol_db_remoterolefield" value="<?php echo $frm->enrol_db_remoterolefield ?>" />
+ </td>
+ <td>
+ <?php print_string("remoterolefield","enrol_database") ?>
+ </td>
<th colspan="2">
<?php print_string('roles', 'role') ?>
Oops, something went wrong.

0 comments on commit 7ccf89f

Please sign in to comment.