External Database enrollment is not creating courses

External Database enrollment is not creating courses

by Salman Zaidi -
Number of replies: 6
Hi

I have been stuck in creation of courses form external db enrollment. I have tried several combination of configuration in external database enrollment. I believe that i am doing some error in configuration or in my understanding.

My understanding is that when an external user logs in, his enrollment and course should automatically be created in moodle at the login time and should be shown in my course block.

But in my case it is not happening so. Although my external db is MSSQL Server and i have successfully done external user authentication but enrollment is not being coming in moodle course table.  Then for a test i created a test db in Mysqli as external db to test the same configurations but failed to see new course creation.  My moodle version is 3.1 and this is bitnami moodle.  Thanks in advance. Please help.  I created coursecat category (as mentioned in new course category filed ) in moodle and its value is set to 11. 

I am now exausted, I don not know where i am doing fault. I am attaching configuration screens to be verified by experts. Can any one please see and advise where did i have done configurations.
Attachment 11.jpg
Attachment 22.jpg
Average of ratings: -
In reply to Salman Zaidi

Re: External Database enrollment is not creating courses

by heli g -

Hi Salman,

It has been a while since I set this up and things may have changed - but do your Categories exist in Moodle?

I used this in 2014 to upload all my Categories:  https://github.com/piersharding/moodle-tool_uploadcoursecategory

Below is a sample from our Courses table:

coursefullname courseshortname2 catnumber
2016 AHIS770P2 Special Topics in Art History 2016|AHIS770|P|2 0023_2382_02
2016 AHIS7RPP1 Honours Project:Art History 2016|AHIS7RP|P|1 0023_2382_02
2016 AHIS7RPP2 Honours Project:Art History 2016|AHIS7RP|P|2 0023_2382_02
2016 AHIS8CYH1 Dissertation: Art History Cont 2016|AHIS8CY|H|1 0023_2382_01
2016 AHIS8CYH1 Dissertation: Art History Cont 2016|AHIS8CY|H|1 0023_2382_01

Where catnumber is the Category ID number, e.g.

cat id number


 An example from the Users table:

username role courseshortname2
200500134 student 2016|PSYC8SS|H|1
200500134 student 2016|PSYC8SS|H|2
200700158 student 2016|EDMN911|E|1
200700158 student 2016|EDMN911|E|2
201000217 student 2016|PBHL841|H|2


We have scheduled the External database enrolment script to run every night - it creates the courses and enrols Students and Teachers - although they are also enrolled on Login (& I believe courses should also be created if they do not exist - but the script takes care of that). You are using Windows? On Ubuntu Linux this runs the script - I am not sure how you would do this in Bitnami...

/usr/bin/php -c /etc/php5/apache2/php.ini -d memory_limit=2048M /path/to/moodle/enrol/database/cli/sync.php -v

The main difference in our config is the Local field mapping. Mine below. Since you are using Role ID, not name, in your Users table I think the Local role field should be id as you have it.

cat idnmuber mapping

Which brings me back to Categories...

1) Do they already exist in Moodle?

2) If they do exist, I believe the Default: id mapping is looking at the record id in the Moodle database, you can see this id number in the path if you edit a category

cat id

Is this as it should be?

