102 Commits

Author SHA1 Message Date
Paul Holden
aa8f7a6a39
MDL-82669 editor: remove reliance on Atto editor in Behat scenarios. 2024-08-02 10:33:34 +01:00
Paul Holden
f1bc96a8ab
MDL-82527 h5p: improve editor Behat scenarios for embedding content.
* Move the shared drag fixture out of the Atto plugin;
* Switch to using faster generators for populating private files;
* Clarify required fields for private files generator
2024-07-18 09:37:47 +01:00
Laurent David
f78c93e325 MDL-77665 mod_h5pactivity: Improve generator package upload
* Allow the specification of the username in order to set the owner
of the H5P file package when creating a new H5P instance.
2024-06-17 06:32:13 +02:00
Laurent David
941c866216 MDL-77665 core_h5p: Allow deployment if user has been deleted
* If user has been deleted we consider that the content can be deployed
by a user who can deploy other packages
* Add behat test to cover for this use case
* Fix the content bank generator as it was failing to upload the content
as the given user
2024-06-17 06:32:13 +02:00
Eloy Lafuente (stronk7)
1093256560
MDL-81522 phpunit: Add missing void return type to all tests
While this change is not 100% required now, it's good habit
and we are checking for it since Moodle 4.4.

All the changes in this commit have been applied automatically
using the moodle.PHPUnit.TestReturnType sniff and are, exclusively
adding the ": void" return types when missing.
2024-06-11 12:18:04 +02:00
Eloy Lafuente (stronk7)
361dfe8145
MDL-75952 general: Since php81, refection->setAccessible() is no-op
Refereces:
- https://wiki.php.net/rfc/make-reflection-setaccessible-no-op
- https://www.php.net/manual/en/reflectionproperty.setaccessible.php
- https://www.php.net/manual/en/reflectionmethod.setaccessible.php

As of PHP 8.1.0, calling this method has no effect; all methods are
invokable by default. So, let's remove all uses from core, they are
no-op.
2024-03-10 21:15:00 +01:00
Gareth Barnard
270326244b
MDL-79802 core_h5p: Add a new setting for adding custom H5P styles. 2024-02-20 18:12:18 +00:00
Paul Holden
0045a58326
MDL-80653 h5p: handle content type creation errors in test.
See also same in c7d08f85.
2024-01-22 09:46:04 +00:00
Sara Arjona
cb4d9cdcb6
MDL-74129 h5p: Preserve metadata information
The metadata information was not restored when an H5P file was uploaded
(it was saved when it was edited directly from the Content bank, but the
original information in the H5P file was lost).
This patch includes all the metadata fields and its values in the original
H5P file to preserve this information too.
2023-11-10 10:33:06 +01:00
Paul Holden
c7d08f855e
MDL-79291 h5p: handle content type creation errors in test generator.
If the endpoint is temporarily down and/or misbehaving, then at least
we'll a clearer failure message.
2023-09-07 15:38:45 +01:00
Amaia Anabitarte
0d11cf1bc9 MDL-78183 core_contentbank: Improve error handling 2023-07-07 12:21:24 +02:00
Meirza
1c2a86c335 MDL-78147 h5p: Added class properties that are not declared
In PHP 8.2 and later, setting a value to an undeclared class property is
deprecated and emits a deprecation notice.
So we need to add missing class properties that still need to be declared.
2023-06-07 05:16:57 +07:00
Ilya Tregubov
34d7edf079 Merge branch 'MDL-77916' of https://github.com/paulholden/moodle 2023-04-18 14:27:49 +08:00
Paul Holden
62d48a1d47
MDL-77916 h5p: register autoloader in helper testcase. 2023-04-13 23:12:13 +01:00
Petr Skoda
43b56a90d9 MDL-76859 h5p: Fix behat failures
- Only resize if the H5P EmbedCommunicator is defined (otherwise, it was causing a
JS error)
- An unnecessary image has been removed from the greeting-card.h5p fixture package.
That way, the text will always be displayed (even if the iframe is still not
resized). Instead of replacing the original greeting-card-887.h5p file, I've
renamed it to greeting-card.h5p, to remove these ugly and unnecessary numbers
at the end of the file name).
2023-04-12 12:26:23 +02:00
Sara Arjona
bd0a6e6dcc MDL-67789 h5p: Save current state using xAPI State
Co-author: Andrew Lyons <andrew@moodle.com>
2023-03-15 09:42:18 +01:00
Sara Arjona
ca37dd3baf MDL-76691 core_h5p: Add core lib changes after upgrading it
Apart from applying the points described in readme_moodle.txt, the following
changes have been done too:

