enrol_student is deprecated in moodle 1.7

enrol_student is deprecated in moodle 1.7

by Ole Thomassen -
Number of replies: 5
Hi,

I am using the wspp webservice module. When I try to use the enrol_students function an error is being thrown. When I study the source code in
http://cvs.moodle.org/contrib/patches/ws/wspp/server.class.php?view=markup under the function enrol_students it says "enrol_student is deprecated in moodle 1.7". I am running Moodle 1.9, is there an alternative function to use to enroll students via the web service call? Or is there a better web service framework I can use for my Moodle 1.9?

Thank you
Ole Thomassen
Average of ratings: -
In reply to Ole Thomassen

Re: enrol_student is deprecated in moodle 1.7

by Patrick Pollet -
enrol_student is indeed deprecated but still present in 1.9 in file lib/deprecated.php. So the error is not a missing function but very likely bad parameters sent to enrol_students. What is exactly the error returned ?


As far as a better framework is concerned, work is in progress . See http://tracker.moodle.org/browse/MDL-12886

Cheers.
In reply to Patrick Pollet

Re: enrol_student is deprecated in moodle 1.7

by Ole Thomassen -
The error returned is ""Could not enrol user Bill Hansen in course .\n"".
In reply to Ole Thomassen

Re: enrol_student is deprecated in moodle 1.7

by Patrick Pollet -
Could you show me the php used to setup the call ? Looks like some parameters are wrong or missing ...

Cheers.


In reply to Patrick Pollet

Re: enrol_student is deprecated in moodle 1.7

by Ole Thomassen -

Hi Patrick

I am using ASP.NET 3.5 (C#) using Web References.

I use the following code 

org.ndcde.moodle01.MoodleWS moodle = new TestMoodleWeb.org.ndcde.moodle01.MoodleWS();// Login

org.ndcde.moodle01.

loginReturn loginObject = moodle.login("thomassen", "mypassword");// Create a string array with userids

String[] studentArray = new String[1] { "155" };// Enroll Students

}

When the object returns I see this message:

moodle_ws_c_sharp.jpg

object enrollmentObject = moodle.enrol_students(loginObject.client, loginObject.sessionkey, "HCO2011W", studentArray, "id");

protected void Page_Load(object sender, EventArgs e) {// Create Moodle WS Object
In reply to Patrick Pollet

Re: enrol_student is deprecated in moodle 1.7

by Ole Thomassen -

Hi Patrick

I am using ASP.NET 3.5 (C#) using Web References.

I use the following code 

// Moodle Object

org.ndcde.moodle01.

MoodleWS moodle = new TestMoodleWeb.org.ndcde.moodle01.MoodleWS();// Login

org.ndcde.moodle01.

loginReturn loginObject = moodle.login("thomassen", "aB91858324");// Create a string array with userids

String[] studentArray = new String[1] { "155" };// Enroll Students

object enrollmentObject = moodle.enrol_students(loginObject.client, loginObject.sessionkey, "HCO2011W", studentArray, "id");

This is the error I see:

moodle_ws_c_sharp.jpg