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

How can we call course custom fields?


Get a user created by core_user_create_users using core_user_get_users

$
0
0
by Vincent LEPELLEY.  

Hello,

I'm trying to do a script PHP using MoodleRest (https://github.com/llagerlof/MoodleRest) to create a user (if it doesn't exist), i can find users created manually (probably because they are using the website..., when newly created accounts are not using it yet).

I use core_user_create_users if core_user_get_users or core_user_get_users_by_field returns no user, but if i run my script twice  : imagine a administrator who is confirming a course enrollment for a new user, the second time the user is created already and core_user_get_users needs to return the user id, but because the user didn't connect in the time between (i think), core_user_get_users return nothing.

Is this intended ?

My ultimate goal is to get the user id to use enrol_manual_enrol_users.

Get token when using external login provider

$
0
0
by Nils Kattenbeck.  

I am trying to get a API token but cannot use a normal username and password as we use an external login provider (shibboleth). Is there an alternative way to generate a token? I know it is possible because the desktop app correctly redirects to the login provider though I am not really keen on studying its source code...

Re: Get roles Webservice API

$
0
0
by Declan Lawton.  

Hi,

According to me, you must reach out to some known web developers for a perfect solution to your web service query. Recently I get in touch with one of the development experts from India and they help me swiftly through a couple of my projects. It is always better to have someone who has a better knowledge of the queries you are facing. You can reach out to them at https://www.moweb.com/

DM me if you are looking for any details.

Thank you,

Declan Lawton.


Moodle Web services - Secure ???

$
0
0
by Nilesh Pathade.  

Hi all,

I am trying to integration my external application which is developed into Java and Angular technology with Moodle.

Moodle has process to create web service token,  

Site adminstration => Plugins => Web Service => Manage token

Enabled all required setting for moodle web services.  Add new web service. 

My Question is that IF WEB SERVICE TOKEN LOST THEN ANYONE CAN ACCESS MY WEB SERVICES.

How to validated my token is coming from valid domain ??? 

OR 
How to call my external API to check valid request before calling any Moodle web service / API

Please correct me 

Thank you 


Getting the hashed password with API

$
0
0
by Alexandre DE RYCKE.  

Hi,

I'm using the API of moodle in an Android app. To make them able to log without internet, we do have a local BDD on the phone. Which have quite the same data as Moodle. 

So if a user try to connect to an account that isn't stored locally, we will take the data of the user via Moodle and save them. The issue here is to get the password via the API.

I tried to use the core_user_get_users_by_field function but there is no password in it.

Is there any solution to this?

Thanks for your help!

Unable to get submissions of group assignment

$
0
0
by Nils Kattenbeck.  

Some teachers of the university I work for would like to automate assignment grading (especially coding tasks). However when I call the "mod_assign_get_submissions" REST function on an assignment with groups submissions enabled no response contains a file url:

Compare:

...,
{
  "id": 226969,
  "userid": 133163,
  "attemptnumber": 0,
  "timecreated": 1587614003,
  "timemodified": 1587614003,
  "status": "submitted",
  "groupid": 0,
  "plugins": [
    {
      "type": "file",
      "name": "Dateiabgabe",
      "fileareas": [
        {
          "area": "submission_files",
          "files": []
        }
      ]
    },
    {
      "type": "comments",
      "name": "Submission comments"    }
  ],
  "gradingstatus": "notgraded"
},
...

to a response of an "ungrouped assignment":

...,
{
  "id": 1,
  "userid": 2,
  "attemptnumber": 0,
  "timecreated": 1587310028,
  "timemodified": 1587325597,
  "status": "submitted",
  "groupid": 0,
  "plugins": [
    {
      "type": "file",
      "name": "File submissions",
      "fileareas": [
        {
          "area": "submission_files",
          "files": [
            {
              "filename": "code.zip",
              "filepath": "/",
              "filesize": 1019,
              "fileurl": "https://127.0.0.1/webservice/pluginfile.php/27/assignsubmission_file/submission_files/1/code.zip",
              "timemodified": 1587325596,
              "mimetype": "application/zip",
              "isexternalfile": false
            }
          ]
        }
      ]
    },
    {
      "type": "comments",
      "name": "Submission comments"
    }
  ],
  "gradingstatus": "notgraded"
},
...

