Skip to content

Feat/lms directory#483

Draft
IvanStepanok wants to merge 5 commits into
openedx:developfrom
raccoongang:feat/lms-directory
Draft

Feat/lms directory#483
IvanStepanok wants to merge 5 commits into
openedx:developfrom
raccoongang:feat/lms-directory

Conversation

@IvanStepanok

Copy link
Copy Markdown
Contributor

Multi-tenant LMS Directory

https://openedx.atlassian.net/wiki/spaces/OEPM/pages/6532923408/Proposal+Multi-instance+configuration+for+the+Mobile+Apps

Lets a single build browse a directory of Open edX platforms, pick one, and sign in against it. When a learner selects a platform the app re-themes to that platform's accent color and branding, routes every API request to its host, and lands on its sign-in (or discovery). The whole feature sits behind the LMS_DIRECTORY config flag, is disabled by default, and fails closed: with the flag off (or misconfigured) the Config accessors return the stock values and the app behaves exactly like today's single-tenant build.

What's included

Directory & selection

  • Pre-login platform picker. LmsLandingFragment shows the intro ("Find my LMS" / "Sign in with QR code") in search mode, or drops straight into the list in curated mode; SiteSelectionFragment hosts the catalog list reached from there
  • Two modes: the client DIRECTORY_MODE (search / curated) is OR-ed with the registry's GET /api/v1/configcurated = remote== "curated". In search mode the field is a debounced (SEARCH_DEBOUNCE_MS) search box that doubles as URL entry; in curated mode there is no search and the featured
  • SiteSelectionViewModel drives a CatalogState machine (Idle, Loading, Loaded, Empty, Error) plus recent-history rows.
  • LmsDirectoryRepository / LmsDirectoryApi talk to GET /api/v1/config, GET /api/v1/director(?q=search,?featured=true), and POST /api/v1/reports — the same registry backend as the iOS app. There is no bundled sample catalog: the feature needs a real DIRECTORY_URL.
  • Selecting a platform persists the choice, applies the accent + login background, and routes to discovery or sign-in based on the p flag.

Branding & sign-in

  • LmsThemeController is a Compose mutableStateOf holder for the selected platform's accentColor loginBackgroundUrl. OpenEdXTnts the accent-driven palette via a private AppColors.withAccent(...) (accent/info colors, outlined secondary-button text, etc.). No public Theme API signature changed.
  • API host switching is handled by an OkHttp BaseUrlOverrideInterceptor: the Retrofit client is built once with the config host, anch request's scheme/host/port toCorePreferences.selectedBaseUrl. Nothing selected → requests pass through untouched.
    • SignInView gains the branded trm's logo, a "Selected LMS" row with a "Change" action back to the picker, and the LmsHeaderImage header. SignUpView and RestorePasswordFragment swap theiLmsHeaderImage, which rendersloginBackgroundUrl when set and falls back to the stock header otherwise.
  • The Compose theme can't reach the, soMainFragment.applyLmsAccentTint() builds a ColorStateList from the accent and applies it to bottomNavView (icon + text tint).

QR sign-in

  • LmsQrScannerActivity wraps zxing's DecoratedBarcodeView + CaptureManager (dependency com.journeyapps:zxing-android-embed scanner with the framing viewfinder and a Close button, returning the scanned value through ScanContract.
  • A scanned value is normalized to the registry search endpoint (host match), then applied through the same selection path as tapping a result; if it doesn't resolve to a known platform, the app connects toly.
  • Camera permission is contributed by the zxing library's manifest (no separate declaration in the app), and zxing handles the runtime

