IMS Enterprise XML format

IMS Enterprise XML format

by Joshua Westerway -
Number of replies: 13
Hi,

I need some help with the format of the IMS enrolment XML file. The help documentation and Moodle Docs are a bit thin in the explanation. I currently have external database enrolment going well from a table that has the fields - COURSE, GROUP, USERID, ROLE. I use a modified enrol.php to get the group enrolments working.

My question is, I can setup a php script to write the XML file from the database table but what does the format look like, what data from my table goes in what tags? Could someone with some knowledge of this working please give me an example XML file? The example on the plugin docs page does not make much sense to me as it does not explain the example well (IMHO).

I can then take the example and put it into my script to run through the rows of the database table and create the XML in the correct way and get this plugin working.

PLEASE!
Anyone? Thanks in advance!

-Josh
Average of ratings: -
In reply to Joshua Westerway

Re: IMS Enterprise XML format

by Adam Barbary -
Hi Josh,

It is not really that hard, once you have a play. I have attached three XML samples, one for the user create, one for course create and the last for membership of a course. The datafields can be whatever your system has, but they need to match across the three examples to work. As we migrated from a webct based system to Moodle, we wanted to utilise the same enrollment system to ease the transfer, hence the three separate processes. This could be rolled into one.

If you do go with three files, just cat them together, user, course then enroll and place that file on your server. Moodle will check it when the cron runs and if there is any change, it will load the new files. Remember to change your enterprise settings in the enrollment area first.

Just a note, the course id becomes the ID and the short name. It is displayed in the breadcrumb area. The IMS Short becomes the Long description in Moodle. It is displayed in the course listings.

Cheers,

Adam Barbary
LMS Support
University of Ballarat
In reply to Adam Barbary

Re: IMS Enterprise XML format

by Joshua Westerway -

Thank you so much, that explained it perfectly, im now writing a php script to output the xml file as per your example from my database table. I tried the enrol xml file and it created the group and put the student in, thanks again!

In reply to Adam Barbary

Re: IMS Enterprise XML format

by HJWUCGA INC. -
Adam,

In the course-create.xml file, how do you associate a course under a category then? I understand that the file only creates the course but does not put in the category we want it go.

For example, create course and put it under the "Sciences" Category.

How do you define that in the file?

Thanks


In reply to HJWUCGA INC.

Re: IMS Enterprise XML format

by Adam Barbary -
Have a look at the code below. The <org> & <orgunit> tags specify the category, in this case Science. The course is Chemistry 101

<group>
<sourcedid>
<source>School Enrolment and Course Database</source>
<id>chem101_2010</id>
</sourcedid>
<description>
<short>Chemistry 101 2010</short>
</description>
<org>
<orgunit>Science</orgunit>
</org>
</group>

If the category doesn't exist, Moodle can create it. Remember to check you IMS Enterprise settings in the Course, Enrollment menu.

Hope that helps,

Adam
In reply to Adam Barbary

Re: IMS Enterprise XML format

by HJWUCGA INC. -
Oh duh.. I though the orgunit was an actual organizational unit =)

Thanks!
In reply to Adam Barbary

Re: IMS Enterprise XML format

by Flex Liong -
Adam,

I too am looking at creating the IMS input file and I'm coming across a weird situation.

When I tried to do a test and concatenating them, it works.

However when I query the database to create the objects, the courses and users are added correctly but the enrolment does not work.

It seems to be skipping them... for example:

SKIPPING role for 13289 (s000285454) in course 3885
Added 0 users to course 201091-BUSI1306-10477
SKIPPING role for 13290 (s000285259) in course 3886
SKIPPING role for 13291 (s000286109) in course 3886
Added 0 users to course 201091-HLTH1376-10478
SKIPPING role for 13292 (s000208604) in course 3887
SKIPPING role for 13293 (s000231319) in course 3887
SKIPPING role for 7266 (s000278145) in course 3887
SKIPPING role for 13294 (s000281102) in course 3887
Added 0 users to course 201091-PIDP3102-10479
SKIPPING role for 13295 (s000105261) in course 3889
Added 0 users to course 201091-CNSK1398-10481
SKIPPING role for 13296 (s85897759) in course 3893
SKIPPING role for 13297 (s000234472) in course 3893
SKIPPING role for 13298 (s000245373) in course 3893
 
