-
Notifications
You must be signed in to change notification settings - Fork 14
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
Filter courses by assignment IDs #6435
Conversation
c4fac34
to
7e73977
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 had a few questions about aspects of the data model I haven't been following and some small suggestions. Otherwise this functions as expected.
) -> Select[tuple[Course]]: | ||
"""Get a list of unique courses. | ||
|
||
:param organization: organization the courses belong to. | ||
:param h_userid: only courses this user has access to. | ||
:param instructor_h_userid: return only courses where instructor_h_userid is an instructor. | ||
:param h_userids: return only courses where these users are members. |
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.
What does a user have to do to qualify as a member of a course? Be a student who has launched at least one assignment in the course?
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.
Yes, for now everything is based on "what we've seen" instead of querying LMS API for more data.
LTIRole.scope == RoleScope.COURSE, | ||
LTIRole.type == RoleType.INSTRUCTOR, | ||
) | ||
) |
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.
To check my understanding - we don't actually store a user's role per course, instead we store the role per assignment. This means that to find courses where the user is an instructor, we find all courses where the user was identified as an instructor in at least one assignment launch?
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.
Yes exactly.
Ideally we store that info at the GroupingMembership
level and not at the assignment level.
I don't want to tackle a big data migration & refactor & dashboard at the same time but we should move in that direction, store the data at the level it's more meaningful.
:param h_userid: only courses this user has access to. | ||
:param instructor_h_userid: return only courses where instructor_h_userid is an instructor. | ||
:param h_userids: return only courses where these users are members. | ||
:param assignment_ids: return only the courses these assignments belong to. |
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.
The Assignment.course
property has a note that an assignment can only belong to one course, but there can be multiple rows in the grouping
table representing the same course. In what circumstances does that happen and does that matter here - ie. if there are multiple rows representing the course, do we need to pick 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.
Courses are duplicated once per application instance, we take the last updated row but they represent the same entity in the LMS.
h_userids = fields.List(fields.Str()) | ||
"""Return metrics for these users only.""" | ||
|
||
assignment_ids = fields.List(fields.Integer()) |
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.
In the dashboard's user APIs we validate several ID fields are integers >= 1. It would be useful I think to have a common field definition that is used by query string parameters that expect integer IDs.
|
||
location = "querystring" | ||
|
||
h_userids = fields.List(fields.Str()) |
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.
Maybe worth adding validation on the format of the user IDs here (acct:[chars]@[authority_chars]
).
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.
Making a note about this one to apply to all the filters.
@@ -156,6 +165,34 @@ def get_courses( | |||
# Only select the ID of the deduplicated courses | |||
).with_entities(Course.id) | |||
|
|||
if instructor_h_userid: |
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.
We don't need to change anything now, but I note that I'm expecting we will be asked to make some subset of the dashboard functionality available for students in future.
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.
Yes, this could be changed to a filter that takes an arbitrary tuple of (h_userid, role_type, role_scope) to make it more flexible, at least at this level.
He have to sort teacher and admins out first so let's revisit this when we have a better understand on what data we'd show for students.
ef0269c
to
b2d0324
Compare
For:
Same as: #6430 but for courses.
Testing
http://localhost:8001/api/dashboard/organizations/local.lms.org.LDtcl7EUTeW2UERPJLAVtA/courses?assignment_ids=397