From 9a497e72c573b59181832ae783740653ee04fe34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 27 Mar 2024 12:45:22 +0100 Subject: [PATCH 01/11] Get the newest library version --- src/Repositories/H5PContentRepository.php | 4 ++-- src/Repositories/H5PEditorStorageRepository.php | 4 ++-- src/Repositories/H5PRepository.php | 5 +++-- src/Services/HeadlessH5PService.php | 17 ++++++++++++++++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Repositories/H5PContentRepository.php b/src/Repositories/H5PContentRepository.php index 7feb8cd5..535a3e98 100644 --- a/src/Repositories/H5PContentRepository.php +++ b/src/Repositories/H5PContentRepository.php @@ -39,7 +39,7 @@ public function create(string $library, string $params, string $nonce): int ['name', $libNames['machineName']], ['major_version', $libNames['majorVersion']], ['minor_version', $libNames['minorVersion']], - ])->first(); + ])->latest()->first(); if ($libDb === null) { throw new H5PException(H5PException::LIBRARY_NOT_FOUND); @@ -74,7 +74,7 @@ public function edit(int $id, string $library, string $params, string $nonce): i ['name', $libNames['machineName']], ['major_version', $libNames['majorVersion']], ['minor_version', $libNames['minorVersion']], - ])->first(); + ])->latest()->first(); if ($libDb === null) { throw new H5PException(H5PException::LIBRARY_NOT_FOUND); diff --git a/src/Repositories/H5PEditorStorageRepository.php b/src/Repositories/H5PEditorStorageRepository.php index dff19cfa..89b87dce 100644 --- a/src/Repositories/H5PEditorStorageRepository.php +++ b/src/Repositories/H5PEditorStorageRepository.php @@ -45,7 +45,7 @@ public function getLanguage($machineName, $majorVersion, $minorVersion, $languag ['major_version', $majorVersion], ['minor_version', $minorVersion], ['name', $machineName], - ])->first(); + ])->latest()->first(); if ($library) { $libraryLanguage = H5PLibraryLanguage::where([ @@ -121,7 +121,7 @@ public function getLibraries($libraries = null) ['name', $library->name], ['major_version', $library->majorVersion], ['minor_version', $library->minorVersion] - ])->first()) + ])->latest()->first()) ->reject(fn($library) => !$library) ->values() ->all(); diff --git a/src/Repositories/H5PRepository.php b/src/Repositories/H5PRepository.php index 39dcf41e..c3c5f1b1 100644 --- a/src/Repositories/H5PRepository.php +++ b/src/Repositories/H5PRepository.php @@ -675,7 +675,7 @@ public function saveLibraryDependencies($libraryId, $dependencies, $dependency_t 'name' => $dependency['machineName'], 'major_version' => $dependency['majorVersion'], 'minor_version' => $dependency['minorVersion'], - ])->firstOrFail(); + ])->latest()->firstOrFail(); H5PLibraryDependency::firstOrCreate([ 'library_id' => $libraryId, @@ -860,7 +860,7 @@ public function loadLibrary($machineName, $majorVersion, $minorVersion) 'minor_version' => $minorVersion, ]) ->with('dependencies.requiredLibrary') - ->first(); + ->latest()->first(); if (is_null($library)) { return; @@ -899,6 +899,7 @@ public function loadLibrarySemantics($machineName, $majorVersion, $minorVersion) $library = H5PLibrary::where('name', $machineName) ->where('major_version', $majorVersion) ->where('minor_version', $minorVersion) + ->latest() ->first(); $semanticsFile = $this->getSemanticsFromFile($machineName, $majorVersion, $minorVersion); diff --git a/src/Services/HeadlessH5PService.php b/src/Services/HeadlessH5PService.php index 91b0aee4..c980295d 100644 --- a/src/Services/HeadlessH5PService.php +++ b/src/Services/HeadlessH5PService.php @@ -170,11 +170,26 @@ public function getConfig(): array /** * Calls editor ajax actions. */ - public function getLibraries(string $machineName = null, string $major_version = null, string $minor_version = null) + public function getLibraries(string $machineName = null, string $major_version = null, string $minor_version = null, int $library_id = null) { $lang = config('hh5p.language'); $libraries_url = url(config('hh5p.h5p_library_url')); + if ($library_id) { + $library = H5PLibrary::findOrFail($library_id); + + if (in_array($library->name, array('H5P.Questionnaire', 'H5P.FreeTextQuestion')) && + !$this->h5p->h5pF->getOption('enable_lrs_content_types')) { + $library->restricted = TRUE; + } + $this->addMoreHtmlTags($library->semantics); + $library + ->append('contentsCount') + ->append('requiredLibrariesCount'); + + return collect([$library]); + } + if ($machineName) { $defaultLang = $this->getEditor()->getLibraryLanguage($machineName, $major_version, $minor_version, $lang); $data = $this->getEditor()->getLibraryData($machineName, $major_version, $minor_version, $lang, '', $libraries_url, $defaultLang); From a5033df27ac2e644c91d1366c4f5710b2014050e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 27 Mar 2024 13:03:49 +0100 Subject: [PATCH 02/11] Added tests --- src/Http/Controllers/LibraryApiController.php | 3 +- tests/Api/LibraryApiTest.php | 62 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/Http/Controllers/LibraryApiController.php b/src/Http/Controllers/LibraryApiController.php index 0228bac0..caad9dad 100644 --- a/src/Http/Controllers/LibraryApiController.php +++ b/src/Http/Controllers/LibraryApiController.php @@ -49,7 +49,8 @@ public function libraries(LibraryListRequest $request): JsonResponse $libraries = $this->hh5pService->getLibraries( $request->get('machineName'), $request->get('majorVersion'), - $request->get('minorVersion') + $request->get('minorVersion'), + $request->get('library_id') ); return response()->json($libraries); diff --git a/tests/Api/LibraryApiTest.php b/tests/Api/LibraryApiTest.php index 0408c701..9ace04b4 100644 --- a/tests/Api/LibraryApiTest.php +++ b/tests/Api/LibraryApiTest.php @@ -240,6 +240,68 @@ public function testGetLibrariesAdmin(): void $this->assertEquals(7, current(array_filter($data, fn($item) => $item->id === $lib2->getKey()))->requiredLibrariesCount); } + public function testGetLibraryById(): void + { + $libraryName = 'DragTheWord'; + + $lib1 = H5PLibrary::factory()->create(['name' => $libraryName, 'patch_version' => 1]); + $lib2 = H5PLibrary::factory()->create(['name' => $libraryName, 'patch_version' => 2]); + H5PLibraryDependency::factory()->count(3)->create(['required_library_id' => $lib1->getKey()]); + H5PLibraryDependency::factory()->count(7)->create(['required_library_id' => $lib2->getKey()]); + H5PContent::factory()->count(2)->create(['library_id' => $lib1->getKey()]); + H5PContent::factory()->count(5)->create(['library_id' => $lib2->getKey()]); + + $this + ->actingAs($this->user, 'api') + ->json('GET', 'api/admin/hh5p/libraries', ['machnieName' => $libraryName, 'majorVersion' => 1, 'minorVersion' => 1]) + ->assertOk() + ->assertJsonFragment([ + 'id' => $lib1->getKey(), + 'patch_version' => 1, + ]); + + $this + ->actingAs($this->user, 'api') + ->json('GET', 'api/admin/hh5p/libraries', ['library_id' => $lib2->getKey()]) + ->assertOk() + ->assertJsonFragment([ + 'id' => $lib2->getKey(), + 'patch_version' => 2, + ]); + } + + public function testGetLibraryByIdAdmin(): void + { + $this->authenticateAsAdmin(); + + $libraryName = 'DragTheWord'; + + $lib1 = H5PLibrary::factory()->create(['name' => $libraryName, 'patch_version' => 1]); + $lib2 = H5PLibrary::factory()->create(['name' => $libraryName, 'patch_version' => 2]); + H5PLibraryDependency::factory()->count(3)->create(['required_library_id' => $lib1->getKey()]); + H5PLibraryDependency::factory()->count(7)->create(['required_library_id' => $lib2->getKey()]); + H5PContent::factory()->count(2)->create(['library_id' => $lib1->getKey()]); + H5PContent::factory()->count(5)->create(['library_id' => $lib2->getKey()]); + + $this + ->actingAs($this->user, 'api') + ->json('GET', 'api/admin/hh5p/libraries', ['machnieName' => $libraryName, 'majorVersion' => 1, 'minorVersion' => 1]) + ->assertOk() + ->assertJsonFragment([ + 'id' => $lib1->getKey(), + 'patch_version' => 1, + ]); + + $this + ->actingAs($this->user, 'api') + ->json('GET', 'api/admin/hh5p/libraries', ['library_id' => $lib2->getKey()]) + ->assertOk() + ->assertJsonFragment([ + 'id' => $lib2->getKey(), + 'patch_version' => 2, + ]); + } + public function test_reinstall_library_dependencies() { $this->authenticateAsAdmin(); From fee003667bcec6bebe9b972d611be222bdada314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 27 Mar 2024 13:09:03 +0100 Subject: [PATCH 03/11] fix --- tests/Api/LibraryApiTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Api/LibraryApiTest.php b/tests/Api/LibraryApiTest.php index 9ace04b4..7055d5e9 100644 --- a/tests/Api/LibraryApiTest.php +++ b/tests/Api/LibraryApiTest.php @@ -253,7 +253,7 @@ public function testGetLibraryById(): void $this ->actingAs($this->user, 'api') - ->json('GET', 'api/admin/hh5p/libraries', ['machnieName' => $libraryName, 'majorVersion' => 1, 'minorVersion' => 1]) + ->json('GET', 'api/hh5p/libraries', ['machnieName' => $libraryName, 'majorVersion' => 1, 'minorVersion' => 1]) ->assertOk() ->assertJsonFragment([ 'id' => $lib1->getKey(), @@ -262,7 +262,7 @@ public function testGetLibraryById(): void $this ->actingAs($this->user, 'api') - ->json('GET', 'api/admin/hh5p/libraries', ['library_id' => $lib2->getKey()]) + ->json('GET', 'api/hh5p/libraries', ['library_id' => $lib2->getKey()]) ->assertOk() ->assertJsonFragment([ 'id' => $lib2->getKey(), From 877e09af56b8a145a5798759e63958ad0614c12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 27 Mar 2024 13:16:30 +0100 Subject: [PATCH 04/11] Fix tests --- tests/Api/LibraryApiTest.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/Api/LibraryApiTest.php b/tests/Api/LibraryApiTest.php index 7055d5e9..1f7edcf4 100644 --- a/tests/Api/LibraryApiTest.php +++ b/tests/Api/LibraryApiTest.php @@ -252,21 +252,19 @@ public function testGetLibraryById(): void H5PContent::factory()->count(5)->create(['library_id' => $lib2->getKey()]); $this - ->actingAs($this->user, 'api') ->json('GET', 'api/hh5p/libraries', ['machnieName' => $libraryName, 'majorVersion' => 1, 'minorVersion' => 1]) ->assertOk() ->assertJsonFragment([ 'id' => $lib1->getKey(), - 'patch_version' => 1, + 'patchVersion' => 1, ]); $this - ->actingAs($this->user, 'api') - ->json('GET', 'api/hh5p/libraries', ['library_id' => $lib2->getKey()]) + ->json('GET', 'api/hh5p/libraries', ['library_id' => $lib1->getKey()]) ->assertOk() ->assertJsonFragment([ - 'id' => $lib2->getKey(), - 'patch_version' => 2, + 'id' => $lib1->getKey(), + 'patchVersion' => 1, ]); } @@ -288,17 +286,17 @@ public function testGetLibraryByIdAdmin(): void ->json('GET', 'api/admin/hh5p/libraries', ['machnieName' => $libraryName, 'majorVersion' => 1, 'minorVersion' => 1]) ->assertOk() ->assertJsonFragment([ - 'id' => $lib1->getKey(), - 'patch_version' => 1, + 'id' => $lib2->getKey(), + 'patchVersion' => 2, ]); $this ->actingAs($this->user, 'api') - ->json('GET', 'api/admin/hh5p/libraries', ['library_id' => $lib2->getKey()]) + ->json('GET', 'api/admin/hh5p/libraries', ['library_id' => $lib1->getKey()]) ->assertOk() ->assertJsonFragment([ - 'id' => $lib2->getKey(), - 'patch_version' => 2, + 'id' => $lib1->getKey(), + 'patchVersion' => 1, ]); } From 17dc74cb85b8dd3246444ba942c5aaa7b40ac215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 27 Mar 2024 13:20:30 +0100 Subject: [PATCH 05/11] Fix --- tests/Api/LibraryApiTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Api/LibraryApiTest.php b/tests/Api/LibraryApiTest.php index 1f7edcf4..4abebe72 100644 --- a/tests/Api/LibraryApiTest.php +++ b/tests/Api/LibraryApiTest.php @@ -242,6 +242,7 @@ public function testGetLibrariesAdmin(): void public function testGetLibraryById(): void { + $this->authenticateAsAdmin(); $libraryName = 'DragTheWord'; $lib1 = H5PLibrary::factory()->create(['name' => $libraryName, 'patch_version' => 1]); @@ -252,6 +253,7 @@ public function testGetLibraryById(): void H5PContent::factory()->count(5)->create(['library_id' => $lib2->getKey()]); $this + ->actingAs($this->user, 'api') ->json('GET', 'api/hh5p/libraries', ['machnieName' => $libraryName, 'majorVersion' => 1, 'minorVersion' => 1]) ->assertOk() ->assertJsonFragment([ @@ -260,6 +262,7 @@ public function testGetLibraryById(): void ]); $this + ->actingAs($this->user, 'api') ->json('GET', 'api/hh5p/libraries', ['library_id' => $lib1->getKey()]) ->assertOk() ->assertJsonFragment([ From 0060f2316ca1cc2f9eea520ef0a4628c0a99c702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 27 Mar 2024 14:11:13 +0100 Subject: [PATCH 06/11] Fix edit content --- src/Repositories/H5PContentRepository.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Repositories/H5PContentRepository.php b/src/Repositories/H5PContentRepository.php index 535a3e98..50b94ef3 100644 --- a/src/Repositories/H5PContentRepository.php +++ b/src/Repositories/H5PContentRepository.php @@ -68,13 +68,8 @@ public function create(string $library, string $params, string $nonce): int public function edit(int $id, string $library, string $params, string $nonce): int { - $libNames = $this->hh5pService->getCore()->libraryFromString($library); - - $libDb = H5PLibrary::where([ - ['name', $libNames['machineName']], - ['major_version', $libNames['majorVersion']], - ['minor_version', $libNames['minorVersion']], - ])->latest()->first(); + $content = H5PContent::where('id', $id)->first(); + $libDb = H5PLibrary::where('id', $content->library_id)->first(); if ($libDb === null) { throw new H5PException(H5PException::LIBRARY_NOT_FOUND); @@ -86,8 +81,6 @@ public function edit(int $id, string $library, string $params, string $nonce): i throw new H5PException(H5PException::INVALID_PARAMETERS_JSON); } - $content = H5PContent::where('id', $id)->first(); - if ($content === null) { throw new H5PException(H5PException::CONTENT_NOT_FOUND); } From 40e4c86992e2894df7802f2f8d3d1edf4b631e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 27 Mar 2024 14:49:40 +0100 Subject: [PATCH 07/11] Fix tests --- src/Repositories/H5PContentRepository.php | 16 +++++++++++++- tests/Api/ContentApiTest.php | 27 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/Repositories/H5PContentRepository.php b/src/Repositories/H5PContentRepository.php index 50b94ef3..019bd51d 100644 --- a/src/Repositories/H5PContentRepository.php +++ b/src/Repositories/H5PContentRepository.php @@ -69,12 +69,26 @@ public function create(string $library, string $params, string $nonce): int public function edit(int $id, string $library, string $params, string $nonce): int { $content = H5PContent::where('id', $id)->first(); - $libDb = H5PLibrary::where('id', $content->library_id)->first(); + $previousLib = H5PLibrary::where('id', $content->library_id)->first(); + + $libNames = $this->hh5pService->getCore()->libraryFromString($library); + + $libDb = H5PLibrary::where([ + ['name', $libNames['machineName']], + ['major_version', $libNames['majorVersion']], + ['minor_version', $libNames['minorVersion']], + ])->latest()->first(); if ($libDb === null) { throw new H5PException(H5PException::LIBRARY_NOT_FOUND); } + // don't update library version if there is new + if ($previousLib->name === $libDb->name) { + $libDb = $previousLib; + $library = $previousLib->uberName; + } + $json = json_decode($params); if ($json === null) { diff --git a/tests/Api/ContentApiTest.php b/tests/Api/ContentApiTest.php index 3a0c8794..094c9ff7 100644 --- a/tests/Api/ContentApiTest.php +++ b/tests/Api/ContentApiTest.php @@ -154,6 +154,33 @@ public function testContentUpdateInvalidJson(): void $response->assertStatus(422); } + public function testContentUpdateNewLibraryVersion(): void + { + $this->authenticateAsAdmin(); + $libraryName = 'DragTheWords'; + $library = H5PLibrary::factory()->create(['name' => $libraryName, 'runnable' => 1]); + $newVersion = H5PLibrary::factory()->create(['name' => $libraryName, 'runnable' => 1, 'patch_version' => 10]); + $content = H5PContent::factory()->create([ + 'library_id' => $library->getKey() + ]); + $id = $content->id; + + $this->actingAs($this->user, 'api')->postJson("/api/admin/hh5p/content/$id", [ + 'nonce' => bin2hex(random_bytes(4)), + 'library' => $newVersion->uberName, + 'params' => '{"params":{"taskDescription":"Documentation tool","pagesList":[{"params":{"elementList":[{"params":{},"library":"H5P.Text 1.1","metadata":{"contentType":"Text","license":"U","title":"Untitled Text","authors":[],"changes":[],"extraTitle":"Untitled Text"},"subContentId":"da3387da-355a-49fb-92bc-3a9a4e4646a9"}],"helpTextLabel":"More information","helpText":""},"library":"H5P.StandardPage 1.5","metadata":{"contentType":"Standard page","license":"U","title":"Untitled Standard page","authors":[],"changes":[],"extraTitle":"Untitled Standard page"},"subContentId":"ac6ffdac-be02-448c-861c-969e6a09dbd5"}],"i10n":{"previousLabel":"poprzedni","nextLabel":"Next","closeLabel":"Close"}},"metadata":{"license":"U","authors":[],"changes":[],"extraTitle":"fdsfds","title":"fdsfds"}}', + ]) + ->assertStatus(200) + ->assertJsonFragment([ + 'id' => $library->getKey(), + 'patchVersion' => $library->patchVersion, + ]) + ->assertJsonMissing([ + 'id' => $newVersion->getKey(), + 'patchVersion' => $newVersion->patchVersion, + ]); + } + public function testContentUpdateAuthor(): void { $this->authenticateAsUser(); From d1f86d0c17b64a64be7de6c740f80b48008a933d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 27 Mar 2024 15:03:07 +0100 Subject: [PATCH 08/11] Fix test --- tests/Api/ContentApiTest.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/Api/ContentApiTest.php b/tests/Api/ContentApiTest.php index 094c9ff7..ef56e886 100644 --- a/tests/Api/ContentApiTest.php +++ b/tests/Api/ContentApiTest.php @@ -170,15 +170,17 @@ public function testContentUpdateNewLibraryVersion(): void 'library' => $newVersion->uberName, 'params' => '{"params":{"taskDescription":"Documentation tool","pagesList":[{"params":{"elementList":[{"params":{},"library":"H5P.Text 1.1","metadata":{"contentType":"Text","license":"U","title":"Untitled Text","authors":[],"changes":[],"extraTitle":"Untitled Text"},"subContentId":"da3387da-355a-49fb-92bc-3a9a4e4646a9"}],"helpTextLabel":"More information","helpText":""},"library":"H5P.StandardPage 1.5","metadata":{"contentType":"Standard page","license":"U","title":"Untitled Standard page","authors":[],"changes":[],"extraTitle":"Untitled Standard page"},"subContentId":"ac6ffdac-be02-448c-861c-969e6a09dbd5"}],"i10n":{"previousLabel":"poprzedni","nextLabel":"Next","closeLabel":"Close"}},"metadata":{"license":"U","authors":[],"changes":[],"extraTitle":"fdsfds","title":"fdsfds"}}', ]) - ->assertStatus(200) - ->assertJsonFragment([ - 'id' => $library->getKey(), - 'patchVersion' => $library->patchVersion, - ]) - ->assertJsonMissing([ - 'id' => $newVersion->getKey(), - 'patchVersion' => $newVersion->patchVersion, - ]); + ->assertStatus(200); + + $this->assertDatabaseHas('hh5p_contents', [ + 'id' => $id, + 'library_id' => $library->getKey(), + ]); + + $this->assertDatabaseMissing('hh5p_contents', [ + 'id' => $id, + 'library_id' => $newVersion->getKey(), + ]); } public function testContentUpdateAuthor(): void From 2dc4b31470df3c50a743b4576eb878d688ccb59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Tue, 9 Jul 2024 12:19:01 +0200 Subject: [PATCH 09/11] fix styles --- src/Models/H5PContent.php | 1 + src/Services/Contracts/HeadlessH5PServiceContract.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Models/H5PContent.php b/src/Models/H5PContent.php index 047805d9..4c094c34 100644 --- a/src/Models/H5PContent.php +++ b/src/Models/H5PContent.php @@ -90,6 +90,7 @@ * @property array $parameters * @property int $user_id * @property H5PLibrary $library + * @property int $library_id */ class H5PContent extends Model { diff --git a/src/Services/Contracts/HeadlessH5PServiceContract.php b/src/Services/Contracts/HeadlessH5PServiceContract.php index 63aaf658..71913b31 100644 --- a/src/Services/Contracts/HeadlessH5PServiceContract.php +++ b/src/Services/Contracts/HeadlessH5PServiceContract.php @@ -41,7 +41,7 @@ public function listLibraries(): Collection; public function getConfig(): array; - public function getLibraries(string $machineName = null, string $major_version = null, string $minor_version = null); + public function getLibraries(string $machineName = null, string $major_version = null, string $minor_version = null, int $library_id = null); public function getEditorSettings($content = null): array; From db5614dd66764561f8eb1af585ecc991b38adf10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Tue, 9 Jul 2024 12:24:46 +0200 Subject: [PATCH 10/11] fixes --- src/Models/H5PLibrary.php | 1 + src/Services/HeadlessH5PService.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Models/H5PLibrary.php b/src/Models/H5PLibrary.php index beb81b1d..d06af291 100644 --- a/src/Models/H5PLibrary.php +++ b/src/Models/H5PLibrary.php @@ -118,6 +118,7 @@ * @property string $name * @property string $embedTypes * @property int $count + * @property int $restricted */ class H5PLibrary extends Model { diff --git a/src/Services/HeadlessH5PService.php b/src/Services/HeadlessH5PService.php index 09520934..82769916 100644 --- a/src/Services/HeadlessH5PService.php +++ b/src/Services/HeadlessH5PService.php @@ -182,7 +182,7 @@ public function getLibraries(string $machineName = null, string $major_version = $library = H5PLibrary::findOrFail($library_id); if (in_array($library->name, array('H5P.Questionnaire', 'H5P.FreeTextQuestion')) && - !$this->h5p->h5pF->getOption('enable_lrs_content_types')) { + !$this->core->h5pF->getOption('enable_lrs_content_types')) { $library->restricted = TRUE; } $this->addMoreHtmlTags($library->semantics); From 967555e412d32b4d48bd691bcdf59a5eeeff3dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Tue, 9 Jul 2024 12:31:46 +0200 Subject: [PATCH 11/11] fix phpstan --- src/Models/H5PLibrary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/H5PLibrary.php b/src/Models/H5PLibrary.php index d06af291..0ea1fe41 100644 --- a/src/Models/H5PLibrary.php +++ b/src/Models/H5PLibrary.php @@ -118,7 +118,7 @@ * @property string $name * @property string $embedTypes * @property int $count - * @property int $restricted + * @property bool $restricted */ class H5PLibrary extends Model {