MDL-40811 JavaScript: Cast activityid to string when checking resources to show/hide
authorAndrew Nicols <andrew@nicols.co.uk>
Wed, 25 Sep 2013 17:09:54 +0000 (18:09 +0100)
committerAndrew Nicols <andrew@nicols.co.uk>
Wed, 25 Sep 2013 17:14:06 +0000 (18:14 +0100)
course/yui/dragdrop/dragdrop.js
course/yui/toolboxes/toolboxes.js

index cb0b53c..d7d8d4e 100644 (file)
@@ -135,8 +135,8 @@ YUI.add('moodle-course-dragdrop', function(Y) {
             var dragnode = drag.get('node');
             var dropnode = e.drop.get('node');
             // Prepare some variables
-            var dragnodeid = Number(Y.Moodle.core_course.util.section.getId(dragnode));
-            var dropnodeid = Number(Y.Moodle.core_course.util.section.getId(dropnode));
+            var dragnodeid = Y.Moodle.core_course.util.section.getId(dragnode);
+            var dropnodeid = Y.Moodle.core_course.util.section.getId(dropnode);
 
             var loopstart = dragnodeid;
             var loopend = dropnodeid;
index 545d696..2dad9f0 100644 (file)
@@ -797,7 +797,9 @@ YUI.add('moodle-course-toolboxes', function(Y) {
                 }
                 var activityid = Y.Moodle.core_course.util.cm.getId(node);
 
-                if (Y.Array.indexOf(response.resourcestotoggle, activityid) != -1) {
+                // NOTE: resourcestotoggle is returned as a string instead
+                // of a Number so we must cast our activityid to a String.
+                if (Y.Array.indexOf(response.resourcestotoggle, "" + activityid) != -1) {
                     node.getData('toolbox').handle_resource_dim(button, node, oldstatus);
                 }
             }, this);