Skip to content
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

feat: allow enrolling learners on invitation only courses #20

Merged

Conversation

tecoholic
Copy link
Member

@tecoholic tecoholic commented Aug 16, 2024

Description

This PR ports the changes from the following upstream PRs for Redwood:

Testing Instructions

Setting up the enterprise stack using Tutor

  • Create a new virutalenv.
    python -m venv venv
    source venv bin activate
    
  • Install Tutor release 18
    pip install "tutor[full]"
    
  • Clone the tecoholic/redwood-upgrade branch of tutor-contrib-enterprisecatalog and install it in your tutor env.
    git clone -b tecoholic/redwood-upgrade [email protected]:open-craft/tutor-contrib-enterprisecatalog.git
    pip install -e tutor-contrib-enterprisecatalog
    
  • Verify that tutor can load the plugin. There should be enterprise-catalog entry.
    tutor plugins list
    
  • Add the following tutor config.yml file:
    ALGOLIA_ADMIN_API_KEY: 
    ALGOLIA_APP_ID: 
    ALGOLIA_INDEX_NAME: 
    ALGOLIA_SEARCH_API_KEY: 
    
  • Create a new tutor plugin that has some fixes: bb8935-fixes.py
    from tutor import hooks
    
    my_config = """
    LEARNER_PORTAL_CONFIG = {
        "learner-portal-enterprise": {
            "FEATURE_ENABLE_PATHWAY_PROGRESS":  '',
            "FEATURE_ENABLE_PATHWAYS":  '',
            "FEATURE_ENABLE_PROGRAMS":  '',
            "FEATURE_LANGUAGE_FACET":  '',
            "FEATURE_PROGRAM_TYPE_FACET":  '',
            "ENABLE_SKILLS_QUIZ":  '',
            "FEATURE_ENABLE_MY_CAREER":  '',
            "FEATURE_CONTENT_HIGHLIGHTS":  True,
            "FEATURE_ENABLE_AUTO_APPLIED_LICENSES":  True,
        }
    }
    """
    
    hooks.Filters.ENV_PATCHES.add_item(
        (
            "openedx-lms-development-settings",
            f"""{my_config}
    MFE_CONFIG_OVERRIDES.update(LEARNER_PORTAL_CONFIG)
    
    COURSE_CATALOG_API_URL="http://discovery:8381/api/v1"
    """,
        )
    )
    
    hooks.Filters.ENV_PATCHES.add_item(
        (
            "discovery-common-settings",
            "CELERY_BROKER_URL = 'redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ DISCOVERY_CACHE_REDIS_DB }}'",
        ),
    )
  • Enable all the necessary plugins
    tutor plugins enable discovery ecommerce mfe enterprise-catalog bb8935-fixes
    
  • Checkout to the PR branch and add that to the mounts
    cd /path/to/edx-enterprise
    git checkout tecoholic/BB-8935-redwood-backports
    tutor mounts add /path/to/edx-enterprise
    
  • Build all the Docker images
    tutor images build enterprise-catalog enterprise-catalog-worker license-manager license-manager-worker license-manager-bulk-enrollment-worker enterprise-access enterprise-access-worker enterprise-subsidy openedx-dev mfe
    
  • Launch tutor
    tutor dev launch
    

That should get everything up and running.

Adding Enterprise Data

LMS

  1. Import the demo course into LMS using tutor command
  2. Create an admin user in the LMS
  3. Create test data for enterprise stack using seed_enterprise_devstack_data.
  4. From the LMS Admin, edit the "Test Enterprise" Enterprise Customer and disable the "Activate data sharing consent prompt".

Course Discovery

  1. Login to course discovery and verify that the demo course is present under "Courses" and "Course Runs". If it is missing, run ./manage.py refresh_course_metadata to pull all the data.
  2. In Discovery, go to "Organizations" and create a "DemoX" organization (or any name) and choose the "Openedx - dev" as the partner. Upload some logos for a good measure here.
  3. Edit the Demo course under "Courses" and set the "DemoX" org as the authoring organizations and "Openedx - dev" as the Partner.
  4. In the Seats section, create a new set "Professional Only" with any Non-ZERO price and save.
  5. Run the management command update_index --disable-change-limit to update the index.
  6. Verify that the owners, and the course_run > seats fields are populated by visiting http://discovery.local.edly.io:8381/api/v1/courses/

Enterprise Catalog

  1. From LMS shell run, ./manage.py lms migrate_enterprise_catalogs --api_user enterprise_catalog_worker. If it fails, replace enterprise_catalog_worker with your admin username. I didn't find the time to debug this bug yet.
  2. Go to the Enterprise Catalog admin and create a new Enterprise Catalog with the Catalog Query. Use a random UUID for the enterprise customer ID. We need this catalog to pull all the "Course" metadata and push it to Algolia. The Test Enterprise only pulls courseruns
{
  "content_type":"course"
}
  1. From Enterprise Catalog shell, run update_content_metadata --force and reindex_algolia --force.
  2. Verify that your Algolia Index is populated with some data.

License Manager

  1. Go to the License Manager Admin
  2. Create a new customer agreement with the UUID of the "Test Enterprise"
  3. Edit the "Standard Paid" plan type and remove the checks for "Ns id required" and "Sf id required"
  4. Create a new "Product" named "Professional seat" with the "Standard Paid" plan type.
  5. Create a new subscription using the "Professional seat" and the customer agreement created above. Set like 100 or 1000 licenses.
  6. From "Licenses", edit 2 of them and mark them as "Activated" with one assigned to each of:

Testing the PR Changes

Note: this requires acting as 2 users simultaneously. Use private mode or 2 profiles or Firefox containers.

Normal Flow

  1. Login as the test-enterprise_learner_1 with password edx. The Learner Dashboard should show the following message.
    image
  2. Clicking the "Go to Dashboard" button should redirect the user to http://apps.local.edly.io:8734/test-enterprise, change this URL to http://apps.local.edly.io:8734/learner-portal-enterprise/test-enterprise.
  3. Go to the course finder page, the Demo Course should be available there. Clicking "Learn More" should show an "Enroll" button. Click Enroll should successfully enroll the user and redirect them to the course page.

Invite only course

  1. Open "Advanced Settings" of the demo course and set "Invitation Only" to true and save.
  2. Repeat the above steps with test-enterprise_learner_2. The enrollment should fail and an error message shown in the enterprise learner portal.
  3. Go to the LMS Admin, edit the "Test Enterprise", check the "Allow enrollment in invite-only courses" flag.
  4. Go to the Course Enrollment Allowed and verify that it is empty.
  5. Now, refresh the enterprise learner portal and click "Enroll". This time the user should be enrolled and taken to the course page.
  6. Simultaneously, verify that the Course Enrollment Allowed page has an entry for the test user.

@tecoholic tecoholic self-assigned this Aug 16, 2024
@tecoholic tecoholic marked this pull request as draft August 16, 2024 12:35
@tecoholic tecoholic requested a review from Agrendalath August 16, 2024 13:07
@tecoholic tecoholic marked this pull request as ready for review August 23, 2024 10:04
enterprise/utils.py Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a backport QA'd on a Redwood instance.

@tecoholic tecoholic force-pushed the tecoholic/BB-8935-redwood-backports branch from 7c62f03 to b41e133 Compare December 6, 2024 11:41
@Agrendalath Agrendalath merged commit f1f2ed2 into opencraft-release/redwood.1 Dec 6, 2024
12 checks passed
@Agrendalath Agrendalath deleted the tecoholic/BB-8935-redwood-backports branch December 6, 2024 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants