Skip to content

Commit

Permalink
Fix server errors (oppia#6454)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankita240796 authored and vojtechjelinek committed Mar 19, 2019
1 parent a7585b1 commit 7175d03
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ oppia.factory('ExpressionSyntaxTreeService', [
// throws an error if not. If optional expectedMax is specified, it
// verifies the number of args is in [expectedNum, expectedMax] range
// inclusive.
var verifyNumArgs = function(args, expectedNum, expectedMax = expectedNum) {
var verifyNumArgs = function(args, expectedNum, expectedMax) {
if (expectedMax === undefined) {
expectedMax = expectedNum;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ oppia.factory('ExplorationDataService', [
explorationId: explorationId,
// Note that the changeList is the full changeList since the last
// committed version (as opposed to the most recent autosave).
autosaveChangeList: function(
changeList,
successCallback = function(response) {},
errorCallback = function() {}) {
autosaveChangeList: function(changeList, successCallback, errorCallback) {
// First save locally to be retrieved later if save is unsuccessful.
LocalStorageService.saveExplorationDraft(
explorationId, changeList, draftChangeListId);
Expand All @@ -75,9 +72,14 @@ oppia.factory('ExplorationDataService', [
// We can safely remove the locally saved draft copy if it was saved
// to the backend.
LocalStorageService.removeExplorationDraft(explorationId);
successCallback(response);
},
errorCallback);
if (successCallback) {
successCallback(response);
}
}, function() {
if (errorCallback) {
errorCallback();
}
});
},
discardDraft: function(successCallback, errorCallback) {
$http.post(explorationDraftAutosaveUrl, {}).then(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ oppia.factory('ThreadDataService', [
// Number of open threads that need action
var _openThreadsCount = 0;

var _fetchThreads = function(successCallback = function() {}) {
var _fetchThreads = function(successCallback) {
var threadsPromise = $http.get(_THREAD_LIST_HANDLER_URL);
var params = {
target_type: 'exploration',
Expand Down Expand Up @@ -81,7 +81,9 @@ oppia.factory('ThreadDataService', [
}
}
}
successCallback();
if (successCallback) {
successCallback();
}
});
};

Expand Down
12 changes: 6 additions & 6 deletions extensions/classifiers/PythonProgramTokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ oppia.constant('PythonProgramTokenType', {

oppia.factory('PythonProgramTokenizer', [
'$log', 'PythonProgramTokenType', function($log, PythonProgramTokenType) {
var groupOfRegEx = function(...params) {
return '(' + Array.prototype.join.call(params, '|') + ')';
var groupOfRegEx = function() {
return '(' + Array.prototype.join.call(arguments, '|') + ')';
};

var regExMayBePresent = function(params) {
return groupOfRegEx(params) + '?';
var regExMayBePresent = function() {
return groupOfRegEx(arguments) + '?';
};

var repeatedRegEx = function(params) {
return groupOfRegEx(params) + '*';
var repeatedRegEx = function() {
return groupOfRegEx(arguments) + '*';
};

var whitespace = '[ \\f\\t]*';
Expand Down
27 changes: 15 additions & 12 deletions extensions/interactions/LogicProof/static/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var logicProofShared = (function() {
* @return {string} A string representing the expression.
*/
var displayExpressionHelper = function(
expression, operators, desirabilityOfBrackets = 0) {
expression, operators, desirabilityOfBrackets) {
var desirabilityOfBracketsBelow = (
expression.top_kind_name === 'binary_connective' ||
expression.top_kind_name === 'binary_relation' ||
Expand Down Expand Up @@ -324,7 +324,7 @@ var logicProofShared = (function() {
* what the user intended and did wrong.
*/
var parseLineString = function(
inputString, operators, vocabulary, isTemplate = false) {
inputString, operators, vocabulary, isTemplate) {
var unparsedArray = preParseLineString(inputString, operators, isTemplate);

// We compile all words occurring in the vocabulary, to help us identify
Expand Down Expand Up @@ -558,11 +558,11 @@ var logicProofShared = (function() {
* largest (in lexicographic ordering) as this is likely to be closest
* to what the user intended.
*/
var assignTypesToExpression = function(
untypedExpression, possibleTopTypes,
language, newKindsPermitted = ['constant', 'variable'],
permitDuplicateDummyNames = false) {
var assignTypesToExpression = function(untypedExpression, possibleTopTypes,
language, newKindsPermitted, permitDuplicateDummyNames) {
var operators = language.operators;
newKindsPermitted = newKindsPermitted || ['constant', 'variable'];
permitDuplicateDummyNames = permitDuplicateDummyNames || false;

var _attemptTyping = function(topType, typingRule) {
if (!operatorIsNew &&
Expand Down Expand Up @@ -774,10 +774,11 @@ var logicProofShared = (function() {
* }
* @raises: as before
*/
var assignTypesToExpressionArray = function(
untypedArray, topTypes, language,
newKindsPermitted = ['constant', 'variable'], isTemplate = false,
numDummies = 0) {
var assignTypesToExpressionArray = function(untypedArray, topTypes, language,
newKindsPermitted, isTemplate, numDummies) {
newKindsPermitted = newKindsPermitted || ['constant', 'variable'];
isTemplate = isTemplate || false;
numDummies = numDummies || 0;
var partiallyTypedArrays = [[[]]];
var partiallyUpdatedOperators = [[{}]];
for (var key in language.operators) {
Expand Down Expand Up @@ -895,7 +896,8 @@ var logicProofShared = (function() {
// Returns a list of all the names of operators in an expression. kinds is an
// array specifying which kinds of operators to return; if it is not supplied
// then all are returned
var getOperatorsFromExpression = function(expression, kinds = false) {
var getOperatorsFromExpression = function(expression, kinds) {
kinds = kinds || false;
var output = getOperatorsFromExpressionArray(
expression.arguments.concat(expression.dummies), kinds);
return (output.indexOf(expression.top_operator_name) === -1 &&
Expand All @@ -904,7 +906,8 @@ var logicProofShared = (function() {
output;
};

var getOperatorsFromExpressionArray = function(array, kinds = false) {
var getOperatorsFromExpressionArray = function(array, kinds) {
kinds = kinds || false;
var output = [];
for (var i = 0; i < array.length; i++) {
var newOutput = getOperatorsFromExpression(array[i], kinds);
Expand Down

0 comments on commit 7175d03

Please sign in to comment.