-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: Instructor Dashboard - Add Content Groups V2 JSON REST API #37849
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
Open
brianjbuck-wgu
wants to merge
2
commits into
openedx:master
Choose a base branch
from
WGU-Open-edX:feature/37848-instructor-dashboard-extra-content-groups
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+730
−11
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """ | ||
| Constants for course groups. | ||
| """ | ||
| from django.utils.translation import gettext_lazy as _ | ||
|
|
||
| COHORT_SCHEME = 'cohort' | ||
| RANDOM_SCHEME = 'random' | ||
| ENROLLMENT_SCHEME = 'enrollment_track' | ||
|
|
||
| CONTENT_GROUP_CONFIGURATION_NAME = _('Content Groups') | ||
| CONTENT_GROUP_CONFIGURATION_DESCRIPTION = _( | ||
| 'Use this group configuration to control access to content.' | ||
| ) |
Empty file.
172 changes: 172 additions & 0 deletions
172
openedx/core/djangoapps/course_groups/rest_api/docs/content-groups-api-v2-spec.yaml
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 |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| swagger: '2.0' | ||
| info: | ||
| title: Content Groups API v2 | ||
| version: 2.0.0 | ||
| description: | | ||
| REST API for managing content group configurations. | ||
|
|
||
| Content groups allow course authors to restrict access to specific | ||
| course content based on cohort membership. | ||
|
|
||
| host: courses.example.com | ||
| basePath: / | ||
| schemes: | ||
| - https | ||
|
|
||
| securityDefinitions: | ||
| JWTAuth: | ||
| type: apiKey | ||
| in: header | ||
| name: Authorization | ||
| description: JWT token authentication. | ||
|
|
||
| security: | ||
| - JWTAuth: [] | ||
|
|
||
| tags: | ||
| - name: Content Groups | ||
| description: Content group configuration management | ||
|
|
||
| parameters: | ||
| CourseId: | ||
| name: course_id | ||
| in: path | ||
| required: true | ||
| type: string | ||
| description: The course key (e.g., course-v1:org+course+run) | ||
| ConfigurationId: | ||
| name: configuration_id | ||
| in: path | ||
| required: true | ||
| type: integer | ||
| description: The ID of the content group configuration | ||
|
|
||
| paths: | ||
| /api/cohorts/v2/courses/{course_id}/group_configurations: | ||
| get: | ||
| tags: | ||
| - Content Groups | ||
| summary: List content group configurations | ||
| description: | | ||
| Returns all content group configurations (scheme='cohort') for a course. | ||
| If no content group exists, an empty one is automatically created. | ||
| operationId: listGroupConfigurations | ||
| produces: | ||
| - application/json | ||
| parameters: | ||
| - $ref: '#/parameters/CourseId' | ||
| responses: | ||
| 200: | ||
| description: Content groups retrieved successfully | ||
| schema: | ||
| $ref: '#/definitions/ContentGroupsListResponse' | ||
| 400: | ||
| description: Invalid course key | ||
| 401: | ||
| description: Authentication required | ||
| 403: | ||
| description: User lacks instructor permission | ||
| 404: | ||
| description: Course not found | ||
|
|
||
| /api/cohorts/v2/courses/{course_id}/group_configurations/{configuration_id}: | ||
| get: | ||
| tags: | ||
| - Content Groups | ||
| summary: Get content group configuration details | ||
| description: | | ||
| Retrieve a specific content group configuration by ID. | ||
| Only returns configurations with scheme='cohort'. | ||
| operationId: getGroupConfiguration | ||
| produces: | ||
| - application/json | ||
| parameters: | ||
| - $ref: '#/parameters/CourseId' | ||
| - $ref: '#/parameters/ConfigurationId' | ||
| responses: | ||
| 200: | ||
| description: Configuration retrieved successfully | ||
| schema: | ||
| $ref: '#/definitions/ContentGroupConfiguration' | ||
| 400: | ||
| description: Invalid course key | ||
| 401: | ||
| description: Authentication required | ||
| 403: | ||
| description: User lacks instructor permission | ||
| 404: | ||
| description: Configuration not found | ||
|
|
||
| definitions: | ||
| Group: | ||
| type: object | ||
| properties: | ||
| id: | ||
| type: integer | ||
| description: Unique identifier for the group | ||
| name: | ||
| type: string | ||
| description: Display name of the group | ||
| version: | ||
| type: integer | ||
| description: Version number of the group | ||
| usage: | ||
| type: array | ||
| items: | ||
| type: object | ||
| description: List of content blocks using this group | ||
|
|
||
| ContentGroupConfiguration: | ||
| type: object | ||
| properties: | ||
| id: | ||
| type: integer | ||
| description: Unique identifier for the configuration | ||
| name: | ||
| type: string | ||
| description: Display name (typically "Content Groups") | ||
| scheme: | ||
| type: string | ||
| enum: [cohort] | ||
| description: Partition scheme type | ||
| description: | ||
| type: string | ||
| description: Human-readable description | ||
| parameters: | ||
| type: object | ||
| description: Additional configuration parameters | ||
| groups: | ||
| type: array | ||
| items: | ||
| $ref: '#/definitions/Group' | ||
| description: List of groups in this configuration | ||
| active: | ||
| type: boolean | ||
| description: Whether this configuration is active | ||
| version: | ||
| type: integer | ||
| description: Version number of the configuration | ||
| read_only: | ||
| type: boolean | ||
| description: Whether this configuration is system-managed | ||
|
|
||
| ContentGroupsListResponse: | ||
| type: object | ||
| properties: | ||
| all_group_configurations: | ||
| type: array | ||
| items: | ||
| $ref: '#/definitions/ContentGroupConfiguration' | ||
| description: List of content group configurations | ||
| should_show_enrollment_track: | ||
| type: boolean | ||
| description: Whether enrollment track groups should be displayed | ||
| should_show_experiment_groups: | ||
| type: boolean | ||
| description: Whether experiment groups should be displayed | ||
| group_configuration_url: | ||
| type: string | ||
| description: Base URL for accessing individual configurations | ||
| course_outline_url: | ||
| type: string | ||
| description: URL to the course outline |
45 changes: 45 additions & 0 deletions
45
openedx/core/djangoapps/course_groups/rest_api/serializers.py
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| """ | ||
| Serializers for content group configurations REST API. | ||
| """ | ||
| from rest_framework import serializers | ||
|
|
||
|
|
||
| class GroupSerializer(serializers.Serializer): | ||
| """ | ||
| Serializer for a single group within a content group configuration. | ||
| """ | ||
| id = serializers.IntegerField() | ||
| name = serializers.CharField(max_length=255) | ||
| version = serializers.IntegerField() | ||
| usage = serializers.ListField( | ||
| child=serializers.DictField(), | ||
| required=False, | ||
| default=list | ||
| ) | ||
|
|
||
|
|
||
| class ContentGroupConfigurationSerializer(serializers.Serializer): | ||
| """ | ||
| Serializer for a content group configuration (UserPartition with scheme='cohort'). | ||
| """ | ||
| id = serializers.IntegerField() | ||
| name = serializers.CharField(max_length=255) | ||
| scheme = serializers.CharField() | ||
| description = serializers.CharField(allow_blank=True) | ||
| parameters = serializers.DictField() | ||
| groups = GroupSerializer(many=True) | ||
| active = serializers.BooleanField() | ||
| version = serializers.IntegerField() | ||
| is_read_only = serializers.BooleanField(required=False, default=False) | ||
|
|
||
|
|
||
| class ContentGroupsListResponseSerializer(serializers.Serializer): | ||
| """ | ||
| Response serializer for listing all content groups. | ||
| """ | ||
| all_group_configurations = ContentGroupConfigurationSerializer(many=True) | ||
| should_show_enrollment_track = serializers.BooleanField() | ||
| should_show_experiment_groups = serializers.BooleanField() | ||
| context_course = serializers.JSONField(required=False, allow_null=True) | ||
| group_configuration_url = serializers.CharField() | ||
| course_outline_url = serializers.CharField() |
3 changes: 3 additions & 0 deletions
3
openedx/core/djangoapps/course_groups/rest_api/tests/__init__.py
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| """ | ||
| Tests for Content Groups REST API v2. | ||
| """ |
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.
Given that there is a djangoapp specific to course_groups, does it make sense to put the related API views there as well? Is there a reason we shouldn't do that?