- The parameter $folderName from the method libraryToString() have been removed
and a new method, libraryToFolderName() has been added to the H5PCore API.
References to libraryToString() with the $folderName set to true have been
replaced to the new method.
- missing-main-library has been added and replaces in some cases to
missing-required-library.
- The framework saveLibraryData method must be called before saveLibrary
(h5p.classes.php file has been patched to leave the original order because
libraryid is required to save the itemid).
- The getLibraryId() method from H5PCore has been rewritten to use MUC, in
order to avoid PHPUnit failures.
2023-02-06 16:48:07 +01:00
Jun Pataleta
fad05d7929 Merge branch 'MDL-76583-master-withoutrename' of https://github.com/andrewnicols/moodle 2023-01-19 09:44:48 +08:00
Andrew Nicols
a3cc26f8bb MDL-76583 core: Update uses of external_* classes 2023-01-19 07:34:09 +08:00
Paul Holden
af8da7c737 MDL-70070 phpunit: correct data provider method names.
They should not be prefixed `test_` because that's how actual
test methods containing assertions are identified by PHPUnit.
2023-01-16 08:28:37 +00:00
Marina Glancy
594a8c5ab7 MDL-76356 various: avoid implicit conversion to arrays
PHP before version 8.1 automatically converted stdClass or 'false' to arrays if
function parameter expects array (for example, "reset").
PHP 8.1 shows notices in these situations
2023-01-10 12:16:52 +01:00
Amaia Anabitarte
2d1883c92e MDL-76004 core_h5p: Ensure the browser is serving updated file 2022-12-14 16:02:44 +01:00
Eloy Lafuente (stronk7)
0ed53be9b2 MDL-66902 tests: Fix all incorrect namespaces
This issue just goes over all the currently incorrect
namespaces in test cases and:

1. Change the namespace to the correct one.
2. Move/rename it to correct location if needed (level 2 and down).
3. Remove not needed MOODLE_INTERNAL check when possible.
4. Remove file phpdoc when the file only has one class.
5. Make small adjustments in case the change of namespace requires it.
2022-09-26 14:12:16 +02:00
Eloy Lafuente (stronk7)
caf55abf17 MDL-74413 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- Moved to the level2 "privacy" namespace:
  - \mod_assign\privacy\feedback_legacy_polyfill_test
  - \mod_assign\privacy\submission_legacy_polyfill_test

- Moved to the level2 "task" namespace:
  - \core_message\task\migrate_message_data_test
  - \ltiservice_gradebookservices\task\cleanup_test
  - \message_email\task\send_email_test
  - \mod_lti\task\clean_access_tokens_test
  - \mod_workshop\task\cron_task_test

- Moved to the level2 "event" namespace:
  - \core_h5p\event\deleted_test
  - \core_h5p\event\viewed_test

- Renamed to a better name:
  - backup_forum_activity_task_test.php (missing "task")
2022-05-07 20:32:30 +02:00
Paul Holden
4102ae35a4 MDL-74283 dml: replace hardcoded concat SQL with appropriate API. 2022-03-22 17:33:03 +00:00
Eloy Lafuente (stronk7)
0c53a3dec8 MDL-73476 phpunit: events, external and search tescase names
All events_test, external_test and search_test classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to lib/external/tests/external_test.php:
- external is not a valid component
- hence, its only valid namespace is "core"
- also, it's testing lib/external/externallib.php
- hence, the file (and class) have been renamed to external_externallib_test.php
  (to avoid conflicts with other external_test that may exist in core)
2022-01-14 16:18:39 +01:00
Andrew Nicols
3a70983d53 MDL-72701 unit tests: Generate default coverage 2021-12-21 09:24:00 +08:00
Eloy Lafuente (stronk7)
deb0e76eee MDL-73278 phpunit: Rename already namespaced classes to match file name
These are the only cases 100% safe to apply the renaming of the
testcase class names to match the file names.

All other cases are not safe, because they are missing namespace
and may enter into name conflicts. Adding namespaces is not as
simple as imagined because it implies to, also, add a good number
of modifications to core. See the issue for more details.
2021-12-07 23:54:29 +01:00
Sara Arjona
eb4e36400e MDL-71956 core_h5p: Add more scenarios to can_edit_content
The method can_edit_content() now supports more scenarios where the
H5P content can be edited:
- Instead of supporting only mod_h5pactivity, now it supports any
mod or block when the user has the addinstance capability.
- If the component implements the can_edit_content method in the
h5p\canedit class and it returns true. For instance, the mod_forum
implements it and return true when filearea is post, if the user
can edit the post where the H5P is.
2021-11-09 16:47:18 +01:00
Sara Arjona
f47a327290 MDL-71970 h5plib_v124: Replace references to new Moodle\H5Pxxx namespace
The joubel/core and joubel/editor libraries have been moved to Moodle
namespace.
This commit adds the new namespace to the places where these classes
are used.
Besides, a couple of minor changes have been done to replace the _test.php
classname and remove some unnecessary defined('MOODLE_INTERNAL').
2021-09-27 11:41:48 +02:00
Sara Arjona
13de79c66f MDL-71885 core_h5p: Add new methods to API 2021-07-05 10:56:13 +02:00
Andrew Nicols
4ff86720bf MDL-71343 core_h5p: Add unit test for helper::parse_js_array
Signed-off-by: Rajneel Totaram <rjnlfj@yahoo.com>
2021-05-01 00:09:40 +12:00
Sara Arjona
39fa45e299 MDL-69331 core_contentbank: Hide disabled H5P content-types
If a H5P content-type is disabled:
- The content bank won't display existing contents having it as a
main library.
- The content bank won't allow to create new contents using it.
2021-04-15 09:16:32 +02:00
Sara Arjona
5308ba0947 MDL-69331 core_h5p: Display error when main library is disabled
H5P contents with the main library disabled won't be deployed; a
message error will be displayed instead of.
2021-04-15 09:03:56 +02:00
Sara Arjona
d3d3b3bdc0 MDL-69331 core_h5p: Add enabled field to libraries
The "enabled" field has been added to the H5P libraries to let
admins decide whether a library should be used or not in the site.
2021-04-15 09:03:56 +02:00
Eloy Lafuente (stronk7)
9fd6ac7c9d MDL-71036 phpunit: xml config - switch coverage info to new includes
This applies the "whitelist" => "include" changes to all the core
phpunit_coverage_info occurrences, so core won't emit any deprecation
warning (see previous commit).

At the same time, modified a bunch of comments in coverage files
to be more readable/understandable.
2021-03-11 23:04:32 +01:00
Eloy Lafuente (stronk7)
40de097e65 MDL-67673 phpunit: Remove deprecated assertContains() uses on strings
Both assertContains() and assertNotContains() are deprecated in PHPUnit 8
for operations on strings. Also the optional case parameter is. All uses
must be changed to one of:

- assertStringContainsString()
- assertStringContainsStringIgnoringCase()
- assertStringNotContainsString()
- assertStringNotContainsStringIgnoringCase()

More info: https://github.com/sebastianbergmann/phpunit/issues/3422

Regexp to find all uses:

ag 'assert(Not)?Contains\('
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
f6711bb394 MDL-67673 phpunit: Fix the return type of template methods
All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.

At the same time, fix a few wrong function names,
provider data and param types, return statements...
2020-10-21 12:45:59 +02:00
Jun Pataleta
8252b24f95 Merge branch 'MDL-69520-master' of git://github.com/sarjona/moodle 2020-10-15 13:53:26 +08:00
Sara Arjona
0c69575cc4 MDL-69520 core_h5p: unit tests for covering example and tutorial 2020-10-14 17:47:48 +02:00
Paul Holden
27f8784204 MDL-69813 h5p: fix undefined addon ordering in framework test. 2020-10-06 10:45:21 +01:00
Sara Arjona
c68897b7e6 MDL-69087 core_h5p: add renderer to let personalize styles
Existing mod_hvp pluging has a renderer to let Moodle instances
alter styles, Javascript, semantics (fields in the editor) and
content: https://github.com/h5p/moodle-mod_hvp/blob/stable/renderer.php

The approach for core_h5p is exactly the same, to let people
to reuse their existing code.
2020-09-24 19:56:12 +02:00
Sara Arjona
67a11150de MDL-68909 h5p: move temporary editor files to draft area 2020-09-10 13:42:16 +02:00
Victor Deniz Falcon
9aa9efbfda MDL-68921 core_h5p: Add H5P libraries metadata settings 2020-08-25 00:48:02 +01:00
Ferran Recio
4b6e92b8e9 MDL-68902 core_h5p: add essay h5p package 2020-06-09 16:58:17 +02:00
Víctor Déniz Falcón
88036713a5 MDL-68641 core_h5p: test dropped because the tested method was deleted 2020-06-04 19:27:59 +01:00
cescobedo
14b463c92a MDL-68448 core_h5p: Add get export information to helper
Create a new method in the helper to use in the player,
in the external WS and in the API. Also, add a
new method in API to help to get export information
by other WS.
2020-05-25 09:12:06 +02:00
Sara Arjona
a42a9ad997 MDL-68227 core_h5p: localize H5P editor strings
H5P editor has a folder with all supported languages in JS files.
A mechanish has been added to let users to translate them using AMOS.
That's how the translations are managed (the order how they are processed):

- If there a JS file for a language, it's loaded.
- If a string has been translated in Moodle (they are placed in
h5plib_vXXX), it will override strings loaded from the JS file.
2020-05-12 16:39:42 +02:00
Sara Arjona
36a3a259de Merge branch 'MDL-68571-master' of git://github.com/cescobedo/moodle 2020-05-11 16:52:48 +02:00
cescobedo
444b2282f1 MDL-68571 core_h5p: Return default handler if no it has been defined 2020-05-11 16:46:27 +02:00