[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/report/competency/amd/src/ -> user_course_navigation.js (source)

   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   * @package    report_competency
  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       * UserCourseNavigation
  28       *
  29       * @param {String} userSelector The selector of the user element.
  30       * @param {String} baseUrl The base url for the page (no params).
  31       * @param {Number} userId The course id
  32       * @param {Number} courseId The user id
  33       */
  34      var UserCourseNavigation = function(userSelector, baseUrl, userId, courseId) {
  35          this._baseUrl = baseUrl;
  36          this._userId = userId + '';
  37          this._courseId = courseId;
  38  
  39          $(userSelector).on('change', this._userChanged.bind(this));
  40      };
  41  
  42      /**
  43       * The user was changed in the select list.
  44       *
  45       * @method _userChanged
  46       * @param {Event} e the event
  47       */
  48      UserCourseNavigation.prototype._userChanged = function(e) {
  49          var newUserId = $(e.target).val();
  50          var queryStr = '?user=' + newUserId + '&id=' + this._courseId;
  51          document.location = this._baseUrl + queryStr;
  52      };
  53  
  54      /** @type {Number} The id of the user. */
  55      UserCourseNavigation.prototype._userId = null;
  56      /** @type {Number} The id of the course. */
  57      UserCourseNavigation.prototype._courseId = null;
  58      /** @type {String} Plugin base url. */
  59      UserCourseNavigation.prototype._baseUrl = null;
  60  
  61      return /** @alias module:report_competency/user_course_navigation */ UserCourseNavigation;
  62  
  63  });


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1