Re: Get a user created by core_user_create_users using core_user_get_users

$
0
0
by Lawrence Lagerlof.  

Hi Vincent. MoodleRest dev here.

This class is just an easier way to query Moodle webservices. It runs synchronous, so if you call a core_user_create_users using this class you will get the same result of querying the webservice manually.

Well, without your code I can't check the problem, but we can review some important items to make your ultimate goal a reality.

- The core_user_create_users accepts a list of users, but if just one of them generates an error like a duplicated username or missing email, none is inserted and an error is returned by the webservice. If the function added all the users succefully a list of IDs is returned.

- core_user_get_users don't accept a list of usernames or emails, so you must query one by one.

Said that, I wrote an example for your specific scenario:

<?php // Load the MoodleRest class require_once('MoodleRest.php'); // Put your webservice url $webservervice_url = 'http://127.0.0.1/moodle/webservice/rest/server.php'; // Put a token that have permission to execute core_user_get_users and core_user_create_users $token = '07284be04dc3e8c48c0da131a8f8e40f'; // Instantiate a MoodleRest object $MoodleRest = new MoodleRest($webservervice_url, $token); // Query user $username = 'buddy'; $query_user['criteria'][0] = array('key' => 'username', 'value' => $username); $result_query = $MoodleRest->request('core_user_get_users', $query_user); // Test if an exception was returned when querying the user data if (!empty($result_query['exception'])) { print_r(array('Error querying user', $result_query)); die(); } // Check if the user was returned. If not, create him if (empty($result_query['users'][0]['id'])) { $people['users'][0] = array( 'username' => $username, 'password' => '123456', 'firstname' => 'Buddy', 'lastname' => "Revell ($username)", 'email' => $username . '@email.fake' ); $result_insert = $MoodleRest->request('core_user_create_users', $people, MoodleRest::METHOD_POST); // Test if an exception was returned when creating the user if (!empty($result_insert['exception'])) { print_r(array('Error creating user', $result_insert)); die(); } print_r(array('Created user', $result_insert)); } else { print_r(array('Returned user', $result_query)); }





Re: Django with Moodle

$
0
0
by Syed Ibrahim.  

I have created the web service but i donot know how to access it in django. Is there any solution? The packages available seem to be outdated.

Upload a file via webservice

$
0
0
by Azmat Ullah.  

Hi,

Is there any documentation that help us is to upload a file using Moodle webservice?

Thanks.

User enrolments with roles

$
0
0
by Mats Magnem.  

Hi

I am using the Moodle API to get the courses that a user is enrolled in. I use the wsfunction "core_enrol_get_users_courses" to do this. I am using a token that belongs to a "service/admin user" and not the actual user, using the "moodle_mobile_app" service. I don't have access to the database, only the Moodle API.

But by using core_enrol_get_users_courses, it seems like it will return all courses without any role definition or status. I would like to get only the courses that the user is f.ex "teacher" or "editingteacher". Or in another scenario, only the courses where the user is "student" or "guest".

Another thing I would like is to only get courses that are in progress. Aka not courses that are marked "hidden" or has an "enddate" back in time or "startdate" in the future.

Is that possible to get through the API without having customizations to the Moodle installation?

Displaying "plugin files" publicly

$
0
0
by Doug Henner.  

Dear All,

on our Moodle - site (Moodle 3.5, adaptable theme) I want to make some videos from Moodle visible for the public. For example we have a short uploaded video like e.g.  

moodledomain.com/pluginfile.php/1734/mod_glossary/entry/235/examplevideo.m4v 


