Repository navigation
feat: resolve the competency-statuses learner for the LMS - #39425
ufedaseyeuconsultant wants to merge 2 commits into
Conversation
The logic that resolves the learner a request is about (self, masquerade target, or another user for staff and CCX coaches) lived on ProgressTabView as a private method. It moves to course_home_api/utils.py as get_student_user so other course home API code can reuse it. The body is unchanged. The progress tab test that patches has_ccx_coach_role now patches it where get_student_user looks it up. Part of openedx/openedx-core#738. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Thanks for the pull request, @ufedaseyeuconsultant! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Add resolve_course_learner, the LMS implementation of the learner resolver contract in openedx-core ADR 0008, and point the new OPENEDX_LEARNING_LEARNER_RESOLVER setting at it. This is part of openedx/openedx-core#738. The resolver runs its checks in the same order as ProgressTabView.get, minus its Progress-tab-enabled and course-load checks, and raises a 403 where the Progress tab returns a 401. It checks the requester's staff access, resolves the learner through get_student_user (own data, masquerade, or a named learner for staff and CCX coaches), and then refuses with PermissionDenied when the resolved learner has no active enrollment, unless the requester has staff access. A learner the requester may not see and an unknown learner both raise a bare Http404 with no message, so the two exceptions are identical. Like the Progress tab, the resolver clears the session's masquerade field data when a staff requester names no other learner. get_student_user gains a contract docstring, and its comment no longer refers to the progress page. Rollout: the setting is inert until an openedx-core release ships the learner competency statuses view that reads it. Co-Authored-By: Claude Fable 5 <[email protected]>
9ef093d to
fa8743f
Compare
Description
The openedx-platform side of openedx/openedx-core#738: the LMS learner resolver that decides whose competency statuses a request may read, with staff, enrollment, and masquerade handling. The openedx-core side (the statuses endpoint, the resolver seam, and its self-only default) is a separate PR there; the seam's contract is openedx-core's ADR 0008.
Two commits:
refactor: extract get_student_user from the progress tab view:ProgressTabView._get_student_usermoves verbatim tolms/djangoapps/course_home_api/utils.pyasget_student_user(request, course_key, student_id, is_staff), so the resolver can reuse the Progress tab's learner-selection behavior (masquerade for self, staff or CCX-coach access for a named id, bareHttp404otherwise) without duplicating it. The Progress tab calls the util; its behavior is unchanged and its tests pass as before (one test's patch target follows the moved import).feat: resolve competency-statuses learner with staff rules:resolve_course_learner(request, course_key, learner_id)in the same module, mirroringProgressTabView.get's order: course-run staff access first, thenget_student_user, then a DRFPermissionDeniedwhen the resolved learner has no active enrollment and the requester has no staff access. A learner the requester may not see and a learner id that matches no user raise the same bareHttp404, so the two responses are byte-identical and user ids cannot be probed.lms/envs/common.pysetsOPENEDX_LEARNING_LEARNER_RESOLVERto the new function, with the repo's setting annotations.Who is affected
Supporting information
docs/openedx_learning/decisions/0008-learner-resolver.rston the core PR's branch): the resolver contract (signature, the two exceptions, the setting).has_access(request.user, "staff", course_key)): a coach naming an unenrolled learner gets a 403, which tells that learner apart from an unknown id. Coaches are authorized to see learners, so that distinction is accepted and documented in the resolver's docstring.claude-fable-5) planned the change and reviewed it; Claude Sonnet 5.5 sub-agents wrote the code and tests under that plan. I reviewed the result.Testing instructions
Automated:
pytest lms/djangoapps/course_home_api/tests/test_utils.py lms/djangoapps/course_home_api/progress/tests/ --ds=lms.envs.test(57 pass at this branch's head;test_utils.pyalone collects 32).pylintandpycodestyleon the touched files.New tests cover every LMS scenario of the ticket: an enrolled learner reading their own statuses (no id, own id); staff naming an enrolled and a since-unenrolled learner; staff masquerading as a specific learner (no id and own id both return the masquerade target); the three masquerade fallbacks to the requester (Learner role, content group, target who unenrolled); the bare-404 identity between a forbidden learner and an unknown id (args compared, both empty); staff of another course run getting the same bare 404; an unenrolled non-staff requester naming an enrolled learner getting the 404, not the 403; the 403 for a never-enrolled and a since-unenrolled requester asking for themselves;
learner_id=0as an unknown id on both the staff and non-staff paths; the CCX-coach refusal for an unenrolled learner (with the requester enrolled, which pins that the refusal checks the resolved learner); a DRF-wrapped request; andimport_string(settings.OPENEDX_LEARNING_LEARNER_RESOLVER)resolving to the function.Manual: none until the LMS mounts the learner URLs and an openedx-core release ships the statuses view; the setting is inert until then. After that, the manual steps on the core PR apply end to end.
Deadline
None.
Other information
lms/includesopenedx_learning's learner URLs. The learner surface needs three platform pieces: thelearner_urlsinclude, theview_course_competency_criteriapermission override from [BE] GET Competency Criteria for Course openedx-core#733, and the resolver with its setting. This PR is the third piece; until the other two land and an openedx-core release ships the statuses view, nothing reads the setting.get_student_userkeeps the Progress tab's known behaviors, including that course-run staff can name any existing user id; the ticket records that as a known limitation.🤖 Generated with Claude Code