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

Filter courses by assignment IDs #6435

Merged
merged 2 commits into from
Jul 9, 2024
Merged

Filter courses by assignment IDs #6435

merged 2 commits into from
Jul 9, 2024

Conversation

marcospri
Copy link
Member

@marcospri marcospri commented Jul 9, 2024

@marcospri marcospri changed the title Course assignment filter Filter courses by assignment IDs Jul 9, 2024
@marcospri marcospri force-pushed the course-assignment-filter branch from c4fac34 to 7e73977 Compare July 9, 2024 07:46
Copy link
Member

@robertknight robertknight left a 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.

lms/services/course.py Outdated Show resolved Hide resolved
) -> 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.
Copy link
Member

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?

Copy link
Member Author

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,
)
)
Copy link
Member

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?

Copy link
Member Author

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.
Copy link
Member

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?

Copy link
Member Author

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())
Copy link
Member

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())
Copy link
Member

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]).

Copy link
Member Author

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:
Copy link
Member

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.

Copy link
Member Author

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.

lms/views/dashboard/api/course.py Outdated Show resolved Hide resolved
@marcospri marcospri force-pushed the course-assignment-filter branch from ef0269c to b2d0324 Compare July 9, 2024 12:05
@marcospri marcospri merged commit 1ac289f into main Jul 9, 2024
9 checks passed
@marcospri marcospri deleted the course-assignment-filter branch July 9, 2024 12:19
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