Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,24 @@ export-elp-epub3:
export-elp-ims:
@$(MAKE) export-elp FORMAT=ims INPUT="$(INPUT)" OUTPUT="$(OUTPUT)" DEBUG="$(DEBUG)" BASE_URL="$(BASE_URL)"

export-elp-h5p:
ifndef INPUT
$(error INPUT is required. Use INPUT=/absolute/path/to/file.elp)
endif
ifndef OUTPUT
$(error OUTPUT is required. Use OUTPUT=/absolute/path/to/output.h5p)
endif
$(eval EXPANDED_INPUT := $(call EXPAND_PATH,$(INPUT)))
@if [ ! -f "$(EXPANDED_INPUT)" ]; then \
echo "❌ INPUT file does not exist: $(EXPANDED_INPUT)"; \
exit 1; \
fi
@mkdir -p $(dir $(OUTPUT))
$(eval TMP_DIR := $(OUTPUT).tmpdir)
@$(MAKE) export-elp FORMAT=h5p INPUT="$(EXPANDED_INPUT)" OUTPUT="$(TMP_DIR)" DEBUG="$(DEBUG)" BASE_URL="$(BASE_URL)"
@mv "$(TMP_DIR)"/*.h5p "$(OUTPUT)"
@rm -rf "$(TMP_DIR)"


# Install nativephp/php-bin package temporarily without modifying composer.json
install-php-bin:
Expand Down Expand Up @@ -388,6 +406,7 @@ help:
@echo " export-elp-scorm2004 - Export .elp to SCORM 2004 format (alias for FORMAT=scorm2004)"
@echo " export-elp-ims - Export .elp to IMS format (alias for FORMAT=ims)"
@echo " export-elp-epub3 - Export .elp to EPUB 3 format (alias for FORMAT=epub3)"
@echo " export-elp-h5p - Export .elp to H5P (experimental) format (alias for FORMAT=h5p)"
@echo " export-elp-elp - Re-export .elp file (alias for FORMAT=elp)"
@echo ""
@echo "Data:"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This version is built with modern technologies (PHP 8, Symfony 7) and provides a
* Creation and edition of interactive educational content
* Multiple iDevices (interactive elements)
* Multilingual support
* Exportation to various formats
* Exportation to multiple formats (SCORM, IMS, EPUB, HTML and H5P)
* Moodle integration
* Real-time collaborative features powered by [Mercure](https://mercure.rocks/)
* Modern and accessible interface built with [Bootstrap](https://getbootstrap.com/)
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^3.0",
"firebase/php-jwt": "^6.10",
"h5p/h5p-core": "^1.27",
"league/flysystem": "^1.0",
"league/flysystem-ziparchive": "^1.0",
"liip/imagine-bundle": "^2.8",
Expand Down
67 changes: 64 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions doc/03-development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,20 @@ The project provides a Makefile to simplify common tasks:
| `make test` | Run unit tests |
| `make lint` | Check PHP code style |
| `make fix` | Automatically fix code style issues |
| `make update` | Update Composer dependencies |
| `make translations` | Update translation files |

### Installing `make`
| `make update` | Update Composer dependencies |
| `make translations` | Update translation files |

### Exporting Content

Use the Makefile to generate packages from `.elp` projects. For example, to create an experimental H5P package:

```bash
make export-elp-h5p INPUT=/path/project.elp OUTPUT=/path/project.h5p
```

Other formats can be exported by replacing `h5p` with `html5`, `scorm12`, `scorm2004`, `ims`, or `epub3`.

### Installing `make`

On Linux, `make` is usually pre-installed. On Windows, install it with:

Expand Down
46 changes: 46 additions & 0 deletions public/app/workarea/menus/navbar/items/navbarFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export default class NavbarFile {
this.exportEPUB3Button = this.menu.navbar.querySelector(
'#navbar-button-export-epub3',
);
this.exportH5PButton = this.menu.navbar.querySelector(
'#navbar-button-export-h5p',
);
this.exportXmlPropertiesButton = this.menu.navbar.querySelector(
'#navbar-button-export-xml-properties',
);
Expand Down Expand Up @@ -79,6 +82,7 @@ export default class NavbarFile {
this.setExportSCORM2004Event();
this.setExportIMSEvent();
this.setExportEPUB3Event();
this.setExportH5PEvent();
this.setExportXmlPropertiesEvent();
this.setImportXmlPropertiesEvent();
this.setLeftPanelsTogglerEvents();
Expand Down Expand Up @@ -274,6 +278,13 @@ export default class NavbarFile {
});
}

setExportH5PEvent() {
this.exportH5PButton.addEventListener('click', () => {
if (eXeLearning.app.project.checkOpenIdevice()) return;
this.exportH5PEvent();
});
}

/**
* Download the project to ePub3
* File -> Export as -> Xml properties
Expand Down Expand Up @@ -1086,6 +1097,41 @@ export default class NavbarFile {
eXeLearning.app.interface.connectionTime.loadLasUpdatedInInterface();
}

async exportH5PEvent() {
let toastData = {
title: _('Export'),
body: _('Generating export files...'),
icon: 'downloading',
};
let toast = eXeLearning.app.toasts.createToast(toastData);
let odeSessionId = eXeLearning.app.project.odeSession;
let response = await eXeLearning.app.api.getOdeExportDownload(
odeSessionId,
'h5p',
);
if (response['responseMessage'] == 'OK') {
this.downloadLink(
response['urlZipFile'],
response['exportProjectName'],
);
toast.toastBody.innerHTML = _('The project has been exported.');
} else {
toast.toastBody.innerHTML = _('An error occurred while exporting the project.');
toast.toastBody.classList.add('error');
eXeLearning.app.modals.alert.show({
title: _('Error'),
body: response['responseMessage'] ? response['responseMessage'] : _('Unknown error.'),
contentId: 'error',
});
}

setTimeout(() => {
toast.remove();
}, 1000);

eXeLearning.app.interface.connectionTime.loadLasUpdatedInInterface();
}

/**
* Export the properties as xml and download it
*
Expand Down
3 changes: 2 additions & 1 deletion src/Command/net/exelearning/Command/ElpExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function configure(): void
$this
->addArgument('input', InputArgument::REQUIRED, 'Input ELP file path (use "-" for stdin)')
->addArgument('output', InputArgument::REQUIRED, 'Output directory')
->addArgument('format', InputArgument::OPTIONAL, 'Export format (elp, html5, html5-sp, scorm12, scorm2004, ims, epub3)', $this->defaultFormat)
->addArgument('format', InputArgument::OPTIONAL, 'Export format (elp, html5, html5-sp, scorm12, scorm2004, ims, epub3, h5p)', $this->defaultFormat)
->addOption('debug', 'd', InputOption::VALUE_NONE, 'Enable debug mode')
->addOption('base-url', 'b', InputOption::VALUE_OPTIONAL, 'Base URL for links', false);
}
Expand All @@ -63,6 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
Constants::EXPORT_TYPE_SCORM2004,
Constants::EXPORT_TYPE_IMS,
Constants::EXPORT_TYPE_EPUB3,
Constants::EXPORT_TYPE_H5P,
];

if (!in_array($format, $validFormats, true)) {
Expand Down
15 changes: 15 additions & 0 deletions src/Command/net/exelearning/Command/ElpExportH5pCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Command\net\exelearning\Command;

use App\Constants;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(
name: 'elp:export-h5p',
description: 'Export ELP to H5P format',
)]
class ElpExportH5pCommand extends ElpExportCommand
{
protected string $defaultFormat = Constants::EXPORT_TYPE_H5P;
}
3 changes: 3 additions & 0 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ class Constants
public const EXPORT_TYPE_SCORM2004 = 'scorm2004';
public const EXPORT_TYPE_IMS = 'ims';
public const EXPORT_TYPE_EPUB3 = 'epub3';
public const EXPORT_TYPE_H5P = 'h5p';

// Export types filename suffixes
public const SUFFIX_TYPE_HTML5 = '_web';
public const SUFFIX_TYPE_HTML5_SP = '_page';
public const SUFFIX_TYPE_SCORM12 = '_scorm';
public const SUFFIX_TYPE_SCORM2004 = '_scorm2004';
public const SUFFIX_TYPE_IMS = '_ims';
public const SUFFIX_TYPE_H5P = '_h5p';

// Export files
public const EXPORT_FILE_INDEX_NAME = 'index';
Expand Down Expand Up @@ -225,6 +227,7 @@ class Constants
public const FILE_EXTENSION_ELP = 'elp';
public const FILE_EXTENSION_ZIP = 'zip';
public const FILE_EXTENSION_EPUB = 'epub';
public const FILE_EXTENSION_H5P = 'h5p';
public const FILE_EXTENSION_XML = 'xml';

// CSV separator
Expand Down
Loading
Loading