MDL-72116 dashboard: Remove some of the current blocks
authorSara Arjona <sara@moodle.com>
Fri, 13 Aug 2021 10:24:36 +0000 (12:24 +0200)
committerSara Arjona <sara@moodle.com>
Mon, 13 Sep 2021 06:27:08 +0000 (08:27 +0200)
The following blocks have been removed from the Dashboard:
- Online users
- Upcoming events
- Learning plans
- Recently accessed courses

This change will only apply on new installations.

15 files changed:
admin/tool/behat/tests/behat/i_am_on_page.feature
admin/tool/lp/tests/behat/plan_workflow.feature
blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_course.feature
blocks/calendar_upcoming/tests/generator/lib.php [new file with mode: 0644]
blocks/lp/tests/generator/lib.php [new file with mode: 0644]
blocks/online_users/tests/behat/block_online_users_course.feature
blocks/online_users/tests/behat/block_online_users_dashboard.feature
blocks/online_users/tests/behat/block_online_users_frontpage.feature
blocks/recentlyaccessedcourses/tests/behat/block_recentlyaccessedcourses_dashboard.feature
blocks/recentlyaccessedcourses/tests/generator/lib.php [new file with mode: 0644]
blocks/tests/externallib_test.php
lib/blocklib.php
my/tests/behat/add_blocks.feature
my/tests/behat/reset_all_pages.feature
my/tests/behat/reset_page.feature

index 8bef7f9..9c60a8b 100644 (file)
@@ -73,7 +73,7 @@ Feature: Use core page resolvers for the I am on the page steps
     Examples:
       | description | identifier | shouldsee                   |
       | Admin page  | "Admin notifications"      | Check for available updates |
-      | Home page   | Homepage   | Recently accessed courses   |
+      | Home page   | Homepage   | Course overview   |
 
   Scenario Outline: When I am on a named page logged in as
     When I am on the <identifier> page logged in as admin
@@ -82,4 +82,4 @@ Feature: Use core page resolvers for the I am on the page steps
     Examples:
       | description | identifier            | shouldsee                   |
       | Admin page  | "Admin notifications" | Check for available updates |
-      | Home page   | Homepage              | Recently accessed courses   |
+      | Home page   | Homepage              | Course overview   |
index 9d8f2eb..6b6a244 100644 (file)
@@ -37,6 +37,9 @@ Feature: Manage plan workflow
       | Test-Plan1 | Test-Comp2 |
       | Test-Plan2 | Test-Comp1 |
       | Test-Plan2 | Test-Comp2 |
+    And the following "blocks" exist:
+      | blockname               | contextlevel | reference | pagetypepattern | defaultregion |
+      | lp                      | System       | 1         | my-index        | content       |
     And I log in as "admin"
     And I set the following system permissions of "User manage own draft plan role" role:
       | capability | permission |
index 1b4d9e0..d160777 100644 (file)
@@ -14,6 +14,9 @@ Feature: Enable the upcoming events block in a course
     And the following "course enrolments" exist:
       | user | course | role |
       | teacher1 | C1 | editingteacher |
+    And the following "blocks" exist:
+      | blockname           | contextlevel | reference | pagetypepattern | defaultregion |
+      | calendar_upcoming   | System       | 1         | my-index        | side-post     |
 
   @javascript
   Scenario: View a site event in the calendar block
diff --git a/blocks/calendar_upcoming/tests/generator/lib.php b/blocks/calendar_upcoming/tests/generator/lib.php
new file mode 100644 (file)
index 0000000..e569db8
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Calendar upcoming events block data generator class.
+ *
+ * @package    block_calendar_upcoming
+ * @category   test
+ * @copyright  2021 Sara Arjona <sara@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class block_calendar_upcoming_generator extends testing_block_generator {
+}
diff --git a/blocks/lp/tests/generator/lib.php b/blocks/lp/tests/generator/lib.php
new file mode 100644 (file)
index 0000000..d6998c4
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Learning plans block data generator class.
+ *
+ * @package    block_lp
+ * @category   test
+ * @copyright  2021 Sara Arjona <sara@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class block_lp_generator extends testing_block_generator {
+}
index 097cee1..119e2da 100644 (file)
@@ -89,6 +89,7 @@ Feature: The online users block allow you to see who is currently online
     And the following config values are set as admin:
       | block_online_users_onlinestatushiding | 0 |
     When I log in as "student1"
+    And I am on "Course 1" course homepage
     Then I should see "Student 1" in the "Online users" "block"
     And "Hide" "icon" should not exist in the ".block.block_online_users" "css_element"
 
index d15e46a..0c46b5b 100644 (file)
@@ -19,6 +19,9 @@ Feature: The online users block allow you to see who is currently online on dash
       | teacher1 | C1 | editingteacher |
       | student1 | C1 | student        |
       | student2 | C1 | student        |
+    And the following "blocks" exist:
+      | blockname           | contextlevel | reference | pagetypepattern | defaultregion |
+      | online_users        | System       | 1         | my-index        | side-post     |
 
   Scenario: View the online users block on the dashboard and see myself
     Given I log in as "teacher1"
index 0c08e52..e8f9591 100644 (file)
@@ -114,6 +114,7 @@ Feature: The online users block allow you to see who is currently online on fron
     And the following config values are set as admin:
       | block_online_users_onlinestatushiding | 0 |
     When I log in as "student1"
+    And I am on site homepage
     Then I should see "Student 1" in the "Online users" "block"
     And "Hide" "icon" should not exist in the ".block.block_online_users" "css_element"
 
index 731e1ef..17f44de 100644 (file)
@@ -25,6 +25,9 @@ Feature: The recently accessed courses block allows users to easily access their
       | student1 | C3     | student |
       | student1 | C4     | student |
       | student1 | C5     | student |
+    And the following "blocks" exist:
+      | blockname               | contextlevel | reference | pagetypepattern | defaultregion |
+      | recentlyaccessedcourses | System       | 1         | my-index        | content       |
 
   Scenario: User has not accessed any course
     Given I log in as "student1"
