Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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
import GroupSearch from 'core_group/comboboxsearch/group';
17
 
18
/**
19
 * Allow the user to search for groups in the action bar.
20
 *
21
 * @module    core_course/actionbar/group
22
 * @copyright 2024 Shamim Rezaie <shamim@moodle.com>
23
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
export default class Group extends GroupSearch {
26
 
27
    baseUrl;
28
 
29
    /**
30
     * Construct the class.
31
     *
32
     * @param {string} baseUrl The base URL for the page.
33
     * @param {int|null} cmid ID of the course module initiating the group search (optional).
34
     */
35
    constructor(baseUrl, cmid = null) {
36
        super(cmid);
37
        this.baseUrl = baseUrl;
38
    }
39
 
40
    /**
41
     * Allow the class to be invoked via PHP.
42
     *
43
     * @param {string} baseUrl The base URL for the page.
44
     * @param {int|null} cmid ID of the course module initiating the group search (optional).
45
     * @returns {Group}
46
     */
47
    static init(baseUrl, cmid = null) {
48
        return new Group(baseUrl, cmid);
49
    }
50
 
51
    /**
52
     * Build up the link that is dedicated to a particular result.
53
     *
54
     * @param {Number} groupID The ID of the group selected.
55
     * @returns {string}
56
     */
57
    selectOneLink(groupID) {
58
        const url = new URL(this.baseUrl);
59
        url.searchParams.set('groupsearchvalue', this.getSearchTerm());
60
        url.searchParams.set('group', groupID);
61
 
62
        return url.toString();
63
    }
64
}