Skip to content

Commit

Permalink
Merge branch 'MDL-72092-master' of https://github.com/Chocolate-light…
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Mar 1, 2022
2 parents 47e880e + b0532ae commit 9dde12d
Show file tree
Hide file tree
Showing 46 changed files with 322 additions and 39 deletions.
3 changes: 3 additions & 0 deletions blocks/badges/tests/behat/block_badges_dashboard.feature
Expand Up @@ -14,6 +14,9 @@ Feature: Enable Block Badges on the dashboard and view awarded badges
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| badges | System | 1 | my-index | side-post |
And I log in as "teacher1"
And I am on "Course 1" course homepage
# Issue badge 1 of 2
Expand Down
36 changes: 35 additions & 1 deletion blocks/calendar_month/db/upgrade.php
Expand Up @@ -43,7 +43,7 @@
* @param object $block
*/
function xmldb_block_calendar_month_upgrade($oldversion, $block) {
global $CFG;
global $CFG, $DB;

// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
Expand All @@ -57,5 +57,39 @@ function xmldb_block_calendar_month_upgrade($oldversion, $block) {
// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2022030200) {
$context = context_system::instance();

// Begin looking for any and all customised /my pages.
$pageselect = 'name = :name and private = :private';
$pageparams['name'] = '__default';
$pageparams['private'] = 1;
$pages = $DB->get_recordset_select('my_pages', $pageselect, $pageparams);
foreach ($pages as $subpage) {
$blockinstance = $DB->get_record('block_instances', ['blockname' => 'calendar_month',
'pagetypepattern' => 'my-index', 'subpagepattern' => $subpage->id]);

if (!$blockinstance) {
// Insert the calendar month into the default index page.
$blockinstance = new stdClass;
$blockinstance->blockname = 'calendar_month';
$blockinstance->parentcontextid = $context->id;
$blockinstance->showinsubcontexts = false;
$blockinstance->pagetypepattern = 'my-index';
$blockinstance->subpagepattern = $subpage->id;
$blockinstance->defaultregion = 'content';
$blockinstance->defaultweight = 0;
$blockinstance->timecreated = time();
$blockinstance->timemodified = time();
$DB->insert_record('block_instances', $blockinstance);
} else if ($blockinstance->defaultregion !== 'content') {
$blockinstance->defaultregion = 'content';
$DB->update_record('block_instances', $blockinstance);
}
}
$pages->close();
upgrade_block_savepoint(true, 2022030200, 'calendar_month', false);
}

return true;
}
2 changes: 1 addition & 1 deletion blocks/calendar_month/version.php
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2022030200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'block_calendar_month'; // Full name of the plugin (used for diagnostics)
28 changes: 28 additions & 0 deletions blocks/classes/external.php
Expand Up @@ -282,6 +282,34 @@ public static function get_dashboard_blocks($userid = 0, $returncontents = false
$returninvisible = has_capability('moodle/my:manageblocks', $context) ? true : false;
$allblocks = self::get_all_current_page_blocks($returninvisible, $params['returncontents']);

// Temporary hack to be removed in 4.1.
// Return always the course overview block so old versions of the app can list the user courses.
if ($mypage == MY_PAGE_DEFAULT && core_useragent::is_moodle_app()) {
$myoverviewfound = false;

foreach ($allblocks as $block) {
if ($block['name'] == 'myoverview' && $block['visible']) {
$myoverviewfound = true;
break;
}
}

if (!$myoverviewfound) {
// Include a course overview fake block.
$allblocks[] = [
'instanceid' => 0,
'name' => 'myoverview',
'region' => 'forced',
'positionid' => null,
'collapsible' => true,
'dockable' => false,
'weight' => 0,
'visible' => true,
];
}
}
// End of the hack to be removed in 4.1 see MDL-73670.

return array(
'blocks' => $allblocks,
'warnings' => $warnings
Expand Down
4 changes: 2 additions & 2 deletions blocks/myoverview/db/upgrade.php
Expand Up @@ -174,8 +174,8 @@ function delete_block_instance(stdClass $instance) {
)->id;

// See if this block already somehow exists, it should not but who knows.
if (!$DB->get_record('block_instances', ['blockname' => 'myoverview',
'pagetypepattern' => 'my-index', 'subpagepattern' => $subpagepattern])) {
if (!$DB->record_exists('block_instances', ['blockname' => 'myoverview',
'pagetypepattern' => 'my-index', 'subpagepattern' => $subpagepattern])) {
$page = new moodle_page();
$systemcontext = context_system::instance();
$page->set_context($systemcontext);
Expand Down
Expand Up @@ -8,6 +8,9 @@ Feature: The private files block allows users to store files privately in moodle
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "teacher1"
And "Private files" "block" should exist
And I should see "No files available" in the "Private files" "block"
Expand Down
34 changes: 34 additions & 0 deletions blocks/recentlyaccesseditems/db/upgrade.php
Expand Up @@ -75,5 +75,39 @@ function xmldb_block_recentlyaccesseditems_upgrade($oldversion, $block) {
// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2022030200) {
$context = context_system::instance();

// Begin looking for any and all customised /my pages.
$pageselect = 'name = :name and private = :private';
$pageparams['name'] = '__default';
$pageparams['private'] = 1;
$pages = $DB->get_recordset_select('my_pages', $pageselect, $pageparams);
foreach ($pages as $subpage) {
$blockinstance = $DB->get_record('block_instances', ['blockname' => 'recentlyaccesseditems',
'pagetypepattern' => 'my-index', 'subpagepattern' => $subpage->id]);

if (!$blockinstance) {
// Insert the recentlyaccesseditems into the default index page.
$blockinstance = new stdClass;
$blockinstance->blockname = 'recentlyaccesseditems';
$blockinstance->parentcontextid = $context->id;
$blockinstance->showinsubcontexts = false;
$blockinstance->pagetypepattern = 'my-index';
$blockinstance->subpagepattern = $subpage->id;
$blockinstance->defaultregion = 'side-post';
$blockinstance->defaultweight = -10;
$blockinstance->timecreated = time();
$blockinstance->timemodified = time();
$DB->insert_record('block_instances', $blockinstance);
} else if ($blockinstance->defaultregion !== 'side-post') {
$blockinstance->defaultregion = 'side-post';
$DB->update_record('block_instances', $blockinstance);
}
}
$pages->close();
upgrade_block_savepoint(true, 2022030200, 'recentlyaccesseditems', false);
}

return true;
}
Expand Up @@ -22,8 +22,6 @@ Feature: The recently accessed items block allows users to easily access their m
| idnumber | Test forum name |
| name | Test forum name |
And I log in as "student1"
And I turn editing mode on
And I add the "Recently accessed items" block

Scenario: User has not accessed any item
Then I should see "No recent items" in the "Recently accessed items" "block"
Expand Down
2 changes: 1 addition & 1 deletion blocks/recentlyaccesseditems/version.php
Expand Up @@ -22,6 +22,6 @@
*/
defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2022030200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'block_recentlyaccesseditems'; // Full name of the plugin (used for diagnostics).
2 changes: 1 addition & 1 deletion blocks/tests/behat/configure_block_throughout_site.feature
Expand Up @@ -51,7 +51,7 @@ Feature: Add and configure blocks throughout the site
Scenario: Blocks on the dashboard page can have roles assigned to them
Given I log in as "manager1"
When I turn editing mode on
Then I should see "Assign roles in Private files block"
Then I should see "Assign roles in Recently accessed items block"

Scenario: Blocks on courses can have roles assigned to them
Given I log in as "teacher1"
Expand Down
94 changes: 94 additions & 0 deletions blocks/timeline/db/upgrade.php
@@ -0,0 +1,94 @@
<?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/>.

/**
* This file keeps track of upgrades to the timeline block
*
* Sometimes, changes between versions involve alterations to database structures
* and other major things that may break installations.
*
* The upgrade function in this file will attempt to perform all the necessary
* actions to upgrade your older installation to the current version.
*
* If there's something it cannot do itself, it will tell you what you need to do.
*
* The commands in here will all be database-neutral, using the methods of
* database_manager class
*
* Please do not forget to use upgrade_set_timeout()
* before any action that may take longer time to finish.
*
* @package block_timeline
* @copyright 2022 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Upgrade the timeline block
* @param int $oldversion
* @param object $block
*/
function xmldb_block_timeline_upgrade($oldversion, $block) {
global $CFG, $DB;

// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v3.7.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v3.8.0 release upgrade line.
// Put any upgrade step following this.

// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2022030200) {
$context = context_system::instance();

// Begin looking for any and all customised /my pages.
$pageselect = 'name = :name and private = :private';
$pageparams['name'] = '__default';
$pageparams['private'] = 1;
$pages = $DB->get_recordset_select('my_pages', $pageselect, $pageparams);
foreach ($pages as $subpage) {
$blockinstance = $DB->get_record('block_instances', ['blockname' => 'timeline',
'pagetypepattern' => 'my-index', 'subpagepattern' => $subpage->id]);

if (!$blockinstance) {
// Insert the timeline into the default index page.
$blockinstance = new stdClass;
$blockinstance->blockname = 'timeline';
$blockinstance->parentcontextid = $context->id;
$blockinstance->showinsubcontexts = false;
$blockinstance->pagetypepattern = 'my-index';
$blockinstance->subpagepattern = $subpage->id;
$blockinstance->defaultregion = 'content';
$blockinstance->defaultweight = -10;
$blockinstance->timecreated = time();
$blockinstance->timemodified = time();
$DB->insert_record('block_instances', $blockinstance);
} else if ($blockinstance->defaultregion !== 'content') {
$blockinstance->defaultregion = 'content';
$DB->update_record('block_instances', $blockinstance);
}
}
$pages->close();
upgrade_block_savepoint(true, 2022030200, 'timeline', false);
}

return true;
}
2 changes: 1 addition & 1 deletion blocks/timeline/version.php
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2022030200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'block_timeline'; // Full name of the plugin (used for diagnostics).
Expand Up @@ -5,7 +5,10 @@ Feature: H5P file upload to content bank for admins
I need to be able to upload a new .h5p file to content bank

Background:
Given I log in as "admin"
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
Expand Down
Expand Up @@ -19,6 +19,9 @@ Feature: H5P file upload to content bank for non admins
| user | course | role |
| teacher1 | C1 | editingteacher |
| teacher2 | C1 | editingteacher |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "teacher1"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
Expand Down
5 changes: 4 additions & 1 deletion contentbank/tests/behat/delete_content.feature
Expand Up @@ -5,7 +5,10 @@ Feature: Delete H5P file from the content bank
I need to be able to delete any H5P content from the content bank

Background:
Given I log in as "admin"
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
Expand Down
5 changes: 4 additions & 1 deletion contentbank/tests/behat/edit_content.feature
Expand Up @@ -5,7 +5,10 @@ Feature: Content bank use editor feature
I need to be able to access the edition options

Background:
Given I log in as "admin"
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
And the following config values are set as admin:
Expand Down
5 changes: 4 additions & 1 deletion contentbank/tests/behat/events.feature
Expand Up @@ -5,7 +5,10 @@ Feature: Confirm content bank events are triggered
I need to be able to check triggered events

Background:
Given I log in as "admin"
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
And I navigate to "H5P > Manage H5P content types" in site administration
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "H5P content type" filemanager
And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"
Expand Down
5 changes: 4 additions & 1 deletion contentbank/tests/behat/view_preferences.feature
Expand Up @@ -5,7 +5,10 @@ Feature: Store the content bank view preference
I need to be able to store my view preference

Background:
Given I log in as "admin"
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I upload "h5p/tests/fixtures/greeting-card-887.h5p" file to "Files" filemanager
Expand Down
3 changes: 3 additions & 0 deletions customfield/field/textarea/tests/behat/default_value.feature
Expand Up @@ -21,6 +21,9 @@ Feature: Default value for the textarea custom field can contain images
And the following "custom field categories" exist:
| name | component | area | itemid |
| Category for test | core_course | course | 0 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
# Upload an image into the private files.
And I log in as "admin"
And I follow "Manage private files"
Expand Down
3 changes: 3 additions & 0 deletions customfield/tests/behat/edit_fields_settings.feature
Expand Up @@ -24,6 +24,9 @@ Feature: Teachers can edit course custom fields
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |

Scenario: Display custom fields on course edit form
When I log in as "teacher1"
Expand Down
5 changes: 5 additions & 0 deletions files/tests/behat/license_help_modal.feature
Expand Up @@ -4,6 +4,11 @@ Feature: View licence links
As a user
I need to be able to navigate to a page containing licence terms from the file manager

Background:
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |

@javascript
Scenario: Uploading a file displays licence list modal
Given I log in as "admin"
Expand Down

0 comments on commit 9dde12d

Please sign in to comment.