mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch '42302-26' of git://github.com/samhemelryk/moodle
This commit is contained in:
commit
e60637052c
@ -79,15 +79,29 @@ switch ($action) {
|
||||
break;
|
||||
case 'hidecategory' :
|
||||
$categoryid = required_param('categoryid', PARAM_INT);
|
||||
$selectedcategoryid = optional_param('selectedcategory', null, PARAM_INT);
|
||||
$outcome->outcome = \core_course\management\helper::action_category_hide_by_id($categoryid);
|
||||
$outcome->categoryvisibility = \core_course\management\helper::get_category_children_visibility($categoryid);
|
||||
$outcome->coursevisibility = \core_course\management\helper::get_category_courses_visibility($categoryid);
|
||||
if ($selectedcategoryid !== null) {
|
||||
$outcome->coursevisibility = array_merge(
|
||||
$outcome->coursevisibility,
|
||||
\core_course\management\helper::get_category_courses_visibility($selectedcategoryid)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'showcategory' :
|
||||
$categoryid = required_param('categoryid', PARAM_INT);
|
||||
$selectedcategoryid = optional_param('selectedcategory', null, PARAM_INT);
|
||||
$outcome->outcome = \core_course\management\helper::action_category_show_by_id($categoryid);
|
||||
$outcome->categoryvisibility = \core_course\management\helper::get_category_children_visibility($categoryid);
|
||||
$outcome->coursevisibility = \core_course\management\helper::get_category_courses_visibility($categoryid);
|
||||
if ($selectedcategoryid !== null) {
|
||||
$outcome->coursevisibility = array_merge(
|
||||
$outcome->coursevisibility,
|
||||
\core_course\management\helper::get_category_courses_visibility($selectedcategoryid)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'getsubcategorieshtml' :
|
||||
$categoryid = required_param('categoryid', PARAM_INT);
|
||||
|
@ -779,7 +779,7 @@ class helper {
|
||||
*/
|
||||
public static function get_category_courses_visibility($categoryid) {
|
||||
global $DB;
|
||||
$sql = "SELECT c.id, c.visible as show
|
||||
$sql = "SELECT c.id, c.visible
|
||||
FROM {course} c
|
||||
WHERE c.category = :category";
|
||||
$params = array('category' => (int)$categoryid);
|
||||
@ -797,7 +797,7 @@ class helper {
|
||||
$select = $DB->sql_like('path', ':path');
|
||||
$path = $category->path . '/%';
|
||||
|
||||
$sql = "SELECT c.id, c.visible as show
|
||||
$sql = "SELECT c.id, c.visible
|
||||
FROM {course_categories} c
|
||||
WHERE ".$select;
|
||||
$params = array('path' => $path);
|
||||
|
@ -862,10 +862,14 @@ class behat_course extends behat_base {
|
||||
* Returns a category node from within the management interface.
|
||||
*
|
||||
* @param string $name The name of the category.
|
||||
* @param bool $link If set to true we'll resolve to the link rather than just the node.
|
||||
* @return \Behat\Mink\Element\NodeElement
|
||||
*/
|
||||
protected function get_management_category_listing_node_by_name($name) {
|
||||
$selector = "//div[@id='category-listing']//li[contains(concat(' ', normalize-space(@class), ' '), ' listitem-category ')]//a[text()='{$name}']/ancestor::li[@data-id]";
|
||||
protected function get_management_category_listing_node_by_name($name, $link = false) {
|
||||
$selector = "//div[@id='category-listing']//li[contains(concat(' ', normalize-space(@class), ' '), ' listitem-category ')]//a[text()='{$name}']";
|
||||
if ($link === false) {
|
||||
$selector .= "/ancestor::li[@data-id]";
|
||||
}
|
||||
return $this->find('xpath', $selector);
|
||||
}
|
||||
|
||||
@ -873,10 +877,14 @@ class behat_course extends behat_base {
|
||||
* Returns a course node from within the management interface.
|
||||
*
|
||||
* @param string $name The name of the course.
|
||||
* @param bool $link If set to true we'll resolve to the link rather than just the node.
|
||||
* @return \Behat\Mink\Element\NodeElement
|
||||
*/
|
||||
protected function get_management_course_listing_node_by_name($name) {
|
||||
$selector = "//div[@id='course-listing']//li[contains(concat(' ', @class, ' '), ' listitem-course ')]//a[text()='{$name}']/ancestor::li[@data-id]";
|
||||
protected function get_management_course_listing_node_by_name($name, $link = false) {
|
||||
$selector = "//div[@id='course-listing']//li[contains(concat(' ', @class, ' '), ' listitem-course ')]//a[text()='{$name}']";
|
||||
if ($link === false) {
|
||||
$selector .= "/ancestor::li[@data-id]";
|
||||
}
|
||||
return $this->find('xpath', $selector);
|
||||
}
|
||||
|
||||
@ -899,8 +907,8 @@ class behat_course extends behat_base {
|
||||
* @param string $name
|
||||
*/
|
||||
public function i_click_on_category_in_the_management_interface($name) {
|
||||
$node = $this->get_management_category_listing_node_by_name($name);
|
||||
$node->find('css', 'a.categoryname')->click();
|
||||
$node = $this->get_management_category_listing_node_by_name($name, true);
|
||||
$node->click();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -910,8 +918,8 @@ class behat_course extends behat_base {
|
||||
* @param string $name
|
||||
*/
|
||||
public function i_click_on_course_in_the_management_interface($name) {
|
||||
$node = $this->get_management_course_listing_node_by_name($name);
|
||||
$node->find('css', 'a.coursename')->click();
|
||||
$node = $this->get_management_course_listing_node_by_name($name, true);
|
||||
$node->click();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,3 +250,61 @@ Feature: We can change the visibility of categories in the management interface.
|
||||
And course in management listing should be visible "C1"
|
||||
And course in management listing should be dimmed "C2"
|
||||
And course in management listing should be visible "C3"
|
||||
|
||||
@javascript @_cross_browser
|
||||
Scenario: Test courses are hidden when selected category parent is hidden.
|
||||
Given the following "categories" exists:
|
||||
| name | category | idnumber |
|
||||
| Cat 1 | 0 | CAT1 |
|
||||
| Cat 2 | CAT1 | CAT2 |
|
||||
| Cat 3 | CAT2 | CAT3 |
|
||||
And the following "courses" exists:
|
||||
| category | fullname | shortname | idnumber |
|
||||
| CAT3 | Course 1 | Course 1 | C1 |
|
||||
|
||||
And I log in as "admin"
|
||||
And I go to the courses management page
|
||||
And I should see the "Course categories" management page
|
||||
And I click on category "Cat 1" in the management interface
|
||||
# Redirect
|
||||
And I should see the "Course categories and courses" management page
|
||||
And I click on category "Cat 2" in the management interface
|
||||
# Redirect
|
||||
And I should see the "Course categories and courses" management page
|
||||
And I click on category "Cat 3" in the management interface
|
||||
# Redirect
|
||||
And I should see the "Course categories and courses" management page
|
||||
And category in management listing should be visible "CAT1"
|
||||
And category in management listing should be visible "CAT2"
|
||||
And category in management listing should be visible "CAT3"
|
||||
And course in management listing should be visible "C1"
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
# AJAX action - no redirect.
|
||||
And category in management listing should be dimmed "CAT1"
|
||||
And category in management listing should be dimmed "CAT2"
|
||||
And category in management listing should be dimmed "CAT3"
|
||||
And course in management listing should be dimmed "C1"
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
# AJAX action - no redirect.
|
||||
And category in management listing should be visible "CAT1"
|
||||
And category in management listing should be visible "CAT2"
|
||||
And category in management listing should be visible "CAT3"
|
||||
And course in management listing should be visible "C1"
|
||||
And I toggle visibility of course "C1" in management listing
|
||||
# AJAX action - no redirect.
|
||||
And category in management listing should be visible "CAT1"
|
||||
And category in management listing should be visible "CAT2"
|
||||
And category in management listing should be visible "CAT3"
|
||||
And course in management listing should be dimmed "C1"
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
# AJAX action - no redirect.
|
||||
And category in management listing should be dimmed "CAT1"
|
||||
And category in management listing should be dimmed "CAT2"
|
||||
And category in management listing should be dimmed "CAT3"
|
||||
And course in management listing should be dimmed "C1"
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
# AJAX action - no redirect.
|
||||
And category in management listing should be visible "CAT1"
|
||||
And category in management listing should be visible "CAT2"
|
||||
And category in management listing should be visible "CAT3"
|
||||
And course in management listing should be dimmed "C1"
|
@ -1102,7 +1102,11 @@ Category.prototype = {
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
handle : function(action, e) {
|
||||
var catarg = {categoryid : this.get('categoryid')};
|
||||
var catarg = {categoryid : this.get('categoryid')},
|
||||
selected = this.get('console').get('activecategoryid');
|
||||
if (selected && selected !== catarg.categoryid) {
|
||||
catarg.selectedcategory = selected;
|
||||
}
|
||||
switch (action) {
|
||||
case 'moveup':
|
||||
e.preventDefault();
|
||||
|
File diff suppressed because one or more lines are too long
@ -1078,7 +1078,11 @@ Category.prototype = {
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
handle : function(action, e) {
|
||||
var catarg = {categoryid : this.get('categoryid')};
|
||||
var catarg = {categoryid : this.get('categoryid')},
|
||||
selected = this.get('console').get('activecategoryid');
|
||||
if (selected && selected !== catarg.categoryid) {
|
||||
catarg.selectedcategory = selected;
|
||||
}
|
||||
switch (action) {
|
||||
case 'moveup':
|
||||
e.preventDefault();
|
||||
|
10
course/yui/src/management/js/category.js
vendored
10
course/yui/src/management/js/category.js
vendored
@ -102,7 +102,11 @@ Category.prototype = {
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
handle : function(action, e) {
|
||||
var catarg = {categoryid : this.get('categoryid')};
|
||||
var catarg = {categoryid : this.get('categoryid')},
|
||||
selected = this.get('console').get('activecategoryid');
|
||||
if (selected && selected !== catarg.categoryid) {
|
||||
catarg.selectedcategory = selected;
|
||||
}
|
||||
switch (action) {
|
||||
case 'moveup':
|
||||
e.preventDefault();
|
||||
@ -323,7 +327,7 @@ Category.prototype = {
|
||||
if (typeof courses[key] === 'object') {
|
||||
course = console.getCourseById(courses[key].id);
|
||||
if (course) {
|
||||
if (courses[key].show === "1") {
|
||||
if (courses[key].visible === "1") {
|
||||
course.markVisible();
|
||||
} else {
|
||||
course.markHidden();
|
||||
@ -353,7 +357,7 @@ Category.prototype = {
|
||||
if (typeof categories[key] === 'object') {
|
||||
category = console.getCategoryById(categories[key].id);
|
||||
if (category) {
|
||||
if (categories[key].show === "1") {
|
||||
if (categories[key].visible === "1") {
|
||||
category.markVisible();
|
||||
} else {
|
||||
category.markHidden();
|
||||
|
Loading…
x
Reference in New Issue
Block a user