diff --git a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js index 656ff82690..dc196bfb34 100644 --- a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js +++ b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js @@ -72,8 +72,12 @@ define('Graph', ['logme'], function (logme) { return; } - createMarkingsFunctions(); - createMovingLabelFunctions(); + if (createMarkingsFunctions() === false) { + return; + } + if (createMovingLabelFunctions() === false) { + return; + } // Create the initial graph and plot it for the user to see. if (generateData() === true) { @@ -87,21 +91,26 @@ define('Graph', ['logme'], function (logme) { return; function createMovingLabelFunctions() { - var c1; + var c1, returnStatus; + returnStatus = true; movingLabels = []; if (config.plot.hasOwnProperty('moving_label') !== true) { - return ; - } - - if ($.isPlainObject(config.plot.moving_label) === true) { - processMovingLabel(config.plot.moving_label); + returnStatus = true; + } else if ($.isPlainObject(config.plot.moving_label) === true) { + if (processMovingLabel(config.plot.moving_label) === false) { + returnStatus = false; + } } else if ($.isArray(config.plot.moving_label) === true) { for (c1 = 0; c1 < config.plot.moving_label.length; c1++) { - processMovingLabel(config.plot.moving_label[c1]); + if (processMovingLabel(config.plot.moving_label[c1]) === false) { + returnStatus = false; + } } } + + return returnStatus; } function processMovingLabel(obj) { @@ -111,24 +120,24 @@ define('Graph', ['logme'], function (logme) { if (obj.hasOwnProperty('@text') === false) { logme('ERROR: You did not define a "text" attribute for the moving_label.'); - return; + return false; } if (typeof obj['@text'] !== 'string') { logme('ERROR: "text" attribute is not a string.'); - return; + return false; } labelText = obj['@text']; if (obj.hasOwnProperty('#text') === false) { logme('ERROR: moving_label is missing function declaration.'); - return; + return false; } if (typeof obj['#text'] !== 'string') { logme('ERROR: Function declaration is not a string.'); - return; + return false; } funcString = obj['#text']; @@ -197,7 +206,7 @@ define('Graph', ['logme'], function (logme) { paramNames.pop(); - return; + return false; } paramNames.pop(); @@ -209,23 +218,31 @@ define('Graph', ['logme'], function (logme) { 'fontColor': fontColor, 'fontWeight': fontWeight }); + + return true; } function createMarkingsFunctions() { - var c1, paramNames; + var c1, paramNames, returnStatus; + + returnStatus = true; asymptotes = []; paramNames = state.getAllParameterNames(); if ($.isPlainObject(config.plot.asymptote)) { - processAsymptote(config.plot.asymptote); + if (processAsymptote(config.plot.asymptote) === false) { + returnStatus = false; + } } else if ($.isArray(config.plot.asymptote)) { for (c1 = 0; c1 < config.plot.asymptote.length; c1 += 1) { - processAsymptote(config.plot.asymptote[c1]); + if (processAsymptote(config.plot.asymptote[c1]) === false) { + returnStatus = false; + } } } - return; + return returnStatus; // Read configuration options for asymptotes, and store them as // an array of objects. Each object will have 3 properties: @@ -259,12 +276,12 @@ define('Graph', ['logme'], function (logme) { } else { logme('ERROR: Attribute "type" for asymptote can be "x" or "y".'); - return; + return false; } } else { logme('ERROR: Attribute "type" for asymptote is not specified.'); - return; + return false; } if (typeof asyObj['#text'] === 'string') { @@ -272,7 +289,7 @@ define('Graph', ['logme'], function (logme) { } else { logme('ERROR: Function body for asymptote is not specified.'); - return; + return false; } newAsyObj.color = '#000'; @@ -288,6 +305,29 @@ define('Graph', ['logme'], function (logme) { newAsyObj.label = asyObj['@label']; } + funcString = $('