MDL-70801 block_myoverview: Upgrade steps to relocate the block

This commit is contained in:
Mathew May 2021-10-21 12:12:48 +08:00
parent 6ca9c2154a
commit e110e5b330
14 changed files with 173 additions and 86 deletions

View file

@ -113,5 +113,18 @@ class block_myoverview extends block_base {
'plugin' => $configs,
];
}
/**
* Disable block editing on the my courses page.
*
* @return boolean
*/
public function instance_can_be_edited() {
if ($this->page->blocks->is_known_region(BLOCK_POS_LEFT) || $this->page->blocks->is_known_region(BLOCK_POS_RIGHT)) {
return true;
} else {
return false;
}
}
}

View file

@ -25,6 +25,8 @@
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/my/lib.php');
/**
* Upgrade code for the MyOverview block.
*
@ -81,5 +83,77 @@ function xmldb_block_myoverview_upgrade($oldversion) {
// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2021052504) {
/**
* Small helper function for this version upgrade to delete instances of this block.
*
* @param stdClass $instance DB record of a block that we need to delete within Moodle.
*/
function delete_block_instance(stdClass $instance) {
global $DB;
if ($instance) {
list($sql, $params) = $DB->get_in_or_equal($instance->id, SQL_PARAMS_NAMED);
$params['contextlevel'] = CONTEXT_BLOCK;
$DB->delete_records_select('context', "contextlevel=:contextlevel AND instanceid " . $sql, $params);
$DB->delete_records('block_positions', ['blockinstanceid' => $instance->id]);
$DB->delete_records('block_instances', ['id' => $instance->id]);
$DB->delete_records_list('user_preferences', 'name',
['block' . $instance->id . 'hidden', 'docked_block_instance_' . $instance->id]);
}
}
// Delete the default indexsys version of the block.
$mysubpagepattern = $DB->get_record(
'my_pages',
['userid' => null, 'name' => MY_PAGE_DEFAULT, 'private' => MY_PAGE_PRIVATE],
'id',
IGNORE_MULTIPLE
)->id;
$instances = $DB->get_records('block_instances', ['blockname' => 'myoverview',
'pagetypepattern' => 'my-index', 'subpagepattern' => $mysubpagepattern]);
foreach ($instances as $instance) {
delete_block_instance($instance);
}
// Begin looking for any and all instances of course overview in customised /my pages.
$pageselect = 'name = :name and private = :private and userid IS NOT NULL';
$pageparams['name'] = MY_PAGE_DEFAULT;
$pageparams['private'] = MY_PAGE_PRIVATE;
$pages = $DB->get_recordset_select('my_pages', $pageselect, $pageparams);
foreach ($pages as $page) {
$blocksql = 'blockname = :blockname and pagetypepattern = :pagetypepattern and subpagepattern = :subpagepattern';
$blockparams['blockname'] = 'myoverview';
$blockparams['pagetypepattern'] = 'my-index';
$blockparams['subpagepattern'] = $page->id;
$instances = $DB->get_records_select('block_instances', $blocksql, $blockparams);
foreach ($instances as $instance) {
delete_block_instance($instance);
}
}
$pages->close();
// Add new instance to the /my/courses.php page.
$subpagepattern = $DB->get_record(
'my_pages',
['userid' => null, 'name' => MY_PAGE_COURSES, 'private' => MY_PAGE_PUBLIC],
'id',
IGNORE_MULTIPLE
)->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])) {
$page = new moodle_page();
$systemcontext = context_system::instance();
$page->set_context($systemcontext);
// Add the block to the default /my/courses.
$page->blocks->add_region('content');
$page->blocks->add_block('myoverview', 'content', 0, false, 'my-index', $subpagepattern);
}
upgrade_block_savepoint(true, 2021052504, 'myoverview', false);
}
return true;
}

View file

@ -101,7 +101,7 @@ function block_myoverview_user_preferences() {
$preferences['block_myoverview_user_sort_preference'] = array(
'null' => NULL_NOT_ALLOWED,
'default' => BLOCK_MYOVERVIEW_SORTING_TITLE,
'default' => BLOCK_MYOVERVIEW_SORTING_LASTACCESSED,
'type' => PARAM_ALPHA,
'choices' => array(
BLOCK_MYOVERVIEW_SORTING_TITLE,

View file

@ -32,7 +32,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "All" to "1"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
# We have to check for the data attribute instead of the list element text as we would get false positives from the "All (except removed from view)" element otherwise
Then "[data-value='allincludinghidden']" "css_element" should exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -43,7 +43,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "All" to "0"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
# We have to check for the data attribute instead of the list element text as we would get false negatives "All (except removed from view)" element otherwise
Then "[data-value='allincludinghidden']" "css_element" should not exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -54,7 +54,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "All (except removed from view)" to "1"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "All (except removed from view)" "list_item" should exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -64,7 +64,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "All (except removed from view)" to "0"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
# 'All (except removed from view)' option has been disabled, so the button is falling back to the 'In progress' option which is the next enabled option.
And I click on "In progress" "button" in the "Course overview" "block"
Then "All (except removed from view)" "list_item" should not exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -75,7 +75,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "In progress" to "1"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "In progress" "list_item" should exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -85,7 +85,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "In progress" to "0"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "In progress" "list_item" should not exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -95,7 +95,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Future" to "1"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "Future" "list_item" should exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -105,7 +105,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Future" to "0"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "Future" "list_item" should not exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -115,7 +115,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Past" to "1"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "Past" "list_item" should exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -125,7 +125,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Past" to "0"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "Past" "list_item" should not exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -135,7 +135,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Starred" to "1"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "Starred" "list_item" should exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -145,7 +145,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Starred" to "0"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "Starred" "list_item" should not exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -155,7 +155,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Removed from view" to "1"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "Removed from view" "list_item" should exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -165,7 +165,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Removed from view" to "0"
And I press "Save"
And I log out
Then I log in as "student1"
Then I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then "Removed from view" "list_item" should not exist in the ".block_myoverview .dropdown-menu" "css_element"
@ -181,7 +181,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Removed from view" to "0"
And I press "Save"
And I log out
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
Then "button#groupingdropdown" "css_element" should not exist in the ".block_myoverview" "css_element"
And I should see "Course 1" in the "Course overview" "block"
And I should see "Course 2" in the "Course overview" "block"
@ -201,7 +201,7 @@ Feature: The my overview block allows admins to easily configure the students' c
And I set the field "Removed from view" to "0"
And I press "Save"
And I log out
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
Then "button#groupingdropdown" "css_element" should not exist in the ".block_myoverview" "css_element"
And I should see "Course 2" in the "Course overview" "block"
And I should see "Course 3" in the "Course overview" "block"

View file

@ -35,7 +35,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | checkboxfield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Checkbox field: Yes" "link" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
@ -48,7 +48,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | checkboxfield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Checkbox field: No" "link" in the "Course overview" "block"
Then I should not see "Course 1" in the "Course overview" "block"
@ -61,7 +61,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | datefield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "1 February 2001" "link" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
@ -74,7 +74,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | datefield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "6 August 1980" "link" in the "Course overview" "block"
Then I should not see "Course 1" in the "Course overview" "block"
@ -87,7 +87,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | datefield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "No Date field" "link" in the "Course overview" "block"
Then I should not see "Course 1" in the "Course overview" "block"
@ -100,7 +100,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | selectfield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
And I should not see "Option 4" in the "Course overview" "block"
When I click on "Option 1" "link" in the "Course overview" "block"
@ -114,7 +114,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | selectfield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Option 2" "link" in the "Course overview" "block"
Then I should not see "Course 1" in the "Course overview" "block"
@ -127,7 +127,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | selectfield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "No Select field" "link" in the "Course overview" "block"
Then I should not see "Course 1" in the "Course overview" "block"
@ -140,7 +140,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | textfield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "fish" "link" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
@ -153,7 +153,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | textfield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "dog" "link" in the "Course overview" "block"
Then I should not see "Course 1" in the "Course overview" "block"
@ -166,7 +166,7 @@ Feature: The my overview block allows users to group courses by custom fields
Given the following config values are set as admin:
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | textfield | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "No Text field" "link" in the "Course overview" "block"
Then I should not see "Course 1" in the "Course overview" "block"
@ -191,7 +191,7 @@ Feature: The my overview block allows users to group courses by custom fields
And I set the field "Visible to" to "Nobody"
And I press "Save changes"
And I log out
When I log in as "student1"
When I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then I should not see "penguin" in the "Course overview" "block"
Then I should not see "No text field" in the "Course overview" "block"

View file

@ -27,7 +27,7 @@ Feature: The my overview block allows users to easily access their courses
| student1 | C5 | student |
Scenario: View past courses
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Past" "link" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
@ -37,7 +37,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 5" in the "Course overview" "block"
Scenario: View future courses
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Future" "link" in the "Course overview" "block"
Then I should see "Course 5" in the "Course overview" "block"
@ -47,7 +47,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 4" in the "Course overview" "block"
Scenario: View inprogress courses
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "In progress" "link" in the "Course overview" "block"
Then I should see "Course 2" in the "Course overview" "block"
@ -57,7 +57,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 5" in the "Course overview" "block"
Scenario: View all (except removed) courses
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "All (except removed from view)" "link" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
@ -70,7 +70,7 @@ Feature: The my overview block allows users to easily access their courses
Given the following config values are set as admin:
| config | value | plugin |
| displaygroupingallincludinghidden | 1 | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
# We have to click on the data attribute instead of the button element text as we might risk to click on the false positive "All (except removed from view)" element instead
When I click on "[data-value='allincludinghidden']" "css_element" in the "Course overview" "block"
@ -81,7 +81,7 @@ Feature: The my overview block allows users to easily access their courses
Then I should see "Course 5" in the "Course overview" "block"
Scenario: View inprogress courses - test persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
And I click on "In progress" "link" in the "Course overview" "block"
And I reload the page
@ -93,7 +93,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 5" in the "Course overview" "block"
Scenario: View all (except removed) courses - w/ persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "All (except removed from view)" "link" in the "Course overview" "block"
And I reload the page
@ -105,7 +105,7 @@ Feature: The my overview block allows users to easily access their courses
Then I should see "Course 5" in the "Course overview" "block"
Scenario: View past courses - w/ persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Past" "link" in the "Course overview" "block"
And I reload the page
@ -117,7 +117,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 5" in the "Course overview" "block"
Scenario: View future courses - w/ persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Future" "link" in the "Course overview" "block"
And I reload the page
@ -129,7 +129,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 4" in the "Course overview" "block"
Scenario: View favourite courses - w/ persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Star this course" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
@ -143,7 +143,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 5" in the "Course overview" "block"
Scenario: List display persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
And I click on "List" "link" in the "Course overview" "block"
And I reload the page
@ -151,7 +151,7 @@ Feature: The my overview block allows users to easily access their courses
And "[data-display='list']" "css_element" in the "Course overview" "block" should be visible
Scenario: Cards display persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
And I click on "Card" "link" in the "Course overview" "block"
And I reload the page
@ -159,7 +159,7 @@ Feature: The my overview block allows users to easily access their courses
And "[data-display='card']" "css_element" in the "Course overview" "block" should be visible
Scenario: Summary display persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
And I click on "Summary" "link" in the "Course overview" "block"
And I reload the page
@ -167,7 +167,7 @@ Feature: The my overview block allows users to easily access their courses
And "[data-display='summary']" "css_element" in the "Course overview" "block" should be visible
Scenario: Course name sort persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "sortingdropdown" "button" in the "Course overview" "block"
And I click on "Course name" "link" in the "Course overview" "block"
And I reload the page
@ -175,7 +175,7 @@ Feature: The my overview block allows users to easily access their courses
And "[data-sort='fullname']" "css_element" in the "Course overview" "block" should be visible
Scenario: Last accessed sort persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "sortingdropdown" "button" in the "Course overview" "block"
And I click on "Last accessed" "link" in the "Course overview" "block"
And I reload the page
@ -183,7 +183,7 @@ Feature: The my overview block allows users to easily access their courses
And "[data-sort='ul.timeaccess desc']" "css_element" in the "Course overview" "block" should be visible
Scenario: Short name sort persistence
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
When I click on "sortingdropdown" "button" in the "Course overview" "block"
Then I should not see "Short name" in the "Course overview" "block"
When the following config values are set as admin:
@ -197,7 +197,7 @@ Feature: The my overview block allows users to easily access their courses
And "[data-sort='shortname']" "css_element" in the "Course overview" "block" should be visible
Scenario: View inprogress courses with hide persistent functionality
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "In progress" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
@ -210,7 +210,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 5" in the "Course overview" "block"
Scenario: View past courses with hide persistent functionality
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Past" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 1')]" "xpath_element"
@ -223,7 +223,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 5" in the "Course overview" "block"
Scenario: View future courses with hide persistent functionality
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Future" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
@ -236,7 +236,7 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 4" in the "Course overview" "block"
Scenario: View all (except hidden) courses with hide persistent functionality
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "All (except removed from view)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
@ -252,7 +252,7 @@ Feature: The my overview block allows users to easily access their courses
Given the following config values are set as admin:
| config | value | plugin |
| displaygroupingallincludinghidden | 1 | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
# We have to click on the data attribute instead of the button element text as we might risk to click on the false positive "All (except removed from view)" element instead
When I click on "[data-value='allincludinghidden']" "css_element" in the "Course overview" "block"
@ -268,7 +268,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: Show course category in cards display
Given the following config values are set as admin:
| displaycategories | 1 | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "Card" "link" in the "Course overview" "block"
Then I should see "Category 1" in the "Course overview" "block"
@ -276,7 +276,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: Show course category in list display
Given the following config values are set as admin:
| displaycategories | 1 | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "List" "link" in the "Course overview" "block"
Then I should see "Category 1" in the "Course overview" "block"
@ -284,7 +284,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: Show course category in summary display
Given the following config values are set as admin:
| displaycategories | 1 | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "Summary" "link" in the "Course overview" "block"
Then I should see "Category 1" in the "Course overview" "block"
@ -292,7 +292,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: Hide course category in cards display
Given the following config values are set as admin:
| displaycategories | 0 | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "Card" "link" in the "Course overview" "block"
Then I should not see "Category 1" in the "Course overview" "block"
@ -300,7 +300,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: Hide course category in list display
Given the following config values are set as admin:
| displaycategories | 0 | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "List" "link" in the "Course overview" "block"
Then I should not see "Category 1" in the "Course overview" "block"
@ -308,12 +308,12 @@ Feature: The my overview block allows users to easily access their courses
Scenario: Show course category in summary display
Given the following config values are set as admin:
| displaycategories | 0 | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "Summary" "link" in the "Course overview" "block"
Then I should not see "Category 1" in the "Course overview" "block"
@accessibility
Scenario: The dashboard page must have sufficient colour contrast
When I log in as "student1"
When I am on the "My courses" page logged in as "student1"
Then the page should meet "wcag143" accessibility standards

View file

@ -24,7 +24,7 @@ Feature: The my overview block allows users to favourite their courses
| student1 | C5 | student |
Scenario: Favourite a course on a course card
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
When I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Star this course" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I reload the page
@ -34,7 +34,7 @@ Feature: The my overview block allows users to favourite their courses
And "//div[@class='card dashboard-card' and contains(.,'Course 3')]//span[@data-region='is-favourite' and @aria-hidden='true']" "xpath_element" should exist
Scenario: Star a course and switch display to list
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
When I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
And I click on "Star this course" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
And I reload the page
@ -47,7 +47,7 @@ Feature: The my overview block allows users to favourite their courses
And "//li[contains(concat(' ', normalize-space(@class), ' '), 'list-group-item') and contains(.,'Course 3')]//span[@data-region='is-favourite' and @aria-hidden='true']" "xpath_element" should exist
Scenario: Star a course and switch display to summary
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
When I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
And I click on "Star this course" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
And I reload the page

View file

@ -24,7 +24,7 @@ Feature: The my overview block allows users to hide their courses
| student1 | C5 | student |
Scenario: Test hide toggle functionality
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "All (except removed from view)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
@ -33,7 +33,7 @@ Feature: The my overview block allows users to hide their courses
Then I should not see "Course 2" in the "Course overview" "block"
Scenario: Test hide toggle functionality w/ favorites
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "All (except removed from view)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
@ -50,7 +50,7 @@ Feature: The my overview block allows users to hide their courses
Then I should see "Course 2" in the "Course overview" "block"
Scenario: Test show toggle functionality
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "All (except removed from view)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
@ -65,7 +65,7 @@ Feature: The my overview block allows users to hide their courses
Then I should see "Course 2" in the "Course overview" "block"
Scenario: Test show toggle functionality w/ favorites
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "All (except removed from view)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
@ -87,7 +87,7 @@ Feature: The my overview block allows users to hide their courses
Then I should see "Course 2" in the "Course overview" "block"
Scenario: Test a course is hidden directly with "All (except removed from view)" courses
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "All (except removed from view)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
@ -98,7 +98,7 @@ Feature: The my overview block allows users to hide their courses
Given the following config values are set as admin:
| config | value | plugin |
| displaygroupingallincludinghidden | 1 | block_myoverview |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
# We have to click on the data attribute instead of the button element text as we might risk to click on the false positive "All (except hidden)" element instead
When I click on "[data-value='allincludinghidden']" "css_element" in the "Course overview" "block"

View file

@ -37,7 +37,7 @@ Feature: The my overview block allows users to persistence of their page limits
| student1 | C13 | student |
Scenario: Toggle the page limit between page reloads
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
When I click on "[data-action='limit-toggle']" "css_element" in the "Course overview" "block"
And I click on "All" "link" in the ".dropdown-menu.show" "css_element"
Then I should see "Course 13"
@ -46,7 +46,7 @@ Feature: The my overview block allows users to persistence of their page limits
And I should see "All" in the "[data-action='limit-toggle']" "css_element"
Scenario: Toggle the page limit between grouping changes
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
When I click on "[data-action='limit-toggle']" "css_element" in the "Course overview" "block"
And I click on "All" "link" in the ".dropdown-menu.show" "css_element"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"

View file

@ -34,7 +34,7 @@ Feature: My overview block pagination
| Course 25 | C25 | 0 |
Scenario: The pagination controls should be hidden if I am not enrolled in any courses
When I log in as "student1"
When I am on the "My courses" page logged in as "student1"
Then I should see "No courses" in the "Course overview" "block"
And I should not see "Show" in the "Course overview" "block"
And ".block_myoverview .dropdown-menu.show" "css_element" should not be visible
@ -57,7 +57,7 @@ Feature: My overview block pagination
| student1 | C10 | student |
| student1 | C11 | student |
| student1 | C12 | student |
When I log in as "student1"
When I am on the "My courses" page logged in as "student1"
Then I should not see "Show" in the "Course overview" "block"
And ".block_myoverview .dropdown-menu.show" "css_element" should not be visible
And ".block_myoverview [data-control='next']" "css_element" should not be visible
@ -80,7 +80,7 @@ Feature: My overview block pagination
| student1 | C11 | student |
| student1 | C12 | student |
| student1 | C13 | student |
When I log in as "student1"
When I am on the "My courses" page logged in as "student1"
Then I should see "12" in the "[data-action='limit-toggle']" "css_element"
And I log out
@ -100,7 +100,7 @@ Feature: My overview block pagination
| student1 | C11 | student |
| student1 | C12 | student |
| student1 | C13 | student |
And I log in as "student1"
And I am on the "My courses" page logged in as "student1"
When I click on "[data-action='limit-toggle']" "css_element" in the "Course overview" "block"
Then I should see "All" in the ".dropdown-menu.show" "css_element"
And I should see "12" in the ".dropdown-menu.show" "css_element"
@ -125,7 +125,7 @@ Feature: My overview block pagination
| student1 | C11 | student |
| student1 | C12 | student |
| student1 | C13 | student |
When I log in as "student1"
When I am on the "My courses" page logged in as "student1"
Then the "class" attribute of ".block_myoverview [data-control='previous']" "css_element" should contain "disabled"
And I log out
@ -145,7 +145,7 @@ Feature: My overview block pagination
| student1 | C11 | student |
| student1 | C12 | student |
| student1 | C13 | student |
When I log in as "student1"
When I am on the "My courses" page logged in as "student1"
And I click on "[data-control='next']" "css_element" in the "Course overview" "block"
Then the "class" attribute of ".block_myoverview [data-control='next']" "css_element" should contain "disabled"
And I log out
@ -178,7 +178,8 @@ Feature: My overview block pagination
| student1 | C23 | student |
| student1 | C24 | student |
| student1 | C25 | student |
When I log in as "student1"
When I am on the "My courses" page logged in as "student1"
And I wait until ".block_myoverview [data-control='next']" "css_element" exists
And I click on "[data-control='next']" "css_element" in the "Course overview" "block"
Then the "class" attribute of ".block_myoverview [data-control='next']" "css_element" should not contain "disabled"
And the "class" attribute of ".block_myoverview [data-control='previous']" "css_element" should not contain "disabled"

View file

@ -21,7 +21,7 @@ Feature: Course overview block show users their progress on courses
| student1 | C1 | student |
Scenario: Course progress percentage should not be displayed if completion is not enabled
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "All (except removed from view)" "link" in the "Course overview" "block"
Then I should not see "0%" in the "Course overview" "block"
@ -34,12 +34,11 @@ Feature: Course overview block show users their progress on courses
| id_completionview | 1 |
And I press "Save and return to course"
And I log out
When I log in as "student1"
When I am on the "My courses" page logged in as "student1"
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
And I should see "0%" in the "Course overview" "block"
And I am on the "Test choice 1" "choice activity" page
And I follow "Dashboard" in the user menu
And I am on the "My courses" page
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
And I should see "100%" in the "Course overview" "block"

View file

@ -39,21 +39,21 @@ Feature: My overview block searching
| student1 | C13 | student |
Scenario: The search should return no courses if I am not enrolled in any
When I log in as "student2"
When I am on the "My courses" page logged in as "student1"
Then I should see "No courses" in the "Course overview" "block"
And I set the field "Search courses" to "Fake example"
And I should see "No courses" in the "Course overview" "block"
And I log out
Scenario: Single page search
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I set the field "Search courses" to "Course 0"
Then I should see "Course 01" in the "Course overview" "block"
And I should not see "Course 13" in the "Course overview" "block"
And I log out
Scenario: Paginated search
Given I log in as "student1"
Given I am on the "My courses" page logged in as "student1"
And I set the field "Search courses" to "Course"
And I should see "Course 01" in the "Course overview" "block"
And I should not see "Course 13" in the "Course overview" "block"

View file

@ -66,15 +66,15 @@ class block_myoverview_testcase extends advanced_testcase {
$this->setUser($user);
$context = context_user::instance($user->id);
if (!$currentpage = my_get_page($user->id, MY_PAGE_PRIVATE)) {
if (!$currentpage = my_get_page($user->id, MY_PAGE_PUBLIC, MY_PAGE_COURSES)) {
throw new moodle_exception('mymoodlesetup');
}
$PAGE->set_url('/my/index.php'); // Need this because some internal API calls require the $PAGE url to be set.
$PAGE->set_url('/my/courses.php'); // Need this because some internal API calls require the $PAGE url to be set.
$PAGE->set_context($context);
$PAGE->set_pagelayout('mydashboard');
$PAGE->set_pagetype('my-index');
$PAGE->blocks->add_region('content'); // Need to add this special regition to retrieve the central blocks.
$PAGE->blocks->add_region('content'); // Need to add this special region to retrieve the central blocks.
$PAGE->set_subpage($currentpage->id);
// Load the block instances for all the regions.

View file

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2021052503; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2021052504; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'block_myoverview'; // Full name of the plugin (used for diagnostics).