Skip to content

feat: GET a course run's competency criteria for the learner Progress tab - #949

Open
tbain wants to merge 6 commits into
openedx:mainfrom
tbain:tbain/733_course_competency_criteria
Open

tbain wants to merge 6 commits into
openedx:mainfrom
tbain:tbain/733_course_competency_criteria

Conversation

@tbain

@tbain tbain commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Description

This PR continues #945, opened by jesperhodge, and carries the same six commits. I am taking over #733, and the earlier review discussion is on that PR.

This is one of two PRs that implement #733. The other is an openedx-platform PR.

Please review this by reading the HTML PR Description.

HTML PR Description

Supporting Docs

AI Review

Review HTML

Fix Report

Summary by CodeRabbit

  • New Features
    • Added a read-only learner API to retrieve course competency criteria, including related taxonomies, competencies, groups, and criteria.
    • Responses can be paginated. Archived or unavailable items are excluded, and courses without eligible criteria return empty results.
  • Documentation
    • Added guidance for configuring learner routes and permissions. Hosts should review the default access policy before exposing the endpoint.

jesperhodge and others added 6 commits November 18, 2026 13:09
Adds get_course_competency_criteria() and GET
api/cbe/v1/courses/<course_key>/criteria/, served from a new learner-only
URL module, openedx_learning.learner_urls. The endpoint returns a course
run's competency criteria hierarchy as four flat lists (taxonomies,
competencies, groups, criteria), leaves out archived and disabled records,
and prunes branches left with no criteria. Access is the new
openedx_learning.view_course_competency_criteria permission, which allows
any signed-in user by default and which openedx-platform overrides.

Part of openedx#733

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fetch the groups below a course run's course-level groups level by level
through parent_id, so a request reads only that run's subtree. Split the
learner view and serializers into their own modules, rename the result
dataclasses with a Learner prefix, document the learner URL module and
permission for hosts, and tighten the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rename kept_course_level_groups to live_course_level_groups_with_criteria
and tags to competency_tags, and move the code that collects the root
groups, adds the groups holding criteria and sorts them into
_groups_with_competency_ids_in_result_order. The output is unchanged.

Add two tests the ticket asks for: a course run without criteria costs
one query even when another course run has criteria under the same
competency, and a change to the system default profile's threshold shows
on the next call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the assert on a competency tag's taxonomy with a TypeError, and
show the groups _groups_with_competency_ids_in_result_order returns as a
tree in its docstring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The learner course-criteria read now names a criterion's ObjectTag
object_id `object_id` and a group's competency tag `tag_id`, the same
names the authoring reads use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 19, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @tbain!

This repository is currently maintained by @axim-engineering.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PR adds a learner-facing course criteria API with filtering, response serialization, access checks, and optional pagination. It separates learner URL configuration from authoring routes and documents how hosts mount the learner routes and configure their permission.

Changes: Learner course criteria

