);
}
+ // Resort.
+ if ($category->can_resort_subcategories() && $category->has_children()) {
+ $actions['resortbyname'] = array(
+ 'url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'name')),
+ 'icon' => new \pix_icon('t/sort', new \lang_string('sort')),
+ 'string' => new \lang_string('resortsubcategoriesbyname', 'moodle')
+ );
+ $actions['resortbyidnumber'] = array(
+ 'url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'idnumber')),
+ 'icon' => new \pix_icon('t/sort', new \lang_string('sort')),
+ 'string' => new \lang_string('resortsubcategoriesbyidnumber', 'moodle')
+ );
+ }
+
// Delete.
if ($category->can_delete_full()) {
$actions['delete'] = array(
}
$hasitems = false;
- if ($createtoplevel || $createsubcategory) {
+ if ($createtoplevel) {
$hasitems = true;
$menu = new action_menu;
if ($createtoplevel) {
if (coursecat::can_approve_course_requests()) {
$actions[] = html_writer::link(new moodle_url('/course/pending.php'), get_string('coursespending'));
}
- if ($category->can_resort_subcategories()) {
+ if (coursecat::get(0)->can_resort_subcategories()) {
$hasitems = true;
- $params = $this->page->url->params();
+ $params = array();
$params['action'] = 'resortcategories';
$params['sesskey'] = sesskey();
+ if ($this->page->url->get_param('categoryid') !== null) {
+ $params['selectedcategoryid'] = $this->page->url->get_param('categoryid');
+ }
$baseurl = new moodle_url('/course/management.php', $params);
$menu = new action_menu(array(
new action_menu_link_secondary(
new moodle_url($baseurl, array('resort' => 'name')),
null,
- get_string('resortbyname')
+ get_string('resortcategoriesbyname')
),
new action_menu_link_secondary(
new moodle_url($baseurl, array('resort' => 'idnumber')),
null,
- get_string('resortbyidnumber')
+ get_string('resortcategoriesbyidnumber')
)
));
- if ($category->id === 0) {
- $menu->actiontext = get_string('resortcategories');
- } else {
- $menu->actiontext = get_string('resortsubcategories');
- }
+ $menu->actiontext = get_string('resortcategories');
$menu->actionicon = new pix_icon('t/contextmenu', ' ', 'moodle', array('class' => 'iconsmall', 'title' => ''));
$actions[] = $this->render($menu);
}
require_once($CFG->dirroot.'/course/lib.php');
$categoryid = optional_param('categoryid', null, PARAM_INT);
+$selectedcategoryid = optional_param('selectedcategoryid', null, PARAM_INT);
$courseid = optional_param('courseid', null, PARAM_INT);
$action = optional_param('action', false, PARAM_ALPHA);
$page = optional_param('page', 0, PARAM_INT);
navigation_node::override_active_url($url);
}
+// Check if there is a selected category param, and if there is apply it.
+if ($course === null && $selectedcategoryid !== null && $selectedcategoryid !== $categoryid) {
+ $url->param('categoryid', $selectedcategoryid);
+}
+
if ($page !== 0) {
$url->param('page', $page);
}
throw new ExpectationException("Could not find the actions for $listingtype", $this->getSession());
}
$actionnode = $actionsnode->find('css', '.action-'.$action);
- if ($this->running_javascript() && !$actionnode->isVisible()) {
- $actionsnode->find('css', 'a.toggle-display')->click();
- if ($actionnode) {
- $actionnode = $listingnode->find('css', '.action-'.$action);
- }
- }
if (!$actionnode) {
throw new ExpectationException("Expected action was not available or not found ($action)", $this->getSession());
}
+ if ($this->running_javascript() && !$actionnode->isVisible()) {
+ $actionsnode->find('css', 'a.toggle-display')->click();
+ $actionnode = $actionsnode->find('css', '.action-'.$action);
+ }
$actionnode->click();
}
}
And I go to the courses management page
And I should see the "Course categories" management page
And I should see "Re-sort categories" 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 should see "Re-sort the top level categories by name" in the ".category-listing-actions" "css_element"
+ And I should see "Re-sort the top level categories by idnumber" in the ".category-listing-actions" "css_element"
And I click on <sortby> "link" in the ".category-listing-actions" "css_element"
# Redirect.
And I should see the "Course categories" management page
Examples:
| sortby | cat1 | cat2 | cat3 |
| "Re-sort categories" | "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" |
+ | "Re-sort the top level categories by name" | "Applied sciences" | "Extended social studies" | "Social studies" |
+ | "Re-sort the top level categories by idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
@javascript
Scenario Outline: Test resorting categories with JS enabled.
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 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 should see "Re-sort the top level categories by name" in the ".category-listing-actions" "css_element"
+ And I should see "Re-sort the top level categories by idnumber" in the ".category-listing-actions" "css_element"
And I click on <sortby> "link" in the ".category-listing-actions" "css_element"
# Redirect.
And I should see the "Course categories" management page
Examples:
| sortby | cat1 | cat2 | cat3 |
| "Re-sort categories" | "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" |
+ | "Re-sort the top level categories by name" | "Applied sciences" | "Extended social studies" | "Social studies" |
+ | "Re-sort the top level categories by idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
Scenario Outline: Test resorting subcategories.
Given the following "categories" exists:
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 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 <sortby> "link" in the ".category-listing-actions" "css_element"
+ And I click on <sortby> action for "Master cat" in management category listing
# Redirect.
And I should see the "Course categories and courses" management page
And I should see category listing <cat1> before <cat2>
Examples:
| sortby | cat1 | cat2 | cat3 |
- | "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" |
+ | "resortbyname" | "Applied sciences" | "Extended social studies" | "Social studies" |
+ | "resortbyidnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
@javascript
Scenario Outline: Test resorting subcategories with JS enabled.
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 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 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 <sortby> "link" in the ".category-listing-actions" "css_element"
+ And I click on <sortby> action for "Master cat" in management category listing
# Redirect.
And I should see the "Course categories and courses" management page
And I should see category listing <cat1> before <cat2>
Examples:
| sortby | cat1 | cat2 | cat3 |
- | "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" |
+ | "resortbyname" | "Applied sciences" | "Extended social studies" | "Social studies" |
+ | "resortbyidnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
# The scenario below this is the same but with JS enabled.
Scenario: Test moving categories up and down by one.
And I go to the courses management page
And I should see the "Course categories" management page
And I click on "Re-sort categories" "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 should see "Re-sort the top level categories by name" in the ".category-listing-actions" "css_element"
+ And I should see "Re-sort the top level categories by idnumber" in the ".category-listing-actions" "css_element"
And I click on <sortby> "link" in the ".category-listing-actions" "css_element"
# Redirect.
And I should see the "Course categories" management page
Examples:
| sortby | cat1 | cat2 | cat3 |
| "Re-sort categories" | "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" |
+ | "Re-sort the top level categories by name" | "Applied sciences" | "Extended social studies" | "Social studies" |
+ | "Re-sort the top level categories by idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
@javascript
Scenario Outline: Sub categories are displayed correctly when resorted
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 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 <sortby> "link" in the ".category-listing-actions" "css_element"
+ And I click on <sortby> action for "Master cat" in management category listing
# Redirect.
And I should see the "Course categories and courses" management page
And I should see category listing <cat1> before <cat2>
Examples:
| sortby | cat1 | cat2 | cat3 |
- | "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" |
+ | "resortbyname" | "Applied sciences" | "Extended social studies" | "Social studies" |
+ | "resortbyidnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
@javascript
Scenario Outline: Test courses are displayed correctly after being resorted.
And I should see "Cat 2-1-2" in the "#course-category-listings ul.ml" "css_element"
And I should not see "Cat 2-1-1-1" in the "#course-category-listings ul.ml" "css_element"
And I should see "Cat 2-1-2-1" in the "#course-category-listings ul.ml" "css_element"
- And I click on "Re-sort subcategories" "link" in the ".category-listing-actions" "css_element"
- And I click on "By idnumber" "link" in the ".category-listing-actions" "css_element"
+ And I click on "resortbyidnumber" action for "Cat 1" in management category listing
# Redirect.
And I should see the "Course categories and courses" management page
And I should see "Cat 1" in the "#course-category-listings ul.ml" "css_element"
# Redirect.
And I should see the "Course categories and courses" management page
And I should see "Cat A (1)" in the "#course-category-listings ul.ml" "css_element"
- And I should not see "Cat B (2)" in the "#course-category-listings ul.ml" "css_element"
\ No newline at end of file
+ And I should not see "Cat B (2)" in the "#course-category-listings ul.ml" "css_element"
$string['resettask'] = 'Task';
$string['resettodefaults'] = 'Reset to defaults';
$string['resortcategories'] = 'Re-sort categories';
-$string['resortsubcategories'] = 'Re-sort subcategories';
+$string['resortcategoriesbyname'] = 'Re-sort the top level categories by name';
+$string['resortcategoriesbyidnumber'] = 'Re-sort the top level categories by idnumber';
+$string['resortsubcategoriesbyname'] = 'Re-sort subcategories by name';
+$string['resortsubcategoriesbyidnumber'] = 'Re-sort subcategories by idnumber';
$string['resortcourses'] = 'Re-sort courses';
$string['resortcoursesbyname'] = 'Re-sort courses by name';
$string['resortbyname'] = 'By name';
$string['socialheadline'] = 'Social forum - latest topics';
$string['someallowguest'] = 'Some courses may allow guest access';
$string['someerrorswerefound'] = 'Some information was missing or incorrect. Look below for details.';
+$string['sort'] = 'Sort';
$string['sortby'] = 'Sort by';
$string['sortbyx'] = 'Sort by {$a} ascending';
$string['sortbyxreverse'] = 'Sort by {$a} descending';