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 |
* Event click on selecting competency in the competency autocomplete.
|
|
|
18 |
*
|
|
|
19 |
* @module tool_lp/competency_plan_navigation
|
|
|
20 |
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
|
|
21 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
define(['jquery'], function($) {
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* CompetencyPlanNavigation
|
|
|
28 |
*
|
|
|
29 |
* @class
|
|
|
30 |
* @param {String} competencySelector The selector of the competency element.
|
|
|
31 |
* @param {String} baseUrl The base url for the page (no params).
|
|
|
32 |
* @param {Number} userId The user id
|
|
|
33 |
* @param {Number} competencyId The competency id
|
|
|
34 |
* @param {Number} planId The plan id
|
|
|
35 |
*/
|
|
|
36 |
var CompetencyPlanNavigation = function(competencySelector, baseUrl, userId, competencyId, planId) {
|
|
|
37 |
this._baseUrl = baseUrl;
|
|
|
38 |
this._userId = userId + '';
|
|
|
39 |
this._competencyId = competencyId + '';
|
|
|
40 |
this._planId = planId;
|
|
|
41 |
this._ignoreFirstCompetency = true;
|
|
|
42 |
|
|
|
43 |
$(competencySelector).on('change', this._competencyChanged.bind(this));
|
|
|
44 |
};
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* The competency was changed in the select list.
|
|
|
48 |
*
|
|
|
49 |
* @method _competencyChanged
|
|
|
50 |
* @param {Event} e
|
|
|
51 |
*/
|
|
|
52 |
CompetencyPlanNavigation.prototype._competencyChanged = function(e) {
|
|
|
53 |
if (this._ignoreFirstCompetency) {
|
|
|
54 |
this._ignoreFirstCompetency = false;
|
|
|
55 |
return;
|
|
|
56 |
}
|
|
|
57 |
var newCompetencyId = $(e.target).val();
|
|
|
58 |
var queryStr = '?userid=' + this._userId + '&planid=' + this._planId + '&competencyid=' + newCompetencyId;
|
|
|
59 |
document.location = this._baseUrl + queryStr;
|
|
|
60 |
};
|
|
|
61 |
|
|
|
62 |
/** @property {Number} The id of the competency. */
|
|
|
63 |
CompetencyPlanNavigation.prototype._competencyId = null;
|
|
|
64 |
/** @property {Number} The id of the user. */
|
|
|
65 |
CompetencyPlanNavigation.prototype._userId = null;
|
|
|
66 |
/** @property {Number} The id of the plan. */
|
|
|
67 |
CompetencyPlanNavigation.prototype._planId = null;
|
|
|
68 |
/** @property {String} Plugin base url. */
|
|
|
69 |
CompetencyPlanNavigation.prototype._baseUrl = null;
|
|
|
70 |
/** @property {Boolean} Ignore the first change event for competencies. */
|
|
|
71 |
CompetencyPlanNavigation.prototype._ignoreFirstCompetency = null;
|
|
|
72 |
|
|
|
73 |
return CompetencyPlanNavigation;
|
|
|
74 |
});
|