Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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 enable inline editing of a comptency grade.
18
 *
19
 * @module     tool_lp/user_competency_course_navigation
20
 * @copyright  2015 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
     * UserCompetencyCourseNavigation
28
     *
29
     * @class tool_lp/user_competency_course_navigation
30
     * @param {String} userSelector The selector of the user element.
31
     * @param {String} competencySelector The selector of the competency element.
32
     * @param {String} baseUrl The base url for the page (no params).
33
     * @param {Number} userId The user id
34
     * @param {Number} competencyId The competency id
35
     * @param {Number} courseId The course id
36
     */
37
    var UserCompetencyCourseNavigation = function(userSelector, competencySelector, baseUrl, userId, competencyId, courseId) {
38
        this._baseUrl = baseUrl;
39
        this._userId = userId + '';
40
        this._competencyId = competencyId + '';
41
        this._courseId = courseId;
42
 
43
        $(userSelector).on('change', this._userChanged.bind(this));
44
        $(competencySelector).on('change', this._competencyChanged.bind(this));
45
    };
46
 
47
    /**
48
     * The user was changed in the select list.
49
     *
50
     * @method _userChanged
51
     * @param {Event} e
52
     */
53
    UserCompetencyCourseNavigation.prototype._userChanged = function(e) {
54
        var newUserId = $(e.target).val();
55
        var queryStr = '?userid=' + newUserId + '&courseid=' + this._courseId + '&competencyid=' + this._competencyId;
56
        document.location = this._baseUrl + queryStr;
57
    };
58
 
59
    /**
60
     * The competency was changed in the select list.
61
     *
62
     * @method _competencyChanged
63
     * @param {Event} e
64
     */
65
    UserCompetencyCourseNavigation.prototype._competencyChanged = function(e) {
66
        var newCompetencyId = $(e.target).val();
67
        var queryStr = '?userid=' + this._userId + '&courseid=' + this._courseId + '&competencyid=' + newCompetencyId;
68
        document.location = this._baseUrl + queryStr;
69
    };
70
 
71
    /** @property {Number} The id of the competency. */
72
    UserCompetencyCourseNavigation.prototype._competencyId = null;
73
    /** @property {Number} The id of the user. */
74
    UserCompetencyCourseNavigation.prototype._userId = null;
75
    /** @property {Number} The id of the course. */
76
    UserCompetencyCourseNavigation.prototype._courseId = null;
77
    /** @property {String} Plugin base url. */
78
    UserCompetencyCourseNavigation.prototype._baseUrl = null;
79
    /** @property {Boolean} Ignore the first change event for competencies. */
80
    UserCompetencyCourseNavigation.prototype._ignoreFirstCompetency = null;
81
 
82
    return UserCompetencyCourseNavigation;
83
});