Skip to content

Commit

Permalink
MDL-35696 enrol_meta: Fixed course sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
amandadoughty committed Nov 24, 2014
1 parent ca0e301 commit cc6dee5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
6 changes: 5 additions & 1 deletion enrol/meta/addinstance_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ function definition() {
$courses = array('' => get_string('choosedots'));
$select = ', ' . context_helper::get_preload_record_columns_sql('ctx');
$join = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
$sql = "SELECT c.id, c.fullname, c.shortname, c.visible $select FROM {course} c $join ORDER BY c.sortorder ASC";

$plugin = enrol_get_plugin('meta');
$sortorder = 'c.' . $plugin->get_config('coursesort', 'sortorder') . ' ASC';

$sql = "SELECT c.id, c.fullname, c.shortname, c.visible $select FROM {course} c $join ORDER BY " . $sortorder;
$rs = $DB->get_recordset_sql($sql, array('contextlevel' => CONTEXT_COURSE));
foreach ($rs as $c) {
if ($c->id == SITEID or $c->id == $course->id or isset($existing[$c->id])) {
Expand Down
2 changes: 2 additions & 0 deletions enrol/meta/lang/en/enrol_meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['coursesort'] = 'Sort course list';
$string['coursesort_help'] = 'This determines whether the list of courses that can be linked are sorted by sort order (i.e. the order set in Site administration > Courses > Manage courses and categories) or alphabetically by course setting.';
$string['linkedcourse'] = 'Link course';
$string['meta:config'] = 'Configure meta enrol instances';
$string['meta:selectaslinked'] = 'Select course as meta linked';
Expand Down
14 changes: 14 additions & 0 deletions enrol/meta/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,19 @@
ENROL_EXT_REMOVED_SUSPENDNOROLES => get_string('extremovedsuspendnoroles', 'core_enrol'),
);
$settings->add(new admin_setting_configselect('enrol_meta/unenrolaction', get_string('extremovedaction', 'enrol'), get_string('extremovedaction_help', 'enrol'), ENROL_EXT_REMOVED_SUSPENDNOROLES, $options));

$sortoptions = array(
'sortorder' => new lang_string('sort_sortorder', 'admin'),
'fullname' => new lang_string('sort_fullname', 'admin'),
'shortname' => new lang_string('sort_shortname', 'admin'),
'idnumber' => new lang_string('sort_idnumber', 'admin'),
);
$settings->add(new admin_setting_configselect(
'enrol_meta/coursesort',
new lang_string('coursesort', 'enrol_meta'),
new lang_string('coursesort_help', 'enrol_meta'),
'sortorder',
$sortoptions
));
}
}
2 changes: 1 addition & 1 deletion enrol/meta/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2014111000; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2014112400; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2014110400; // Requires this Moodle version
$plugin->component = 'enrol_meta'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 60*60; // run cron every hour by default, it is not out-of-sync often

0 comments on commit cc6dee5

Please sign in to comment.