Report this LMS

  • ReportLmsSheet is a Material3 ModalBottomSheet (drag handle, skipPartiallyExpanded) with 6categories (inappropriate, scam ', ' broken, other), a required note, and an optional base64 screenshot.
  • ReportLmsViewModel.submit() posage, platform: "android"}(+optionalreporter_email/screenshot_base64) to POST /api/v1/reports. The target is always the current platform (Config. getApiHost '). Reports go to the registry moderators, not to the LMS.
  • The Profile entry point shows only ' Enabled &&!corePreferences.lmsDirectoryCurated` — no report affordance in curated/institution mode.

Configuration & feature flag

  • New LMS_DIRECTORY block parsed NABLED, DIRECTORY_URL,DIRECTORY_MODE`).
  • Gate: `isReachable = enabled && d
  • Config.getApiHostURL(), getOAuthClientId(), and getFeedbackEmailAddress() consult the persisted selection only when `isRern the stock config values.
  • Selection is persisted in CorePreferences (selectedBaseUrl, selectedLmsAccentColor, selectedOAuthClientId, selectedFgoUrl, selectedLmsLoginBackgroundUrl, selectedLmsTitle, lmsDirectoryCurated). `clearCorePreferences ' wipes them on logout.

Connectivity & lifecycle

  • AppViewModel.isLmsSelectionRequired = getLMSDirectoryConfig().isReachable && selectedBaseUrl.isNullOrBlank(). OR LmsLandingFragment when selection is required (and there's no pending auth code); once a platform is picked, launch goes straight to its sign-in.
  • Logout clears the selection (clearCorePreferences()); on restart, AppRouter clears the theme (LmsThemeController.clear()) and t` when the feature is reachable, and nothing is selected. A disabled/unreachable build leaves the app fully single-tenant.

Tests

  • SiteSelectionViewModelTest (autry record and routes to discovery /to sign-in. - BaseUrlOverrideInterceptorTest elected LMS; passes through when nothing selected / selection blank. - LmsDetailDtoTest (app): DTO→domields fall back to base_url / null credentials.

How to enable

Off by default. Set ENABLED: true and a real DIRECTORY_URL in the relevant config.yaml:

LMS_DIRECTORY:
  ENABLED: true                                                                                     
  DIRECTORY_URL: "https://your-regi
  DIRECTORY_MODE: "search"   # "search" | "curated"; the registry's /api/v1/config can promote to curated

As shipped: dev is on (pointing at; prod and stage are off (ENABLED: false, empty URL). With the flag off or the URL empty, isReachable is false and the app is stuck
single-tenant.

Lets a single build browse the Open edX platforms published by a site
registry, re-theme to the chosen one, and sign in against it. Off by
default (LMS_DIRECTORY.ENABLED=false); the app stays single-tenant when
the flag is off.

- core: LMSDirectoryConfig flag; Config.getApiHostURL() resolves to the
  selected LMS when enabled; CorePreferences.selectedBaseUrl/accentColor;
  lmsdirectory client (API/repo/models/Koin); LmsThemeController re-tints
  OpenEdXTheme to the platform's brand color
- auth: LMS landing (Find my LMS / QR sign-in via ZXing), directory
  search/curated browse + manual entry, per-LMS theming on selection
- profile: 'Report this LMS' bottom sheet (flag-gated) posting to the registry
- app: flag-gated landing before sign-in; DI + startup wiring; seed theme
  from persisted accent on cold start
- default_config: LMS_DIRECTORY block for dev/stage/prod
- build: zxing-android-embedded for QR scanning
The catalog only returned summaries, so sign-in used the empty stock OAuth
client and requests still hit the config host — login failed. Now:
- fetch the full record on selection (LmsDetail): OAuth client id, feedback
  email, logo, accent; persist them in CorePreferences
- Config.getOAuthClientId()/getFeedbackEmailAddress() honor the selected LMS
- BaseUrlOverrideInterceptor rewrites every request to the selected host on the
  fly (the Retrofit client is built once, before selection) — the missing piece
  that let requests reach the chosen platform
- SignIn shows the selected LMS logo + a 'Selected LMS / Change' banner
- verified end-to-end: pick Sandbox -> branded sign-in -> logged into
  sandbox.openedx.org with the demo course loaded
- BaseUrlOverrideInterceptor routes requests to the selected host and is a no-op
  when nothing is selected (the mechanism that lets sign-in reach the platform).
- LmsDetailDto maps the OAuth client id / feedback email / host that the catalog
  summary lacks, with blank values falling back correctly.
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jul 8, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @IvanStepanok!

This repository is currently maintained by @openedx/openedx-mobile-maintainers.

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.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


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.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jul 8, 2026
@IvanStepanok IvanStepanok changed the base branch from main to develop July 8, 2026 09:12
Upstream openedx#420 replaced the browser-OAuth-code login with SAML SSO, deleting
getAccessTokenFromCode / browserAuthCodeLogin / loginAuthCode / BrowserAuthHelper /
GRANT_TYPE_CODE. The LMS Directory sign-in was built on that chain, so rather than
resurrect what upstream removed, the directory now signs in through upstream's
standard login against the re-pointed base URL:

- Keep the directory feature: pre-login picker, per-LMS branding (accent, logo,
  login-background header), the 'Selected LMS / Change' banner, and Report this LMS.
- Drop the browser-auth-code path: removed signInAuthCode + loginFailure and the
  authCode wiring in SignInFragment/AppActivity/DI; sign-in uses username/password
  (or SSO) against the selected host via BaseUrlOverrideInterceptor.
- Config keeps both getLMSDirectoryConfig() and upstream's SSO getters.
- Tests: stub Config.getLMSDirectoryConfig() in SignInViewModelTest; pass the new
  config arg in ProfileViewModelTest.

Verified locally: compile, full testDevelopDebugUnitTest, and detektAll all pass.
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

3 participants