Layer / File(s) Summary
Criteria data and assembly
src/openedx_learning/applets/cbe/data.py, src/openedx_learning/applets/cbe/api.py, tests/openedx_learning/applets/cbe/test_course_criteria_api.py
Adds learner data classes and an API that assembles ordered taxonomy, competency, group, and criterion lists. The API filters archived or unavailable data. Tests cover result contents, exclusions, empty results, and query counts.
Learner endpoint and response
src/openedx_learning/applets/cbe/rules.py, src/openedx_learning/applets/cbe/rest_api/*, src/openedx_learning/learner_urls.py, tests/openedx_learning/applets/cbe/test_course_criteria_views.py
Adds an authenticated GET endpoint with course-key validation and a course-specific permission check. Read-only serializers return criteria data. Optional pagination is based on competencies and includes associated records.
Host URL configuration
projects/urls.py, AGENTS.md, src/openedx_learning/README.rst
Adds the learner URL module to the host configuration. Documentation describes learner-only mounting, permission configuration, and subsection usage keys in the response.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant LearnerClient
  participant LearnerCourseCriteriaView
  participant PermissionRules
  participant get_course_competency_criteria
  LearnerClient->>LearnerCourseCriteriaView: GET course criteria
  LearnerCourseCriteriaView->>PermissionRules: Check course criteria permission
  LearnerCourseCriteriaView->>get_course_competency_criteria: Retrieve course criteria
  LearnerCourseCriteriaView->>LearnerClient: Return serialized criteria
Loading

Possibly related issues

  • openedx/openedx-core issue 733: Specifies the course-run criteria endpoint and payload that this PR implements.
  • openedx/openedx-core issue 730: Describes a Progress tab feature that uses criteria and subsection data returned by this API.
  • openedx/openedx-core issue 734: Describes Progress tab cards that consume criteria fields returned by this API.

Possibly related PRs

  • openedx/openedx-core#945: Adds the criteria endpoint contract, API function, and permission that this PR extends with learner-specific routing, views, serializers, and access behavior.

Suggested reviewers: alezconsultant, ufedaseyeuconsultant, ormsbee

Merge Risk: Minimal · up to b9492

This adds a read-only learner endpoint for a course run's competency criteria, plus the URL configuration hosts need to mount it. No concrete defect was found. The default permission admits any signed-in user, which is documented, so hosts that need stricter access must override it before exposing the route.

Security architecture risk: Moderate · up to b9492

The new endpoint defaults to allowing every signed-in user to request any course’s competency criteria, including identifiers for hidden or unreleased subsections. Hosts are instructed to install a stricter course-access policy before enabling it. Permission checks precede data access and the endpoint is read-only, limiting the consequence to disclosure, but the required host integration could not be verified.

Retained concerns

  • Medium · security · inferred: The new learner boundary falls back to authentication alone unless the host replaces its permission. A host that enables the route without that replacement can expose criteria, effective rule payloads, and hidden or unreleased subsection identifiers for attacker-selected courses. Existing host restrictions on authoring taxonomy access do not automatically protect this separate endpoint. This is an introduced integration and rollout risk; whether the paired production host supplies the required policy is unresolved.
Security review details

Security Blast Radius

  • inferred — With the documented permission backend and unchanged default predicate, an ordinary authenticated caller can select course keys repeatedly to read eligible course-criteria metadata across the host’s stored courses, without an enrollment or organization restriction in this endpoint. The inspected path grants no write authority and returns no learner progress records.

Security Findings and Attack Paths

  • inferred — The conditional disclosure path is a signed-in caller supplying a target course key, passing the authentication-only default, and receiving that course’s eligible criteria and subsection identifiers. This path matters when a host exposes the new route without installing the required replacement policy; the evidence does not show that condition in production.

Trust Boundaries and Controls

  • observed — The view requires authentication and calls the named permission with the normalized course key before invoking assembly, including on paginated requests. Test source exercises a replacement deny rule and expects a 403 response without criteria data.
  • observed — The pre-existing authoring boundary delegates to taxonomy visibility, whose local default permits enabled taxonomies. That broad default predates this PR. The learner endpoint uses a different permission, so a host’s existing taxonomy-policy replacement does not substitute for the new course-policy integration.

Resilience and Maintainability Implications

  • observed — The inspected GET call chain performs ORM reads and response construction rather than authoring mutations or learner-progress updates. Optional pagination slices the assembled result afterward; its page-size limit is not a bound on the underlying assembly work.

Hardening Proposals

  • proposed — Make an unconfigured learner permission deny access, or require an explicit host policy before enabling the route. Couple route exposure to verification that ordinary users cannot read unrelated courses or organizations, so deployment omissions cannot silently retain the authentication-only fallback.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat: GET a course run's competency criteria for the learner Progress tab" matches the main change. The PR adds a learner-only GET endpoint at api/cbe/v1/courses/<course_key>/criteria/ that…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat: GET a course run's competency criteria for the learner Progress tab" matches the main change. The PR adds a learner-only GET endpoint at api/cbe/v1/courses/<course_key>/criteria/ that returns a course run's competency criteria hierarchy. The title is specific, concise, and follows conventional commit style. It names the endpoint's purpose and audience.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cd6bf35c-6e64-4a9a-af84-53a03fd1abf9
Commits

Reviewing files that changed from the base of the PR and between 62e3ff2 and b9492ce.

Files selected for processing: 15

  • AGENTS.md
  • projects/urls.py
  • src/openedx_learning/README.rst
  • src/openedx_learning/applets/cbe/api.py
  • src/openedx_learning/applets/cbe/data.py
  • src/openedx_learning/applets/cbe/rest_api/learner_urls.py
  • src/openedx_learning/applets/cbe/rest_api/paginators.py
  • src/openedx_learning/applets/cbe/rest_api/v1/learner_serializers.py
  • src/openedx_learning/applets/cbe/rest_api/v1/learner_urls.py
  • src/openedx_learning/applets/cbe/rest_api/v1/learner_views.py
  • src/openedx_learning/applets/cbe/rest_api/v1/serializers.py
  • src/openedx_learning/applets/cbe/rules.py
  • src/openedx_learning/learner_urls.py
  • tests/openedx_learning/applets/cbe/test_course_criteria_api.py
  • tests/openedx_learning/applets/cbe/test_course_criteria_views.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

3 participants