mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-45884 navigation: tidied up code and added behat tests
This commit is contained in:
parent
4d378e9f70
commit
aab6438ca1
@ -122,7 +122,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
$temp->add(new admin_setting_configcheckbox('navshowcategories', new lang_string('navshowcategories', 'admin'), new lang_string('confignavshowcategories', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowmycoursecategories', new lang_string('navshowmycoursecategories', 'admin'), new lang_string('navshowmycoursecategories_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowallcourses', new lang_string('navshowallcourses', 'admin'), new lang_string('confignavshowallcourses', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('navcollapsemycourses', new lang_string('navcollapsemycourses', 'admin'), new lang_string('confignavcollapsemycourses', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('navcollapsemycourses', new lang_string('navcollapsemycourses', 'admin'), new lang_string('navcollapsemycourses_desc', 'admin'), 0));
|
||||
$sortoptions = array(
|
||||
'sortorder' => new lang_string('sort_sortorder', 'admin'),
|
||||
'fullname' => new lang_string('sort_fullname', 'admin'),
|
||||
|
@ -0,0 +1,55 @@
|
||||
@block @block_navigation
|
||||
Feature: Test collapse my courses navigation setting
|
||||
As a student
|
||||
I visit my My Moodle page and observe the the My Courses branch
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
And the following "categories" exist:
|
||||
| name | category | idnumber |
|
||||
| cat1 | 0 | cat1 |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course1 | c1 | cat1 |
|
||||
| Course2 | c2 | cat1 |
|
||||
| Course3 | c3 | cat1 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | c1 | student |
|
||||
| student1 | c2 | student |
|
||||
|
||||
Scenario: The My Courses branch is expanded on the My Moodle page by default
|
||||
When I log in as "student1"
|
||||
And I follow "My home"
|
||||
Then I should see "c1" in the "Navigation" "block"
|
||||
And I should see "c2" in the "Navigation" "block"
|
||||
And I should not see "c3" in the "Navigation" "block"
|
||||
|
||||
Scenario: The My Courses branch is collapsed when collapse my courses is on
|
||||
Given I log in as "admin"
|
||||
And I set the following administration settings values:
|
||||
| Keep My Courses collapsed initially | 1 |
|
||||
And I log out
|
||||
Given I log in as "student1"
|
||||
And I follow "My home"
|
||||
Then I should not see "c1" in the "Navigation" "block"
|
||||
And I should not see "c2" in the "Navigation" "block"
|
||||
And I should not see "c3" in the "Navigation" "block"
|
||||
|
||||
@javascript
|
||||
Scenario: My Courses can be expanded on the My Moodle page when collapse my courses is on
|
||||
Given I log in as "admin"
|
||||
And I set the following administration settings values:
|
||||
| Keep My Courses collapsed initially | 1 |
|
||||
And I log out
|
||||
Given I log in as "student1"
|
||||
And I follow "My home"
|
||||
And I should not see "c1" in the "Navigation" "block"
|
||||
And I should not see "c2" in the "Navigation" "block"
|
||||
And I should not see "c3" in the "Navigation" "block"
|
||||
And I expand "My courses" node
|
||||
Then I should see "c1" in the "Navigation" "block"
|
||||
And I should see "c2" in the "Navigation" "block"
|
||||
And I should not see "c3" in the "Navigation" "block"
|
@ -271,7 +271,6 @@ $string['confignavcourselimit'] = 'Limits the number of courses shown to the use
|
||||
$string['confignavshowallcourses'] = 'This setting determines whether users who are enrolled in courses can see Courses (listing all courses) in the navigation, in addition to My Courses (listing courses in which they are enrolled).';
|
||||
$string['confignavshowcategories'] = 'Show course categories in the navigation bar and navigation blocks. This does not occur with courses the user is currently enrolled in, they will still be listed under mycourses without categories.';
|
||||
$string['confignotifyloginfailures'] = 'Send login failure notification messages to these selected users. This requires an internal logstore (eg Standard Logstore) to be enabled.';
|
||||
$string['confignavcollapsemycourses'] = 'Show the My Courses area as collapsed.';
|
||||
$string['confignotifyloginthreshold'] = 'If notifications about failed logins are active, how many failed login attempts by one user or one IP address is it worth notifying about?';
|
||||
$string['confignotloggedinroleid'] = 'Users who are not logged in to the site will be treated as if they have this role granted to them at the site context. Guest is almost always what you want here, but you might want to create roles that are less or more restrictive. Things like creating posts still require the user to log in properly.';
|
||||
$string['configopentogoogle'] = 'If you enable this setting, then Google will be allowed to enter your site as a Guest. In addition, people coming in to your site via a Google search will automatically be logged in as a Guest. Note that this only provides transparent access to courses that already allow guest access.';
|
||||
@ -740,7 +739,8 @@ $string['navshowfrontpagemods_help'] = 'If enabled, front page activities will b
|
||||
$string['navshowallcourses'] = 'Show all courses';
|
||||
$string['navshowcategories'] = 'Show course categories';
|
||||
$string['navshowmycoursecategories'] = 'Show my course categories';
|
||||
$string['navcollapsemycourses'] = 'Show My Courses as collapsed';
|
||||
$string['navcollapsemycourses'] = 'Keep My Courses collapsed initially';
|
||||
$string['navcollapsemycourses_desc'] = 'When enabled the My Courses branch will never be expanded initially. The user will need to click to expand it. At present the My Courses branch is only expanded initially when on the My Moodle page.';
|
||||
$string['navshowmycoursecategories_help'] = 'If enabled courses in the users my courses branch will be shown in categories.';
|
||||
$string['navsortmycoursessort'] = 'Sort my courses';
|
||||
$string['navsortmycoursessort_help'] = 'This determines whether courses are listed under My courses according to the sort order (i.e. the order set in Site administration > Courses > Manage courses and categories) or alphabetically by course setting.';
|
||||
|
@ -979,7 +979,7 @@ class global_navigation extends navigation_node {
|
||||
protected $initialised = false;
|
||||
/** @var array An array of course information */
|
||||
protected $mycourses = array();
|
||||
/** @var array An array for containing root navigation nodes */
|
||||
/** @var navigation_node[] An array for containing root navigation nodes */
|
||||
protected $rootnodes = array();
|
||||
/** @var bool A switch for whether to show empty sections in the navigation */
|
||||
protected $showemptysections = true;
|
||||
@ -1133,13 +1133,13 @@ class global_navigation extends navigation_node {
|
||||
$this->rootnodes['courses']->isexpandable = true;
|
||||
}
|
||||
|
||||
if (empty($CFG->navcollapsemycourses)){
|
||||
if ($this->rootnodes['mycourses']->isactive) {
|
||||
$this->load_courses_enrolled();
|
||||
}
|
||||
} else {
|
||||
$this->rootnodes['mycourses']->collapse = true;
|
||||
$this->rootnodes['mycourses']->make_inactive();
|
||||
// Load the users enrolled courses if they are viewing the My Moodle page AND the admin has not
|
||||
// set that they wish to keep the My Courses branch collapsed by default.
|
||||
if (empty($CFG->navcollapsemycourses) && $this->rootnodes['mycourses']->isactive){
|
||||
$this->load_courses_enrolled();
|
||||
} else {
|
||||
$this->rootnodes['mycourses']->collapse = true;
|
||||
$this->rootnodes['mycourses']->make_inactive();
|
||||
}
|
||||
|
||||
$canviewcourseprofile = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user