Skip to content

Conversation

ChristopherChudzicki
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki commented Oct 15, 2025

What are the relevant tickets?

All the PRs we make where we copy-and-paste the setup directions for mitxonline <> Learn.

Description (What does it do?)

This PR adds directions for running MITxOnline and MIT Learn locally in a way that they can communicate.

How can this be tested?

  1. Follow the directions in the README
  2. Create a program with some required and elective courses. Useful things to know:
    • Create courses and programs with ./manage.py create_courseware, ./manage.py create_courseware_page; see --help for details. Note: program readable ids should start with program-v1:.
    • Add instructors/relevant data for your program in Wagtail at http://mitxonline.odl.local:8013/cms
  3. Run MITxOnline ETL against your local MITxOnline; ./manage.py backpopulate_mitxonline_data --delete, and ./manage.py backpopulate_mitxonline_data
  4. Ensure product-page-course feature flag is on in your personal posthog
  5. Try backpopulating mitxonline data against local, ./manage.py backpopulate_mitxonline_data
  6. Try Viewing a program page or course page, e.g., http://learn.odl.local:8062/courses/COURSE_ID_HERE or http://learn.odl.local:8062/programs/PROGRAM_ID_HERE

@ChristopherChudzicki ChristopherChudzicki added the Needs Review An open Pull Request that is ready for review label Oct 15, 2025
extra_hosts:
# This allows containers to access services running on a host linux machine
# Unnecessary but harmless for mac/windows users
- "host.docker.internal:host-gateway"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lacking a linux machine, i have not actually tested that this enables it, but Copilot and SO https://stackoverflow.com/questions/70725881/what-is-the-equivalent-of-add-host-host-docker-internalhost-gateway-in-a-comp suggest it should

Copy link
Contributor

@dsubak dsubak left a comment

Choose a reason for hiding this comment

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

You may want to hold off for another, more experienced review, but these instructions are pretty much bang on what I ended up figuring out when I set it up on my own. Thanks for the writeup!

@jkachel
Copy link
Contributor

jkachel commented Oct 16, 2025

The goal of this is to allow MITx Online and Learn to be set up so that MITx Online can have some data in it, and Learn can pull that data out for its needs, right? This seems OK for that purpose.


### Connecting with MITxOnline

Set up the [mitxonline](https://github.com/mitodl/mitxonline) as indicated there. _Note: A working OpenEdx installation is not necessary for integration with Learn._
Copy link
Member

Choose a reason for hiding this comment

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

Maybe place this sentence after setting the env variables below in MIT-Learn and MITx Online, and starting up both.

Also, OPENEDX_API_CLIENT_ID and OPENEDX_API_CLIENT_SECRET require values for the mitxonline app to start successfully, but they are not mentioned in that repo's README or included in the example .env file. They are mentioned in the "Using Tutor" instructions but I skipped that step.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this PR should also enable mitxonline users to log in via mit-learn's apisix/keycloak instance, but if so I could not validate that because something seems off with my local setup and I was unable to log in that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this PR should also enable mitxonline users to log in via mit-learn's apisix/keycloak instance, but if so I could not validate that because something seems off with my local setup and I was unable to log in that way.

Do you mean click login via MITxOnline login button? I had forgotten that does a surprising infinite loop. I'm not sure what causes that, but logging in via MIT Learn works.

@jkachel Do you have any idea? IMO not critical though.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I was getting that endless loop initially, then started adjusting other env values with best guesses and got apisix or keycloak errors instead.

KEYCLOAK_CLIENT_ID=apisix
KEYCLOAK_CLIENT_SECRET=HckCZXToXfaetbBx0Fo3xbjnC468oMi4 # pragma: allowlist-secret
KEYCLOAK_DISCOVERY_URL=http://kc.ol.local:8066/realms/ol-local/.well-known/openid-configuration
KEYCLOAK_REALM_NAME=ol-local
Copy link
Member

Choose a reason for hiding this comment

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

I could not log in with these settings. But the backpopulate command works regardless.

If the goal of this PR is just to backpopulate from a local mitxonline instance, then these keycloak settings can be omitted.

If the goal is also to allow login via MIT-Learn's apisix/keycloak instance, then something is off, maybe I have a bad or missing environment value somewhere.

Copy link
Contributor

@gumaerc gumaerc left a comment

Choose a reason for hiding this comment

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

I've been testing this on Ubuntu Linux 24.04. I was able to eventually get the dashboard connected and see my programs / enrollments on the frontend, after changing some of the settings I noted below. However, I was unable to get the program page in Learn working. When I try and load the page for my test program, I get "Error fetching course page metadata for programv1%3Aprogam-v1-test-program" (Yes, that is the readable ID of my test program). The message says "connect ECONNREFUSED 127.0.0.1:8065." This indicates that the API in the watch server (since the metadata seems to be queried by the server and not the client) has mitxonline.odl.local as the MITx Online base url, which is going to evaluate to 127.0.0.1. I think in the docker configuration, if we somehow get the watch container itself to use host.docker.internal:8013 for that, then it should work?

```env
# MIT Learn, frontend.local.env
## This is the default; it should not be overridden
NEXT_PUBLIC_MITX_ONLINE_BASE_URL=${MITX_ONLINE_BASE_URL}
Copy link
Contributor

Choose a reason for hiding this comment

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

It's worth noting that this is the default in frontend.env anyway, probably don't need to set it in frontend.local.env as well

# MITxOnline, .env
CSRF_COOKIE_DOMAIN=.odl.local
CORS_ALLOWED_ORIGINS=http://mitxonline.odl.local:8065, http://learn.odl.local:8062
CSRF_TRUSTED_ORIGINS=http://mitxonline.odl.local:8065, http://learn.odl.local:8062
Copy link
Contributor

Choose a reason for hiding this comment

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

In other places, we are still referencing open.odl.local. We should either say that here, or change it everywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. We should change it everywhere, but IMO not in this PR. I use learn.odl.local and had forgotten.

- MITX_ONLINE_UPSTREAM=${MITX_ONLINE_UPSTREAM:-mitxonline.odl.local:8013}
- MITX_ONLINE_DOMAIN=${MITX_ONLINE_DOMAIN:-mitxonline.odl.local}
- MITX_ONLINE_UPSTREAM=${MITX_ONLINE_UPSTREAM:-host.docker.internal:8013}
- MITX_ONLINE_DOMAIN=${MITX_ONLINE_DOMAIN:-host.docker.internal}
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to set MITX_ONLINE_DOMAIN to mitxonline.odl.local. This allows you to access http://mitxonline.odl.local:8065/ in a browser and then, using your already logged in session in APISIX, you are automatically authenticated to use Django admin in MITx Online.

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

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants