overhangio / openedx-scorm-xblock

SCORM XBlock for Open edX
GNU Affero General Public License v3.0
37 stars 48 forks source link

Allow configuring the storage backend independently from the main storage backend #8

Closed sampaccoud closed 3 years ago

sampaccoud commented 3 years ago

Problem description

We are interested to install this XBlock on existing sites. We absolutely need to use object storage for Scorm uploads but will not be able to modify the storage backend for the whole Django OpenEdX project on which the XBlock is installed.

Solution proposed

Add a separte setting to configure the storage backend for the XBlock. If this setting is not set, default to Django's main storage backend.

natea commented 3 years ago

@sampaccoud we have the same need for multi-tenant support on our Tahoe platform. Does it make sense to have this setting at the XBlock level or at the Django site level (so that you can specify the storage location for all XBlocks added to a particular site - not the whole Open edX site, just the individual microsites). We have been historically doing this in the SiteConfiguration object.

regisb commented 3 years ago

Hi all! The approach I'm currently leaning towards is very generic, where you can implement just any function to override the Scorm storage backend. Something along the lines of:

def scorm_storage_function(xblock):
    # return an instance of a Django storage backend. You can add as much code as you want here,
    # including imports and accessing the xblock instance attributes.
    ...

XBLOCK_SETTINGS["ScormXBlock"] = {
    "STORAGE_FUNC": scorm_storage_function
}

Alternatively, an importable string could be passed to the XBlock settings:

XBLOCK_SETTINGS["ScormXBlock"] = {
    "STORAGE_FUNC": "my.custom.storage.module.get_scorm_storage"
}

Would that work for you?

sampaccoud commented 3 years ago

Is "ScormXBlock" the Python entry point of the XBlock?

regisb commented 3 years ago

Is "ScormXBlock" the Python entry point of the XBlock?

No, it's "scorm". https://github.com/overhangio/openedx-scorm-xblock#usage https://github.com/overhangio/openedx-scorm-xblock/blob/master/setup.py#L44