grade/report/grader/amd/src/group.js

  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. * Allow the user to search for groups within the grader report.
  17. *
  18. * @module gradereport_grader/group
  19. * @copyright 2023 Mathew May <mathew.solutions>
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  21. */
  22. import GroupSearch from 'core_group/comboboxsearch/group';
  23. import Url from 'core/url';
  24. export default class Group extends GroupSearch {
  25. courseID;
  26. constructor() {
  27. super();
  28. // Define our standard lookups.
  29. this.selectors = {...this.selectors,
  30. courseid: '[data-region="courseid"]',
  31. };
  32. const component = document.querySelector(this.componentSelector());
  33. this.courseID = component.querySelector(this.selectors.courseid).dataset.courseid;
  34. }
  35. static init() {
  36. return new Group();
  37. }
  38. /**
  39. * Build up the link that is dedicated to a particular result.
  40. *
  41. * @param {Number} groupID The ID of the group selected.
  42. * @returns {string|*}
  43. */
  44. selectOneLink(groupID) {
  45. return Url.relativeUrl('/grade/report/grader/index.php', {
  46. id: this.courseID,
  47. groupsearchvalue: this.getSearchTerm(),
  48. group: groupID,
  49. }, false);
  50. }
  51. }