-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add XApiBaseEnrollmentFilter #108
Conversation
NATIONAL_ID_REGEX = r"^[1-2]\d{9}$" | ||
COURSE_ID_REGEX = r'(course-v1:[^/+]+(/|\+)[^/+]+(/|\+)[^/?]+)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where was extracted this Regex?
It seems a little different than
https://github.com/openedx/edx-platform/blob/master/openedx/core/constants.py#L12
>>> from django.conf import settings
>>> settings.COURSE_KEY_REGEX
'(?:[^/+]+(/|\\+)[^/+]+(/|\\+)[^/?]+)'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from that place the modification is the course-v1:
eox_nelp/utils.py
Outdated
Course | ||
""" | ||
course_key = CourseKey.from_string(course_id) | ||
course_overviews = CourseOverview.get_from_ids([course_key]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why if the methods is called get_course_from_id
(from one id), you use a method for multiple ids instead of the method for one??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is a copy of this which implements this line course_overviews = get_course_overviews([course_key])
however I made a mistake and I copied the logic from the method get_course_overviews_from_ids instead of the get_course_overviews method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is a copy of this which implements this line course_overviews = get_course_overviews([course_key])
however I made a mistake and I copied the logic from the method get_course_overviews_from_ids instead of the get_course_overviews method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied the logic because we already have the CourseOverview model and was easier however the other logic requires a backend, so it will be easier to implement new api backend
if course_overviews: | ||
return course_overviews[0] | ||
|
||
raise ValueError(f"Course with id {course_id} does not exist.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you prefer the raise of an exception instead a None
return as the CourseOverview do ?
https://github.com/openedx/edx-platform/blob/master/openedx/core/djangoapps/content/course_overviews/models.py#L415
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy of this
course_overviews = CourseOverview.get_from_ids([course_key]) | ||
|
||
if course_overviews: | ||
return course_overviews[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok yes is very weird but that method return like a dict of course_overviews:
https://github.com/openedx/edx-platform/blob/master/openedx/core/djangoapps/content/course_overviews/models.py#L438
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to implement the right method
@johanv26 I have already applied some changes and tested that by making an enrollment in the about page, could please you try again :D |
83b1d4e
to
8cf8feb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested again and passed last error, with course_overviews using a list of ordered_dict. But after passing that I had an error with course_language
being None
course_language = course['language'] | ||
|
||
# Create new attributes based on the course properties | ||
definition_name = LanguageMap(**({course_language: display_name} if display_name is not None else {})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johanv26 How did you set the course language to None since that option is not available on studio ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Is working after some changes.
feat: use default language when the course doesn't have that value
Still I wonder how did you set to None the language, I couldn't do that I just considered that case, how did you create that course ? |
This filter allows to implement the required object structure by the NELC team https://edunext.atlassian.net/browse/FUTUREX-251
dacc260
to
5247237
Compare
@andrey-canon I was reseaching a little and I found that seems this backend use the mysql course_overview as source. From studio is possible to set with Here I also share you how in my local env I set arabic language, then using modulestore, yes my course language is |
Description
This filter allows to implement the required object structure by the NELC team https://edunext.atlassian.net/browse/FUTUREX-251
Testing instructions
Before
After
Additional information
Include anything else that will help reviewers and consumers understand the change.
Checklist for Merge