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

SCORM not loading on preview domain #135

Open
igobranco opened this issue Sep 5, 2024 · 0 comments
Open

SCORM not loading on preview domain #135

igobranco opened this issue Sep 5, 2024 · 0 comments
Assignees

Comments

@igobranco
Copy link

igobranco commented Sep 5, 2024

The preview LMS domain doesn't load correctly the SCORM package, it raises a cross site scripting error.
This should also affect multi site LMS instances that use SCORM packages.

This happens because by default the SCORM storage uses only the LMS_BASE domain and not the user requested domain.

If you replace the scorm_xblock_storage function from

def scorm_xblock_storage(xblock):

With this:

def scorm_xblock_storage(xblock):
    from django.conf import settings
    from storages.backends.s3boto3 import S3Boto3Storage
    from xmodule.util.xmodule_django import get_current_request_hostname
    domain = get_current_request_hostname()
    if not domain:
      if SERVICE_VARIANT == "lms":
          domain = settings.LMS_BASE
      else:
          domain = settings.CMS_BASE
    return S3Boto3Storage(
        bucket=AWS_STORAGE_BUCKET_NAME,
        access_key=AWS_ACCESS_KEY_ID,
        secret_key=AWS_SECRET_ACCESS_KEY,
        querystring_expire=86400,
        custom_domain=f"{domain}/scorm-proxy"
    )
XBLOCK_SETTINGS["ScormXBlock"] = {
    "STORAGE_FUNC": scorm_xblock_storage,
}

Use the current user request hostname instead of the base LMS domain.

On NAU I've patched with this custom code and the SCORMs started working on preview domain.

Private references:

CC @MoisesGSalas @felipemontoya

@Ian2012 Ian2012 self-assigned this Sep 5, 2024
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

No branches or pull requests

2 participants