Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moodle LMS Backend - Course run synchronization #732

Open
jbpenrath opened this issue Apr 4, 2024 · 2 comments
Open

Moodle LMS Backend - Course run synchronization #732

jbpenrath opened this issue Apr 4, 2024 · 2 comments
Labels

Comments

@jbpenrath
Copy link
Member

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

def synchronize_course_runs(serialized_course_runs):

https://github.com/openfun/fun-apps/blob/5db13c900f4c41b17c99744957b8f4d96fa359e5/courses/tasks.py#L20

@kernicPanel
Copy link
Member

@kernicPanel
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants