Quantcast
Channel: Web services
Viewing all 2361 articles
Browse latest View live

Django with Moodle

$
0
0
by Robert Pringle.  

Hello,


For our university project we've been assigned to work with the uni Moodle database. We need to be able to access the Moodle database and retrieve information from it and update our Django database with this information for the project to be a success. Basically every-time a student submits an assignment on Moodle I need to update their Django database file by giving them a 'point'. Django is a web application framework. Is there any APIs that exist and are a good starting point to go from an if not how would I go about developing this into a working product?


Problem getting course enrolment methods

$
0
0
by Pete Edwards.  

I want to get a list of enrolment methods for a course that I know has manual enrolments and 2 cohorts synced.

I have tried core_enrol_get_course_enrolment_methods but cannot get this to return anything but an empty array []. I saw a post related to this from 2016 but no resolution - I can't imagine it has been a problem since then.

I also tried using core_course_get_courses_by_field - this was slightly more successful as it at least lists the enrolment plugin types:

      "enrollmentmethods": [
        "manual",
        "cohort",
        "cohort"
      ],

It is helpful to know there are cohort syncs in place but its not much use without knowing what they are. 

It is also interesting to note that the discrepancy between the British spelling of enrolment in the call and the American spelling 'enrollment' in the result!

Any advice would be appreciated. I'm happy to raise a bug if I am not missing something.

Where can I find documentation for the right parameters???

$
0
0
by barak dopama.  

So I found this list of webservice api calls: https://docs.moodle.org/dev/Web_service_API_functions

Unfortunately I cannot use most of it's functions because many of them require additional arguments, Without them I always get an invalidparameter error response. But I can't find any documentation on which parameters are required. So If you know a link to a detailed documentation of every function please tell me. Especially core_calendar_get_calendar_monthly_view and core_calendar_get_calendar_events are important for me but a list of everything would be even better. 

Re: Where can I find documentation for the right parameters???

$
0
0
by Karen Holland.  

As this Moodle WS API user guide link explains, WS APIs differ according to the exact version of Moodle your site is using, hence you need to use the internal site's own WS API documentation page as best practice.

Go to Site Administration -> Plugins -> Web Services -> API Documentation

Search for the function you need, ie core_calendar_get_calendar_monthly_view, and expand its section to view all the technical details, such as arguments accepted, responses, error messages and capability restrictions.

You can find a WS API example on the Moodle Demo Sandbox 3.8 site here and you need to log in as admin of course!


Re: Where can I find documentation for the right parameters???

$
0
0
by barak dopama.  

Thank you Miss Holland. The sandbox helped me a lot. smile

[3.7.1]Webservice core_user_get_users does not return 'Email'

$
0
0
by Richard van Iwaarden.  

We are currently experiencing that webservice core_user_get_users not returns the Email address from the user.

I have checked the permissions for the webservice-user and it has permissions to see full user details.

We should get this:

General structure

object {
users list of ( 
object {
id int   //ID of the userusername string  Optional//The usernamefirstname string  Optional//The first name(s) of the userlastname string  Optional//The family name of the userfullname string   //The fullname of the useremail string  Optional//An email address - allow email as root@localhostaddress string  Optional//Postal addressphone1 string  Optional//Phone 1phone2 string  Optional//Phone 2icq string  Optional//icq numberskype string  Optional//skype idyahoo string  Optional//yahoo idaim string  Optional//aim idmsn string  Optional//msn numberdepartment string  Optional//departmentinstitution string  Optional//institutionidnumber string  Optional//An arbitrary ID code number perhaps from the institutioninterests string  Optional//user interests (separated by commas)firstaccess int  Optional//first access to the site (0 if never)lastaccess int  Optional//last access to the site (0 if never)auth string  Optional//Auth plugins include manual, ldap, etcsuspended int  Optional//Suspend user account, either false to enable user login or true to disable itconfirmed int  Optional//Active user: 1 if confirmed, 0 otherwiselang string  Optional//Language code such as "en", must exist on servercalendartype string  Optional//Calendar type such as "gregorian", must exist on servertheme string  Optional//Theme name such as "standard", must exist on servertimezone string  Optional//Timezone code such as Australia/Perth, or 99 for defaultmailformat int  Optional//Mail format code is 0 for plain text, 1 for HTML etcdescription string  Optional//User profile descriptiondescriptionformat int  Optional//int format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)city string  Optional//Home city of the userurl string  Optional//URL of the usercountry string  Optional//Home country code of the user, such as AU or CZprofileimageurlsmall string   //User image profile URL - small versionprofileimageurl string   //User image profile URL - big versioncustomfieldsOptional//User custom fields (also known as user profile fields)
list of ( 
object {
type string   //The type of the custom field - text field, checkbox...value string   //The value of the custom fieldname string   //The name of the custom fieldshortname string   //The shortname of the custom field - to be able to build the field class in the code
} 
)preferencesOptional//Users preferences
list of ( 
object {
name string   //The name of the preferencesvalue string   //The value of the preference
} 
)} 
)warningsOptional//list of warnings
list of ( 
  //warning
object {
item string  Optional//always set to 'key'itemid int  Optional//faulty key namewarningcode string   //the warning code can be used by the client app to implement specific behaviourmessage string   //untranslated english message to explain the warning
} 
)} 
But what we are getting is this:

