diff --git a/course/management.php b/course/management.php index 2eafcc8eaf0..c470875393a 100644 --- a/course/management.php +++ b/course/management.php @@ -235,7 +235,10 @@ if ($action !== false && confirm_sesskey()) { if ($data = $mform->get_data()) { // The form has been submit handle it. if ($data->fulldelete == 1 && $category->can_delete_full()) { - $continueurl = new moodle_url('/course/management.php', array('categoryid' => $category->parent)); + $continueurl = new moodle_url('/course/management.php'); + if ($category->parent != '0') { + $continueurl->param('categoryid', $category->parent); + } $notification = get_string('coursecategorydeleted', '', $category->get_formatted_name()); $deletedcourses = $category->delete_full(true); foreach ($deletedcourses as $course) { diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index 67833867e17..d8b3ab8087b 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -69,10 +69,10 @@ class behat_course extends behat_base { public function i_create_a_course_with(TableNode $table) { return array( new Given('I go to the courses management page'), - new Given('I should see the "Course categories" management page'), - new Given('I click on "Miscellaneous" category listing'), - new Given('I should see the "Course categories and courses" management page'), - new Given('I click on "New course" "link" in the "#course-listing" "css_element"'), + new Given('I should see the "'.get_string('categories').'" management page'), + new Given('I click on category "'.get_string('miscellaneous').'" in the management interface'), + new Given('I should see the "'.get_string('categoriesandcoures').'" management page'), + new Given('I click on "'.get_string('newcourse').'" "link" in the "#course-listing" "css_element"'), new Given('I fill the moodle form with:', $table), new Given('I press "' . get_string('savechanges') . '"') ); @@ -812,22 +812,38 @@ class behat_course extends behat_base { /** * Returns the id of the category with the given idnumber. + * + * Please note that this function requires the category to exist. If it does not exist an ExpectationException is thrown. + * * @param string $idnumber * @return string + * @throws ExpectationException */ protected function get_category_id($idnumber) { global $DB; - return $DB->get_field('course_categories', 'id', array('idnumber' => $idnumber), MUST_EXIST); + try { + return $DB->get_field('course_categories', 'id', array('idnumber' => $idnumber), MUST_EXIST); + } catch (dml_missing_record_exception $ex) { + throw new ExpectationException(sprintf("There is no category in the database with the idnumber '%s'", $idnumber)); + } } /** * Returns the id of the course with the given idnumber. + * + * Please note that this function requires the category to exist. If it does not exist an ExpectationException is thrown. + * * @param string $idnumber * @return string + * @throws ExpectationException */ protected function get_course_id($idnumber) { global $DB; - return $DB->get_field('course', 'id', array('idnumber' => $idnumber), MUST_EXIST); + try { + return $DB->get_field('course', 'id', array('idnumber' => $idnumber), MUST_EXIST); + } catch (dml_missing_record_exception $ex) { + throw new ExpectationException(sprintf("There is no course in the database with the idnumber '%s'", $idnumber)); + } } /** @@ -843,7 +859,9 @@ class behat_course extends behat_base { } /** - * @param $name + * Returns a category node from within the management interface. + * + * @param string $name The name of the category. * @return \Behat\Mink\Element\NodeElement */ protected function get_management_category_listing_node_by_name($name) { @@ -852,7 +870,9 @@ class behat_course extends behat_base { } /** - * @param $name + * Returns a course node from within the management interface. + * + * @param string $name The name of the course. * @return \Behat\Mink\Element\NodeElement */ protected function get_management_course_listing_node_by_name($name) { @@ -873,29 +893,34 @@ class behat_course extends behat_base { } /** - * Toggle the expansion of a category revealing its sub categories within the management UI. + * Clicks on a category in the management interface. * - * @Given /^I click on "(?P[^"]*)" (?Pcourse|category) listing$/ + * @Given /^I click on category "(?P[^"]*)" in the management interface$/ * @param string $name - * @param string $listing */ - public function i_click_on_listing($name, $listing) { - if ($listing === 'course') { - $node = $this->get_management_course_listing_node_by_name($name); - $node->find('css', 'a.coursename')->click(); - } else { - $node = $this->get_management_category_listing_node_by_name($name); - $node->find('css', 'a.categoryname')->click(); - } + 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(); } /** - * Toggle the expansion of a category revealing its sub categories within the management UI. + * Clicks on a course in the management interface. * - * @Given /^I click to toggle subcategories expansion "(?P[^"]*)"$/ + * @Given /^I click on course "(?P[^"]*)" in the management interface$/ + * @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(); + } + + /** + * Click to expand a category revealing its sub categories within the management UI. + * + * @Given /^I click to expand category "(?P[^"]*)" in the management interface$/ * @param string $idnumber */ - public function i_click_to_toggle_subcategories_expansion($idnumber) { + public function i_click_to_expand_category_in_the_management_interface($idnumber) { $categorynode = $this->get_management_category_listing_node_by_idnumber($idnumber); $exception = new ExpectationException('Category "' . $idnumber . '" does not contain an expand or collapse toggle.', $this->getSession()); $togglenode = $this->find('css', 'a[data-action=collapse],a[data-action=expand]', $exception, $categorynode); @@ -903,7 +928,7 @@ class behat_course extends behat_base { } /** - * Throws an exception if the category with the matching idnumber is not "visible" in the management UI. + * Checks that a category within the management interface is visible. * * @Given /^category in management listing should be visible "(?P[^"]*)"$/ * @param string $idnumber @@ -916,7 +941,7 @@ class behat_course extends behat_base { } /** - * Throws an exception if the category with the matching idnumber is "visible" in the management UI. + * Checks that a category within the management interface is dimmed. * * @Given /^category in management listing should be dimmed "(?P[^"]*)"$/ * @param string $idnumber @@ -929,7 +954,7 @@ class behat_course extends behat_base { } /** - * Throws an exception if the course with the matching idnumber is not "visible" in the management UI. + * Checks that a course within the management interface is visible. * * @Given /^course in management listing should be visible "(?P[^"]*)"$/ * @param string $idnumber @@ -942,7 +967,7 @@ class behat_course extends behat_base { } /** - * Throws an exception if the course with the matching idnumber is "visible" in the management UI. + * Checks that a course within the management interface is dimmed. * * @Given /^course in management listing should be dimmed "(?P[^"]*)"$/ * @param string $idnumber @@ -996,36 +1021,62 @@ class behat_course extends behat_base { } /** - * @Given /^I click to move (?Pcategory|course) "(?P[^"]*)" (?Pup|down) one(?P without highlight)?$/ - * @param $listing - * @param $idnumber - * @param $direction + * Moves a category displayed in the management interface up or down one place. + * + * @Given /^I click to move category "(?P[^"]*)" (?Pup|down) one$/ + * + * @param string $idnumber The category idnumber + * @param string $direction The direction to move in, either up or down */ - public function i_click_to_move_listing_by_one($listing, $idnumber, $direction, $nohighlight = false) { - $up = ($direction === 'up'); - if ($listing === 'category') { - $node = $this->get_management_category_listing_node_by_idnumber($idnumber); - } else { - $node = $this->get_management_course_listing_node_by_idnumber($idnumber); - } + public function i_click_to_move_category_by_one($idnumber, $direction) { + $node = $this->get_management_category_listing_node_by_idnumber($idnumber); + $this->user_moves_listing_by_one('category', $node, $direction); + } + + /** + * Moves a course displayed in the management interface up or down one place. + * + * @Given /^I click to move course "(?P[^"]*)" (?Pup|down) one$/ + * + * @param string $idnumber The course idnumber + * @param string $direction The direction to move in, either up or down + */ + public function i_click_to_move_course_by_one($idnumber, $direction) { + $node = $this->get_management_course_listing_node_by_idnumber($idnumber); + $this->user_moves_listing_by_one('course', $node, $direction); + } + + /** + * Moves a course or category listing within the management interface up or down by one. + * + * @param string $listingtype One of course or category + * @param \Behat\Mink\Element\NodeElement $listingnode + * @param string $direction One of up or down. + * @param bool $highlight If set to false we don't check the node has been highlighted. + */ + protected function user_moves_listing_by_one($listingtype, $listingnode, $direction, $highlight = true) { + $up = (strtolower($direction) === 'up'); if ($up) { - $exception = new ExpectationException($listing.' listing "' . $idnumber . '" does not contain a moveup button.', $this->getSession()); - $button = $this->find('css', 'a.action-moveup', $exception, $node); + $exception = new ExpectationException($listingtype.' listing does not contain a moveup button.', $this->getSession()); + $button = $this->find('css', 'a.action-moveup', $exception, $listingnode); } else { - $exception = new ExpectationException($listing.' listing "' . $idnumber . '" does not contain a movedown button.', $this->getSession()); - $button = $this->find('css', 'a.action-movedown', $exception, $node); + $exception = new ExpectationException($listingtype.' listing does not contain a movedown button.', $this->getSession()); + $button = $this->find('css', 'a.action-movedown', $exception, $listingnode); } $button->click(); - if ($this->running_javascript() && empty($nohighlight)) { - $listitem = $node->getParent(); + if ($this->running_javascript() && $highlight) { + $listitem = $listingnode->getParent(); $exception = new ExpectationException('Nothing was highlighted, ajax didn\'t occur or didn\'t succeed.', $this->getSession()); $this->spin(array($this, 'listing_is_highlighted'), $listitem->getTagName().'#'.$listitem->getAttribute('id'), 2, $exception, true); } } /** - * @param \Behat\Mink\Element\NodeElement $listitem - * @return mixed + * Used by spin to determine the callback has been highlighted. + * + * @param behat_course $self A self reference (default first arg from a spin callback) + * @param \Behat\Mink\Element\NodeElement $selector + * @return bool */ protected function listing_is_highlighted($self, $selector) { $listitem = $this->find('css', $selector); @@ -1033,30 +1084,47 @@ class behat_course extends behat_base { } /** - * Confirms that listings appear in a specific order. + * Check that one course appears before another in the course category management listings. * - * @Given /^I should see (?Pcategory|course) listing "(?P[^"]*)" before "(?P[^"]*)"$/ - * @param string $listing Is either category or course - * @param string $before The name of the before listitem. - * @string string $after The name of the after listitem. + * @Given /^I should see course listing "(?P[^"]*)" before "(?P[^"]*)"$/ + * + * @param string $preceedingcourse The first course to find + * @param string $followingcourse The second course to find (should be AFTER the first course) + * @throws ExpectationException */ - public function i_should_see_listing_before($listing, $before, $after) { - $xpath = "//div[@id='{$listing}-listing']//li[contains(concat(' ', @class, ' '), ' listitem-{$listing} ')]//a[text()='{$before}']/ancestor::li[@data-id]//following::a[text()='{$after}']"; - $msg = "{$before} {$listing} does not appear before {$after} {$listing}"; + public function i_should_see_course_listing_before($preceedingcourse, $followingcourse) { + $xpath = "//div[@id='course-listing']//li[contains(concat(' ', @class, ' '), ' listitem-course ')]//a[text()='{$preceedingcourse}']/ancestor::li[@data-id]//following::a[text()='{$followingcourse}']"; + $msg = "{$preceedingcourse} course does not appear before {$followingcourse} course"; if (!$this->getSession()->getDriver()->find($xpath)) { throw new ExpectationException($msg, $this->getSession()); } } /** - * Returns an array of checks to be performed to make sure we are on the management page with the expected components. + * Check that one category appears before another in the course category management listings. * - * @Given /^I should see the "(?P[^"]*)" management page(?P with a course selected)?$/ - * @param string $mode - * @param bool $withcourse + * @Given /^I should see category listing "(?P[^"]*)" before "(?P[^"]*)"$/ + * + * @param string $preceedingcategory The first category to find + * @param string $followingcategory The second category to find (should be after the first category) + * @throws ExpectationException + */ + public function i_should_see_category_listing_before($preceedingcategory, $followingcategory) { + $xpath = "//div[@id='category-listing']//li[contains(concat(' ', @class, ' '), ' listitem-category ')]//a[text()='{$preceedingcategory}']/ancestor::li[@data-id]//following::a[text()='{$followingcategory}']"; + $msg = "{$preceedingcategory} category does not appear before {$followingcategory} category"; + if (!$this->getSession()->getDriver()->find($xpath)) { + throw new ExpectationException($msg, $this->getSession()); + } + } + + /** + * Checks that we are on the course management page that we expect to be on and that no course has been selected. + * + * @Given /^I should see the "(?P[^"]*)" management page$/ + * @param string $mode The mode to expected. One of 'Courses', 'Course categories' or 'Course categories and courses' * @return Given[] */ - public function i_should_see_the_courses_management_page($mode, $withcourse = false) { + public function i_should_see_the_courses_management_page($mode) { $return = array( new Given('I should see "Course and category management" in the "h2" "css_element"') ); @@ -1075,33 +1143,68 @@ class behat_course extends behat_base { $return[] = new Given('"#course-listing" "css_element" should exists'); break; } - if (!empty($withcourse)) { - $return[] = new Given('"#course-detail" "css_element" should exists'); - } else { - $return[] = new Given('"#course-detail" "css_element" should not exists'); - } + $return[] = new Given('"#course-detail" "css_element" should not exists'); return $return; } /** - * @Given /^I click on "(?P[^"]*)" action for "(?P[^"]*)" in management (?Pcourse|category) listing$/ + * Checks that we are on the course management page that we expect to be on and that a course has been selected. + * + * @Given /^I should see the "(?P[^"]*)" management page with a course selected$/ + * @param string $mode The mode to expected. One of 'Courses', 'Course categories' or 'Course categories and courses' + * @return Given[] */ - public function i_click_on_action_for_item_in_management_course_listing($action, $name, $listing) { - if ($listing === 'category') { - $node = $this->get_management_category_listing_node_by_name($name); - } else { - $node = $this->get_management_course_listing_node_by_name($name); - $listing = 'course'; - } - $actionsnode = $node->find('xpath', "//*[contains(concat(' ', normalize-space(@class), ' '), '{$listing}-item-actions')]"); + public function i_should_see_the_courses_management_page_with_a_course_selected($mode) { + $return = $this->i_should_see_the_courses_management_page($mode); + array_pop($return); + $return[] = new Given('"#course-detail" "css_element" should exists'); + return $return; + } + + /** + * Locates a course in the course category management interface and then triggers an action for it. + * + * @Given /^I click on "(?P[^"]*)" action for "(?P[^"]*)" in management course listing$/ + * + * @param string $action The action to take. One of + * @param string $name The name of the course as it is displayed in the management interface. + */ + public function i_click_on_action_for_item_in_management_course_listing($action, $name) { + $node = $this->get_management_course_listing_node_by_name($name); + $this->user_clicks_on_management_listing_action('course', $node, $action); + } + + /** + * Locates a category in the course category management interface and then triggers an action for it. + * + * @Given /^I click on "(?P[^"]*)" action for "(?P[^"]*)" in management category listing$/ + * + * @param string $action The action to take. One of + * @param string $name The name of the category as it is displayed in the management interface. + */ + public function i_click_on_action_for_item_in_management_category_listing($action, $name) { + $node = $this->get_management_category_listing_node_by_name($name); + $this->user_clicks_on_management_listing_action('category', $node, $action); + } + + /** + * Finds the node to use for a management listitem action and clicks it. + * + * @param string $listingtype Either course or category. + * @param \Behat\Mink\Element\NodeElement $listingnode + * @param string $action The action being taken + * @throws Behat\Mink\Exception\ExpectationException + */ + protected function user_clicks_on_management_listing_action($listingtype, $listingnode, $action) { + $actionsnode = $listingnode->find('xpath', "//*[contains(concat(' ', normalize-space(@class), ' '), '{$listingtype}-item-actions')]"); if (!$actionsnode) { - throw new ExpectationException("Could not find the actions for $listing $name", $this->getSession()); + throw new ExpectationException("Could not find the actions for $listingtype", $this->getSession()); } $actionnode = $actionsnode->find('css', '.action-'.$action); if ($actionnode === null && $this->running_javascript()) { $actionsnode->find('css', 'a.toggle-display')->click(); if ($actionnode) { - $actionnode = $node->find('css', '.action-'.$action); + $actionnode = $listingnode->find('css', '.action-'.$action); } } if (!$actionnode) { diff --git a/course/tests/behat/category_change_visibility.feature b/course/tests/behat/category_change_visibility.feature index ff75c0b140b..d51aef56e72 100644 --- a/course/tests/behat/category_change_visibility.feature +++ b/course/tests/behat/category_change_visibility.feature @@ -59,7 +59,7 @@ Feature: We can change the visibility of categories in the management interface. And I should see "Cat 1" in the "#category-listing ul.ml" "css_element" And I should not see "Cat 2" in the "#category-listing ul.ml" "css_element" And category in management listing should be visible "CAT1" - And I click on "Cat 1" category listing + 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 should see "Cat 1" in the "#category-listing ul.ml" "css_element" @@ -95,7 +95,7 @@ Feature: We can change the visibility of categories in the management interface. And I should see "Cat 1" in the "#category-listing ul.ml" "css_element" And I should not see "Cat 2" in the "#category-listing ul.ml" "css_element" And category in management listing should be visible "CAT1" - And I click to toggle subcategories expansion "CAT1" + And I click to expand category "CAT1" in the management interface # AJAX loads sub category. And category in management listing should be visible "CAT1" And category in management listing should be visible "CAT2" @@ -125,7 +125,7 @@ Feature: We can change the visibility of categories in the management interface. 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 "Cat 1" category listing + 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 should see "Cat 1" in the "#category-listing ul.ml" "css_element" @@ -200,7 +200,7 @@ Feature: We can change the visibility of categories in the management interface. 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 "Cat 1" category listing + 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 should see "Cat 1" in the "#category-listing ul.ml" "css_element" diff --git a/course/tests/behat/category_management.feature b/course/tests/behat/category_management.feature index 1b88c104303..5dbc4f9f22d 100644 --- a/course/tests/behat/category_management.feature +++ b/course/tests/behat/category_management.feature @@ -65,7 +65,7 @@ Feature: Test category management actions And I should see "This category is empty" And I press "Cancel" # Redirect - And I should see the "Course categories" management page + And I should see the "Course categories and courses" management page And I should see "Cat 1" in the "#category-listing ul.ml" "css_element" And I should see "Cat 2" in the "#category-listing ul.ml" "css_element" And I should see "Cat 3" in the "#category-listing ul.ml" "css_element" @@ -175,7 +175,7 @@ Feature: Test category management actions And I should see the "Course categories and courses" management page And I should see "Cat 1" in the "#course-listing h3" "css_element" - @javascript @MDL-31830 + @javascript Scenario: Test that I can create a category and view it in the management interface Given the following "categories" exists: | name | category | idnumber | diff --git a/course/tests/behat/category_resort.feature b/course/tests/behat/category_resort.feature index 3ece4d7eb5c..147617f1c61 100644 --- a/course/tests/behat/category_resort.feature +++ b/course/tests/behat/category_resort.feature @@ -71,20 +71,20 @@ Feature: Test we can resort categories in the management interface. And I go to the courses management page And I should see the "Course categories" management page And I click on "Master cat" "link" - # Redirect. + # Redirect. And I should see the "Course categories and courses" management page - And I should see "Re-sort categories" in the ".category-listing-actions" "css_element" + And I should see "Re-sort subcategories" in the ".category-listing-actions" "css_element" And I should see "By name" in the ".category-listing-actions" "css_element" And I should see "By idnumber" in the ".category-listing-actions" "css_element" And I click on "link" in the ".category-listing-actions" "css_element" - # Redirect. + # Redirect. And I should see the "Course categories and courses" management page And I should see category listing before And I should see category listing before Examples: | sortby | cat1 | cat2 | cat3 | - | "Re-sort categories" | "Social studies" | "Applied sciences" | "Extended social studies" | + | "Re-sort subcategories" | "Social studies" | "Applied sciences" | "Extended social studies" | | "By name" | "Applied sciences" | "Extended social studies" | "Social studies" | | "By idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" | @@ -103,10 +103,10 @@ Feature: Test we can resort categories in the management interface. And I click on "Master cat" "link" # Redirect. And I should see the "Course categories and courses" management page - And I should see "Re-sort categories" in the ".category-listing-actions" "css_element" + And I should see "Re-sort subcategories" in the ".category-listing-actions" "css_element" And I should not see "By name" in the ".category-listing-actions" "css_element" And I should not see "By idnumber" in the ".category-listing-actions" "css_element" - And I click on "Re-sort categories" "link" + And I click on "Re-sort subcategories" "link" And I should see "By name" in the ".category-listing-actions" "css_element" And I should see "By idnumber" in the ".category-listing-actions" "css_element" And I click on "link" in the ".category-listing-actions" "css_element" @@ -117,7 +117,7 @@ Feature: Test we can resort categories in the management interface. Examples: | sortby | cat1 | cat2 | cat3 | - | "Re-sort categories" | "Social studies" | "Applied sciences" | "Extended social studies" | + | "Re-sort subcategories" | "Social studies" | "Applied sciences" | "Extended social studies" | | "By name" | "Applied sciences" | "Extended social studies" | "Social studies" | | "By idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" | @@ -134,7 +134,7 @@ Feature: Test we can resort categories in the management interface. 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 "Cat 1" category listing + And I click on category "Cat 1" in the management interface # Redirect. We should a 1, 1a, 1b, 1c, 2. And I should see the "Course categories and courses" management page And I should see category listing "Cat 1" before "Cat 1a" @@ -173,7 +173,7 @@ Feature: Test we can resort categories in the management interface. # Redirect. We should a 2, 1. And I should see the "Course categories and courses" management page And I should see category listing "Cat 2" before "Cat 1" - And I click on "Cat 1" category listing + And I click on category "Cat 1" in the management interface # Redirect. We should a 2, 1, 1b, 1c, 1a. And I should see the "Course categories and courses" management page And I should see category listing "Cat 2" before "Cat 1" @@ -194,7 +194,7 @@ Feature: Test we can resort categories in the management interface. 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 "Cat 1" category listing + 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 should see category listing "Cat 1" before "Cat 1a" @@ -212,16 +212,4 @@ Feature: Test we can resort categories in the management interface. And I should see category listing "Cat 1" before "Cat 1b" And I should see category listing "Cat 1b" before "Cat 1c" And I should see category listing "Cat 1c" before "Cat 1a" - And I should see category listing "Cat 1a" before "Cat 2" - And I click to move category "CATA" down one without highlight - # AJAX request. No redirect. We should a 1, 1b, 1c, 1a, 2. - And I should see category listing "Cat 1" before "Cat 1b" - And I should see category listing "Cat 1b" before "Cat 1c" - And I should see category listing "Cat 1c" before "Cat 1a" - And I should see category listing "Cat 1a" before "Cat 2" - And I click to move category "CATB" up one without highlight - # AJAX request. No redirect. We should a 1, 1b, 1c, 1a, 2. - And I should see category listing "Cat 1" before "Cat 1b" - And I should see category listing "Cat 1b" before "Cat 1c" - And I should see category listing "Cat 1c" before "Cat 1a" And I should see category listing "Cat 1a" before "Cat 2" \ No newline at end of file diff --git a/course/tests/behat/course_category_management_listing.feature b/course/tests/behat/course_category_management_listing.feature index 6ac0b5b75bf..4f75808015c 100644 --- a/course/tests/behat/course_category_management_listing.feature +++ b/course/tests/behat/course_category_management_listing.feature @@ -45,7 +45,7 @@ Feature: Course category management interface performs as expected And I should see "Courses" in the "#course-listing h3" "css_element" And I should see "Cat 1" in the "#category-listing" "css_element" And I should see "Please select a category" in the "#course-listing" "css_element" - And I click on "Cat 1" category listing + 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 should see "Course categories" in the "#category-listing h3" "css_element" @@ -59,7 +59,7 @@ Feature: Course category management interface performs as expected And I should see the "Courses" management page And I should see "Cat 1" in the "#course-listing h3" "css_element" And I should see "Course 1" in the "#course-listing" "css_element" - And I click on "Course 1" course listing + And I click on course "Course 1" in the management interface # Redirect. And I should see the "Courses" management page with a course selected And I should see "Cat 1" in the "#course-listing h3" "css_element" @@ -173,7 +173,7 @@ Feature: Course category management interface performs as expected And I should not see "Cat 1-1-2" And I should not see "Cat 2-1" And I should not see "Cat 2-1-1" - And I click to toggle subcategories expansion "CAT1" + And I click to expand category "CAT1" in the management interface # AJAX action - no redirect. And I should see "Cat 1" And I should see "Cat 2" @@ -183,7 +183,7 @@ Feature: Course category management interface performs as expected And I should not see "Cat 1-1-2" And I should not see "Cat 2-1" And I should not see "Cat 2-1-1" - And I click to toggle subcategories expansion "CAT3" + And I click to expand category "CAT3" in the management interface # AJAX action - no redirect. And I should see "Cat 1" And I should see "Cat 2" @@ -193,7 +193,7 @@ Feature: Course category management interface performs as expected And I should see "Cat 1-1-2" And I should not see "Cat 2-1" And I should not see "Cat 2-1-1" - And I click to toggle subcategories expansion "CAT2" + And I click to expand category "CAT2" in the management interface # AJAX action - no redirect. And I should see "Cat 1" And I should see "Cat 2" @@ -203,7 +203,7 @@ Feature: Course category management interface performs as expected And I should see "Cat 1-1-2" And I should see "Cat 2-1" And I should not see "Cat 2-1-1" - And I click to toggle subcategories expansion "CAT7" + And I click to expand category "CAT7" in the management interface # AJAX action - no redirect. And I should see "Cat 1" And I should see "Cat 2" @@ -213,7 +213,7 @@ Feature: Course category management interface performs as expected And I should see "Cat 1-1-2" And I should see "Cat 2-1" And I should see "Cat 2-1-1" - And I click to toggle subcategories expansion "CAT1" + And I click to expand category "CAT1" in the management interface # AJAX action - no redirect. And I should see "Cat 1" And I should see "Cat 2" @@ -223,7 +223,7 @@ Feature: Course category management interface performs as expected And I should not see "Cat 1-1-2" And I should see "Cat 2-1" And I should see "Cat 2-1-1" - And I click to toggle subcategories expansion "CAT1" + And I click to expand category "CAT1" in the management interface # AJAX action - no redirect. And I should see "Cat 1" And I should see "Cat 2" @@ -275,7 +275,7 @@ Feature: Course category management interface performs as expected And I click on "Master cat" "link" # Redirect. And I should see the "Course categories and courses" management page - And I click on "Re-sort categories" "link" + And I click on "Re-sort subcategories" "link" And I should see "By name" in the ".category-listing-actions" "css_element" And I should see "By idnumber" in the ".category-listing-actions" "css_element" And I click on "link" in the ".category-listing-actions" "css_element" @@ -286,7 +286,7 @@ Feature: Course category management interface performs as expected Examples: | sortby | cat1 | cat2 | cat3 | - | "Re-sort categories" | "Social studies" | "Applied sciences" | "Extended social studies" | + | "Re-sort subcategories" | "Social studies" | "Applied sciences" | "Extended social studies" | | "By name" | "Applied sciences" | "Extended social studies" | "Social studies" | | "By idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" | @@ -653,7 +653,7 @@ Feature: Course category management interface performs as expected 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 "Cat 1" category listing + And I click on category "Cat 1" in the management interface And I click on "edit" action for "Course 1" in management course listing # Redirect And I should see "Edit course settings" diff --git a/course/tests/behat/course_change_visibility.feature b/course/tests/behat/course_change_visibility.feature index e0236d14878..08ae96cfa8b 100644 --- a/course/tests/behat/course_change_visibility.feature +++ b/course/tests/behat/course_change_visibility.feature @@ -16,7 +16,7 @@ Feature: We can change the visibility of courses in the management interface. 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 "Cat 1" category listing + 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 should see "Cat 1" in the "#category-listing ul.ml" "css_element" @@ -63,7 +63,7 @@ Feature: We can change the visibility of courses in the management interface. 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 "Cat 1" category listing + 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 should see "Cat 1" in the "#category-listing ul.ml" "css_element" diff --git a/course/tests/behat/course_resort.feature b/course/tests/behat/course_resort.feature index a0e8b14b76d..1b03560c8ce 100644 --- a/course/tests/behat/course_resort.feature +++ b/course/tests/behat/course_resort.feature @@ -18,7 +18,7 @@ Feature: Test we can resort course in the management interface. 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 "Cat 1" category listing + 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 should see "Re-sort courses" in the ".course-listing-actions" "css_element" @@ -51,7 +51,7 @@ Feature: Test we can resort course in the management interface. 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 "Cat 1" category listing + 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 should see "Re-sort courses" in the ".course-listing-actions" "css_element" @@ -87,7 +87,7 @@ Feature: Test we can resort course in the management interface. 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 "Cat 1" category listing + 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 should see "Course categories" in the "#category-listing h3" "css_element" @@ -124,7 +124,7 @@ Feature: Test we can resort course in the management interface. 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 "Cat 1" category listing + 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 should see "Course categories" in the "#category-listing h3" "css_element" diff --git a/course/tests/management_helper_test.php b/course/tests/management_helper_test.php index 45c7f3881e3..901388cf3e2 100644 --- a/course/tests/management_helper_test.php +++ b/course/tests/management_helper_test.php @@ -1169,7 +1169,8 @@ class core_course_management_helper_test extends advanced_testcase { 'moodle/course:enrolreview', 'moodle/course:delete', 'moodle/backup:backupcourse', - 'moodle/restore:restorecourse' + 'moodle/restore:restorecourse', + 'moodle/site:accessallgroups' ), $roleid, $context->id); $details = \core_course\management\helper::get_course_detail_array(new course_in_list($course)); diff --git a/course/yui/build/moodle-course-management/moodle-course-management-debug.js b/course/yui/build/moodle-course-management/moodle-course-management-debug.js index 0421bb14d30..a8703804e48 100644 --- a/course/yui/build/moodle-course-management/moodle-course-management-debug.js +++ b/course/yui/build/moodle-course-management/moodle-course-management-debug.js @@ -1316,9 +1316,10 @@ Category.prototype = { var console = this.get('console'), key, course; + Y.log('Changing categories course visibility', 'info', 'moodle-course-management'); try { for (key in courses) { - if (courses.hasOwnProperty[key]) { + if (typeof courses[key] === 'object') { course = console.getCourseById(courses[key].id); if (course) { if (courses[key].show === "1") { @@ -1345,9 +1346,10 @@ Category.prototype = { var console = this.get('console'), key, category; + Y.log('Changing categories subcategory visibility', 'info', 'moodle-course-management'); try { for (key in categories) { - if (categories.hasOwnProperty[key]) { + if (typeof categories[key] === 'object') { category = console.getCategoryById(categories[key].id); if (category) { if (categories[key].show === "1") { diff --git a/course/yui/build/moodle-course-management/moodle-course-management-min.js b/course/yui/build/moodle-course-management/moodle-course-management-min.js index 6cdaf761567..4a22850a4ac 100644 --- a/course/yui/build/moodle-course-management/moodle-course-management-min.js +++ b/course/yui/build/moodle-course-management/moodle-course-management-min.js @@ -1,3 +1,3 @@ YUI.add("moodle-course-management",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}function r(e){n.superclass.constructor.apply(this,[e])}function i(){i.superclass.constructor.apply(this,arguments)}function s(){s.superclass.constructor.apply(this,arguments)}function o(){o.superclass.constructor.apply(this,arguments)}n.NAME="moodle-course-management",n.CSS_PREFIX="management",n.ATTRS={element:{setter:function(t){return typeof t=="string"&&(t=e.one("#"+t)),t}},categorylisting:{value:null},courselisting:{value:null},coursedetails:{value:null},activecategoryid:{value:null},activecourseid:{value:null},categories:{setter:function(t,n){if(e.Lang.isArray(t))return t;var r=this.get(n);return r.push(t),r},value:[]},courses:{validator:function(t){return e.Lang.isArray(t)},value:[]},page:{getter:function(e,t){return e===null&&(e=this.get("element").getData(t),this.set(t,e)),e},value:null},totalpages:{getter:function(e,t){return e===null&&(e=this.get("element").getData(t),this.set(t,e)),e},value:null},totalcourses:{getter:function(e,t){return e===null&&(e=this.get("element").getData(t),this.set(t,e)),e},value:null},ajaxurl:{getter:function(e){return e===null&&(e=M.cfg.wwwroot+"/course/ajax/management.php"),e},value:null},dragdrop:{value:null}},n.prototype={categoriesinit:!1,initializer:function(){this.set("element","coursecat-management");var e=this.get("element"),t=e.one("#category-listing"),n=e.one("#course-listing"),i=null,s=null;t&&(i=t.one('.listitem[data-selected="1"]')),n&&(s=n.one('.listitem[data-selected="1"]')),this.set("categorylisting",t),this.set("courselisting",n),this.set("coursedetails",e.one("#course-detail")),i&&this.set("activecategoryid",i.getData("id")),s&&this.set("activecourseid",s.getData("id")),this.initialiseCategories(t),this.initialiseCourses(),n&&this.set("dragdrop",new r({console:this}))},initialiseCategories:function(e){var t=0;if(!e)return!1;e.all(".listitem[data-id]").each(function(e){this.set("categories",new s({node:e,console:this})),t++},this),this.categoriesinit||(this.get("categorylisting").delegate("click",this.handleCategoryDelegation,"a[data-action]",this),this.categoriesinit=!0)},initialiseCourses:function(){var e=this.getCategoryById(this.get("activecategoryid")),t=this.get("courselisting"),n=0;if(!t)return!1;if(!e)return!1;t.all(".listitem[data-id]").each(function(t){this.registerCourse(new o({node:t,console:this,category:e})),n++},this),t.delegate("click",this.handleCourseDelegation,"a[data-action]",this)},registerCourse:function(e){var t=this.get("courses");t.push(e),this.set("courses",t)},handleCourseDelegation:function(e){var t=e.currentTarget,n=t.getData("action"),r=t.ancestor(".listitem").getData("id"),i=this.getCourseById(r);i&&i.handle(n,e)},handleCategoryDelegation:function(e){var t=e.currentTarget,n=t.getData("action"),r=t.ancestor(".listitem").getData("id"),i=this.getCategoryById(r);i&&i.handle(n,e)},getCategoryById:function(e){var t,n,r=this.get("categories"),i=r.length;for(t=0;t .course-listing"),s=r?r.one("ul.ml"):null,o=i?i.one("ul.ml"):null,u=i?i.getData("canmoveoutof"):!1,a=u?n:o;if(!o)return!1;o.all("> li").each(function(e){this.initCourseListing(e,a)},this),o.setData("dd",new e.DD.Drop({node:o})),u&&s&&s.all("li > div").each(function(e){this.initCategoryListitem(e)},this),e.DD.DDM.on("drag:start",this.dragStart,this),e.DD.DDM.on("drag:end",this.dragEnd,this),e.DD.DDM.on("drag:drag",this.dragDrag,this),e.DD.DDM.on("drop:over",this.dropOver,this),e.DD.DDM.on("drop:enter",this.dropEnter,this),e.DD.DDM.on("drop:exit",this.dropExit,this),e.DD.DDM.on("drop:hit",this.dropHit,this)},initCourseListing:function(t,n){t.setData("dd",(new e.DD.Drag({node:t,target:{padding:"0 0 0 20"}})).addHandle(".drag-handle").plug(e.Plugin.DDProxy,{moveOnEnd:!1,borderStyle:!1}).plug(e.Plugin.DDConstrained,{constrain2node:n}))},initCategoryListitem:function(t){t.setData("dd",new e.DD.Drop({node:t}))},dragStart:function(e){var t=e.target,n=t.get("node"),r=t.get("dragNode");n.addClass("course-being-dragged"),r.addClass("course-being-dragged-proxy").set("innerHTML",n.one("a.coursename").get("innerHTML")),this.previoussibling=n.get("previousSibling")},dragEnd:function(e){var t=e.target,n=t.get("node");n.removeClass("course-being-dragged"),this.get("console").get("element").all("#category-listing li.highlight").removeClass("highlight")},dragDrag:function(e){var t=e.target.lastXY[1];t div a.action-moveup"),o=i.one(" > div a.action-movedown");if(!a||!o)s=i.one(" > div a.action-moveup"),f=u.one(" > div a.action-movedown"),!a&&!o?(l=e.Node.create(' '),f.replace(l),s.replace(f),l.replace(s),l.destroy()):o||s.insert(f,"after");this.updated(!0)}else window.location.reload()},movedown:function(t,n,r){var i,s,o,u,a,f,l,c=this.checkAjaxResponse(t,n,r);if(c===!1)return!1;i=this.get("node"),s=i.next(".listitem");if(s){i.insert(s,"before"),f=s.one(" > div a.action-movedown"),o=i.one(" > div a.action-moveup");if(!f||!o)a=s.one(" > div a.action-moveup"),u=i.one(" > div a.action-movedown"),!f&&!o?(l=e.Node.create(' '),a.replace(l),u.replace(a),l.replace(u),l.destroy()):o||u.insert(a,"before");this.updated(!0)}else window.location.reload()},show:function(e,t,n){var r=this.checkAjaxResponse(e,t,n);if(r===!1)return!1;this.markVisible(),this.updated()},markVisible:function(){return this.get("node").setAttribute("data-visible","1"),!0},hide:function(e,t,n){var r=this.checkAjaxResponse(e,t,n);if(r===!1)return!1;this.markHidden(),this.updated()},markHidden:function(){return this.get("node").setAttribute("data-visible","0"),!0},updated:function(e){e&&this.highlight()},highlight:function(){var e=this.get("node");e.siblings(".highlight").removeClass("highlight"),e.addClass("highlight"),this.highlighttimeout&&window.clearTimeout(this.highlighttimeout),this.highlighttimeout=window.setTimeout(function(){e.removeClass("highlight")},2500)}},e.extend(i,e.Base,i.prototype),s.NAME="moodle-course-management-category",s.CSS_PREFIX="management-category",s.ATTRS={categoryid:{getter:function(e,t){return e===null&&(e=this.get("node").getData("id"),this.set(t,e)),e},value:null,writeOnce:!0},selected:{getter:function(e,t){return e===null&&(e=this.get("node").getData(t),e===null&&(e=!1),this.set(t,e)),e},value:null},courses:{validator:function(t){return e.Lang.isArray(t)},value:[]}},s.prototype={initializer:function(){this.set("itemname","category")},getName:function(){return this.get("node").one("a.categoryname").get("innerHTML")},registerCourse:function(e){var t=this.get("courses");t.push(e),this.set("courses",t)},handle:function(e,t){var n={categoryid:this.get("categoryid")};switch(e){case"moveup":t.preventDefault(),this.get("console").performAjaxAction("movecategoryup",n,this.moveup,this);break;case"movedown":t.preventDefault(),this.get("console").performAjaxAction("movecategorydown",n,this.movedown,this);break;case"show":t.preventDefault(),this.get("console").performAjaxAction("showcategory",n,this.show,this);break;case"hide":t.preventDefault(),this.get("console").performAjaxAction("hidecategory",n,this.hide,this);break;case"expand":t.preventDefault(),this.get("node").getData("expanded")==="0"&&(this.get("node").setAttribute("data-expanded","1").setData("expanded","true"),this.get("console").performAjaxAction("getsubcategorieshtml",n,this.loadSubcategories,this)),this.expand();break;case"collapse":t.preventDefault(),this.collapse();break;default:return!1}},expand:function(){var e=this.get("node"),t=e.one("a[data-action=expand]");e.removeClass("collapsed"),t.setAttribute("data-action","collapse").one("img").setAttrs({src:M.util.image_url("t/switch_minus","moodle"),title:M.util.get_string("collapse","moodle"),alt:M.util.get_string("collapse","moodle")})},collapse:function(){var e=this.get("node"),t=e.one("a[data-action=collapse]");e.addClass("collapsed"),t.setAttribute("data-action","expand").one("img").setAttrs({src:M.util.image_url("t/switch_plus","moodle"),title:M.util.get_string("expand","moodle"),alt:M.util.get_string("expand","moodle")})},loadSubcategories:function(e,t,n){var r=this.checkAjaxResponse(e,t,n),i=this.get("node"),s=this.get("console");return r===!1?!1:(i.append(r.html),s.initialiseCategories(i),M.core&&M.core.actionmenu&&M.core.actionmenu.newDOMNode&&M.core.actionmenu.newDOMNode(i),!0)},moveCourseTo:function(t){var n=this;e.use("moodle-core-notification-confirm",function(){var e=new M.core.confirm({title:M.util.get_string("confirm","moodle"),question:M.util.get_string("confirmcoursemove","moodle",{course:t.getName(),category:n.getName()}),yesLabel:M.util.get_string("yes","moodle"),noLabel:M.util.get_string("no","moodle")});e.on("complete-yes",function(){e.hide(),e.destroy(),this.get("console").performAjaxAction("movecourseintocategory",{categoryid:this.get("categoryid"),courseid:t.get("courseid")},this.completeMoveCourse,this)},n),e.show()})},completeMoveCourse:function(e,t,n){var r=this.checkAjaxResponse(e,t,n),i;return r===!1?!1:(i=this.get("console").getCourseById(n.courseid),i?(this.highlight(),i&&i.remove(),!0):!1)},show:function(e,t,n){var r=this.checkAjaxResponse(e,t,n) -;if(r===!1)return!1;this.markVisible(),r.categoryvisibility&&this.updateChildVisibility(r.categoryvisibility),r.coursevisibility&&this.updateCourseVisiblity(r.coursevisibility),this.updated()},hide:function(e,t,n){var r=this.checkAjaxResponse(e,t,n);if(r===!1)return!1;this.markHidden(),r.categoryvisibility&&this.updateChildVisibility(r.categoryvisibility),r.coursevisibility&&this.updateCourseVisiblity(r.coursevisibility),this.updated()},updateCourseVisiblity:function(e){var t=this.get("console"),n,r;try{for(n in e)e.hasOwnProperty[n]&&(r=t.getCourseById(e[n].id),r&&(e[n].show==="1"?r.markVisible():r.markHidden()))}catch(i){}return this},updateChildVisibility:function(e){var t=this.get("console"),n,r;try{for(n in e)e.hasOwnProperty[n]&&(r=t.getCategoryById(e[n].id),r&&(e[n].show==="1"?r.markVisible():r.markHidden()))}catch(i){}return this}},e.extend(s,i,s.prototype),o.NAME="moodle-course-management-course",o.CSS_PREFIX="management-course",o.ATTRS={courseid:{},selected:{getter:function(e,t){return e===null&&(e=this.get("node").getData(t),this.set(t,e)),e},value:null},node:{},console:{writeOnce:"initOnly"},category:{writeOnce:"initOnly"}},o.prototype={initializer:function(){var e=this.get("node"),t=this.get("category");this.set("courseid",e.getData("id")),t&&t.registerCourse&&t.registerCourse(this),this.set("itemname","course")},getName:function(){return this.get("node").one("a.coursename").get("innerHTML")},handle:function(e,t){var n=this.get("console"),r={courseid:this.get("courseid")};switch(e){case"moveup":t.halt(),n.performAjaxAction("movecourseup",r,this.moveup,this);break;case"movedown":t.halt(),n.performAjaxAction("movecoursedown",r,this.movedown,this);break;case"show":t.halt(),n.performAjaxAction("showcourse",r,this.show,this);break;case"hide":t.halt(),n.performAjaxAction("hidecourse",r,this.hide,this);break;default:return!1}},remove:function(){this.get("console").removeCourseById(this.get("courseid")),this.get("node").remove()},moveAfter:function(e,t){var n=this.get("console"),r={courseid:this.get("courseid"),moveafter:e,previous:t};n.performAjaxAction("movecourseafter",r,this.moveAfterResponse,this)},moveAfterResponse:function(e,t,n){var r=this.checkAjaxResponse(e,t,n),i=this.get("node"),s;if(r===!1)return s=i.ancestor("ul").one("li[data-id="+n.previous+"]"),s?s.insertAfter(i,"after"):i.ancestor("ul").one("li").insert(i,"before"),!1;this.highlight()}},e.extend(o,i,o.prototype)},"@VERSION@",{requires:["base","node","io-base","moodle-core-notification-exception","json-parse","dd-constrain","dd-proxy","dd-drop","dd-delegate","node-event-delegate"]}); +;if(r===!1)return!1;this.markVisible(),r.categoryvisibility&&this.updateChildVisibility(r.categoryvisibility),r.coursevisibility&&this.updateCourseVisiblity(r.coursevisibility),this.updated()},hide:function(e,t,n){var r=this.checkAjaxResponse(e,t,n);if(r===!1)return!1;this.markHidden(),r.categoryvisibility&&this.updateChildVisibility(r.categoryvisibility),r.coursevisibility&&this.updateCourseVisiblity(r.coursevisibility),this.updated()},updateCourseVisiblity:function(e){var t=this.get("console"),n,r;try{for(n in e)typeof e[n]=="object"&&(r=t.getCourseById(e[n].id),r&&(e[n].show==="1"?r.markVisible():r.markHidden()))}catch(i){}return this},updateChildVisibility:function(e){var t=this.get("console"),n,r;try{for(n in e)typeof e[n]=="object"&&(r=t.getCategoryById(e[n].id),r&&(e[n].show==="1"?r.markVisible():r.markHidden()))}catch(i){}return this}},e.extend(s,i,s.prototype),o.NAME="moodle-course-management-course",o.CSS_PREFIX="management-course",o.ATTRS={courseid:{},selected:{getter:function(e,t){return e===null&&(e=this.get("node").getData(t),this.set(t,e)),e},value:null},node:{},console:{writeOnce:"initOnly"},category:{writeOnce:"initOnly"}},o.prototype={initializer:function(){var e=this.get("node"),t=this.get("category");this.set("courseid",e.getData("id")),t&&t.registerCourse&&t.registerCourse(this),this.set("itemname","course")},getName:function(){return this.get("node").one("a.coursename").get("innerHTML")},handle:function(e,t){var n=this.get("console"),r={courseid:this.get("courseid")};switch(e){case"moveup":t.halt(),n.performAjaxAction("movecourseup",r,this.moveup,this);break;case"movedown":t.halt(),n.performAjaxAction("movecoursedown",r,this.movedown,this);break;case"show":t.halt(),n.performAjaxAction("showcourse",r,this.show,this);break;case"hide":t.halt(),n.performAjaxAction("hidecourse",r,this.hide,this);break;default:return!1}},remove:function(){this.get("console").removeCourseById(this.get("courseid")),this.get("node").remove()},moveAfter:function(e,t){var n=this.get("console"),r={courseid:this.get("courseid"),moveafter:e,previous:t};n.performAjaxAction("movecourseafter",r,this.moveAfterResponse,this)},moveAfterResponse:function(e,t,n){var r=this.checkAjaxResponse(e,t,n),i=this.get("node"),s;if(r===!1)return s=i.ancestor("ul").one("li[data-id="+n.previous+"]"),s?s.insertAfter(i,"after"):i.ancestor("ul").one("li").insert(i,"before"),!1;this.highlight()}},e.extend(o,i,o.prototype)},"@VERSION@",{requires:["base","node","io-base","moodle-core-notification-exception","json-parse","dd-constrain","dd-proxy","dd-drop","dd-delegate","node-event-delegate"]}); diff --git a/course/yui/build/moodle-course-management/moodle-course-management.js b/course/yui/build/moodle-course-management/moodle-course-management.js index ee7a052b411..cb60e737038 100644 --- a/course/yui/build/moodle-course-management/moodle-course-management.js +++ b/course/yui/build/moodle-course-management/moodle-course-management.js @@ -1284,7 +1284,7 @@ Category.prototype = { course; try { for (key in courses) { - if (courses.hasOwnProperty[key]) { + if (typeof courses[key] === 'object') { course = console.getCourseById(courses[key].id); if (course) { if (courses[key].show === "1") { @@ -1312,7 +1312,7 @@ Category.prototype = { category; try { for (key in categories) { - if (categories.hasOwnProperty[key]) { + if (typeof categories[key] === 'object') { category = console.getCategoryById(categories[key].id); if (category) { if (categories[key].show === "1") { diff --git a/course/yui/src/management/js/category.js b/course/yui/src/management/js/category.js index 39585c21c8e..e2a967e32b6 100644 --- a/course/yui/src/management/js/category.js +++ b/course/yui/src/management/js/category.js @@ -317,9 +317,10 @@ Category.prototype = { var console = this.get('console'), key, course; + Y.log('Changing categories course visibility', 'info', 'moodle-course-management'); try { for (key in courses) { - if (courses.hasOwnProperty[key]) { + if (typeof courses[key] === 'object') { course = console.getCourseById(courses[key].id); if (course) { if (courses[key].show === "1") { @@ -346,9 +347,10 @@ Category.prototype = { var console = this.get('console'), key, category; + Y.log('Changing categories subcategory visibility', 'info', 'moodle-course-management'); try { for (key in categories) { - if (categories.hasOwnProperty[key]) { + if (typeof categories[key] === 'object') { category = console.getCategoryById(categories[key].id); if (category) { if (categories[key].show === "1") {