Skip to content

Commit

Permalink
h5p plugin content types export
Browse files Browse the repository at this point in the history
  • Loading branch information
mi7chal committed Sep 2, 2024
1 parent 869c41d commit f1df84c
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Moosh/Command/Moodle41/H5pCore/H5pCoreContentTypesExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@


/**
* Exports content types from H5p core to file in csv format.
* Exports content types from H5p core to file in csv format. In fact content type in H5p is just
* a runnable library. Be aware that H5p Plugin libraries are stored separately from H5p Core libraries.
* moosh hp5-core-contenttypes-export [-n, --name]
*
* @example 1: Export content types with default filename (h5p-core-contenttypes-export.csv).
Expand Down
3 changes: 2 additions & 1 deletion Moosh/Command/Moodle41/H5pCore/H5pCoreLibrariesExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
use Moosh\MooshCommand;

/**
* Exports libraries from H5p to file in csv format.
* Exports libraries from H5p to file in csv format. In fact content type in H5p is just
* a runnable library. Be aware that H5p Plugin libraries are stored separately from H5p Core libraries.
* moosh hp5-core-libraries-export [-n, --name]
*
* @example 1: Export libraries with default filename (h5p-core-libraries-export.csv).
Expand Down
49 changes: 49 additions & 0 deletions Moosh/Command/Moodle41/H5pPlugin/H5pPluginContentTypesExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* moosh - Moodle Shell
*
* @copyright 2012 onwards Tomasz Muras
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace Moosh\Command\Moodle41\H5pPlugin;
use Moosh\MooshCommand;

/**
* Exports libraries or content types from H5p to file in csv format. In fact content type in H5p is just
* a runnable library. Be aware that H5p Plugin libraries are stored separately from H5p Core libraries.
* H5p core libraries.
* moosh hp5-plugin-contenttypes-export [-n, --name]
*
* @example 1: Export content types with default filename (h5p-core-contenttypes-export.csv).
* moosh hp5-plugin-contenttypes-export
*
* @example 2: Export content types to with custom filename: "my-custom-file.csv"
* moosh hp5-plugin-contenttypes-export -n my-custom-file
*
* @example 3: Export content types to txt file (using csv format)
* moosh hp5-plugin-contenttypes-export -n my-custom-txt-file.txt
*
* @author Michal Chruscielski <[email protected]>
*/
class H5pPluginContentTypesExport extends MooshCommand
{
public function __construct()
{
parent::__construct('contenttypes-export', 'h5p-plugin');

$this->addOption('n|name:', 'name of exported csv file', "h5p-plugin-contenttypes-export.csv");
}

public function execute()
{
$filename = $this->expandedOptions['name'];

$manager = new H5pPluginExportManager();
$manager->exportContentTypes($filename, $this->verbose);

if($this->verbose) {
mtrace("Content types export successful.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
use Moosh\MooshCommand;

/**
* Exports libraries from H5p to file in csv format.
* Exports libraries from H5p to file in csv format. In fact content type in H5p is just
* a runnable library. Be aware that H5p Plugin libraries are stored separately from H5p Core libraries.
* moosh hp5-plugin-libraries-export [-n, --name]
*
* @example 1: Export libraries with default filename (h5p-core-libraries-export.csv).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private function export($filename, $verbose, $runnable){
}

if(!class_exists(framework::class)) {
cli_error("H5p factory class cannot be loaded.");
cli_error("H5p factory class cannot be loaded. Check if H5p plugin is properly installed and configured.");
}

// Using factory object instead of fetching from database. It provides actual data fetching,
Expand Down
36 changes: 32 additions & 4 deletions www/commands/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,8 @@ Example:

h5p-core-contenttypes-export
----
Exports libraries from H5p core to file in csv format.
Exports libraries from H5p core to file in csv format. Be aware that H5p Core libraries are stored separately
from H5p Plugin libraries.

Available options:

Expand All @@ -1737,7 +1738,8 @@ Example 3: Export content types to txt file (using csv format)

h5p-core-libraries-export
----
Exports content types from H5p core to file in csv format.
Exports content types from H5p core to file in csv format. Be aware that H5p Core libraries are stored separately
from H5p Plugin libraries.

Available options:

Expand All @@ -1760,8 +1762,9 @@ Example 3: Export content types to txt file (using csv format)

h5p-plugin-libraries-export
----
Exports libraries from H5p plugin to file in csv format. In H5p plugin content types and libraries
are treated as one data type.
Exports libraries from H5p plugin to file in csv format. In fact H5p content types
are just libraries that are marked as runnable. Be aware that H5p Plugin libraries are stored separately
from H5p Core libraries.

Available options:

Expand All @@ -1782,6 +1785,31 @@ Example 3: Export libraries to txt file (using csv format)

moosh h5p-plugin-libraries-export -n my-custom-txt-file.txt

h5p-plugin-contenttypes-export
----
Exports content types from H5p plugin to file in csv format. In fact H5p content types
are just libraries that are marked as runnable. Be aware that H5p Plugin libraries are stored separately
from H5p Core libraries.

Available options:

| Option | Description |
|------------|---------------------------|
| -n, --name | Defines target file name. |


Example 1: Export content types types

moosh h5p-plugin-contenttypes-export

Example 2: Export content types with custom filename "my-custom-file.csv"

moosh h5p-plugin-contenttypes-export -n my-custom-file

Example 3: Export content types to txt file (using csv format)

moosh h5p-plugin-contenttypes-export -n my-custom-txt-file.txt


info
----
Expand Down

0 comments on commit f1df84c

Please sign in to comment.