{
    "users": [
        {
            "id": 4708,
            "username": "xxxxxx@xxx.com",
            "firstname": "Firstname",
            "lastname": "Lastname",
            "fullname": "Firstname Lastname",
            "department": "Informatie Processen en Systemen",
            "idnumber": "546735674367",
            "firstaccess": 1519653876,
            "lastaccess": 1579690555,
            "auth": "saml2",
            "suspended": false,
            "confirmed": true,
            "lang": "en",
            "theme": "",
            "timezone": "99",
            "mailformat": 1,
            "description": "",
            "descriptionformat": 1,
            "profileimageurlsmall": "xxxxxxxx/user/icon/fordson/f2?rev=1940784",
            "profileimageurl": "xxxxxxxxxxxxxxx/user/icon/fordson/f1?rev=1940784"
        }
    ],
    "warnings": []
}

Email address seems to be missing? 

And yes, this user has an Email address in his profile.... which is the same as the login (maybe that's the problem?)

Re: [3.7.1]Webservice core_user_get_users does not return 'Email'

$
0
0
by Andreas Grabs.  

Hi Richard,

the webservice needs the capability "moodle/user:viewhiddendetails" in addition to the documented capabilities.

Best regards
Andreas

Re: [3.7.1]Webservice core_user_get_users does not return 'Email'

$
0
0
by Richard van Iwaarden.  

The user that we are using has system admin rights. I just checked and it has the moodle/user:viewhiddendetails capabilities.

Could it has something to do with roles? Would it be so that you can not get the Email address from an admin account?


Re: [3.7.1]Webservice core_user_get_users does not return 'Email'

$
0
0
by Andreas Grabs.  

Hi Richard,

I dived a little deeper and found that this function is a little weird.

If you have your capabilities system wide like an admin, which it is in your case, then you won't get the email address at all.
If you have less rights like a trainer you might get the email address depending on your capabilities in the course the user you ask for is enrolled in. Maybe I am wrong in my interpretation wink.

So my recommendation is: Use another function like "core_user_get_users_by_field" which is, in my point of view, much more convenient. We use this function in some projects without such problem.

Best regards
Andreas

Re: [3.7.1]Webservice core_user_get_users does not return 'Email'

$
0
0
by Richard van Iwaarden.  

Thanks Andreas, this will help us a lot.

Should we report this as a bug? Can you explain al little better what's wrong with the code, as I'm not a programmer...


Re: Get enrolment timestart / timeend via WebService

$
0
0
by Mayank Tyagi.  

Hi Lukas,

No there are no inbuilt webservice for manual enrolment. You need to make your own webservice for this. But moodle have inbuilt core function "enrol_get_enrolment_end" which return enrolment end time. If you want you can use this function according to your need.

Warm Regards,
Mayank

Re: How me add student to certain course using REST API?

$
0
0
by Mayank Tyagi.  

Hi,

You can use "enrol_manual_enrol_users" to enrol user in a certain course via manual enrolment method.

Re: How to get courses in a category and any subcategories with courses

$
0
0
by Mayank Tyagi.  

No there is no inbuilt webservice that return such information. You need to make your custom webservice for this.

Re: [3.7.1]Webservice core_user_get_users does not return 'Email'

$
0
0
by Richard van Iwaarden.  

Hi Andreas,

The webservice core_user_get_users_by_field has exactly the same problems.

We can see a difference when we use manual accounts or SAML2 accounts. SAML2 accounts never seem to work, the mail address is not being returned at all.


Re: [3.7.1]Webservice core_user_get_users does not return 'Email'

$
0
0
by Richard van Iwaarden.  

Found it out!


This web service respects the 'maildisplay' settings from users. If set to '2' (allow only course members to see my Email) it will never be returned by the web service.

In my opinion is this very bad BTW. The setting should not be respected, it is not possible now to administrate accounts using a web service. For example: users that change their mail address, we can not update them with web services.

Should I report this as a bug?

Re: [3.7.1]Webservice core_user_get_users does not return 'Email'

Re: [3.7.1]Webservice core_user_get_users does not return 'Email'

$
0
0
by Andreas Grabs.  

Hi Richard,

yes, you are right. Both function use the same function "user_get_user_details_courses" to get the user details.

Sorry, for that.

Best regards
Andreas

Re: [3.7.1]Webservice core_user_get_users does not return 'Email'

$
0
0
by Andreas Grabs.  

Hi Richard,

thank you! That must be the reason we never had a problem with that.

Best regards
Andreas

Re: mailformat and maildisplay

$
0
0
by Mayank Tyagi.  

Hi Dallas,

According to my understanding from your post, these parameter are part of "email_to_user" function for sending email.
mailformat = 1/0 ( 0 (zero) text-only emails, 1 (one) for HTML/Text emails. )
maildisplay = true/false (Display email)

Svar: Re: How to get courses in a category and any subcategories with courses

$
0
0
by KS Læring.  

Thank you, Mayank!

When doing https://domain/webservice/rest/server.php?wstoken=&wsfunction=core_course_get_categories&criteria[0][key]=parent&criteria[0][value]=&moodlewsrestformat=json there seems to be key called "path" with an interesting value containing the category tree.

However, I am not sure if the current API allows querying on the "path" key?
Viewing all 2361 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>