1 |
efrain |
1 |
H5P PHP library
|
|
|
2 |
---------------
|
|
|
3 |
|
|
|
4 |
Downloaded last release from: https://github.com/h5p/h5p-php-library/tags
|
|
|
5 |
|
|
|
6 |
When no new tags are released, a specific commit can also be used. In that case, the version number used in the thirdpartylibs.xml
|
|
|
7 |
will be <branch name>-<commit hash>. For instance, master-f3579c0.
|
|
|
8 |
|
|
|
9 |
Import procedure:
|
|
|
10 |
* Remove the content in this folder (but the readme_moodle.txt)
|
|
|
11 |
* Copy all the files from the folder repository in this directory.
|
|
|
12 |
|
|
|
13 |
Removed:
|
|
|
14 |
* composer.json
|
|
|
15 |
* .gitignore
|
|
|
16 |
* .travis.yml
|
|
|
17 |
|
|
|
18 |
Changed:
|
|
|
19 |
0. Open the new version of joubel/core/h5p.classes.php and at the beginning of the H5PCore class (around line 2082), check the
|
|
|
20 |
value of the coreApi minor and major versions. If they are different from the values in the current Moodle version, instead of
|
|
|
21 |
upgrading the library in the current h5plib_vxxx, a new h5plib_vX.Y should be released (as it was done in MDL-80544). The new
|
|
|
22 |
h5plib module should be named taking into account that X is the coreApi.majorVersion and Y is the coreApi.minorVersion.
|
|
|
23 |
|
|
|
24 |
1. Replace the $_SESSION references with $SESSION. That implies that the information is saved to backends, so only the Moodle one
|
|
|
25 |
should be used by core (core should be free from $_SESSION and always use $SESSION).
|
|
|
26 |
More specifically, in h5p.classes.php file, into hashToken() method:
|
|
|
27 |
* Declare the global $SESSION.
|
|
|
28 |
* Change all the $_SESSION by $SESSION.
|
|
|
29 |
* Change all the $_SESSION['xxxx'] by $SESSION->xxxx.
|
|
|
30 |
A script for testing this part can be found in MDL-68068
|
|
|
31 |
|
|
|
32 |
2. Add namespace to this library to avoid collision. It means:
|
|
|
33 |
- Add the "namespace Moodle;" line at the top of all the h5p*.php files in the root folder.
|
|
|
34 |
- Replace \H5Pxxx uses to H5Pxxx (for instance, in h5p-default-storage.class.php there are several references to \H5PCore that
|
|
|
35 |
must be replaced with H5PCore).
|
|
|
36 |
- Add "use ZipArchive;" in h5p.classes.h5p (check that it's still used before replacing it when upgrading the library).
|
|
|
37 |
|
|
|
38 |
3. Check if there are changes in the getLocalization() method in h5p.classes.php and update lang/en/h5p.php accordingly.
|
|
|
39 |
If there are changes, check the t() method in h5p/classes/framework.php too (updating or adding new ones).
|
|
|
40 |
|
|
|
41 |
4. In saveLibraries() method in core/h5p.classes.php, check $this->h5pF->saveLibraryData is called before $this->h5pC->fs->saveLibrary.
|
|
|
42 |
The library needs to be saved in the database first before creating the files, because the libraryid is used as itemid for the files.
|
|
|
43 |
|
|
|
44 |
5. Check if new methods have been added to any of the interfaces. If that's the case, implement them in the proper class. For
|
|
|
45 |
instance, if a new method is added to h5p-file-storage.interface.php, it should be implemented in h5p/classes/file_storage.php.
|
|
|
46 |
|
|
|
47 |
6. Open js/h5p.js and in function contentUserDataAjax() add the following patch:
|
|
|
48 |
function contentUserDataAjax(contentId, dataType, subContentId, done, data, preload, invalidate, async) {
|
|
|
49 |
if (H5PIntegration.user === undefined) {
|
|
|
50 |
// Not logged in, no use in saving.
|
|
|
51 |
done('Not signed in.');
|
|
|
52 |
return;
|
|
|
53 |
}
|
|
|
54 |
// Moodle patch to let override this method.
|
|
|
55 |
if (H5P.contentUserDataAjax !== undefined) {
|
|
|
56 |
return H5P.contentUserDataAjax(contentId, dataType, subContentId, done, data, preload, invalidate, async);
|
|
|
57 |
}
|
|
|
58 |
// End of Moodle patch.
|
|
|
59 |
|
|
|
60 |
var options = {
|