hypothesis / lms

LTI app for integrating with learning management systems
BSD 2-Clause "Simplified" License
46 stars 14 forks source link

Spike: API integration with Moodle #6001

Closed marcospri closed 7 months ago

marcospri commented 8 months ago

To support features like groups, sections, files, pages we rely on an API integration to get access to data that's not exposed through LTI otherwise.

Authentication

The authentication method suggested there: https://docs.moodle.org/dev/Creating_a_web_service_client#How_to_get_a_user_token

involves fetching a token based on the user's username and password and call:

https://www.yourmoodle.com/login/token.php?username=USERNAME&password=PASSWORD&service=SERVICESHORTNAME

that would involved our own password prompt for the moodle password which seems ill advised from our point.

As an alternative we could use a token created for an user with enough privileges for our use case (ie access to all courses etc): https://docs.moodle.org/403/en/Using_web_services#Create_a_token

I've seen at least one other product that "recomends" this approach https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_article=KB0061973

My suggestion would be to use this token approach while checking with Moodle if there's any plans to support more traditional oauth2 approaches, see:

https://tracker.moodle.org/browse/MDL-61383 https://tracker.moodle.org/browse/MDL-76831

The token approach is simple enough so implementing it as a first approach doesn't add a big maintenance burden.

Groups integration

As part of PoC to test the API integration I used groups as the first example.

While Moodle has groups and group sets (called groupings in Moodle) that map 1 to 1 to other LMSes it allows groups that don't belong to any of the group sets, ie they belong directly to the course.

This adds extra complexity compared to other implementations.

marcospri commented 7 months ago

Previous attempts at this:

marcospri commented 7 months ago

List of available LTI variables:

https://github.com/moodle/moodle/blob/main/mod/lti/locallib.php#L3851