-
Bug
-
Resolution: Fixed
-
Minor
-
1.7
-
None
-
Microsoft SQL
-
MOODLE_17_STABLE
-
MOODLE_17_STABLE
Autocreation of courses that exist in external database but do not yet exist in moodle fails. If the course already exists, the user will be enrolled with the proper role but the course will not be created otherwise. Course creation at both login time and when manually syncing with the external database by calling:
php ./enrol_database_sync.php
No error is returned in error_log on user login but enrol_database_sync.php does show:
PHP Notice: Undefined index: course in /var/www/html/moodle-cvs/lib/adodb/drivers/adodb-mssql.inc.php on line 785
the course shown here, is what I have enrol_remotecoursefield set to (I've tried changing the name to make sure I'm not hitting a reserved word with no change in result).
Adding some debugging statements to the code, it looks like the problem show up in enrol.php at line 197 where $extcourse is set from the $rs object. With mssql_n as the database for external enrollment, $extcourse ends up blank. Too see why this was I added a print_r($rs); statement just before the while (!$rs->EOF) loop. Here are my results for mssql_n:
adorecordset_mssql_n Object
(
[databaseType] => mssql_n
[dataProvider] => native
[fields] => Array
(
[0] => s07-bi101-03
)
... (rest of output is in rs_mssql.txt attachment)
as you can see, fields[course] is not set but fields[0] is. With the same print_r statement but switching my external database to use a mysql table with similar data I get:
adorecordset_mysql Object
(
[dataProvider] => native
[fields] => Array
(
[0] => sp07-bi103-04
[course] => sp07-bi103-04
)
,,, (rest of output is in rs_mysql.txt attachment)
so field[course] is being set for mysql. If (after switching back to mssql) I change line 197 in enrol.php to:
$extcourse = $rs->Fields(0);
then course creation works but a new PHP notice appears:
PHP Notice: Undefined index: peopleid in /var/www/html/moodle-cvs/lib/adodb/drivers/adodb-mssql.inc.php on line 785
peopleid is what I have enrol_remoteuserfield set to. So the problem may exist there also.