MDL-42629 course: management peer-review alterations

* Added confirmation when bulk moving courses.
* Increased min-width of category course count to allow for 3 digits.
* Fixed sub-category => subcategory
* Renamed console JS vars to managementconsole
* Added typeof operator
* Renamed oldcatcourses and newcatcourses as suggested
* Added a span around course count and interacted with that.
* Fixed icon sizing
* Fixed management behat tests
* Fixed wrapping of strings in menus
This commit is contained in:
Sam Hemelryk 2013-11-05 11:08:16 +08:00
parent c7a2291f8b
commit 38a15200b9
18 changed files with 184 additions and 156 deletions

View File

@ -72,8 +72,8 @@ switch ($action) {
$a->total = $totalcourses;
$str = get_string('showingxofycourses', 'moodle', $a);
}
$outcome->newcatcourses = $category->get_courses_count();
$outcome->oldcatcourses = $totalcourses;
$outcome->totalcatcourses = $category->get_courses_count();
$outcome->fromcatcoursecount = $totalcourses;
$outcome->paginationtotals = $str;
break;
case 'movecourseafter' :

View File

@ -244,7 +244,7 @@ class helper {
$actions['assignroles'] = array(
'url' => new \moodle_url('/admin/roles/assign.php', array('contextid' => $category->get_context()->id,
'return' => 'management')),
'icon' => new \pix_icon('i/assignroles', new \lang_string('assignroles', 'role')),
'icon' => new \pix_icon('t/assignroles', new \lang_string('assignroles', 'role')),
'string' => new \lang_string('assignroles', 'role')
);
}
@ -263,7 +263,7 @@ class helper {
if ($category->can_review_cohorts()) {
$actions['cohorts'] = array(
'url' => new \moodle_url('/cohort/index.php', array('contextid' => $category->get_context()->id)),
'icon' => new \pix_icon('i/cohort', new \lang_string('cohorts', 'cohort')),
'icon' => new \pix_icon('t/cohort', new \lang_string('cohorts', 'cohort')),
'string' => new \lang_string('cohorts', 'cohort')
);
}

View File

@ -225,7 +225,11 @@ class core_course_management_renderer extends plugin_renderer_base {
}
$countid = 'course-count-'.$category->id;
$html .= html_writer::span(get_string('courses'), 'accesshide', array('id' => $countid));
$html .= html_writer::span($category->coursecount.$courseicon, 'course-count dimmed', array('aria-labelledby' => $countid));
$html .= html_writer::span(
html_writer::span($category->coursecount).$courseicon,
'course-count dimmed',
array('aria-labelledby' => $countid)
);
$html .= html_writer::end_div();
$html .= html_writer::end_div();
if ($isexpanded) {

View File

@ -177,6 +177,7 @@ if ($action !== false && confirm_sesskey()) {
// - bulkmovecategories.
// - bulkresortcategories.
$redirectback = false;
$redirectmessage = false;
switch ($action) {
case 'resortcategories' :
$sort = required_param('resort', PARAM_ALPHA);
@ -293,6 +294,12 @@ if ($action !== false && confirm_sesskey()) {
// If this fails we want to catch the exception and report it.
$redirectback = \core_course\management\helper::action_category_move_courses_into($category, $moveto,
$courseids);
if ($redirectback) {
$a = new stdClass;
$a->category = $moveto->get_formatted_name();
$a->courses = count($courseids);
$redirectmessage = get_string('bulkmovecoursessuccess', 'moodle', $a);
}
} catch (moodle_exception $ex) {
$redirectback = false;
$notificationsfail[] = $ex->getMessage();
@ -349,6 +356,12 @@ if ($action !== false && confirm_sesskey()) {
// They're not sorting anything.
break;
}
if (!in_array($sortcategoriesby, array('idnumber', 'name'))) {
$sortcategoriesby = false;
}
if (!in_array($sortcoursesby, array('idnumber', 'fullname', 'shortname'))) {
$sortcoursesby = false;
}
if ($for === 'thiscategory') {
$categoryids = array(
@ -364,22 +377,22 @@ if ($action !== false && confirm_sesskey()) {
}
$categories = coursecat::get_many($categoryids);
} else if ($for === 'allcategories') {
$categories = coursecat::get_all_visible();
if ($sortcategoriesby) {
\core_course\management\helper::action_category_resort_subcategories(coursecat::get(0), $sortcategoriesby);
}
$categorieslist = coursecat::make_categories_list('moodle/category:manage');
$categoryids = array_keys($categorieslist);
$categories = coursecat::get_many($categoryids);
unset($categorieslist);
} else {
break;
}
if (!in_array($sortcategoriesby, array('idnumber', 'name'))) {
$sortcategoriesby = false;
}
if (!in_array($sortcoursesby, array('idnumber', 'fullname', 'shortname'))) {
$sortcoursesby = false;
}
foreach ($categories as $cat) {
if ($sortcategoriesby) {
// Don't clean up here, we'll do it once we're all done.
\core_course\management\helper::action_category_resort_subcategories($cat, $sortcategoriesby, false);
}
if (in_array($sortcoursesby, array('idnumber', 'fullname', 'shortname'))) {
if ($sortcoursesby) {
\core_course\management\helper::action_category_resort_courses($cat, $sortcoursesby, false);
}
}
@ -392,7 +405,11 @@ if ($action !== false && confirm_sesskey()) {
}
}
if ($redirectback) {
redirect($PAGE->url);
if ($redirectmessage) {
redirect($PAGE->url, $redirectmessage, 5);
} else {
redirect($PAGE->url);
}
}
}

View File

@ -72,7 +72,7 @@ class behat_course extends behat_base {
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 click on "'.get_string('createnewcourse').'" "link" in the "#course-listing" "css_element"'),
new Given('I fill the moodle form with:', $table),
new Given('I press "' . get_string('savechanges') . '"')
);

View File

@ -184,8 +184,7 @@ Feature: Test category management actions
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 "Create new" "link" in the ".category-listing-actions" "css_element"
And I click on "Top level category" "link" in the ".category-listing-actions" "css_element"
And I click on "Create new category" "link" in the ".category-listing-actions" "css_element"
# Redirect.
And I should see "Add new category"
And I fill the moodle form with:
@ -197,8 +196,7 @@ Feature: Test category management actions
And I should see "Test category 2" in the "#course-listing h3" "css_element"
And I should see category listing "Cat 1" before "Test category 2"
And I should see "No courses in this category"
And I click on "Create new" "link" in the ".category-listing-actions" "css_element"
And I click on "Sub category" "link" in the ".category-listing-actions" "css_element"
And I click on "createnewsubcategory" action for "Test category 2" in management category listing
# Redirect
And I should see "Add new category"
And I fill the moodle form with:

View File

@ -5,7 +5,7 @@ Feature: Test we can resort categories in the management interface.
I need to test we can resort sub categories.
I need to test we can manually sort categories.
Scenario Outline: Test resorting categories.
Scenario Outline: Test bulk sorting all categories.
Given the following "categories" exists:
| category | name | idnumber | sortorder |
| 0 | Social studies | Ext003 | 1 |
@ -15,10 +15,9 @@ 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 should see "Sort categories" in the ".category-listing-actions" "css_element"
And I should see "Sort the top level categories by name" in the ".category-listing-actions" "css_element"
And I should see "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"
And I select "All categories" from "menuselectsortby"
And I select <sortby> from "menuresortcategoriesby"
And I press "Go"
# Redirect.
And I should see the "Course categories" management page
And I should see category listing <cat1> before <cat2>
@ -26,38 +25,35 @@ Feature: Test we can resort categories in the management interface.
Examples:
| sortby | cat1 | cat2 | cat3 |
| "Sort categories" | "Social studies" | "Applied sciences" | "Extended social studies" |
| "Sort the top level categories by name" | "Applied sciences" | "Extended social studies" | "Social studies" |
| "Sort the top level categories by idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
| "By name" | "Applied sciences" | "Extended social studies" | "Social studies" |
| "By idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
@javascript
Scenario Outline: Test resorting categories with JS enabled.
Scenario Outline: Test bulk sorting current category.
Given the following "categories" exists:
| category | name | idnumber | sortorder |
| 0 | Social studies | Ext003 | 1 |
| 0 | Applied sciences | Sci001 | 2 |
| 0 | Extended social studies | Ext002 | 3 |
| 0 | Test category | Tes001 | 1 |
| Tes001 | Social studies | Ext003 | 2 |
| Tes001 | Applied sciences | Sci001 | 3 |
| Tes001 | Extended social studies | Ext002 | 4 |
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 should see "Sort categories" 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 "Sort categories" "link"
And I should see "Sort the top level categories by name" in the ".category-listing-actions" "css_element"
And I should see "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"
And I click on "Test category" "link"
# Redirect.
And I should see the "Course categories" management page
And I should see the "Course categories and courses" management page
And I select "This category" from "menuselectsortby"
And I select <sortby> from "menuresortcategoriesby"
And I press "Go"
# Redirect.
And I should see the "Course categories and courses" management page
And I should see category listing <cat1> before <cat2>
And I should see category listing <cat2> before <cat3>
Examples:
| sortby | cat1 | cat2 | cat3 |
| "Sort categories" | "Social studies" | "Applied sciences" | "Extended social studies" |
| "Sort the top level categories by name" | "Applied sciences" | "Extended social studies" | "Social studies" |
| "Sort the top level categories by idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
| "By name" | "Applied sciences" | "Extended social studies" | "Social studies" |
| "By idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
Scenario Outline: Test resorting subcategories.
Given the following "categories" exists:

View File

@ -245,10 +245,9 @@ 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 "Sort categories" "link"
And I should see "Sort the top level categories by name" in the ".category-listing-actions" "css_element"
And I should see "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"
And I select "All categories" from "menuselectsortby"
And I select <sortby> from "menuresortcategoriesby"
And I press "Go"
# Redirect.
And I should see the "Course categories" management page
And I should see category listing <cat1> before <cat2>
@ -256,9 +255,8 @@ Feature: Course category management interface performs as expected
Examples:
| sortby | cat1 | cat2 | cat3 |
| "Sort categories" | "Social studies" | "Applied sciences" | "Extended social studies" |
| "Sort the top level categories by name" | "Applied sciences" | "Extended social studies" | "Social studies" |
| "Sort the top level categories by idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
| "By name" | "Applied sciences" | "Extended social studies" | "Social studies" |
| "By idnumber" | "Extended social studies" | "Social studies" | "Applied sciences" |
@javascript
Scenario Outline: Sub categories are displayed correctly when resorted

View File

@ -507,8 +507,8 @@ DragDrop.prototype = {
* @method initializer
*/
initializer : function() {
var console = this.get('console'),
container = console.get('element'),
var managementconsole = this.get('console'),
container = managementconsole.get('element'),
categorylisting = container.one('#category-listing'),
courselisting = container.one('#course-listing > .course-listing'),
categoryul = (categorylisting) ? categorylisting.one('ul.ml') : null,
@ -683,7 +683,7 @@ DragDrop.prototype = {
drop = e.drop.get('node'),
iscategory = (drop.ancestor('.listitem-category') !== null),
iscourse = !iscategory && (drop.test('.listitem-course')),
console = this.get('console'),
managementconsole = this.get('console'),
categoryid,
category,
courseid,
@ -700,15 +700,15 @@ DragDrop.prototype = {
if (iscategory) {
categoryid = drop.ancestor('.listitem-category').getData('id');
Y.log('Course ' + courseid + ' dragged into category ' + categoryid);
category = console.getCategoryById(categoryid);
category = managementconsole.getCategoryById(categoryid);
if (category) {
course = console.getCourseById(courseid);
course = managementconsole.getCourseById(courseid);
if (course) {
category.moveCourseTo(course);
}
}
} else if (iscourse || drop.ancestor('#course-listing')) {
course = console.getCourseById(courseid);
course = managementconsole.getCourseById(courseid);
previoussibling = drag.get('previousSibling');
aftercourseid = (previoussibling) ? previoussibling.getData('id') || 0 : 0;
previousid = (this.previoussibling) ? this.previoussibling.getData('id') : 0;
@ -1191,14 +1191,14 @@ Category.prototype = {
loadSubcategories : function(transactionid, response, args) {
var outcome = this.checkAjaxResponse(transactionid, response, args),
node = this.get('node'),
console = this.get('console');
managementconsole = this.get('console');
if (outcome === false) {
Y.log('AJAX failed to load sub categories for '+this.get('itemname'), 'warn', 'moodle-course-management');
return false;
}
Y.log('AJAX loaded subcategories for '+this.get('itemname'), 'info', 'moodle-course-management');
node.append(outcome.html);
console.initialiseCategories(node);
managementconsole.initialiseCategories(node);
if (M.core && M.core.actionmenu && M.core.actionmenu.newDOMNode) {
M.core.actionmenu.newDOMNode(node);
}
@ -1246,7 +1246,7 @@ Category.prototype = {
*/
completeMoveCourse : function(transactionid, response, args) {
var outcome = this.checkAjaxResponse(transactionid, response, args),
console = this.get('console'),
managementconsole = this.get('console'),
category,
course,
totals;
@ -1254,7 +1254,7 @@ Category.prototype = {
Y.log('AJAX failed to move courses into this category: '+this.get('itemname'), 'warn', 'moodle-course-management');
return false;
}
course = console.getCourseById(args.courseid);
course = managementconsole.getCourseById(args.courseid);
if (!course) {
Y.log('Course was moved but the course listing could not be found to reflect this', 'warn', 'moodle-course-management');
return false;
@ -1263,24 +1263,24 @@ Category.prototype = {
this.highlight();
if (course) {
if (outcome.paginationtotals) {
totals = console.get('courselisting').one('.listing-pagination-totals');
totals = managementconsole.get('courselisting').one('.listing-pagination-totals');
if (totals) {
totals.set('innerHTML', outcome.paginationtotals);
}
}
if (outcome.newcatcourses !== 'undefined') {
totals = this.get('node').one('.course-count');
if (outcome.totalcatcourses !== 'undefined') {
totals = this.get('node').one('.course-count span');
if (totals) {
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.newcatcourses));
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.totalcatcourses));
}
}
if (outcome.oldcatcourses !== 'undefined') {
category = console.get('activecategoryid');
category = console.getCategoryById(category);
if (typeof outcome.fromcatcoursecount !== 'undefined') {
category = managementconsole.get('activecategoryid');
category = managementconsole.getCategoryById(category);
if (category) {
totals = category.get('node').one('.course-count');
totals = category.get('node').one('.course-count span');
if (totals) {
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.oldcatcourses));
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.fromcatcoursecount));
}
}
}
@ -1349,14 +1349,14 @@ Category.prototype = {
* @param courses
*/
updateCourseVisiblity : function(courses) {
var console = this.get('console'),
var managementconsole = this.get('console'),
key,
course;
Y.log('Changing categories course visibility', 'info', 'moodle-course-management');
try {
for (key in courses) {
if (typeof courses[key] === 'object') {
course = console.getCourseById(courses[key].id);
course = managementconsole.getCourseById(courses[key].id);
if (course) {
if (courses[key].visible === "1") {
course.markVisible();
@ -1379,14 +1379,14 @@ Category.prototype = {
* @param categories
*/
updateChildVisibility : function(categories) {
var console = this.get('console'),
var managementconsole = this.get('console'),
key,
category;
Y.log('Changing categories subcategory visibility', 'info', 'moodle-course-management');
try {
for (key in categories) {
if (typeof categories[key] === 'object') {
category = console.getCategoryById(categories[key].id);
category = managementconsole.getCategoryById(categories[key].id);
if (category) {
if (categories[key].visible === "1") {
category.markVisible();
@ -1495,24 +1495,24 @@ Course.prototype = {
* @returns {Boolean}
*/
handle : function(action, e) {
var console = this.get('console'),
var managementconsole = this.get('console'),
args = {courseid : this.get('courseid')};
switch (action) {
case 'moveup':
e.halt();
console.performAjaxAction('movecourseup', args, this.moveup, this);
managementconsole.performAjaxAction('movecourseup', args, this.moveup, this);
break;
case 'movedown':
e.halt();
console.performAjaxAction('movecoursedown', args, this.movedown, this);
managementconsole.performAjaxAction('movecoursedown', args, this.movedown, this);
break;
case 'show':
e.halt();
console.performAjaxAction('showcourse', args, this.show, this);
managementconsole.performAjaxAction('showcourse', args, this.show, this);
break;
case 'hide':
e.halt();
console.performAjaxAction('hidecourse', args, this.hide, this);
managementconsole.performAjaxAction('hidecourse', args, this.hide, this);
break;
default:
Y.log('Invalid AJAX action requested of managed course.', 'warn', 'moodle-course-management');
@ -1537,13 +1537,13 @@ Course.prototype = {
* @param {Number} previousid the course it was previously after in case we need to revert.
*/
moveAfter : function(moveaftercourse, previousid) {
var console = this.get('console'),
var managementconsole = this.get('console'),
args = {
courseid : this.get('courseid'),
moveafter : moveaftercourse,
previous : previousid
};
console.performAjaxAction('movecourseafter', args, this.moveAfterResponse, this);
managementconsole.performAjaxAction('movecourseafter', args, this.moveAfterResponse, this);
},
/**

File diff suppressed because one or more lines are too long

View File

@ -499,8 +499,8 @@ DragDrop.prototype = {
* @method initializer
*/
initializer : function() {
var console = this.get('console'),
container = console.get('element'),
var managementconsole = this.get('console'),
container = managementconsole.get('element'),
categorylisting = container.one('#category-listing'),
courselisting = container.one('#course-listing > .course-listing'),
categoryul = (categorylisting) ? categorylisting.one('ul.ml') : null,
@ -675,7 +675,7 @@ DragDrop.prototype = {
drop = e.drop.get('node'),
iscategory = (drop.ancestor('.listitem-category') !== null),
iscourse = !iscategory && (drop.test('.listitem-course')),
console = this.get('console'),
managementconsole = this.get('console'),
categoryid,
category,
courseid,
@ -690,15 +690,15 @@ DragDrop.prototype = {
courseid = drag.getData('id');
if (iscategory) {
categoryid = drop.ancestor('.listitem-category').getData('id');
category = console.getCategoryById(categoryid);
category = managementconsole.getCategoryById(categoryid);
if (category) {
course = console.getCourseById(courseid);
course = managementconsole.getCourseById(courseid);
if (course) {
category.moveCourseTo(course);
}
}
} else if (iscourse || drop.ancestor('#course-listing')) {
course = console.getCourseById(courseid);
course = managementconsole.getCourseById(courseid);
previoussibling = drag.get('previousSibling');
aftercourseid = (previoussibling) ? previoussibling.getData('id') || 0 : 0;
previousid = (this.previoussibling) ? this.previoussibling.getData('id') : 0;
@ -1165,12 +1165,12 @@ Category.prototype = {
loadSubcategories : function(transactionid, response, args) {
var outcome = this.checkAjaxResponse(transactionid, response, args),
node = this.get('node'),
console = this.get('console');
managementconsole = this.get('console');
if (outcome === false) {
return false;
}
node.append(outcome.html);
console.initialiseCategories(node);
managementconsole.initialiseCategories(node);
if (M.core && M.core.actionmenu && M.core.actionmenu.newDOMNode) {
M.core.actionmenu.newDOMNode(node);
}
@ -1218,38 +1218,38 @@ Category.prototype = {
*/
completeMoveCourse : function(transactionid, response, args) {
var outcome = this.checkAjaxResponse(transactionid, response, args),
console = this.get('console'),
managementconsole = this.get('console'),
category,
course,
totals;
if (outcome === false) {
return false;
}
course = console.getCourseById(args.courseid);
course = managementconsole.getCourseById(args.courseid);
if (!course) {
return false;
}
this.highlight();
if (course) {
if (outcome.paginationtotals) {
totals = console.get('courselisting').one('.listing-pagination-totals');
totals = managementconsole.get('courselisting').one('.listing-pagination-totals');
if (totals) {
totals.set('innerHTML', outcome.paginationtotals);
}
}
if (outcome.newcatcourses !== 'undefined') {
totals = this.get('node').one('.course-count');
if (outcome.totalcatcourses !== 'undefined') {
totals = this.get('node').one('.course-count span');
if (totals) {
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.newcatcourses));
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.totalcatcourses));
}
}
if (outcome.oldcatcourses !== 'undefined') {
category = console.get('activecategoryid');
category = console.getCategoryById(category);
if (typeof outcome.fromcatcoursecount !== 'undefined') {
category = managementconsole.get('activecategoryid');
category = managementconsole.getCategoryById(category);
if (category) {
totals = category.get('node').one('.course-count');
totals = category.get('node').one('.course-count span');
if (totals) {
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.oldcatcourses));
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.fromcatcoursecount));
}
}
}
@ -1314,13 +1314,13 @@ Category.prototype = {
* @param courses
*/
updateCourseVisiblity : function(courses) {
var console = this.get('console'),
var managementconsole = this.get('console'),
key,
course;
try {
for (key in courses) {
if (typeof courses[key] === 'object') {
course = console.getCourseById(courses[key].id);
course = managementconsole.getCourseById(courses[key].id);
if (course) {
if (courses[key].visible === "1") {
course.markVisible();
@ -1342,13 +1342,13 @@ Category.prototype = {
* @param categories
*/
updateChildVisibility : function(categories) {
var console = this.get('console'),
var managementconsole = this.get('console'),
key,
category;
try {
for (key in categories) {
if (typeof categories[key] === 'object') {
category = console.getCategoryById(categories[key].id);
category = managementconsole.getCategoryById(categories[key].id);
if (category) {
if (categories[key].visible === "1") {
category.markVisible();
@ -1456,24 +1456,24 @@ Course.prototype = {
* @returns {Boolean}
*/
handle : function(action, e) {
var console = this.get('console'),
var managementconsole = this.get('console'),
args = {courseid : this.get('courseid')};
switch (action) {
case 'moveup':
e.halt();
console.performAjaxAction('movecourseup', args, this.moveup, this);
managementconsole.performAjaxAction('movecourseup', args, this.moveup, this);
break;
case 'movedown':
e.halt();
console.performAjaxAction('movecoursedown', args, this.movedown, this);
managementconsole.performAjaxAction('movecoursedown', args, this.movedown, this);
break;
case 'show':
e.halt();
console.performAjaxAction('showcourse', args, this.show, this);
managementconsole.performAjaxAction('showcourse', args, this.show, this);
break;
case 'hide':
e.halt();
console.performAjaxAction('hidecourse', args, this.hide, this);
managementconsole.performAjaxAction('hidecourse', args, this.hide, this);
break;
default:
return false;
@ -1497,13 +1497,13 @@ Course.prototype = {
* @param {Number} previousid the course it was previously after in case we need to revert.
*/
moveAfter : function(moveaftercourse, previousid) {
var console = this.get('console'),
var managementconsole = this.get('console'),
args = {
courseid : this.get('courseid'),
moveafter : moveaftercourse,
previous : previousid
};
console.performAjaxAction('movecourseafter', args, this.moveAfterResponse, this);
managementconsole.performAjaxAction('movecourseafter', args, this.moveAfterResponse, this);
},
/**

View File

@ -187,14 +187,14 @@ Category.prototype = {
loadSubcategories : function(transactionid, response, args) {
var outcome = this.checkAjaxResponse(transactionid, response, args),
node = this.get('node'),
console = this.get('console');
managementconsole = this.get('console');
if (outcome === false) {
Y.log('AJAX failed to load sub categories for '+this.get('itemname'), 'warn', 'moodle-course-management');
return false;
}
Y.log('AJAX loaded subcategories for '+this.get('itemname'), 'info', 'moodle-course-management');
node.append(outcome.html);
console.initialiseCategories(node);
managementconsole.initialiseCategories(node);
if (M.core && M.core.actionmenu && M.core.actionmenu.newDOMNode) {
M.core.actionmenu.newDOMNode(node);
}
@ -242,7 +242,7 @@ Category.prototype = {
*/
completeMoveCourse : function(transactionid, response, args) {
var outcome = this.checkAjaxResponse(transactionid, response, args),
console = this.get('console'),
managementconsole = this.get('console'),
category,
course,
totals;
@ -250,7 +250,7 @@ Category.prototype = {
Y.log('AJAX failed to move courses into this category: '+this.get('itemname'), 'warn', 'moodle-course-management');
return false;
}
course = console.getCourseById(args.courseid);
course = managementconsole.getCourseById(args.courseid);
if (!course) {
Y.log('Course was moved but the course listing could not be found to reflect this', 'warn', 'moodle-course-management');
return false;
@ -259,24 +259,24 @@ Category.prototype = {
this.highlight();
if (course) {
if (outcome.paginationtotals) {
totals = console.get('courselisting').one('.listing-pagination-totals');
totals = managementconsole.get('courselisting').one('.listing-pagination-totals');
if (totals) {
totals.set('innerHTML', outcome.paginationtotals);
}
}
if (outcome.newcatcourses !== 'undefined') {
totals = this.get('node').one('.course-count');
if (outcome.totalcatcourses !== 'undefined') {
totals = this.get('node').one('.course-count span');
if (totals) {
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.newcatcourses));
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.totalcatcourses));
}
}
if (outcome.oldcatcourses !== 'undefined') {
category = console.get('activecategoryid');
category = console.getCategoryById(category);
if (typeof outcome.fromcatcoursecount !== 'undefined') {
category = managementconsole.get('activecategoryid');
category = managementconsole.getCategoryById(category);
if (category) {
totals = category.get('node').one('.course-count');
totals = category.get('node').one('.course-count span');
if (totals) {
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.oldcatcourses));
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.fromcatcoursecount));
}
}
}
@ -345,14 +345,14 @@ Category.prototype = {
* @param courses
*/
updateCourseVisiblity : function(courses) {
var console = this.get('console'),
var managementconsole = this.get('console'),
key,
course;
Y.log('Changing categories course visibility', 'info', 'moodle-course-management');
try {
for (key in courses) {
if (typeof courses[key] === 'object') {
course = console.getCourseById(courses[key].id);
course = managementconsole.getCourseById(courses[key].id);
if (course) {
if (courses[key].visible === "1") {
course.markVisible();
@ -375,14 +375,14 @@ Category.prototype = {
* @param categories
*/
updateChildVisibility : function(categories) {
var console = this.get('console'),
var managementconsole = this.get('console'),
key,
category;
Y.log('Changing categories subcategory visibility', 'info', 'moodle-course-management');
try {
for (key in categories) {
if (typeof categories[key] === 'object') {
category = console.getCategoryById(categories[key].id);
category = managementconsole.getCategoryById(categories[key].id);
if (category) {
if (categories[key].visible === "1") {
category.markVisible();

View File

@ -91,24 +91,24 @@ Course.prototype = {
* @returns {Boolean}
*/
handle : function(action, e) {
var console = this.get('console'),
var managementconsole = this.get('console'),
args = {courseid : this.get('courseid')};
switch (action) {
case 'moveup':
e.halt();
console.performAjaxAction('movecourseup', args, this.moveup, this);
managementconsole.performAjaxAction('movecourseup', args, this.moveup, this);
break;
case 'movedown':
e.halt();
console.performAjaxAction('movecoursedown', args, this.movedown, this);
managementconsole.performAjaxAction('movecoursedown', args, this.movedown, this);
break;
case 'show':
e.halt();
console.performAjaxAction('showcourse', args, this.show, this);
managementconsole.performAjaxAction('showcourse', args, this.show, this);
break;
case 'hide':
e.halt();
console.performAjaxAction('hidecourse', args, this.hide, this);
managementconsole.performAjaxAction('hidecourse', args, this.hide, this);
break;
default:
Y.log('Invalid AJAX action requested of managed course.', 'warn', 'moodle-course-management');
@ -133,13 +133,13 @@ Course.prototype = {
* @param {Number} previousid the course it was previously after in case we need to revert.
*/
moveAfter : function(moveaftercourse, previousid) {
var console = this.get('console'),
var managementconsole = this.get('console'),
args = {
courseid : this.get('courseid'),
moveafter : moveaftercourse,
previous : previousid
};
console.performAjaxAction('movecourseafter', args, this.moveAfterResponse, this);
managementconsole.performAjaxAction('movecourseafter', args, this.moveAfterResponse, this);
},
/**

View File

@ -53,8 +53,8 @@ DragDrop.prototype = {
* @method initializer
*/
initializer : function() {
var console = this.get('console'),
container = console.get('element'),
var managementconsole = this.get('console'),
container = managementconsole.get('element'),
categorylisting = container.one('#category-listing'),
courselisting = container.one('#course-listing > .course-listing'),
categoryul = (categorylisting) ? categorylisting.one('ul.ml') : null,
@ -229,7 +229,7 @@ DragDrop.prototype = {
drop = e.drop.get('node'),
iscategory = (drop.ancestor('.listitem-category') !== null),
iscourse = !iscategory && (drop.test('.listitem-course')),
console = this.get('console'),
managementconsole = this.get('console'),
categoryid,
category,
courseid,
@ -246,15 +246,15 @@ DragDrop.prototype = {
if (iscategory) {
categoryid = drop.ancestor('.listitem-category').getData('id');
Y.log('Course ' + courseid + ' dragged into category ' + categoryid);
category = console.getCategoryById(categoryid);
category = managementconsole.getCategoryById(categoryid);
if (category) {
course = console.getCourseById(courseid);
course = managementconsole.getCourseById(courseid);
if (course) {
category.moveCourseTo(course);
}
}
} else if (iscourse || drop.ancestor('#course-listing')) {
course = console.getCourseById(courseid);
course = managementconsole.getCourseById(courseid);
previoussibling = drag.get('previousSibling');
aftercourseid = (previoussibling) ? previoussibling.getData('id') || 0 : 0;
previousid = (this.previoussibling) ? this.previoussibling.getData('id') : 0;

View File

@ -72,7 +72,7 @@ $string['addresourceoractivity'] = 'Add an activity or resource';
$string['addresourcetosection'] = 'Add a resource to section \'{$a}\'';
$string['address'] = 'Address';
$string['addstudent'] = 'Add student';
$string['addsubcategory'] = 'Add a sub-category';
$string['addsubcategory'] = 'Add a subcategory';
$string['addteacher'] = 'Add teacher';
$string['admin'] = 'Admin';
$string['adminhelpaddnewuser'] = 'To manually create a new user account';
@ -210,6 +210,7 @@ $string['blocksetup'] = 'Setting up block tables';
$string['blocksuccess'] = '{$a} tables have been set up correctly';
$string['brief'] = 'Brief';
$string['bulkactions'] = 'Bulk actions';
$string['bulkmovecoursessuccess'] = 'Successfully moved {$a->courses} courses into {$a->category}';
$string['bycourseorder'] = 'By course order';
$string['byname'] = 'by {$a}';
$string['bypassed'] = 'Bypassed';
@ -1741,8 +1742,8 @@ $string['stringsnotset'] = 'The following strings are not defined in {$a}';
$string['studentnotallowed'] = 'Sorry, but you can not enter this course as \'{$a}\'';
$string['students'] = 'Students';
$string['studentsandteachers'] = 'Students and teachers';
$string['subcategories'] = 'Sub-categories';
$string['subcategory'] = 'Sub category';
$string['subcategories'] = 'Subcategories';
$string['subcategory'] = 'Subcategory';
$string['subcategoryof'] = 'Subcategory of {$a}';
$string['submit'] = 'Submit';
$string['success'] = 'Success';

View File

@ -263,6 +263,7 @@ input.titleeditor { width: 330px; vertical-align: text-bottom; }
#course-category-listings > div > div {min-height:300px;}
#course-category-listings h3 {margin:0;padding:0.6em 1em 0.5em;text-align:left;background-color:#f7f7f9;border-bottom:1px solid #e1e1e8;}
#course-category-listings h4 {margin:1em 0 0;padding:0.6em 1em 0.5em;text-align:left;}
#course-category-listings .moodle-actionmenu {white-space:nowrap;}
#course-category-listings .listing-actions {text-align:center;padding:0.4em 0.3em 0.3em;}
#course-category-listings .listing-actions > * {display:inline-block;line-height:2.2em;}
#course-category-listings .listing-actions > .moodle-actionmenu {display:inline-block;}
@ -287,8 +288,6 @@ input.titleeditor { width: 330px; vertical-align: text-bottom; }
#course-category-listings li[data-selected='1']:last-of-type > div {border-bottom-color:#e1e1e8;}
#course-category-listings > div > div > ul.ml > li:first-child > div {border-top:0;}
.jsenabled #course-category-listings .category-item-actions .menu-action-text {padding-left:0.3em;}
#course-category-listings .listing-actions .moodle-actionmenu:not([data-enhanced]) li {line-height:normal;}
#course-category-listings .listing-actions .moodle-actionmenu:not([data-enhanced]) > .menubar a,
#course-category-listings .listing-actions .moodle-actionmenu:not([data-enhanced]) > .menu .menu-action-text {display:inline-block;}
@ -296,8 +295,9 @@ input.titleeditor { width: 330px; vertical-align: text-bottom; }
#course-category-listings .listing-actions .moodle-actionmenu:not([data-enhanced]) > .menubar a > img {display:none;}
#course-category-listings .item-actions {margin-right:1em;display:inline-block;display:initial;}
#course-category-listings .item-actions img {margin: 0 0.3em;}
#course-category-listings .item-actions .menu .menu-action {margin-right:1em;}
#course-category-listings .item-actions img {margin: 0 4px;vertical-align:inherit;}
#course-category-listings .item-actions .menu img {max-width:none;width:12px;}
#course-category-listings .item-actions .menu a {padding:4px 1em 4px 4px;}
#course-category-listings li .tree-icon {margin-left:0;}
#course-category-listings li li .tree-icon {margin-left:1em;}
@ -312,7 +312,7 @@ input.titleeditor { width: 330px; vertical-align: text-bottom; }
#course-listing .listitem .categoryname {display:inline-block;margin-left:1em;color:#a1a1a8;}
#course-listing .listitem .coursename {display:inline-block;}
#category-listing .course-count {color:#a1a1a8;margin-right:2em;min-width:35px;display:inline-block;}
#category-listing .course-count {color:#a1a1a8;margin-right:2em;min-width:3.5em;display:inline-block;}
#category-listing .listitem.collapsed > ul.ml {display: none;}
#category-listing .course-count .smallicon {width:0.8em;height:0.8em;vertical-align:middle;margin:0 0.3em;}

View File

@ -664,6 +664,9 @@ span.editinstructions {
margin:1rem 0 0;
padding:0.6rem 1rem 0.5rem;
}
.moodle-actionmenu {
white-space:nowrap;
}
.listing-actions {
text-align:center;
padding:0.4rem 0.3rem 0.3rem;
@ -747,7 +750,16 @@ span.editinstructions {
display:inline-block;
display:initial;
img {
margin: 0 0.3em;
margin: 0 4px;
}
.menu {
a {
padding:4px 1em 4px 4px;
}
img {
width: 12px;
max-width:none;
}
}
}
@ -832,7 +844,9 @@ span.editinstructions {
}
}
> .firstpage .listitem:first-child > div .item-actions .action-moveup,
> .lastpage .listitem:last-child > div .item-actions .action-movedown {display: none;}
> .lastpage .listitem:last-child > div .item-actions .action-movedown {
display: none;
}
.bulk-action-checkbox {
vertical-align:middle;
margin:-2px 6px 0 0;
@ -861,12 +875,14 @@ span.editinstructions {
background-color: inherit;
}
&:first-child > div .item-actions .action-moveup,
&:last-child > div .item-actions .action-movedown {display: none;}
&:last-child > div .item-actions .action-movedown {
display: none;
}
}
.course-count {
color:#a1a1a8;
margin-right:2rem;
min-width:35px;
min-width:3.5em;
display:inline-block;
.smallicon {
width:0.8rem;
@ -944,8 +960,6 @@ span.editinstructions {
margin: 1em;
}
}
/** JS MUST be enabled for this next style **/
.jsenabled #course-category-listings .category-item-actions .menu-action-text {padding-left:0.3em;}
/** Management header styling **/
.coursecat-management-header {

File diff suppressed because one or more lines are too long