h5p-xblock 0.2.18
XBlock to play self hosted h5p content inside open edX
License: MIT
Keywords: python edx h5p xblock


# Play H5P content in Open edX using h5pxblock

H5P Xblock provides ability to host and play H5P content in open edX. It has few more features

1. Ability to mark H5P content complete in open edX
2. Ability to capture score of H5P content in open edX
3. Save learner state which can be retrieved later
4. Ability to host H5P content on cloud storage like AWS S3

## Setup

### Install Xblock

```bash
pip install h5p-xblock
```

or if you're using tutor to manage your organization:

```bash
tutor config save --append OPENEDX_EXTRA_PIP_REQUIREMENTS=h5p-xblock
tutor images build openedx
```

### Update Advanced Settings of course

Update course advanced settings by adding `h5pxblock`

![Update course advanced settings](https://github.com/edly-io/h5pxblock/blob/master/docs/images/course_advance_settings.png?raw=true)

### Upload H5P Content

Xblock should be available in Advanced component list of course unit now. Add xblock in unit and click "Edit" button to upload H5P content and configure it.

![Upload and configure H5P content in Studio](https://github.com/edly-io/h5pxblock/blob/master/docs/images/upload_content.png?raw=true)

### Publish Content

Use "Preview" button to preview it or publish your content and use "View Live Version" button to see how it appears on LMS

![Preview H5P content in LMS](https://github.com/edly-io/h5pxblock/blob/master/docs/images/preview_content.png?raw=true)

### Configuring storage backend (S3 example)

H5P relies on `DEFAULT_FILE_STORAGE` by default. If you want to use a different
storage for H5P content (e.g., a dedicated S3 bucket, or when `AWS_QUERYSTRING_AUTH = True`
and you need unsigned URLs), configure one of the following:

1. Django ≥ 4.2/5.x (preferred): add a storage entry named `h5pxblock_storage` to `STORAGES`:

```python
STORAGES = {
    "default": {
        "BACKEND": "django.core.files.storage.FileSystemStorage",
        "OPTIONS": {"location": "/var/media"},
    },
    "h5pxblock_storage": {
        "BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
        "OPTIONS": {
            "bucket_name": "my-s3-public-bucket",
            "querystring_auth": False,
        },
    },
}
```

2. Legacy fallback (still supported):

```python
H5PXBLOCK_STORAGE = {
    "storage_class": "storages.backends.s3boto3.S3Boto3Storage",  # or "STORAGE_CLASS"
    "settings": {  # or "STORAGE_KWARGS"
        "bucket_name": "my-s3-public-bucket",
        "querystring_auth": False,
    },
}
```

Please ensure that your bucket is publicly accessible (or otherwise correctly configured)
to enable seamless content storage and retrieval via S3.

## Working with translations

You can help by translating this project. Follow the steps below:

1. You need `i18n_tool` to "collect" and "compile" translations. If you already have it, proceed to the next item; otherwise:

```bash
pip install git+https://github.com/openedx/i18n-tools
```

1. Create a folder for the translations in `locale/`, eg: `locale/es_419/LC_MESSAGES/`, and create your `text.po` file
with all the translations.
1. Run `make compile_translations`, this will generate the `text.mo` file.
1. Create a pull request with your changes.