modlib.php - creating an API

modlib.php - creating an API

Jock Coats -
回帖数:2

Hello all,

Quick question on feasibility first. Not ready to code or ask too deep questions.

I want to write a local plugin that takes information from our student records system and assigns availability criteria json strings to a particular set of modules.

Am I allowed/able to create an externallib.php that calls a function like update_moduleinfo() in the course/modlib.php and, if I do/can can the moduleinfo variable I need to send it only contain the availability json string or do I need to populate it first with all the information about the module just to change one piece?

Cheers,

Jock

回复Jock Coats

Re: modlib.php - creating an API

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
You can do whatever you like when exposing web services in a local plugin. BUT... externallib.php is now old school.

Have you read...

https://moodledev.io/docs/4.4/apis/subsystems/availability

https://moodledev.io/docs/4.5/apis/subsystems/external/writing-a-service
回复Howard Miller

Re: modlib.php - creating an API

Jock Coats -
I suspect it might not turn out to be a webservice in the end. I have a feeling we'll want to create a local plugin and tables to store the SRS's list of "gradable components" (i.e. the assessment diet for each course) and hen use that table to make sure nobody messes with the availability conditions on the assessment activities. The Availability API looks useful. Alas we've taken the view that we are going to upgrade from one LTS release to the next rather than all the ones in between, so our next major upgrade is going to be next summer to 4.5, but, this bit of our project is a priority level 1 for our full rollout in September 2025 so we may as well wait till we're ready to play with 4.5 before and have it in place when we switch to 4.5

Thanks,
Jock