MDL-31830 course: management interface fixes as noted

* Fixed the highlighing of the default category when no categories have been selected.
* Fixed the bug preventing the action menu for AJAX loaded categories from functioning.
* Repositioned course idnumber infront of course actions.
* Fixed display of moveup on first item and movedown on last item (courses and categories)
* Fixed up resort selected categories string.
This commit is contained in:
Sam Hemelryk 2013-10-02 15:32:09 +13:00
parent 5aff38e4d8
commit f454e3247d
9 changed files with 68 additions and 69 deletions

View File

@ -111,11 +111,12 @@ class core_course_management_renderer extends plugin_renderer_base {
public function category_listing(coursecat $category = null) {
if ($category === null) {
$category = coursecat::get_default();
$selectedparents = array();
$selectedcategory = null;
} else {
$selectedparents = $category->get_parents();
$selectedparents[] = $category->id;
$selectedcategory = $category->id;
}
$catatlevel = array_shift($selectedparents);
@ -123,7 +124,9 @@ class core_course_management_renderer extends plugin_renderer_base {
$html = html_writer::start_div('category-listing');
$html .= html_writer::tag('h3', get_string('categories'));
$html .= $this->category_listing_actions($category);
if ($category !== null) {
$html .= $this->category_listing_actions($category);
}
$html .= html_writer::start_tag('ul', array('class' => 'ml'));
foreach ($listing as $listitem) {
// Render each category in the listing.
@ -135,7 +138,7 @@ class core_course_management_renderer extends plugin_renderer_base {
$listitem,
$subcategories,
$listitem->get_children_count(),
$category->id,
$selectedcategory,
$selectedparents
);
}
@ -161,7 +164,7 @@ class core_course_management_renderer extends plugin_renderer_base {
$selectedcategory = null, $selectedcategories = array()) {
$isexpandable = ($totalsubcategories > 0);
$isexpanded = (!empty($subcategories));
$activecategory = ($selectedcategory == $category->id);
$activecategory = ($selectedcategory === $category->id);
$attributes = array(
'class' => 'listitem listitem-category',
'data-id' => $category->id,
@ -379,9 +382,6 @@ class core_course_management_renderer extends plugin_renderer_base {
'limit' => $perpage
);
$courseid = isset($course) ? $course->id : null;
$first = true;
$last = false;
$i = $page * $perpage;
$html = html_writer::start_div('course-listing', array(
'data-category' => $category->id,
@ -395,12 +395,7 @@ class core_course_management_renderer extends plugin_renderer_base {
$html .= $this->listing_pagination($category, $page, $perpage);
$html .= html_writer::start_tag('ul', array('class' => 'ml'));
foreach ($category->get_courses($options) as $listitem) {
$i++;
if ($i == $totalcourses) {
$last = true;
}
$html .= $this->course_listitem($category, $listitem, $courseid, $first, $last);
$first = false;
$html .= $this->course_listitem($category, $listitem, $courseid);
}
$html .= html_writer::end_tag('ul');
$html .= $this->listing_pagination($category, $page, $perpage, true);
@ -483,12 +478,9 @@ class core_course_management_renderer extends plugin_renderer_base {
* @param coursecat $category The currently selected category and the category the course belongs to.
* @param course_in_list $course The course to produce HTML for.
* @param int $selectedcourse The id of the currently selected course.
* @param bool $firstincategory True if this course is the first course in the category.
* @param bool $lastincategory True if this course is the last course in the category.
* @return string
*/
public function course_listitem(coursecat $category, course_in_list $course, $selectedcourse,
$firstincategory = false, $lastincategory = false) {
public function course_listitem(coursecat $category, course_in_list $course, $selectedcourse) {
$text = $course->get_formatted_name();
$attributes = array(
@ -514,8 +506,8 @@ class core_course_management_renderer extends plugin_renderer_base {
$html .= html_writer::end_div();
$html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename'));
$html .= html_writer::start_div('float-right');
$html .= $this->course_listitem_actions($category, $course, $firstincategory, $lastincategory);
$html .= html_writer::tag('span', s($course->idnumber), array('class' => 'dimmed idnumber'));
$html .= $this->course_listitem_actions($category, $course);
$html .= html_writer::end_div();
$html .= html_writer::end_div();
$html .= html_writer::end_tag('li');
@ -578,12 +570,9 @@ class core_course_management_renderer extends plugin_renderer_base {
*
* @param coursecat $category The currently selected category.
* @param course_in_list $course The course to renderer actions for.
* @param bool $firstincategory True if the course is the first course in the category.
* @param bool $lastincategory True if the course is the last course in the category.
* @return string
*/
public function course_listitem_actions(coursecat $category, course_in_list $course,
$firstincategory = false, $lastincategory = false) {
public function course_listitem_actions(coursecat $category, course_in_list $course) {
$baseurl = new moodle_url(
'/course/management.php',
array('courseid' => $course->id, 'categoryid' => $course->category, 'sesskey' => sesskey())
@ -615,22 +604,18 @@ class core_course_management_renderer extends plugin_renderer_base {
}
// Move up/down.
if ($category->can_resort_courses()) {
if (!$firstincategory) {
$actions[] = $this->action_icon(
new moodle_url($baseurl, array('action' => 'movecourseup')),
new pix_icon('t/up', get_string('up')),
null,
array('data-action' => 'moveup', 'class' => 'action-moveup')
);
}
if (!$lastincategory) {
$actions[] = $this->action_icon(
new moodle_url($baseurl, array('action' => 'movecoursedown')),
new pix_icon('t/down', get_string('down')),
null,
array('data-action' => 'movedown', 'class' => 'action-movedown')
);
}
$actions[] = $this->action_icon(
new moodle_url($baseurl, array('action' => 'movecourseup')),
new pix_icon('t/up', get_string('up')),
null,
array('data-action' => 'moveup', 'class' => 'action-moveup')
);
$actions[] = $this->action_icon(
new moodle_url($baseurl, array('action' => 'movecoursedown')),
new pix_icon('t/down', get_string('down')),
null,
array('data-action' => 'movedown', 'class' => 'action-movedown')
);
}
if (empty($actions)) {
return '';

View File

@ -1138,6 +1138,9 @@ Category.prototype = {
Y.log('AJAX loaded subcategories for '+this.get('itemname'), 'info', 'core_course');
node.append(outcome.html);
console.initialise_categories(node);
if (M.core && M.core.actionmenu && M.core.actionmenu.newDOMNode) {
M.core.actionmenu.newDOMNode(node);
}
},
/**

File diff suppressed because one or more lines are too long

View File

@ -1114,6 +1114,9 @@ Category.prototype = {
}
node.append(outcome.html);
console.initialise_categories(node);
if (M.core && M.core.actionmenu && M.core.actionmenu.newDOMNode) {
M.core.actionmenu.newDOMNode(node);
}
},
/**

View File

@ -184,6 +184,9 @@ Category.prototype = {
Y.log('AJAX loaded subcategories for '+this.get('itemname'), 'info', 'core_course');
node.append(outcome.html);
console.initialise_categories(node);
if (M.core && M.core.actionmenu && M.core.actionmenu.newDOMNode) {
M.core.actionmenu.newDOMNode(node);
}
},
/**

View File

@ -149,6 +149,7 @@ $string['asc'] = 'Ascending';
$string['assessment'] = 'Assessment';
$string['assignadmins'] = 'Assign admins';
$string['assigncreators'] = 'Assign creators';
$string['assignedrolecount'] = '{$a->role} X {$a->count}';
$string['assignsiteroles'] = 'Assign site-wide roles';
$string['authenticateduser'] = 'Authenticated user';
$string['authenticateduserdescription'] = 'All logged in users.';
@ -206,6 +207,7 @@ $string['blocksediton'] = 'Blocks editing on';
$string['blocksetup'] = 'Setting up block tables';
$string['blocksuccess'] = '{$a} tables have been set up correctly';
$string['brief'] = 'Brief';
$string['bulkactions'] = 'Bulk actions';
$string['bycourseorder'] = 'By course order';
$string['byname'] = 'by {$a}';
$string['bypassed'] = 'Bypassed';
@ -245,6 +247,7 @@ $string['clickhere'] = 'Click here ...';
$string['clicktohideshow'] = 'Click to expand or collapse';
$string['clicktochangeinbrackets'] = '{$a} (Click to change)';
$string['closewindow'] = 'Close this window';
$string['collapse'] = 'Collapse';
$string['collapseall'] = 'Collapse all';
$string['commentincontext'] = 'Find this comment in context';
$string['comments'] = 'Comments';
@ -295,6 +298,7 @@ $string['coursecategories'] = 'Course categories';
$string['coursecategory'] = 'Course category';
$string['coursecategory_help'] = 'This setting determines the category in which the course will appear in the list of courses.';
$string['coursecategorydeleted'] = 'Deleted course category {$a}';
$string['coursecatmanagement'] = 'Course and category management';
$string['coursecompletion'] = 'Course completion';
$string['coursecompletions'] = 'Course completions';
$string['coursecreators'] = 'Course creator';
@ -371,6 +375,7 @@ $string['create'] = 'Create';
$string['createaccount'] = 'Create my new account';
$string['createcategory'] = 'Create category';
$string['createfolder'] = 'Create a folder in {$a}';
$string['createnew'] = 'Create new';
$string['createsubcategoryof'] = 'Create subcategory of {$a}';
$string['createuserandpass'] = 'Choose your username and password';
$string['createuser'] = 'Create user';
@ -654,6 +659,7 @@ $string['emptydragdropregion'] = 'empty region';
$string['enable'] = 'Enable';
$string['encryptedcode'] = 'Encrypted code';
$string['english'] = 'English';
$string['enrolmentmethods'] = 'Enrolment methods';
$string['entercourse'] = 'Click to enter this course';
$string['enteremail'] = 'Enter your email address';
$string['enteremailaddress'] = 'Enter in your email address to reset your
@ -691,6 +697,7 @@ $string['existingcoursedeleting'] = 'Existing course, deleting it first';
$string['existingcreators'] = 'Existing course creators';
$string['existingstudents'] = 'Enrolled students';
$string['existingteachers'] = 'Existing teachers';
$string['expand'] = 'Expand';
$string['expandall'] = 'Expand all';
$string['explanation'] = 'Explanation';
$string['extendenrol'] = 'Extend enrolment (individual)';
@ -709,6 +716,7 @@ $string['fileuploadwithcontent'] = 'File uploads should not include the content
$string['filloutallfields'] = 'Please fill out all fields in this form';
$string['filter'] = 'Filter';
$string['findmorecourses'] = 'Find more courses...';
$string['first'] = 'First';
$string['firstaccess'] = 'First access';
$string['firstname'] = 'First name';
$string['firstnamephonetic'] = 'First name - phonetic';
@ -938,6 +946,7 @@ $string['langltr'] = 'Language direction left-to-right';
$string['langrtl'] = 'Language direction right-to-left';
$string['language'] = 'Language';
$string['languagegood'] = 'This language pack is up-to-date! :-)';
$string['last'] = 'Last';
$string['lastaccess'] = 'Last access';
$string['lastedited'] = 'Last edited';
$string['lastlogin'] = 'Last login';
@ -1093,6 +1102,7 @@ $string['modchooserdisable'] = 'Activity chooser off';
$string['moduleintro'] = 'Description';
$string['modulesetup'] = 'Setting up module tables';
$string['modulesuccess'] = '{$a} tables have been set up correctly';
$string['modulesused'] = 'Modules used';
$string['moodledocs'] = 'Moodle Docs';
$string['moodledocslink'] = 'Moodle Docs for this page';
$string['moodleversion'] = 'Moodle version';
@ -1117,6 +1127,7 @@ $string['movehere'] = 'Move to here';
$string['moveleft'] = 'Move left';
$string['moveright'] = 'Move right';
$string['movesection'] = 'Move section {$a}';
$string['moveselectedcategoriesto'] = 'Move selected categories to';
$string['moveselectedcoursesto'] = 'Move selected courses to...';
$string['movetoanotherfolder'] = 'Move to another folder';
$string['moveup'] = 'Move up';
@ -1320,6 +1331,8 @@ $string['paymentsorry'] = 'Thank you for your payment! Unfortunately your payme
$string['paymentthanks'] = 'Thank you for your payment! You are now enrolled in your course:<br />"{$a}"';
$string['pendingrequests'] = 'Pending requests';
$string['periodending'] = 'Period ending ({$a})';
$string['perpage'] = 'Per page';
$string['perpagea'] = 'Per page: {$a}';
$string['personal'] = 'Personal';
$string['personalprofile'] = 'Personal profile';
$string['phone'] = 'Phone';
@ -1351,6 +1364,7 @@ $string['preferences'] = 'Preferences';
$string['preferredlanguage'] = 'Preferred language';
$string['preferredtheme'] = 'Preferred theme';
$string['preprocessingbackupfile'] = 'Preprocessing backup file';
$string['prev'] = 'Prev';
$string['preview'] = 'Preview';
$string['previewhtml'] = 'HTML format preview';
$string['previeworchoose'] = 'Preview or choose a theme';
@ -1423,7 +1437,14 @@ $string['resetstartdate'] = 'Reset start date';
$string['resetstatus'] = 'Status';
$string['resettask'] = 'Task';
$string['resettodefaults'] = 'Reset to defaults';
$string['resortcategories'] = 'Re-sort categories';
$string['resortcourses'] = 'Re-sort courses';
$string['resortcoursesbyname'] = 'Re-sort courses by name';
$string['resortbyname'] = 'By name';
$string['resortbyshortname'] = 'By shortname';
$string['resortbyfullname'] = 'By fullname';
$string['resortbyidnumber'] = 'By idnumber';
$string['resortselectedcategoriesby'] = 'Re-sort sub categories of selected categories';
$string['resource'] = 'Resource';
$string['resourcedisplayauto'] = 'Automatic';
$string['resourcedisplaydownload'] = 'Force download';
@ -1456,6 +1477,7 @@ $string['returningtosite'] = 'Returning to this web site?';
$string['returntooriginaluser'] = 'Return to {$a}';
$string['revert'] = 'Revert';
$string['role'] = 'Role';
$string['roleassignments'] = 'Role assignments';
$string['rolemappings'] = 'Role mappings';
$string['rolerenaming'] = 'Role renaming';
$string['rolerenaming_help'] = 'This setting allows the displayed names for roles used in the course to be changed. Only the displayed name is changed - role permissions are not affected. New role names will appear on the course participants page and elsewhere within the course. If the renamed role is one that the administrator has selected as a course manager role, then the new role name will also appear as part of the course listings.';
@ -1565,6 +1587,8 @@ $string['showdescription'] = 'Display description on course page';
$string['showdescription_help'] = 'If enabled, the description above will be displayed on the course page just below the link to the activity or resource.';
$string['showgrades'] = 'Show gradebook to students';
$string['showgrades_help'] = 'Many activities in the course allow grades to be set. This setting determines whether a student can view a list of all their grades for the course via a grades link in the course administration block.';
$string['showingacourses'] = 'Showing all {$a} courses';
$string['showingxofycourses'] = 'Showing courses {$a->start} to {$a->end} of {$a->total} courses';
$string['showlistofcourses'] = 'Show list of courses';
$string['showmodulecourse'] = 'Show list of courses containing activity';
$string['showonly'] = 'Show only';
@ -1666,6 +1690,8 @@ $string['studentnotallowed'] = 'Sorry, but you can not enter this course as \'{$
$string['students'] = 'Students';
$string['studentsandteachers'] = 'Students and teachers';
$string['subcategories'] = 'Sub-categories';
$string['subcategory'] = 'Sub category';
$string['subcategoryof'] = 'Subcategory of {$a}';
$string['submit'] = 'Submit';
$string['success'] = 'Success';
$string['summary'] = 'Summary';
@ -1897,30 +1923,3 @@ $string['yourself'] = 'yourself';
$string['yourteacher'] = 'your {$a}';
$string['yourwordforx'] = 'Your word for \'{$a}\'';
$string['zippingbackup'] = 'Zipping backup';
$string['coursecatmanagement'] = 'Course and category management';
$string['subcategoryof'] = 'Subcategory of {$a}';
$string['resortcategories'] = 'Re-sort categories';
$string['resortcourses'] = 'Re-sort courses';
$string['resortbyname'] = 'By name';
$string['resortbyshortname'] = 'By shortname';
$string['resortbyfullname'] = 'By fullname';
$string['resortbyidnumber'] = 'By idnumber';
$string['subcategory'] = 'Sub category';
$string['createnew'] = 'Create new';
$string['expand'] = 'Expand';
$string['collapse'] = 'Collapse';
$string['assignedrolecount'] = '{$a->role} X {$a->count}';
$string['roleassignments'] = 'Role assignments';
$string['enrolmentmethods'] = 'Enrolment methods';
$string['modulesused'] = 'Modules used';
$string['perpage'] = 'Per page';
$string['perpagea'] = 'Per page: {$a}';
$string['first'] = 'First';
$string['last'] = 'Last';
$string['prev'] = 'Prev';
$string['showingacourses'] = 'Showing all {$a} courses';
$string['showingxofycourses'] = 'Showing courses {$a->start} to {$a->end} of {$a->total} courses';
$string['resortselectedcategoriesby'] = 'Re-sort sub categories of selected categories by';
$string['moveselectedcategoriesto'] = 'Move selected categories to';
$string['bulkactions'] = 'Bulk actions';

View File

@ -289,7 +289,9 @@ input.titleeditor { width: 330px; vertical-align: text-bottom; }
#course-category-listings .listitem > div .item-actions .action-show,
#course-category-listings .listitem[data-visible="0"] > div .item-actions .action-hide,
#course-category-listings .listitem[data-visible="0"] > ul .item-actions.category-item-actions .action-hide,
#course-category-listings .listitem[data-visible="0"] > ul .item-actions.category-item-actions .action-show {display: none;}
#course-category-listings .listitem[data-visible="0"] > ul .item-actions.category-item-actions .action-show,
#course-category-listings .listitem:first-child > div .item-actions .action-moveup,
#course-category-listings .listitem:last-child > div .item-actions .action-movedown {display: none;}
#course-listing li > div {padding-left:1em;}

View File

@ -806,6 +806,10 @@ span.editinstructions {
}
}
}
&:first-child > div .item-actions .action-moveup,
&:last-child > div .item-actions .action-movedown {
display: none;
}
}
#course-listing {

File diff suppressed because one or more lines are too long