This commit is contained in:
Eloy Lafuente (stronk7) 2014-06-17 00:09:50 +02:00
commit d519545a54
4 changed files with 66 additions and 2 deletions

View File

@ -122,6 +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('navexpandmycourses', new lang_string('navexpandmycourses', 'admin'), new lang_string('navexpandmycourses_desc', 'admin'), 1));
$sortoptions = array(
'sortorder' => new lang_string('sort_sortorder', 'admin'),
'fullname' => new lang_string('sort_fullname', 'admin'),

View File

@ -0,0 +1,56 @@
@block @block_navigation
Feature: Test expand 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"
@javascript
Scenario: The My Courses branch is collapsed when expand my courses is off
Given I log in as "admin"
And I set the following administration settings values:
| Expand My Courses initially on My Moodle page | 0 |
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 expand my courses is off
Given I log in as "admin"
And I set the following administration settings values:
| Expand My Courses initially on My Moodle page | 0 |
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"

View File

@ -732,6 +732,8 @@ $string['navadduserpostslinks'] = 'Add links to view user posts';
$string['navadduserpostslinks_help'] = 'If enabled two links will be added to each user in the navigation to view discussions the user has started and posts the user has made in forums throughout the site or in specific courses.';
$string['navigationupgrade'] = 'This upgrade introduces two new navigation blocks that will replace these blocks: Administration, Courses, Activities and Participants. If you had set any special permissions on those blocks you should check to make sure everything is behaving as you want it.';
$string['navcourselimit'] = 'Course limit';
$string['navexpandmycourses'] = 'Expand My Courses initially on My Moodle page';
$string['navexpandmycourses_desc'] = 'When enabled the My Courses branch will be expanded initially on the My Moodle page and any pages within the My Moodle area.';
$string['navshowfullcoursenames'] = 'Show course full names';
$string['navshowfullcoursenames_help'] = 'If enabled courses in the navigation will be shown with using their full name rather than their short name.';
$string['navshowfrontpagemods'] = 'Show front page activities in the navigation';

View File

@ -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,8 +1133,13 @@ class global_navigation extends navigation_node {
$this->rootnodes['courses']->isexpandable = true;
}
if ($this->rootnodes['mycourses']->isactive) {
// 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->navexpandmycourses) && $this->rootnodes['mycourses']->isactive){
$this->load_courses_enrolled();
} else {
$this->rootnodes['mycourses']->collapse = true;
$this->rootnodes['mycourses']->make_inactive();
}
$canviewcourseprofile = true;