-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Introduce EnrollmentTrackUserPartition. #14682
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4896b20
Introduce EnrollmentTrackUserPartition.
9ff4560
REMOVE: Hacky UX code to enable togging enrollment groups.
04bf534
Add temporary hack until TNL-6731 is addressed.
c1e8d48
Change group to a method.
68d6efc
Change group to a method.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,7 +83,6 @@ def delete_course_and_groups(course_key, user_id): | |
| def get_lms_link_for_item(location, preview=False): | ||
| """ | ||
| Returns an LMS link to the course with a jump_to to the provided location. | ||
|
|
||
| :param location: the location to jump to | ||
| :param preview: True if the preview version of LMS should be returned. Default value is false. | ||
| """ | ||
|
|
@@ -296,32 +295,26 @@ def get_group_display_name(user_partitions, xblock_display_name): | |
| """ | ||
| for user_partition in user_partitions: | ||
| for group in user_partition['groups']: | ||
| if str(group['id']) in xblock_display_name: | ||
| # Temporary hack until TNL-6731 is addressed. | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to reviewers: this issue will be fixed before this PR merges. |
||
| if group['id'] > 99 and str(group['id']) in xblock_display_name: | ||
| return group['name'] | ||
|
|
||
|
|
||
| def get_user_partition_info(xblock, schemes=None, course=None): | ||
| """ | ||
| Retrieve user partition information for an XBlock for display in editors. | ||
|
|
||
| * If a partition has been disabled, it will be excluded from the results. | ||
|
|
||
| * If a group within a partition is referenced by the XBlock, but the group has been deleted, | ||
| the group will be marked as deleted in the results. | ||
|
|
||
| Arguments: | ||
| xblock (XBlock): The courseware component being edited. | ||
|
|
||
| Keyword Arguments: | ||
| schemes (iterable of str): If provided, filter partitions to include only | ||
| schemes with the provided names. | ||
|
|
||
| course (XBlock): The course descriptor. If provided, uses this to look up the user partitions | ||
| instead of loading the course. This is useful if we're calling this function multiple | ||
| times for the same course want to minimize queries to the modulestore. | ||
|
|
||
| Returns: list | ||
|
|
||
| Example Usage: | ||
| >>> get_user_partition_info(block, schemes=["cohort", "verification"]) | ||
| [ | ||
|
|
@@ -358,7 +351,6 @@ def get_user_partition_info(xblock, schemes=None, course=None): | |
| ] | ||
| } | ||
| ] | ||
|
|
||
| """ | ||
| course = course or modulestore().get_course(xblock.location.course_key) | ||
|
|
||
|
|
@@ -377,11 +369,11 @@ def get_user_partition_info(xblock, schemes=None, course=None): | |
|
|
||
| # Exclude disabled partitions, partitions with no groups defined | ||
| # Also filter by scheme name if there's a filter defined. | ||
| if p.active and p.groups and (schemes is None or p.scheme.name in schemes): | ||
| if p.active and p.groups() and (schemes is None or p.scheme.name in schemes): | ||
|
|
||
| # First, add groups defined by the partition | ||
| groups = [] | ||
| for g in p.groups: | ||
| for g in p.groups(): | ||
|
|
||
| # Falsey group access for a partition mean that all groups | ||
| # are selected. In the UI, though, we don't show the particular | ||
|
|
@@ -395,7 +387,7 @@ def get_user_partition_info(xblock, schemes=None, course=None): | |
| }) | ||
|
|
||
| # Next, add any groups set on the XBlock that have been deleted | ||
| all_groups = set(g.id for g in p.groups) | ||
| all_groups = set(g.id for g in p.groups()) | ||
| missing_group_ids = selected_groups - all_groups | ||
| for gid in missing_group_ids: | ||
| groups.append({ | ||
|
|
@@ -419,38 +411,39 @@ def get_user_partition_info(xblock, schemes=None, course=None): | |
| def get_visibility_partition_info(xblock): | ||
| """ | ||
| Retrieve user partition information for the component visibility editor. | ||
|
|
||
| This pre-processes partition information to simplify the template. | ||
|
|
||
| Arguments: | ||
| xblock (XBlock): The component being edited. | ||
|
|
||
| Returns: dict | ||
|
|
||
| """ | ||
| user_partitions = get_user_partition_info(xblock, schemes=["verification", "cohort"]) | ||
| user_partitions = get_user_partition_info(xblock, schemes=["verification", "enrollment_track", "cohort"]) | ||
| cohort_partitions = [] | ||
| enrollment_mode_partitions = [] | ||
| verification_partitions = [] | ||
| has_selected_groups = False | ||
| has_selected_content_groups = False | ||
| has_selected_enrollment_modes = False | ||
| selected_verified_partition_id = None | ||
|
|
||
| # Pre-process the partitions to make it easier to display the UI | ||
| for p in user_partitions: | ||
| has_selected = any(g["selected"] for g in p["groups"]) | ||
| has_selected_groups = has_selected_groups or has_selected | ||
|
|
||
| if p["scheme"] == "cohort": | ||
| cohort_partitions.append(p) | ||
| has_selected_content_groups = any(g["selected"] for g in p["groups"]) | ||
| elif p["scheme"] == "verification": | ||
| verification_partitions.append(p) | ||
| if has_selected: | ||
| selected_verified_partition_id = p["id"] | ||
| # if has_selected: | ||
| # selected_verified_partition_id = p["id"] | ||
| elif p["scheme"] == "enrollment_track": | ||
| enrollment_mode_partitions.append(p) | ||
| has_selected_enrollment_modes = any(g["selected"] for g in p["groups"]) | ||
|
|
||
| return { | ||
| "user_partitions": user_partitions, | ||
| "cohort_partitions": cohort_partitions, | ||
| "enrollment_mode_partitions": enrollment_mode_partitions, | ||
| "verification_partitions": verification_partitions, | ||
| "has_selected_groups": has_selected_groups, | ||
| "has_selected_content_groups": has_selected_content_groups, | ||
| "has_selected_enrollment_modes": has_selected_enrollment_modes, | ||
| "selected_verified_partition_id": selected_verified_partition_id, | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note to reviewers: exclude the enrollment_track partition.