feat: course optimizer extended report - #426
Open
nsprenkle wants to merge 4 commits into
Open
Conversation
Studio proxies both kicking off a Course Optimizer extended-analysis run (CourseAnalysisReportView, generating the course export server-side via the existing create_export_tarball) and polling its status (CourseAnalysisReportStatusView) to the xpert-ai-workflows backend, keyed by a shared secret -- the browser only ever talks to Studio.
…lows Reached via Docker's host-gateway alias, since it runs on the host machine rather than in the devstack docker network.
Gates the Course Optimizer extended-report section in the authoring MFE, matching enable_course_optimizer's existing CourseWaffleFlag pattern. Without this, the frontend's default for this flag would apply unconditionally everywhere, since it's absent from every course waffle flags API response until a real flag exists to answer for it.
There was a problem hiding this comment.
Pull request overview
Adds Studio-side support for the Course Re-Run Assistant (CORA) / Course Optimizer “extended report” by introducing a feature flag, new API endpoints that proxy to the xpert-ai-workflows backend, and the required configuration/settings.
Changes:
- Adds a course-scoped waffle flag
contentstore.enable_course_optimizer_extended_reportand exposes it via the course waffle flags API. - Introduces two new v0 REST endpoints to start an extended analysis run and to fetch the latest run status (server-to-server proxy to
xpert-ai-workflows). - Adds CMS settings for the backend base URL, API key, and request timeout (plus devstack defaults) and adds unit tests for the new endpoints.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
cms/envs/devstack.py |
Adds devstack defaults for the xpert-ai-workflows URL and shared secret. |
cms/envs/common.py |
Defines documented CMS settings for workflow URL/API key/timeout. |
cms/djangoapps/contentstore/toggles.py |
Adds the new course-level waffle flag and helper function. |
cms/djangoapps/contentstore/rest_api/v1/views/tests/test_course_waffle_flags.py |
Updates expected waffle-flag response to include the new flag. |
cms/djangoapps/contentstore/rest_api/v1/serializers/course_waffle_flags.py |
Exposes the new flag via the serializer method field. |
cms/djangoapps/contentstore/rest_api/v0/views/course_optimizer.py |
Implements the two new proxy endpoints for extended report run + status. |
cms/djangoapps/contentstore/rest_api/v0/views/__init__.py |
Re-exports new views for v0 API. |
cms/djangoapps/contentstore/rest_api/v0/urls.py |
Registers the new v0 routes. |
cms/djangoapps/contentstore/rest_api/v0/tests/test_course_optimizer.py |
Adds unit tests covering authz and proxy behavior for the new endpoints. |
Suppressed comments (2)
cms/djangoapps/contentstore/rest_api/v0/views/course_optimizer.py:540
_COURSE_ANALYSIS_REPORT_REQUEST_TIMEOUT_SECONDSis not defined here, so this endpoint will raise aNameErrorbefore making the request. Use the existingCOURSE_ANALYSIS_WORKFLOW_REQUEST_TIMEOUT_SECONDSsetting (as the POST endpoint does) or define the constant.
response = requests.get(
f'{settings.COURSE_ANALYSIS_WORKFLOW_URL}/courses/{course_id}/runs/latest',
headers={'X-Api-Key': settings.COURSE_ANALYSIS_WORKFLOW_API_KEY},
timeout=_COURSE_ANALYSIS_REPORT_REQUEST_TIMEOUT_SECONDS,
)
cms/djangoapps/contentstore/rest_api/v0/views/course_optimizer.py:536
- Same as the POST endpoint: the status proxy should also be gated by
contentstore.enable_course_optimizer_extended_reportso the extended-report feature is truly off by default at the API layer.
course_key = CourseKey.from_string(course_id)
if not has_course_author_access(request.user, course_key):
self.permission_denied(request)
try:
response = requests.get(
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+515
to
+516
| ) | ||
| def get(self, request: Request, course_id: str): |
Comment on lines
+471
to
+476
| course_key = CourseKey.from_string(course_id) | ||
| if not has_course_author_access(request.user, course_key): | ||
| self.permission_denied(request) | ||
|
|
||
| course_block = modulestore().get_course(course_key) | ||
| tarball = create_export_tarball(course_block, course_key, {}) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Provides support for the Course Re-Run Assistant / CORA / extended course optimizer report project. Specifically:
contentstore.enable_course_optimizer_extended_reportfor enabling this feature. Off by default.POST /api/contentstore/v0/course_analysis_report/{course_id}to post course material to our xpert-ai-workflows endpoint for analysis.GET /api/contentstore/v0/course_analysis_report_status/{course_id}to check the status of a given analysis.COURSE_ANALYSIS_WORKFLOW_API_KEYfor authentication to thexpert-ai-workflowsservice.Supporting information
Tickets:
Supporting PRs:
Testing instructions
contentstore.enable_course_optimizer_extended_reportwaffle flag.course-optimizer-reportplugin infrontend-app-learningfrom the supporting PR.Deadline
ASAP