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 |
* Module to navigation between users in a course.
|
|
|
18 |
*
|
|
|
19 |
* @module tool_lp/module_navigation
|
|
|
20 |
* @copyright 2019 Damyon Wiese
|
|
|
21 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
define(['jquery'], function($) {
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* ModuleNavigation
|
|
|
28 |
*
|
|
|
29 |
* @class tool_lp/module_navigation
|
|
|
30 |
* @param {String} moduleSelector The selector of the module element.
|
|
|
31 |
* @param {String} baseUrl The base url for the page (no params).
|
|
|
32 |
* @param {Number} courseId The course id
|
|
|
33 |
* @param {Number} moduleId The activity module (filter)
|
|
|
34 |
*/
|
|
|
35 |
var ModuleNavigation = function(moduleSelector, baseUrl, courseId, moduleId) {
|
|
|
36 |
this._baseUrl = baseUrl;
|
|
|
37 |
this._moduleId = moduleId;
|
|
|
38 |
this._courseId = courseId;
|
|
|
39 |
|
|
|
40 |
$(moduleSelector).on('change', this._moduleChanged.bind(this));
|
|
|
41 |
};
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
* The module was changed in the select list.
|
|
|
45 |
*
|
|
|
46 |
* @method _moduleChanged
|
|
|
47 |
* @param {Event} e the event
|
|
|
48 |
*/
|
|
|
49 |
ModuleNavigation.prototype._moduleChanged = function(e) {
|
|
|
50 |
var newModuleId = $(e.target).val();
|
|
|
51 |
var queryStr = '?mod=' + newModuleId + '&courseid=' + this._courseId;
|
|
|
52 |
document.location = this._baseUrl + queryStr;
|
|
|
53 |
};
|
|
|
54 |
|
|
|
55 |
/** @property {Number} The id of the course. */
|
|
|
56 |
ModuleNavigation.prototype._courseId = null;
|
|
|
57 |
/** @property {Number} The id of the module. */
|
|
|
58 |
ModuleNavigation.prototype._moduleId = null;
|
|
|
59 |
/** @property {String} Plugin base url. */
|
|
|
60 |
ModuleNavigation.prototype._baseUrl = null;
|
|
|
61 |
|
|
|
62 |
return ModuleNavigation;
|
|
|
63 |
});
|