1 |
efrain |
1 |
// This file is part of Moodle - http://moodle.org/
|
|
|
2 |
//
|
|
|
3 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
4 |
// it under the terms of the GNU General Public License as published by
|
|
|
5 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
6 |
// (at your option) any later version.
|
|
|
7 |
//
|
|
|
8 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
11 |
// GNU General Public License for more details.
|
|
|
12 |
//
|
|
|
13 |
// You should have received a copy of the GNU General Public License
|
|
|
14 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
15 |
|
|
|
16 |
/**
|
|
|
17 |
* Allow the user to search for learners within the grader report.
|
|
|
18 |
*
|
|
|
19 |
* @module gradereport_grader/user
|
|
|
20 |
* @copyright 2023 Mathew May <mathew.solutions>
|
|
|
21 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
22 |
*/
|
|
|
23 |
import UserSearch from 'core_user/comboboxsearch/user';
|
|
|
24 |
import Url from 'core/url';
|
|
|
25 |
import * as Repository from 'gradereport_grader/local/user/repository';
|
|
|
26 |
|
|
|
27 |
// Define our standard lookups.
|
|
|
28 |
const selectors = {
|
|
|
29 |
component: '.user-search',
|
|
|
30 |
courseid: '[data-region="courseid"]',
|
|
|
31 |
};
|
|
|
32 |
const component = document.querySelector(selectors.component);
|
|
|
33 |
const courseID = component.querySelector(selectors.courseid).dataset.courseid;
|
|
|
34 |
|
|
|
35 |
export default class User extends UserSearch {
|
|
|
36 |
|
|
|
37 |
constructor() {
|
|
|
38 |
super();
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
static init() {
|
|
|
42 |
return new User();
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* Get the data we will be searching against in this component.
|
|
|
47 |
*
|
|
|
48 |
* @returns {Promise<*>}
|
|
|
49 |
*/
|
|
|
50 |
fetchDataset() {
|
|
|
51 |
return Repository.userFetch(courseID).then((r) => r.users);
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* Build up the view all link.
|
|
|
56 |
*
|
|
|
57 |
* @returns {string|*}
|
|
|
58 |
*/
|
|
|
59 |
selectAllResultsLink() {
|
|
|
60 |
return Url.relativeUrl('/grade/report/grader/index.php', {
|
|
|
61 |
id: courseID,
|
|
|
62 |
gpr_search: this.getSearchTerm()
|
|
|
63 |
}, false);
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
* Build up the link that is dedicated to a particular result.
|
|
|
68 |
*
|
|
|
69 |
* @param {Number} userID The ID of the user selected.
|
|
|
70 |
* @returns {string|*}
|
|
|
71 |
*/
|
|
|
72 |
selectOneLink(userID) {
|
|
|
73 |
return Url.relativeUrl('/grade/report/grader/index.php', {
|
|
|
74 |
id: courseID,
|
|
|
75 |
gpr_search: this.getSearchTerm(),
|
|
|
76 |
gpr_userid: userID,
|
|
|
77 |
}, false);
|
|
|
78 |
}
|
|
|
79 |
}
|