MDL-83840 course: add warning when hiding category
This commit is contained in:
committed by
Katie.Ransom
parent
c64e967ce6
commit
8c355f1f1c
@@ -178,7 +178,9 @@ class core_course_management_renderer extends plugin_renderer_base {
|
||||
'data-selected' => $activecategory ? '1' : '0',
|
||||
'data-visible' => $category->visible ? '1' : '0',
|
||||
'role' => 'treeitem',
|
||||
'aria-expanded' => $isexpanded ? 'true' : 'false'
|
||||
'aria-expanded' => $isexpanded ? 'true' : 'false',
|
||||
'data-course-count' => $category->get_courses_count(['recursive' => 1]),
|
||||
'data-category-name' => $category->get_formatted_name(),
|
||||
);
|
||||
$text = $category->get_formatted_name();
|
||||
if (($parent = $category->get_parent_coursecat()) && $parent->id) {
|
||||
|
||||
@@ -227,6 +227,7 @@ Feature: We can change the visibility of categories in the management interface.
|
||||
And course in management listing should be dimmed "C2"
|
||||
And course in management listing should be visible "C3"
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
And I click on "Hide" "button" in the "Hide category?" "dialogue"
|
||||
And a new page should not have loaded since I started watching
|
||||
And category in management listing should be dimmed "CAT1"
|
||||
And category in management listing should be visible "CAT2"
|
||||
@@ -277,6 +278,7 @@ Feature: We can change the visibility of categories in the management interface.
|
||||
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
|
||||
And I click on "Hide" "button" in the "Hide category?" "dialogue"
|
||||
And a new page should not have loaded since I started watching
|
||||
And category in management listing should be dimmed "CAT1"
|
||||
And category in management listing should be dimmed "CAT2"
|
||||
@@ -295,6 +297,7 @@ Feature: We can change the visibility of categories in the management interface.
|
||||
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
|
||||
And I click on "Hide" "button" in the "Hide category?" "dialogue"
|
||||
And a new page should not have loaded since I started watching
|
||||
And category in management listing should be dimmed "CAT1"
|
||||
And category in management listing should be dimmed "CAT2"
|
||||
@@ -306,3 +309,59 @@ Feature: We can change the visibility of categories in the management interface.
|
||||
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"
|
||||
|
||||
@javascript
|
||||
Scenario: Test confirm popup when hiding a category
|
||||
Given the following "categories" exist:
|
||||
| name | category | idnumber |
|
||||
| Cat 1 | 0 | CAT1 |
|
||||
| Cat 1b | CAT1 | CAT1B |
|
||||
| Cat 1c | CAT1 | CAT1C |
|
||||
| Cat 2 | 0 | CAT2 |
|
||||
And the following "courses" exist:
|
||||
| category | fullname | shortname | idnumber |
|
||||
| CAT1B | Course 1 | Course 1 | C1 |
|
||||
| CAT1B | Course 2 | Course 2 | C2 |
|
||||
| CAT1C | Course 3 | Course 3 | C3 |
|
||||
And I log in as "admin"
|
||||
And I go to the courses management page
|
||||
And I should see the "Course categories and courses" management page
|
||||
And I click on category "Cat 1" in the management interface
|
||||
And category in management listing should be visible "CAT1"
|
||||
And category in management listing should be visible "CAT1B"
|
||||
And category in management listing should be visible "CAT1C"
|
||||
And category in management listing should be visible "CAT2"
|
||||
|
||||
# Category should not be hidden if the dialogue is cancelled.
|
||||
And I toggle visibility of category "CAT1C" in management listing
|
||||
And I should see "The category Cat 1c contains 1 course" in the "Hide category?" "dialogue"
|
||||
And I click on "Cancel" "button" in the "Hide category?" "dialogue"
|
||||
And category in management listing should be visible "CAT1"
|
||||
And category in management listing should be visible "CAT1B"
|
||||
And category in management listing should be visible "CAT1C"
|
||||
And category in management listing should be visible "CAT2"
|
||||
|
||||
# Hide CAT1 - course count should include courses all subcategories.
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
And I should see "The category Cat 1 contains 3 courses" in the "Hide category?" "dialogue"
|
||||
And I click on "Hide" "button" in the "Hide category?" "dialogue"
|
||||
And category in management listing should be dimmed "CAT1"
|
||||
And category in management listing should be dimmed "CAT1B"
|
||||
And category in management listing should be dimmed "CAT1C"
|
||||
And category in management listing should be visible "CAT2"
|
||||
|
||||
# Dialogue should not show when showing a category.
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
And "Hide category?" "dialogue" should not exist
|
||||
And category in management listing should be visible "CAT1"
|
||||
And category in management listing should be visible "CAT1B"
|
||||
And category in management listing should be visible "CAT1C"
|
||||
And category in management listing should be visible "CAT2"
|
||||
|
||||
# Dialogue should not show when hiding a category that contains no courses.
|
||||
And I toggle visibility of category "CAT2" in management listing
|
||||
And "Hide category?" "dialogue" should not exist
|
||||
And category in management listing should be visible "CAT1"
|
||||
And category in management listing should be visible "CAT1B"
|
||||
And category in management listing should be visible "CAT1C"
|
||||
And category in management listing should be dimmed "CAT2"
|
||||
|
||||
@@ -85,6 +85,7 @@ Feature: We can change the visibility of courses in the management interface.
|
||||
And category in management listing should be visible "CAT1"
|
||||
And course in management listing should be dimmed "C1"
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
And I click on "Hide" "button" in the "Hide category?" "dialogue"
|
||||
And a new page should not have loaded since I started watching
|
||||
And category in management listing should be dimmed "CAT1"
|
||||
And course in management listing should be dimmed "C1"
|
||||
@@ -93,6 +94,7 @@ Feature: We can change the visibility of courses in the management interface.
|
||||
And category in management listing should be visible "CAT1"
|
||||
And course in management listing should be dimmed "C1"
|
||||
And I toggle visibility of category "CAT1" in management listing
|
||||
And I click on "Hide" "button" in the "Hide category?" "dialogue"
|
||||
And I toggle visibility of course "C1" in management listing
|
||||
And I select "Courses" from the "Viewing" singleselect
|
||||
And a new page should have loaded since I started watching
|
||||
|
||||
+22
-1
@@ -1306,7 +1306,28 @@ Category.prototype = {
|
||||
break;
|
||||
case 'hide':
|
||||
e.preventDefault();
|
||||
this.get('console').performAjaxAction('hidecategory', catarg, this.hide, this);
|
||||
var courseCount = this.get('node').getData('course-count');
|
||||
if (courseCount === '0') {
|
||||
this.get('console').performAjaxAction('hidecategory', catarg, this.hide, this);
|
||||
break;
|
||||
}
|
||||
var warningStr = courseCount === '1' ? 'hidecategoryone' : 'hidecategorymany';
|
||||
var warningParams = {
|
||||
category: this.get('node').getData('category-name'),
|
||||
coursecount: courseCount,
|
||||
};
|
||||
require(['core/notification', 'core/str'], function(Notification, Str) {
|
||||
Notification.saveCancelPromise(
|
||||
Str.get_string('hidecategory'),
|
||||
Str.get_string(warningStr, 'core', warningParams),
|
||||
Str.get_string('hide')
|
||||
).then(function() {
|
||||
this.get('console').performAjaxAction('hidecategory', catarg, this.hide, this);
|
||||
}.bind(this)
|
||||
).catch(function() {
|
||||
// User cancelled, no action needed.
|
||||
});
|
||||
}.bind(this));
|
||||
break;
|
||||
case 'expand':
|
||||
e.preventDefault();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1280,7 +1280,28 @@ Category.prototype = {
|
||||
break;
|
||||
case 'hide':
|
||||
e.preventDefault();
|
||||
this.get('console').performAjaxAction('hidecategory', catarg, this.hide, this);
|
||||
var courseCount = this.get('node').getData('course-count');
|
||||
if (courseCount === '0') {
|
||||
this.get('console').performAjaxAction('hidecategory', catarg, this.hide, this);
|
||||
break;
|
||||
}
|
||||
var warningStr = courseCount === '1' ? 'hidecategoryone' : 'hidecategorymany';
|
||||
var warningParams = {
|
||||
category: this.get('node').getData('category-name'),
|
||||
coursecount: courseCount,
|
||||
};
|
||||
require(['core/notification', 'core/str'], function(Notification, Str) {
|
||||
Notification.saveCancelPromise(
|
||||
Str.get_string('hidecategory'),
|
||||
Str.get_string(warningStr, 'core', warningParams),
|
||||
Str.get_string('hide')
|
||||
).then(function() {
|
||||
this.get('console').performAjaxAction('hidecategory', catarg, this.hide, this);
|
||||
}.bind(this)
|
||||
).catch(function() {
|
||||
// User cancelled, no action needed.
|
||||
});
|
||||
}.bind(this));
|
||||
break;
|
||||
case 'expand':
|
||||
e.preventDefault();
|
||||
|
||||
+22
-1
@@ -122,7 +122,28 @@ Category.prototype = {
|
||||
break;
|
||||
case 'hide':
|
||||
e.preventDefault();
|
||||
this.get('console').performAjaxAction('hidecategory', catarg, this.hide, this);
|
||||
var courseCount = this.get('node').getData('course-count');
|
||||
if (courseCount === '0') {
|
||||
this.get('console').performAjaxAction('hidecategory', catarg, this.hide, this);
|
||||
break;
|
||||
}
|
||||
var warningStr = courseCount === '1' ? 'hidecategoryone' : 'hidecategorymany';
|
||||
var warningParams = {
|
||||
category: this.get('node').getData('category-name'),
|
||||
coursecount: courseCount,
|
||||
};
|
||||
require(['core/notification', 'core/str'], function(Notification, Str) {
|
||||
Notification.saveCancelPromise(
|
||||
Str.get_string('hidecategory'),
|
||||
Str.get_string(warningStr, 'core', warningParams),
|
||||
Str.get_string('hide')
|
||||
).then(function() {
|
||||
this.get('console').performAjaxAction('hidecategory', catarg, this.hide, this);
|
||||
}.bind(this)
|
||||
).catch(function() {
|
||||
// User cancelled, no action needed.
|
||||
});
|
||||
}.bind(this));
|
||||
break;
|
||||
case 'expand':
|
||||
e.preventDefault();
|
||||
|
||||
@@ -1040,6 +1040,11 @@ $string['hiddensectionsinvisible'] = 'Hidden sections are completely invisible';
|
||||
$string['hiddenwithbrackets'] = '(hidden)';
|
||||
$string['hide'] = 'Hide';
|
||||
$string['hideadvancedsettings'] = 'Hide advanced settings';
|
||||
$string['hidecategory'] = 'Hide category?';
|
||||
$string['hidecategoryone'] = 'The category {$a->category} contains 1 course.
|
||||
<br/>If you hide it, users without permission to view hidden categories will no longer have access to the course.';
|
||||
$string['hidecategorymany'] = 'The category {$a->category} contains {$a->coursecount} courses.
|
||||
<br/>If you hide it, users without permission to view hidden categories will no longer have access to the courses.';
|
||||
$string['hidechartdata'] = 'Hide chart data';
|
||||
$string['hidefromstudents'] = 'Hide on course page';
|
||||
$string['hideoncoursepage'] = 'Make available but don\'t show on course page';
|
||||
|
||||
Reference in New Issue
Block a user