that one I want to present for the not logged-in user on the front page.


So i created a web service "publicvideos".


... enabled "File upload" as well as "moodle/course:managefiles:" for that service.


... added Function "core_files_get_filesbrowse moodle files" for that service

... created a token. For trial purposes I chose an admin user with administer privileges 

    as service I chose "publicvideos"

    assume the token is "123456789"

... activated REST as well as XML-RPC protocol


So I changed the url above to


moodledomain.com/pluginfile.php/1734/mod_glossary/entry/235/examplevideo.m4v?token=123456789



I expected to download examplevideo.m4v by that link but still getting:


error"Access Control Exception"

errorcode"accessexception"

stacktracenull

debuginfonull

reproductionlinknull



As I said I want to display the video on that start page. Is that basically the right way ?

If yes can you tell what is wrong / missing ?


Thanks a lot !


Best,


Doug


Help with core_enrol_get_users_courses

Problem With Cache

$
0
0
by Petros Kara.  

I am developing locally (xampp) a web service inside a Moodle plug in. 

When i make a change in my code (ex. externallib.php), i must hit the button 'Purge All Cache' (and specifically the 'Language Strings' option) to see the new result.
Otherwise i see the old result.

My 'Cache all language strings' option is also set to 'NO'.

Also i have done everything inside this topic
https://docs.moodle.org/dev/Making_changes_show_up_during_development

Do you have a solution (quick or dirty ;P) to my problem? 

Thank you in advance!!!




How to Disable Email Notification to course participants send by teacher.

$
0
0
by Shahnawaz Khan.  

Dear All,

I am admin to my Moodle server. I just want disable email notification to participants of a course send by his/her tutor.  

Actually when students are offline then only they are getting emails as notification send by his/her tutor through course participant list. other wise they get notification in their web page when they are online.   

So, i just want disable students should not receive email notification when they are offline, when message send by his teacher by selecting the course participants.

Kind,Regards,

Shahnawaz khan  


Re: "No permission to create web service token for the service" with custom service

$
0
0
by Ricardo Caiado.  

Thanks, Brian!!

Save my day!!

Ricardo

User enrolments with roles

$
0
0
by Mats Magnem.  

Hi

I am using the Moodle API to get the courses that a user is enrolled in. I use the wsfunction "core_enrol_get_users_courses" to do this. I am using a token that belongs to a "service/admin user" and not the actual user, using the "moodle_mobile_app" service. I don't have access to the database, only the Moodle API.

But by using core_enrol_get_users_courses, it seems like it will return all courses without any role definition or status. I would like to get only the courses that the user is f.ex "teacher" or "editingteacher". Or in another scenario, only the courses where the user is "student" or "guest".

Another thing I would like is to only get courses that are in progress. Aka not courses that are marked "hidden" or has an "enddate" back in time or "startdate" in the future.

Is that possible to get through the API without having customizations to the Moodle installation?

How to get logged in userid ?

$
0
0
by Magal H.  

Hi, is there a way to get the id (or user info) of the currently logged in user using web services?

I have a subdomain that needs to check if a user is already logged in and display data. Could be also useful in order to display user info in the navbar.

Thanks for the help

Re: Help with core_enrol_get_users_courses

$
0
0
by Magal H.  

Just tested on our system and we get a successful result displayed. Maybe service disabled?

Launch a course using web services

$
0
0
by Sumeet kumar.  

Hello All,

I am very new to moodle, So please forgive me if i ask a stupid question. I searched for quite sometime before posting the  questions.

We are trying to create a new interface for Moodle using moodle web service. We were able to login, logout and get list of course assigned to a user using token. Now, we are trying to launch a particular course from our interface. But we are not finding in any method in web services using which we can launch the course from our interface.  We tried using player.php but it is asking us to login again as we are using token for login.

Any help in this regard would be great.

Thanks in advance

Rishi

Viewing all 2361 articles
Browse latest View live


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