mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
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.
This commit is contained in:
parent
73a7133ef8
commit
8a81d74244
18 changed files with 565 additions and 87 deletions
|
@ -43,7 +43,7 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
|
|||
* the system context.
|
||||
*/
|
||||
public function test_get_content_system_context_user_has_capabilities() {
|
||||
global $DB;
|
||||
global $DB, $CFG;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
|
@ -66,8 +66,9 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
|
|||
// Add some content to the content bank.
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_contentbank');
|
||||
// Add some content bank files in the system context.
|
||||
$filepath = $CFG->dirroot . '/h5p/tests/fixtures/filltheblanks.h5p';
|
||||
$contentbankcontents = $generator->generate_contentbank_data('contenttype_h5p', 3, $admin->id,
|
||||
$systemcontext, true);
|
||||
$systemcontext, true, $filepath);
|
||||
|
||||
// Log in as admin.
|
||||
$this->setUser($admin);
|
||||
|
@ -156,6 +157,8 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
|
|||
* any category course should be able to access/view the content in the course category context.
|
||||
*/
|
||||
public function test_get_content_course_category_context_user_has_capabilities() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Create a course category.
|
||||
|
@ -175,8 +178,9 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
|
|||
// Add some content to the content bank.
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_contentbank');
|
||||
// Add some content bank files in the course category context.
|
||||
$filepath = $CFG->dirroot . '/h5p/tests/fixtures/filltheblanks.h5p';
|
||||
$contentbankcontents = $generator->generate_contentbank_data('contenttype_h5p', 3, $admin->id,
|
||||
$coursecatcontext, true);
|
||||
$coursecatcontext, true, $filepath);
|
||||
|
||||
$this->setUser($admin);
|
||||
// Get the content bank nodes displayed to the admin in the course category context.
|
||||
|
@ -277,6 +281,8 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
|
|||
* in the course should be able to access/view the content.
|
||||
*/
|
||||
public function test_get_content_course_context_user_has_capabilities() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Create course1.
|
||||
|
@ -290,8 +296,9 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
|
|||
// Add some content to the content bank.
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_contentbank');
|
||||
// Add some content bank files in the course context.
|
||||
$filepath = $CFG->dirroot . '/h5p/tests/fixtures/filltheblanks.h5p';
|
||||
$contentbankcontents = $generator->generate_contentbank_data('contenttype_h5p', 3, $admin->id,
|
||||
$coursecontext, true);
|
||||
$coursecontext, true, $filepath);
|
||||
|
||||
$this->setUser($admin);
|
||||
// Get the content bank nodes displayed to the admin in the course context.
|
||||
|
|
|
@ -182,6 +182,8 @@ class repository_contentbank_search_testcase extends advanced_testcase {
|
|||
* and system content. Other authenticated users should be able to access only the system content.
|
||||
*/
|
||||
public function test_get_search_contents_user_can_access_certain_content() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$systemcontext = \context_system::instance();
|
||||
|
@ -201,16 +203,17 @@ class repository_contentbank_search_testcase extends advanced_testcase {
|
|||
// Add some content to the content bank in different contexts.
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_contentbank');
|
||||
// Add a content bank file in the system context.
|
||||
$filepath = $CFG->dirroot . '/h5p/tests/fixtures/ipsums.h5p';
|
||||
$systemcontents = $generator->generate_contentbank_data('contenttype_h5p', 1, $admin->id,
|
||||
$systemcontext, true, 'file.h5p', 'systemcontentfile');
|
||||
$systemcontext, true, $filepath, 'systemcontentfile');
|
||||
$systemcontent = reset($systemcontents);
|
||||
// Add a content bank file in the course1 context.
|
||||
$course1contents = $generator->generate_contentbank_data('contenttype_h5p', 1, $admin->id,
|
||||
$course1context, true, 'file.h5p', 'coursecontentfile1');
|
||||
$course1context, true, $filepath, 'coursecontentfile1');
|
||||
$course1content = reset($course1contents);
|
||||
// Add a content bank file in the course2 context.
|
||||
$generator->generate_contentbank_data('contenttype_h5p', 1, $admin->id,
|
||||
$course2context, true, 'file.h5p', 'coursecontentfile2');
|
||||
$course2context, true, $filepath, 'coursecontentfile2');
|
||||
|
||||
// Log in as an editing teacher.
|
||||
$this->setUser($editingteacher);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue