Skip to content

Commit

Permalink
fix invisible dropdown options, show enrolment in course details
Browse files Browse the repository at this point in the history
  • Loading branch information
my-curiosity committed Nov 13, 2024
1 parent 109eb21 commit 061953b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = function(grunt) {
options: {
jshintrc: true
},
files: ["**/amd/src/*.js"]
files: ["**/amd/src/*.js", '!**/amd/src/jquery.dataTables.js']
},
uglify: {
dynamic_mappings: {
Expand Down
2 changes: 1 addition & 1 deletion amd/build/dataTables.bootstrap4.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/jquery.dataTables.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/table_filter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion amd/src/table_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ define(['jquery'], function($) {
columns.forEach(function(element) {
$(columnDropdownID).append($('<option>', {
value: counter,
text: element.name
text: element.name,
hidden: !element.visible ? true : undefined
}));
counter++;
});
Expand Down
11 changes: 10 additions & 1 deletion classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
require_once("$CFG->libdir/adminlib.php");
require_once($CFG->dirroot . '/course/externallib.php');
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
require_once("$CFG->dirroot/enrol/locallib.php");

use external_api;
use external_function_parameters;
Expand Down Expand Up @@ -974,7 +975,7 @@ public static function get_course_info($courseid) {
0
);
$users = [];
$userenrolments = $DB->get_records_sql('SELECT ue.userid, ue.id FROM {user_enrolments} ue,
$userenrolments = $DB->get_records_sql('SELECT ue.userid, ue.id, ue.enrolid FROM {user_enrolments} ue,
{enrol} e WHERE e.id = ue.enrolid AND e.courseid = ?', [$courseid]);
foreach ($usersraw as $u) {
$u = (array)$u;
Expand All @@ -999,6 +1000,13 @@ public static function get_course_info($courseid) {
}
$u['roles'] = $userroles;
$u['enrol_id'] = $userenrolments[$u['id']]->id;

// Get enrol instance name for this user.
$enrolid = $userenrolments[$u['id']]->enrolid;
$instance = $DB->get_record('enrol', array('id'=>$enrolid), '*', MUST_EXIST);
$plugin = enrol_get_plugin($instance->enrol);
$u['enrol_name'] = $plugin->get_instance_name($instance);

$users[] = $u;
}

Expand Down Expand Up @@ -1129,6 +1137,7 @@ public static function get_course_info_returns() {
'lastaccess' => new external_value(PARAM_RAW, 'lastaccess of the user to the course'),
'roles' => new external_multiple_structure(new external_value(PARAM_TEXT, 'array with roles for each user')),
'enrol_id' => new external_value(PARAM_INT, 'id of user enrolment to course'),
'enrol_name' => new external_value(PARAM_TEXT, 'name of user enrolment'),
])
),
'activities' => new external_multiple_structure(
Expand Down
4 changes: 2 additions & 2 deletions templates/course_detail.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Example context (json):
<table class="stripe hover row-border" id="userincourse">
<thead>
<tr>
<th>ID</th>
<th>{{#str}}enrolmentmethods{{/str}}</th>
<th>{{#str}}username{{/str}}</th>
<th>{{#str}}firstname{{/str}}</th>
<th>{{#str}}lastname{{/str}}</th>
Expand All @@ -225,7 +225,7 @@ Example context (json):
<tbody>
{{#users}}
<tr>
<td>{{id}}</td>
<td>{{enrol_name}}</td>
<td>{{username}}</td>
<td>{{firstname}}</td>
<td>{{lastname}}</td>
Expand Down

0 comments on commit 061953b

Please sign in to comment.