MDL-53730 JavaScript: Fix for competency autoselect issue.
authorAdrian Greeve <adrian@moodle.com>
Thu, 5 May 2016 03:32:40 +0000 (11:32 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Fri, 6 May 2016 01:27:32 +0000 (09:27 +0800)
When trying to select a user or competency the first select
would not work. Worked fine on the second select. This fixes
that problem and tidies up the code.

admin/tool/lp/amd/src/user_competency_course_navigation.js

index 7cfa93d..a7a43ba 100644 (file)
@@ -38,8 +38,6 @@ define(['jquery'], function($) {
         this._userId = userId + '';
         this._competencyId = competencyId + '';
         this._courseId = courseId;
-        this._ignoreFirstUser = true;
-        this._ignoreFirstCompetency = true;
 
         $(userSelector).on('change', this._userChanged.bind(this));
         $(competencySelector).on('change', this._competencyChanged.bind(this));
@@ -52,11 +50,6 @@ define(['jquery'], function($) {
      * @param {Event} e
      */
     UserCompetencyCourseNavigation.prototype._userChanged = function(e) {
-        if (this._ignoreFirstUser) {
-            this._ignoreFirstUser = false;
-            return;
-        }
-
         var newUserId = $(e.target).val();
         var queryStr = '?userid=' + newUserId + '&courseid=' + this._courseId + '&competencyid=' + this._competencyId;
         document.location = this._baseUrl + queryStr;
@@ -69,10 +62,6 @@ define(['jquery'], function($) {
      * @param {Event} e
      */
     UserCompetencyCourseNavigation.prototype._competencyChanged = function(e) {
-        if (this._ignoreFirstCompetency) {
-            this._ignoreFirstCompetency = false;
-            return;
-        }
         var newCompetencyId = $(e.target).val();
         var queryStr = '?userid=' + this._userId + '&courseid=' + this._courseId + '&competencyid=' + newCompetencyId;
         document.location = this._baseUrl + queryStr;