Open jbpenrath opened 3 months ago
We will need to add these functions to the created joanie webservice https://github.com/openfun/joanie/blob/main/docs/moodle.md#create-a-joanie-webservice
And add something like this in src/backend/joanie/lms_handler/backends/moodle.py
class MoodleLMSBackend(BaseLMSBackend):
[…]
def create_course(self, course):
"""Create a course."""
course_data = {
"fullname": course.title,
"shortname": course.code,
"categoryid": course.category_id,
"summary": course.description,
"format": "topics",
"showgrades": 1,
"lang": "en",
"numsections": 1,
"startdate": course.start_date,
"enddate": course.end_date,
}
try:
return self.moodle("core_course_create_courses", courses=[course_data])[0]
except (MoodleException, NetworkMoodleException, EmptyResponseException) as e:
logger.error("Moodle error while creating course %s: %s", course.title, e)
raise MoodleUserCreateException() from e
Feature Request
Is your feature request related to a problem or unsupported use case? Please describe. Like we did with OpenEdX, it would be nice to be able to automatically synchronize Moodle course runs on Joanie when one is created/updated.
First of all, we have to check about the feasability of this feature. Does Moodle has a webhook triggering system when course run is created/updated ?
Discovery, Documentation, Adoption, Migration Strategy https://github.com/openfun/joanie/blob/576d20c9e4193c79ca0a56322e46de8520dcdf6a/src/backend/joanie/core/utils/webhooks.py#L31 https://github.com/openfun/fun-apps/blob/5db13c900f4c41b17c99744957b8f4d96fa359e5/courses/tasks.py#L20