diff --git a/blocks/recentlyaccessedcourses/tests/generator/lib.php b/blocks/recentlyaccessedcourses/tests/generator/lib.php
new file mode 100644 (file)
index 0000000..f89468f
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Recently accessed courses block data generator class.
+ *
+ * @package    block_recentlyaccessedcourses
+ * @category   test
+ * @copyright  2021 Sara Arjona <sara@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class block_recentlyaccessedcourses_generator extends testing_block_generator {
+}
index f5bb942..937b640 100644 (file)
@@ -325,7 +325,7 @@ class core_block_externallib_testcase extends externallib_advanced_testcase {
         $PAGE->set_url('/my/index.php');    // Need this because some internal API calls require the $PAGE url to be set.
 
         // Force a setting change to check the returned blocks settings.
-        set_config('displaycategories', 0, 'block_recentlyaccessedcourses');
+        set_config('displaycategories', 0, 'block_myoverview');
 
         // Get the expected default blocks.
         $alldefaultblocksordered = $DB->get_records_menu('block_instances',
@@ -337,15 +337,15 @@ class core_block_externallib_testcase extends externallib_advanced_testcase {
         $result = core_block_external::get_dashboard_blocks($user->id);
         // We need to execute the return values cleaning process to simulate the web service server.
         $result = external_api::clean_returnvalue(core_block_external::get_dashboard_blocks_returns(), $result);
-        // Expect all blogs except learning plans one (no learning plans to show).
-        $this->assertCount(count($alldefaultblocksordered) - 1, $result['blocks']);
+        // Expect all default blocks defined in blocks_add_default_system_blocks().
+        $this->assertCount(count($alldefaultblocksordered), $result['blocks']);
         $returnedblocks = array();
         foreach ($result['blocks'] as $block) {
             // Check all the returned blocks are in the expected blocks array.
             $this->assertContains($block['name'], $alldefaultblocksordered);
             $returnedblocks[] = $block['name'];
             // Check the configuration returned for this default block.
-            if ($block['name'] == 'recentlyaccessedcourses') {
+            if ($block['name'] == 'myoverview') {
                 // Convert config to associative array to avoid DB sorting randomness.
                 $config = array_column($block['configs'], null, 'name');
                 $this->assertArrayHasKey('displaycategories', $config);
@@ -353,8 +353,7 @@ class core_block_externallib_testcase extends externallib_advanced_testcase {
                 $this->assertEquals('plugin', $config['displaycategories']['type']);
             }
         }
-        // Remove lp block.
-        array_shift($alldefaultblocksordered);
+
         // Check that we received the blocks in the expected order.
         $this->assertEquals(array_values($alldefaultblocksordered), $returnedblocks);
     }
@@ -387,8 +386,8 @@ class core_block_externallib_testcase extends externallib_advanced_testcase {
         $result = core_block_external::get_dashboard_blocks($user->id);
         // We need to execute the return values cleaning process to simulate the web service server.
         $result = external_api::clean_returnvalue(core_block_external::get_dashboard_blocks_returns(), $result);
-        // Expect all blogs plus sticky one except learning plans one (no learning plans to show).
-        $this->assertCount(count($alldefaultblocks), $result['blocks']);
+        // Expect all default blocks defined in blocks_add_default_system_blocks() plus sticky one.
+        $this->assertCount(count($alldefaultblocks) + 1, $result['blocks']);
         $found = false;
         foreach ($result['blocks'] as $block) {
             if ($block['name'] == 'myprofile') {
@@ -432,8 +431,8 @@ class core_block_externallib_testcase extends externallib_advanced_testcase {
         $result = core_block_external::get_dashboard_blocks($user->id);
         // We need to execute the return values cleaning process to simulate the web service server.
         $result = external_api::clean_returnvalue(core_block_external::get_dashboard_blocks_returns(), $result);
-        // Expect all default blogs plys the one we added except learning plans one (no learning plans to show).
-        $this->assertCount(count($alldefaultblocks), $result['blocks']);
+        // Expect all default blocks defined in blocks_add_default_system_blocks() plus the one we added.
+        $this->assertCount(count($alldefaultblocks) + 1, $result['blocks']);
         $found = false;
         foreach ($result['blocks'] as $block) {
             if ($block['name'] == 'myprofile') {
index 35a6102..af86926 100644 (file)
@@ -2607,7 +2607,7 @@ function blocks_add_default_system_blocks() {
         $subpagepattern = null;
     }
 
-    $newblocks = array('timeline', 'private_files', 'online_users', 'badges', 'calendar_month', 'calendar_upcoming');
-    $newcontent = array('lp', 'recentlyaccessedcourses', 'myoverview');
+    $newblocks = array('timeline', 'private_files', 'badges', 'calendar_month');
+    $newcontent = array('myoverview');
     $page->blocks->add_blocks(array(BLOCK_POS_RIGHT => $newblocks, 'content' => $newcontent), 'my-index', $subpagepattern);
 }
index fd612d1..92be5f3 100644 (file)
@@ -24,4 +24,4 @@ Feature: Add blocks to dashboard page
     Then I should see "Latest announcements" in the "Latest announcements" "block"
     And I should see "Latest badges" in the "Latest badges" "block"
     And I should see "Calendar" in the "Calendar" "block"
-    And I should see "Upcoming events" in the "Upcoming events" "block"
+    And I should not see "Upcoming events"
index c762b73..9f24eb8 100644 (file)
@@ -45,8 +45,8 @@ Feature: Reset all personalised pages to default
     And I navigate to "Appearance > Default Dashboard page" in site administration
     And I press "Blocks editing on"
     And I add the "Latest announcements" block
-    And I open the "Online users" blocks action menu
-    And I follow "Delete Online users"
+    And I open the "Latest badges" blocks action menu
+    And I follow "Delete Latest badges block"
     And I press "Yes"
     And I press "Blocks editing off"
     And I log out
@@ -54,13 +54,13 @@ Feature: Reset all personalised pages to default
     And I log in as "student1"
     And I follow "Dashboard" in the user menu
     And I should not see "Latest announcements"
-    And I should see "Online users"
+    And I should see "Latest badges"
     And I log out
 
     And I log in as "student3"
     And I follow "Dashboard" in the user menu
     And I should not see "Latest announcements"
-    And I should see "Online users"
+    And I should see "Latest badges"
     And I log out
 
     And I log in as "admin"
@@ -73,13 +73,13 @@ Feature: Reset all personalised pages to default
     And I follow "Dashboard" in the user menu
     Then I should see "Latest announcements"
     And I should not see "Comments"
-    And I should not see "Online users"
+    And I should not see "Latest badges"
     And I log out
 
     And I log in as "student3"
     And I follow "Dashboard" in the user menu
     And I should see "Latest announcements"
-    And I should not see "Online users"
+    And I should not see "Latest badges"
     And I log out
 
     # Check that this did not affect the customised profiles.
index 707fb9b..c7fd951 100644 (file)
@@ -26,6 +26,6 @@ Feature: Reset dashboard page to default
     Then I should not see "Latest announcements"
     And I should see "Latest badges"
     And I should see "Calendar"
-    And I should see "Upcoming events"
+    And I should not see "Upcoming events"
     And I should not see "Comments"
     And I should not see "Reset page to default"