-
Notifications
You must be signed in to change notification settings - Fork 0
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 learners enrolment list api #143
Conversation
9188f07
to
e771ef7
Compare
e771ef7
to
e35c17a
Compare
e35c17a
to
ba6f8c8
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.
great work @tehreem-sadat !
please address my comment about str
then it's good to go 👍🏼
def get_date_joined(self, obj: get_user_model) -> str: | ||
"""Return user ID.""" | ||
return str(self._get_user(obj).date_joined) # type: ignore | ||
|
||
def get_last_login(self, obj: get_user_model) -> str: | ||
"""Return user ID.""" | ||
return str(self._get_user(obj).last_login) # type: ignore |
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.
don't trust str
when converting date and time. At least it is not timezone-aware
def get_date_joined(self, obj: get_user_model) -> str: | |
"""Return user ID.""" | |
return str(self._get_user(obj).date_joined) # type: ignore | |
def get_last_login(self, obj: get_user_model) -> str: | |
"""Return user ID.""" | |
return str(self._get_user(obj).last_login) # type: ignore | |
def get_date_joined(self, obj: Any) -> str: | |
date_joined = self._get_user(obj).date_joined | |
return date_joined.isoformat() if date_joined else None | |
def get_last_login(self, obj: Any) -> str: | |
last_login = self._get_user(obj).last_login | |
return last_login.isoformat() if last_login else None |
@@ -340,12 +347,91 @@ def _extract_exam_scores(representation_item: dict[str, Any]) -> None: | |||
representation_item[possible_key] = score[1] if score else 'no attempt' | |||
|
|||
representation = super().to_representation(instance) | |||
|
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.
please recover the deleted empty line, here and everywhere unless you intentionally want to delete it
For this one, it is more readable to have the empty lines separating the logic
ba6f8c8
to
8c13c84
Compare
8c13c84
to
7f4ab83
Compare
Add enrollment api.
Example usage:
To get all enrolments:
/api/fx/learners/v1/enrollments/
To get all enrolments - with complete details
/api/fx/learners/v1/enrollments/?optional_field_tags=__all__
To get all enrolments - for certain courses -> Send ',' separated list of course ids:
/api/fx/learners/v1/enrollments/?course_ids=course_id1, course_id2
To get all enrolments - for certain users -> Send ',' separated list of user ids:
/api/fx/learners/v1/enrollments/?user_ids=1,2
To get all enrolments - for specific user and course -> Send ',' separated list of user ids and course_ids:
/api/fx/learners/v1/enrollments/?user_ids=1,2&course_ids=course_id1
Note:
500 error will be raised for invalid course_ids.