the s000XXXXXX are our user ids... I've looked at the XML file and it seems correct to me

For example, there should 2 students for 201091-HLTH1376-10478 (s000285259 and s000286109) but they are being skipped ... here is the XML


.....

<group>
<sourcedid>
<source>MOODLEdb</source>
<id> 201091-HLTH1376-10478</id>
</sourcedid>
<description>
<short>HLTH 1376: The Politics of Food (CRN 10478)</short>
</description>
</group>


.....


<membership>
<sourcedid>
<source>MOODLEdb</source>
<id>201091-HLTH1376-10478</id>
</sourcedid>



<member>
<sourcedid>
<source>MOODLEdb</source>
<id>s000285259</id>
</sourcedid>
<idtype>1</idtype>
<role recstatus="1" roletype="01">
<status>1</status>
<userid>s000285259</userid>
</role>
</member>


<member>
<sourcedid>
<source>MOODLEdb</source>
<id>s000286109</id>
</sourcedid>
<idtype>1</idtype>
<role recstatus="1" roletype="01">
<status>1</status>
<userid>s000286109</userid>
</role>
</member>

</membership>

....


thoughts?



In reply to Flex Liong

Re: IMS Enterprise XML format

by Adam Barbary -
My first thoughts were, has the user been created before you tried assigning the role, then I noticed a little change in your syntax which may explain why Moodle has skipped the membership.

First, your code...

<membership>
<sourcedid>
<source>MOODLEdb</source>
<id>201091-HLTH1376-10478</id>
</sourcedid>
<member>
<sourcedid>
<source>MOODLEdb</source>
<id>s000285259</id>
</sourcedid>
<idtype>1</idtype>
<role recstatus="1" roletype="01">
<status>1</status>
<userid>s000285259</userid>
</role>
</member>
</membership>

Now my code ...

<membership>
<sourcedid>
<source>MOODLEdb</source>
<id>201091-HLTH1376-10478</id>
</sourcedid>
<member>
<sourcedid>
<source>MOODLEdb</source>
<id>s000285259</id>
</sourcedid>
<idtype>1</idtype>
<role roletype="01" recstatus="1" >
<status>1</status>
<userid>s000285259</userid>
</role>
</member>
</membership>

It appears that by reversing these two tags it has prevented the XML parser from doing its job. Try swapping them around and let us know how you get on.

Cheers,

Adam
In reply to Adam Barbary

Re: IMS Enterprise XML format

by Flex Liong -
Adam,

I noticed that too but in my script, it is suppose to write out the order I specified, which is the same as you highlighted... <role roletype="01" recstatus="1" >

But for some reason, it's reversed when I view the file created... weird.


In reply to Flex Liong

Re: IMS Enterprise XML format

by Adam Barbary -
Before you go to far, do a find and replace and see if the XML loads.
In reply to Adam Barbary

Re: IMS Enterprise XML format

by Adam Barbary -
Oh fiddlesticks that should be too far.
In reply to Adam Barbary

Re: IMS Enterprise XML format

by Flex Liong -
fiddlesticks ... I have not heard that for a long time LOL

I'll see what I can do after I return from my Christmas holidays.

Happy Holidays!
In reply to Adam Barbary

Re: IMS Enterprise XML format

by john ellingsworth -
I had to modify line 907:

if(preg_match('{<role\s+roletype=["\'](.+?)["\'].*?>}is', $mmatch[1], $matches)){

to the following:
if(preg_match('{<role\s+roletype\s+=\s+["\'](.+?)["\'].*?>}is', $mmatch[1], $matches)){

due to extra spaces between the "=", e.g.

<role roletype = "04">
<status>1</status>

I'll submit a bug for this if necessary.

Regards,

John