API for Assignments

API for Assignments

by Manuel Alejandro Gómez Nicasio -
Number of replies: 2

Hello all,

I'd like to create some activities programmatically. In specific I'm looking to be able to create assignments and also file resources.

Development shouldn't be a problem, at the school I work for we have the technical skills and resources to do the required programming. We also have our own information system in which we already have some information we want to put on Moodle.

I'm looking for an API to create the assignments, something like

our-moodle-site.org/api/assignment

and via the HTTP POST method send all the required information

{
  'course_id':'42',
  'section':'2',
  'name':'Assignment Example',
  'description':'bla bla bla',
  'due_date':'2019-12-20 19:00:00',
  'cutoff_date': '2019-12-20 19:00:00',
  //etc.
}

Does Moodle have an API to create activities such as an assignment? If so, Can you point me out to the documentation? If this exist I only need to create the client, that will be really easy.

If such a feature doesn't exist, Can you point me out to some document, if any, about how to extend Moodle? If I have to do this I'll need to create the API endpoint and the client, harder but still doable.

Thankyou

Average of ratings: -
In reply to Manuel Alejandro Gómez Nicasio

Re: API for Assignments

by Benjamin Ellis -
Picture of Particularly helpful Moodlers

Hi,

No, there is no assignment API - the APIs available are at https://docs.moodle.org/dev/Core_APIs/ .  What you could possibly do is create a plugin that uses the web services API which uses the assignments functionality (possibly in lib.php or locallib.php) to do what you require.  Moodle is extendable via plugins functionality see https://docs.moodle.org/dev/Plugin_types for more.  

Have fun smile

In reply to Benjamin Ellis

Re: API for Assignments

by Manuel Alejandro Gómez Nicasio -

Hi,

I think I'll first start with the tutorial https://docs.moodle.org/dev/Tutorial to learn to create a basic plugin. Then I'll look into https://docs.moodle.org/dev/Web_service_API_functions for the specific function I need: to create an assignment.

A quick check didn't show anything. Is there a web service API for assignments or activities?

It will be fun for sure big grin