Attendance API

Attendance API

by viktor skoko -
Number of replies: 9

Hi Moodle community, I am relatively new to `Moodle` LMS so I might be just unaware of items that I need for my integration, but after doing lots of reading, I still couldn't find what I am looking for. My team and I work on a clients' Moodle - SIS implementation and here is our situation:

1) We don't have access to clients' Moodle server (account) - so we are not hosting it, we can't see the DB and currently we can not get access to it.
2) We solely use API Web Service to communicate to clients' Moodle server using authorization token in their Moodle Instance, and so far we have built multiple functionalities regarding this integration such is getting and pushing students, getting and pushing courses, getting and creating enrollments, getting rolles etc. More than 15 functionalities.
3) In the stock API Documentation, we can not find any `function` regarding pulling students' attendance in the way we need it - to get the data from the `Attendance` plugin they assign to each course and populate with Present, Absent etc.

Does anyone know what is the route we need to take?

Average of ratings: -
In reply to viktor skoko

Re: Attendance API

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
In reply to Marcus Green

Re: Attendance API

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
heh... please don't contact the attendance developer "privately" unless you are willing to pay for his time to provide you with help.... he (and the company he works for) gives away a lot of code for free, gives away a lot of his time to help in the community, but if you want private help/support that's something that you will need to pay for...

The best place to ask for free help is here in the forums - bad Marcus wink

It sounds like you really need to set up your own Moodle installation locally to help you test and view the documentation - Moodle provides built-in documentation for it's webservices, but you need to install the plugins you are using (like attendance) and you need to have admin access to the install so you can see the documentation under admin> Plugins > Web services > API documentation.
In reply to Dan Marsden

Re: Attendance API

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
"The best place to ask for free help is here in the forums - bad Marcus"
Absolutely correct, I was thinking of commercial support. Direct support is very time consuming, and if you ask in a forum other people may benefit, and other people may help flesh out the answer.

I had not noticed the post was in a forum dedicated to attendance. Most plugins don't have their own forum, which shows what a significant plugin it is.
In reply to Dan Marsden

Re: Attendance API

by viktor skoko -
Thanks for the reply Dan,
I didn't mention, on the initial post, that we DO have access and admin rights to our client's Moodle instance. What I meant by #1 bullet above is that we do not have access to the DB.
Are there any steps that we can take, that will give us more info on the `Attendance` module?
In reply to viktor skoko

Re: Attendance API

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
make sure they are using a supported version of Moodle, and have the latest version of the attendance plugin for that version - then the built-in webservices documentation should show all the webservices specific to attendance that are available. you can also see a partial (less easy to read) list of these in this file:
https://github.com/danmarsden/moodle-mod_attendance/blob/MOODLE_311_STABLE/db/services.php

Note that these expect you will use other core webservices for getting information about the course, users etc.
In reply to Dan Marsden

Re: Attendance API

by viktor skoko -
Web Services you've mentioned are already available for us. However, these services do not provide data we are trying to obtain. None of those will return attendance data for, lets say a course, or a an enrollment, or a user, or a category. None of them describes that it returns any attendance data for that matter. So, I am a bit confused how attendance data is supposed to be accessed in the first place.
If we can not find relevant "stock" Web Service, can this be resolved by adding some sort of a plugin or a report that would be designed for our needs either by our client's Moodle host or by us? Also, the thing that Marcus mentioned above , "ad-hoc" queries, could we use them, and if yes, what is the way for us to get to that functionality? Are there any documentation files regarding?
In reply to viktor skoko

Re: Attendance API

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
yeah - you'll need to call multiple web services.
first you need to know "which" attendance you want information about first so you'd use something like the core get_course_contents webservice
to get information about the attendance instances inside that course,

then once you have that information you can call the attendance get_sessions() web service to get information about all the sessions within that course/attendance.

then once you have the sessions you can use that information to call update_user_status directly or get_session to get more information about a specific attendance including who has attended that session.

Good luck!
Average of ratings: Useful (1)
In reply to viktor skoko

Re: Attendance API

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
" we are aiming to offer an easier initial experience by turning a number of advanced features off by default"
I suggested that just so you can see what is in the datatable in order to write code to access that data. As Dan says you would need to make multiple calls for your specific requirements. Although you could write your own custom services Ito do multiple things I suggest using what exists as it has already been written, tested and debugged.

I do almost nothing but moodle dev and find the best documentation to be reading code, its fairly guaranteed to be up to date.