if ($numcourses > COURSE_MAX_COURSES_PER_DROPDOWN) {
return false;
}
-
+ $orderby = 'visible DESC, sortorder ASC';
$options = array(0 => get_string('site'));
- if ($courses = get_user_capability_course('tool/monitor:subscribe', null, true, 'fullname')) {
+ if ($courses = get_user_capability_course('tool/monitor:subscribe', null, true, 'fullname', $orderby)) {
foreach ($courses as $course) {
$options[$course->id] = format_string($course->fullname, true,
array('context' => \context_course::instance($course->id)));
public static function get_rules_by_courseid($courseid, $limitfrom = 0, $limitto = 0) {
global $DB;
$select = "courseid = ? OR courseid = ?";
- return self::get_instances($DB->get_records_select('tool_monitor_rules', $select, array(0, $courseid), null, '*',
- $limitfrom, $limitto));
+ $orderby = "courseid DESC, name ASC";
+ return self::get_instances($DB->get_records_select('tool_monitor_rules', $select, array(0, $courseid), $orderby,
+ '*', $limitfrom, $limitto));
}
/**
* @return array list of subscriptions
*/
public static function get_user_subscriptions($limitfrom = 0, $limitto = 0, $userid = 0,
- $order = 's.timecreated DESC' ) {
+ $order = 's.courseid ASC, r.name' ) {
global $DB, $USER;
if ($userid == 0) {
$userid = $USER->id;