Q. about edit_course and assigning a role within a course ?

Q. about edit_course and assigning a role within a course ?

by Catalin Maican -
Number of replies: 4
Hello,

I have several questions about Patrick's version (http://cipcnet.insa-lyon.fr/Members/ppollet/public/moodlews) of web services:
1. in the "edit_course" method I have seen that one may specify various parameters for creating a course. How can I set the teachers ? Using the "teacher" and "teachers" properties - do I set here the users that should be teachers ? If so, how can I specify the type/role of the teacher (creator, teacher, non-editing teacher) ? Or maybe, a "set_teacher"/assign method would do the trick ?

2. how can a role be specified/assigned for a user ?

3. how can I create a "group" and add users in it ?

Thanks,
Catalin
Average of ratings: -
In reply to Catalin Maican

Re: Q. about edit_course and assigning a role within a course ?

by Patrick Pollet -
Hello,

I am glad you still use my version . Hope it behave well in your place wink

Question 1: No The "teacher"/"teachers" properties are simple strings that were used by Moodle to display the "proper" definition of a teacher in various places. It could be "animator", "coordinator" or whatever. The same goes for "student"/"students" that could be "attendant","member" ... and were set in course parameters. This is a "left-over" of Moodle pre-1.7 since I did not find these settings in Moodle 1.7 . (I still have not migrated to 1.8).

Question 2: The only thing you can currently do is "enrol_students" that should assign the "legacy" student's role to a list of users. Other roles are not supported.


Question 3: not yet supported in rev 1.5.9.


As you can see in the "list of supported operations", my purpose in that Web Service was to focus in get_xxx operations to be able to export Moodle's entities in my other SIS (Zope/Plone , Drupal and French eSup portal).

It was my expectation that others (more familiar with Moodle roles ) will take over and add the needed set_xxx operations, and also make sure the Web Service still behave as expected in Moodle 1.8 and 1.9 ...

Unfortunately Martin D. never answered to my request to have a CVS access to the branch contrib/patches/ws (see http://moodle.org/mod/forum/post.php?reply=329947)
so that others could take over and improve my code. So I am still the only one developer and my motivation is down to nearly zero since it fits my current needs and I do not have time to add features I do not yet need and cannot fully test due to the too high speed of Moodle's new releases.

Actually I am afraid that my implementation using SOAP is a dead-end due to the apperance of XML-RPC in Moodle 1.8 that is "the official way of doing it" .
See http://kb.ucla.edu/articles/how-does-moodle-implement-web-services


In reply to Patrick Pollet

Re: Q. about edit_course and assigning a role within a course ?

by Catalin Maican -
Hello Patrick,

Thank you for answering. What is the complexity of adding a "set_role" for a specific course? I suppose that Moodle exposes some functions for this...

Would it be better to implement it using direct sql in the methods that I need ?

I'm interested only in setting a role for a user in a course and adding/editing a group and group users.

I didn't work with XML-RPC before and I'll look on the Internet for some .NET libraries. Is in the current release of Moodle the "WHOLE" API exposed, as said in the link you gave me?

Thanks,
Catalin
In reply to Catalin Maican

Re: Q. about edit_course and assigning a role within a course ?

by Patrick Pollet -
>Would it be better to implement it using direct sql in the methods that I need ?


Oh no, Moodle's API does have the proper functions to do that. A good place to look is the directory enrol/flatfile/ in your Moodle's implementation. the question is : Is it worth the effort since Moodle DO have a very nice "enrolment by flat file" feature that can be activated in the cron and is supported in any version :
See http://yourmoodle/moodle/admin/enrol_config.php?enrol=flatfile

and the doc at http://docs.moodle.org/fr/enrol/flatfile


We do use it here quite a lot. You just have to put the proper enrolments.txt file in moodledata/1 and wait for 30 minutes. You will get a mail with the status of the enrolment wink)


The same goes for creating a group in a course and adding users to it. API does have all needed calls. (ismember($gid,$uid), add_user_to_group($gid,$uid)...
Problem is that groups seem to change in every version . They now are talking about "groups grouping" (?) and global groups ... I just can't follow unless I keep up with the latest Moodle, something I cannot afford to do.

A good place to search it the phpxref output of current Moodle's code at http://xref.moodle.org
(see the directory group at the top level).

As far as XML-RPC is concerned, I have no experience on it. I guess that the whole Moodle API will be exposed in a very near future, thus making my efforts obsolete ...

Cheers
In reply to Patrick Pollet

Re: Q. about edit_course and assigning a role within a course ?

by Catalin Maican -
Thank you for letting me know about the flatfile...I hope it will be enough. Also, I've seen that there are other options for enrolling our students..

Regarding the add_role method I'll give you a message here with it when/if it will be done.

Thanks again,
Catalin