We are using idnumber which is a field that references ids in our External database (not Moodle's database).


I hope this helps

Heli

In reply to heli g

Re: External Database enrollment is not creating courses

by Salman Zaidi -

Hi Heli,

Thanks for reply in detail. I tried with same data and tables you have shown in your reply  but failed to get new course upon login of external user.

I reply your questions as below. 

1. I did not create the same categories with same id number (as in external courseinfo table) in moodle. Though now i have created a category with same id number as you mentioned in your example and i have inserted the same data as of yours.

2. This category id number is in catnumber field of courseinfo table and that course is placed against a user in userrol table which i logged in with no course creation result.

3. My moodle is on Windows and I have configured wget extension and set "C:\Program Files (x86)\GnuWin32\bin\wget.exe" and  Files (x86)\GnuWin32\bin\wget.exe -q -O NUL http://localhost:8080/moodle/enrol/database/cli/sync.php in argument. BUT i am NOT in the phase of running or testing sync.php script as i believe that first i need to have course creation feature working on login activity of external user.

4. You are right that the Default: id mapping is looking at the record id in the Moodle database, and i have seen this id number in the path when i have edited category.

5. i have changed the local role field as shortname now and update the value of role field as varchar having string "Student".


I HAVE DONE THE SAME WORK AS SHOWN IN YOUR EXAMPLE BUT STILL I HAVE NO RESULT. That might be due the fact that i am still unclear about New Course Creation panel parameters. especially, 1. New course ID number field, 2. New course category field, 3. Default new course category.

A. I assume that 1. New Course ID number field is not present in remote new course table as also in yours too. Although i have set it as idnumber (as mentioned by default). Please tell me what this New course id number field is.

B. What is this New course category field. I set it as catnumber which the part of courseinfo table. I assume this field must be that should match with category id number in category edit setting of moodle. In my case i set it as of yours i.e. 0023_2382_01.(This category belongs to the course which is enrolled by the user which i am logging in to see the result)

C. Default new course category, I have set it Miscellaneous and this does not have any idnumber set in edit category setting of moodle. I assume that this parameter will hold courses which do not have any category in external.

PLEASE CORRECT MY CONCEPT IN ABOVE NARRATION AS I AM STILL GETTING NOTHING AFTER ALL CLONE SETTINGS AS YOU HAVE PRESENTED, Except the new course creation panel. Please share parameters of new course creation panel and clarify New course ID number field and New course category field specifically.

Thanks and much appreciate.

In reply to Salman Zaidi

Re: External Database enrollment is not creating courses

by m question -

I did have the same problem before, the reason was that I didn't create category thinking moodle will create categories as courses

so the steps that worked for me

1)create the category in Moodle

2)make sure that categories id match the id of category in your external db

3)test the connection

4)run enroll cron (/path/to/moodle/enrol/database/cli/sync.php)


In reply to m question

Re: External Database enrollment is not creating courses

by Salman Zaidi -
Hi Heli and moodle question

Thanks, I have successfully configured and now I can see courses from external db into moodle.

I need to bulk upload categories with their id into moodle. I have more than 380 categories. working on how to bulk upload those categories instead of creating each category one by one through admin panel of moodle.


Second thing, I want to add all course parameters into moodle course e.g. Location, Description, start and end date and day. I dont know how can I do this. because by default, moodle only see course full and short name from external db.

Do I need to write php script to add other course parameters into moodle mysql course table?

I want moodle to show courses for users just like a simple application showing course info in formatted form. Like tables with heading and description. Requirement is not to show any course format of moodle, as moodle always force course page to show in topic, weekly or other formats. While I dont want all those. I just need to show my course info and enroll button and thats it.

Have you any idea how can this be accomplished in simple way.  ??? Thanks

In reply to Salman Zaidi

Re: External Database enrollment is not creating courses

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

You should be able to upload categories directly into the moodle database from a csv file.

Confused on your course display - before a user is enrolled in a course, they already display like you want...

In reply to Emma Richardson

Re: External Database enrollment is not creating courses

by Salman Zaidi -

Hi Emma

Yes, I have installed upload course categories plugin and that worked for me for bulk categories. I have created csv file comprising category name, cat id(used to mapped external db enrollments)  and description. Each enrollment is now mapped with respected categories.

Now I have new task i.e. to create transcript (not certificate) for student. Student should be able to download transcript and transcript information is again not present in moodle db. The information is in external db.
I have thoughts that I can do this by following steps

1. I need to first bring required data into moodle db through a php script (creating a transcript table or reporting table or add new fields into certificate table).

2. I need to customize the certificate plugin. The problem is that current certificate format is very much different from what I need. I need a dynamic length A4 transcript. length will vary according to courses and their outcome information.

Any Idea and take on this to correct my opinion?


Thanks for help.


Salman