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

Add support for Moodle Course Completion Webhooks #4

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ATechAdventurer
Copy link
Member

No description provided.

@ATechAdventurer ATechAdventurer changed the title Support/moodle Add support for Moodle Course Completion Webhooks Sep 16, 2023
@ATechAdventurer
Copy link
Member Author

The only thing that remains is a way to easily define course_id => group_id.

I don't think the source of truth for this map should be stored here and maybe inside Moodle itself

moodle/moodle.go Outdated Show resolved Hide resolved
moodle/moodle.go Outdated Show resolved Hide resolved
moodle/moodle.go Outdated Show resolved Hide resolved
moodle/moodle.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
log.Printf("user %s completed moodle course %s", user.Email, body.CourseID)
}

err = kc.AddUserToGroup(r.Context(), user.ID, "6e413212-c1d8-4bc9-abb3-51944ca35327")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider exposing the group ID as an env var in case it ever changes

@@ -100,6 +100,40 @@ func (k *Keycloak) GetUser(ctx context.Context, userID string) (*User, error) {
}

user := &User{
ID: gocloak.PString(kcuser.ID),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary in this PR, but it would be nice to move the gocloak.User -> User conversion logic into a helper function to avoid duplication.

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

Successfully merging this pull request may close these issues.

2 participants