fix: respect allow_enrollment_in_invite_only_courses #14
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
This fix allows enterprise learners to enroll into invite-only enterprise courses using the
frontend-app-learner-portal-enterprise
MFE.This issue is easy to reproduce. Let's imagine we have an enterprise customer, with one invitation-only course in its catalog, enough funds and one linked leaner. The learner will see the following if visit the portal:
Clicking
Enroll
will result in some error:Let's follow the request to understand what's causing it. First, frontend is sending a POST request to
http://localhost:18270/api/v1/policy-redemption/<per_learner_spend_credit_access_policy_uuid>/redeem/
URL with a body like this:Then, this endpoint is failing because of inability to create a subsidy transaction:
enterprise-subsidy
service, in turn, is failing to create a transaction because LMS is failing to create an enrollment:And LMS is failing to create an enrollment because
edx-enterprise
'senroll_learners_in_courses
is failing:Unlike
CourseEnrollmentView
, this endpoint doesn't createCourseEnrollmentAllowed
object automatically if an enterprise customer hasallow_enrollment_in_invite_only_courses
set toTrue
. In this PR we fix exactly this.Testing
Configuring devstack to test this is a bit tedious.
First, get a working enterprise setup like described in the testing steps section of openedx/frontend-app-learner-portal-enterprise#887, but with some differences:
ENTERPRISE_ALGOLIA_SEARCH_API_KEY
todevstack.py
.0x29a/bb8626/enroll-enterprise-learners-in-invite-only-courses
branch foredx-enterprise
repo.frontend-app-learner-portal-enterprise
.Installing frontend-app-learner-portal-enterprise
section, run alsoexport ALGOLIA_SEARCH_API_KEY=<your_search_api_key>
.Enrolling users
step.Then you have to make
Enroll
button work, which requires three additional services:Also you need to create some missing role assignments, so these services can work together:
[email protected]
toenterprise_subsidy_admin
role here: http://localhost:18280/admin/subsidy/enterprisesubsidyroleassignment/[email protected]
and[email protected]
toenterprise_catalog_admin
role here: http://localhost:18160/admin/catalog/enterprisecatalogroleassignment/Finally, in this context, some course is enroll-able only if it has price and if organization that own this course has a non-zero balance to subsidize learning. That's why you'll need to do the following:
$10,000,000.00
amount. After this, verify that the ledger's balance is 10 mil $.first_enrollable_paid_seat_price
==100
.Now you can register some leaner, link it to the previously chosen enterprise customer in
http://localhost:18000/admin/enterprise/enterprisecustomer/<enterprise_customer_uuid>/manage_learners
, and trying to enroll via the portal. It should fail unlessAllow enrollment in invite only courses
checkbox onhttp://localhost:18000/admin/enterprise/enterprisecustomer/<enterprise_customer_uuid>/change/
page is set.Private ref