Skip to content

Commit

Permalink
Separate remaining constants into individual files. (oppia#6996)
Browse files Browse the repository at this point in the history
* Services

* Interactions

* Removed exceptional directories from linter

* Modified CODEOWNERS

* Add requires

* Fix lint

* Fix lint

* Update CODEOWNERS

* Revert package lock
  • Loading branch information
YashJipkate authored and seanlip committed Jun 25, 2019
1 parent f9a5dec commit 7ad9d06
Show file tree
Hide file tree
Showing 23 changed files with 189 additions and 107 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@
/core/templates/dev/head/pages/profile-page/ @kevinlee12
/core/templates/dev/head/services/UserService*.ts @kevinlee12

/core/templates/dev/head/services/services.constants.ts @kevinlee12

# Critical files.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@

require('domain/utilities/UrlInterpolationService.ts');

oppia.constant(
'STORY_DATA_URL_TEMPLATE', '/story_data_handler/<story_id>');

oppia.constant(
'STORY_NODE_COMPLETION_URL_TEMPLATE',
'/story_node_completion_handler/<story_id>/<node_id>');
require('domain/story_viewer/story-viewer-domain.constants.ts');

oppia.factory('StoryViewerBackendApiService', [
'$http', '$q', 'UrlInterpolationService', 'STORY_DATA_URL_TEMPLATE',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2018 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @fileoverview Constants for story viewer domain.
*/

oppia.constant(
'STORY_DATA_URL_TEMPLATE', '/story_data_handler/<story_id>');

oppia.constant(
'STORY_NODE_COMPLETION_URL_TEMPLATE',
'/story_node_completion_handler/<story_id>/<node_id>');
13 changes: 1 addition & 12 deletions core/templates/dev/head/services/ContextService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,7 @@
* context.
*/

oppia.constant('PAGE_CONTEXT', {
EXPLORATION_EDITOR: 'editor',
EXPLORATION_PLAYER: 'learner',
QUESTION_EDITOR: 'question_editor',
QUESTION_PLAYER: 'question_player',
OTHER: 'other'
});

oppia.constant('EXPLORATION_EDITOR_TAB_CONTEXT', {
EDITOR: 'editor',
PREVIEW: 'preview'
});
require('services/services.constants.ts');

oppia.factory('ContextService', [
'UrlService', 'EXPLORATION_EDITOR_TAB_CONTEXT', 'PAGE_CONTEXT',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* configured to support.
*/

oppia.constant(
'EXPLORATION_FEATURES_URL', '/explorehandler/features/<exploration_id>');
require('services/services.constants.ts');

oppia.factory('ExplorationFeaturesBackendApiService', [
'$http', 'UrlInterpolationService', 'EXPLORATION_FEATURES_URL',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ require('domain/statistics/PlaythroughObjectFactory.ts');
require('domain/statistics/PlaythroughIssueObjectFactory.ts');
require('domain/utilities/UrlInterpolationService.ts');

oppia.constant(
'FETCH_ISSUES_URL', '/issuesdatahandler/<exploration_id>');

oppia.constant(
'FETCH_PLAYTHROUGH_URL',
'/playthroughdatahandler/<exploration_id>/<playthrough_id>');

oppia.constant(
'RESOLVE_ISSUE_URL', '/resolveissuehandler/<exploration_id>');
require('services/services.constants.ts');

oppia.factory('PlaythroughIssuesBackendApiService', [
'$http', 'PlaythroughIssueObjectFactory', 'PlaythroughObjectFactory',
Expand Down
11 changes: 1 addition & 10 deletions core/templates/dev/head/services/PlaythroughService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@ require('domain/utilities/StopwatchObjectFactory.ts');
require('domain/utilities/UrlInterpolationService.ts');
require('services/ExplorationFeaturesService.ts');

oppia.constant(
'STORE_PLAYTHROUGH_URL',
'/explorehandler/store_playthrough/<exploration_id>');

// Enables recording playthroughs from learner sessions.
oppia.constant('EARLY_QUIT_THRESHOLD_IN_SECS', 45);
oppia.constant('NUM_INCORRECT_ANSWERS_THRESHOLD', 3);
oppia.constant('NUM_REPEATED_CYCLES_THRESHOLD', 3);
oppia.constant('CURRENT_ACTION_SCHEMA_VERSION', 1);
oppia.constant('CURRENT_ISSUE_SCHEMA_VERSION', 1);
require('services/services.constants.ts');

oppia.factory('PlaythroughService', [
'$http', 'ExplorationFeaturesService', 'LearnerActionObjectFactory',
Expand Down
6 changes: 1 addition & 5 deletions core/templates/dev/head/services/PromoBarService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
* @fileoverview Service Promo bar.
*/

// Whether to enable the promo bar functionality. This does not actually turn on
// the promo bar, as that is gated by a config value (see config_domain). This
// merely avoids checking for whether the promo bar is enabled for every Oppia
// page visited.
oppia.constant('ENABLE_PROMO_BAR', true);
require('services/services.constants.ts');

oppia.factory('PromoBarService', [
'$http', '$q', 'ENABLE_PROMO_BAR',
Expand Down
2 changes: 1 addition & 1 deletion core/templates/dev/head/services/RteHelperService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @fileoverview A helper service for the Rich text editor(RTE).
*/

oppia.constant('RTE_COMPONENT_SPECS', richTextComponents);
require('services/services.constants.ts');

oppia.factory('RteHelperService', [
'$document', '$filter', '$interpolate', '$log', '$uibModal',
Expand Down
2 changes: 1 addition & 1 deletion core/templates/dev/head/services/SearchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @fileoverview search service for activityTilesInfinityGrid
*/

oppia.constant('SEARCH_DATA_URL', '/searchhandler/data');
require('services/services.constants.ts');

oppia.factory('SearchService', [
'$http', '$log', '$rootScope', '$translate', 'SEARCH_DATA_URL',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
* @fileoverview Service to fetch statistics about an exploration's states.
*/

oppia.constant(
'STATE_ANSWER_STATS_URL',
'/createhandler/state_answer_stats/<exploration_id>');
require('services/services.constants.ts');

oppia.factory('StateTopAnswersStatsBackendApiService', [
'$http', 'UrlInterpolationService', 'STATE_ANSWER_STATS_URL',
Expand Down
68 changes: 68 additions & 0 deletions core/templates/dev/head/services/services.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright 2018 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @fileoverview Constants for shared services across Oppia.
*/

oppia.constant('PAGE_CONTEXT', {
EXPLORATION_EDITOR: 'editor',
EXPLORATION_PLAYER: 'learner',
QUESTION_EDITOR: 'question_editor',
QUESTION_PLAYER: 'question_player',
OTHER: 'other'
});

oppia.constant('EXPLORATION_EDITOR_TAB_CONTEXT', {
EDITOR: 'editor',
PREVIEW: 'preview'
});

oppia.constant(
'EXPLORATION_FEATURES_URL', '/explorehandler/features/<exploration_id>');

oppia.constant(
'FETCH_ISSUES_URL', '/issuesdatahandler/<exploration_id>');

oppia.constant(
'FETCH_PLAYTHROUGH_URL',
'/playthroughdatahandler/<exploration_id>/<playthrough_id>');

oppia.constant(
'RESOLVE_ISSUE_URL', '/resolveissuehandler/<exploration_id>');

oppia.constant(
'STORE_PLAYTHROUGH_URL',
'/explorehandler/store_playthrough/<exploration_id>');

// Enables recording playthroughs from learner sessions.
oppia.constant('EARLY_QUIT_THRESHOLD_IN_SECS', 45);
oppia.constant('NUM_INCORRECT_ANSWERS_THRESHOLD', 3);
oppia.constant('NUM_REPEATED_CYCLES_THRESHOLD', 3);
oppia.constant('CURRENT_ACTION_SCHEMA_VERSION', 1);
oppia.constant('CURRENT_ISSUE_SCHEMA_VERSION', 1);

// Whether to enable the promo bar functionality. This does not actually turn on
// the promo bar, as that is gated by a config value (see config_domain). This
// merely avoids checking for whether the promo bar is enabled for every Oppia
// page visited.
oppia.constant('ENABLE_PROMO_BAR', true);

oppia.constant('RTE_COMPONENT_SPECS', richTextComponents);

oppia.constant('SEARCH_DATA_URL', '/searchhandler/data');

oppia.constant(
'STATE_ANSWER_STATS_URL',
'/createhandler/state_answer_stats/<exploration_id>');
14 changes: 1 addition & 13 deletions extensions/classifiers/PythonProgramTokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,7 @@
* https://github.com/python/cpython/blob/2.7/Lib/tokenize.py
*/


oppia.constant('PythonProgramTokenType', {
COMMENT: 'COMMENT',
NL: 'NL',
STRING: 'STRING',
INDENT: 'INDENT',
DEDENT: 'DEDENT',
ENDMARKER: 'ENDMARKER',
NUMBER: 'NUMBER',
NAME: 'NAME',
OP: 'OP',
ERRORTOKEN: 'ERRORTOKEN'
});
require('classifiers/classifiers-extension.constants.ts');

oppia.factory('PythonProgramTokenizer', [
'$log', 'PythonProgramTokenType', function($log, PythonProgramTokenType) {
Expand Down
30 changes: 30 additions & 0 deletions extensions/classifiers/classifiers-extension.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2018 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @fileoverview Constants for classfiers extensions.
*/

oppia.constant('PythonProgramTokenType', {
COMMENT: 'COMMENT',
NL: 'NL',
STRING: 'STRING',
INDENT: 'INDENT',
DEDENT: 'DEDENT',
ENDMARKER: 'ENDMARKER',
NUMBER: 'NUMBER',
NAME: 'NAME',
OP: 'OP',
ERRORTOKEN: 'ERRORTOKEN'
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ require('classifiers/PythonProgramTokenizer.ts');
require('classifiers/SVMPredictionService.ts');
require('classifiers/WinnowingPreprocessingService.ts');

// Minimum confidence required for a predicted answer group to be shown to user.
// Generally a threshold of 0.7-0.8 is assumed to be a good one in practice,
// however value need not be in those bounds.
oppia.constant('CODE_REPL_PREDICTION_SERVICE_THRESHOLD', 0.7);
require('interactions/interactions-extension.constants.ts');

oppia.factory('CodeReplPredictionService', [
'CountVectorizerService', 'PythonProgramTokenType',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ require('interactions/GraphInput/directives/GraphDetailService.ts');
require('services/contextual/DeviceInfoService.ts');
require('services/stateful/FocusManagerService.ts');

require('interactions/interactions-extension.constants.ts');

oppia.directive('graphViz', [
'UrlInterpolationService', function(UrlInterpolationService) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ require('services/HtmlEscaperService.ts');
require('services/contextual/UrlService.ts');
require('services/contextual/WindowDimensionsService.ts');

oppia.constant('GRAPH_INPUT_LEFT_MARGIN', 120);

oppia.directive('oppiaInteractiveGraphInput', [
'GraphInputRulesService', 'HtmlEscaperService', 'UrlInterpolationService',
'UrlService', 'EVENT_NEW_CARD_AVAILABLE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ require('domain/utilities/UrlInterpolationService.ts');
require('interactions/GraphInput/directives/GraphDetailService.ts');
require('services/HtmlEscaperService.ts');

require('interactions/interactions-extension.constants.ts');

oppia.directive('oppiaResponseGraphInput', [
'GraphDetailService', 'HtmlEscaperService', 'UrlInterpolationService',
'GRAPH_INPUT_LEFT_MARGIN',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ require(
'interactions/MusicNotesInput/directives/' +
'OppiaInteractiveMusicNotesInputDirective.ts');

require('interactions/interactions-extension.constants.ts');

oppia.factory('MusicNotesInputRulesService', [
'NOTE_NAMES_TO_MIDI_VALUES', function(NOTE_NAMES_TO_MIDI_VALUES) {
var _getMidiNoteValue = function(note) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,7 @@ require(
require('services/contextual/WindowDimensionsService.ts');
require('services/HtmlEscaperService.ts');

// Gives the staff-lines human readable values.
oppia.constant('NOTE_NAMES_TO_MIDI_VALUES', {
A5: 81,
G5: 79,
F5: 77,
E5: 76,
D5: 74,
C5: 72,
B4: 71,
A4: 69,
G4: 67,
F4: 65,
E4: 64,
D4: 62,
C4: 60
});
require('interactions/interactions-extension.constants.ts');

oppia.directive('oppiaInteractiveMusicNotesInput', [
'CurrentInteractionService', 'HtmlEscaperService',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ require('classifiers/SVMPredictionService.ts');
require('classifiers/TextInputTokenizer.ts');
require('classifiers/CountVectorizerService.ts');

// Minimum confidence required for a predicted answer group to be shown to user.
// Generally a threshold of 0.7-0.8 is assumed to be a good one in practice,
// however value need not be in those bounds.
oppia.constant('TEXT_INPUT_PREDICTION_SERVICE_THRESHOLD', 0.7);
require('interactions/interactions-extension.constants.ts');

oppia.factory('TextInputPredictionService', [
'CountVectorizerService', 'SVMPredictionService',
Expand Down
Loading

0 comments on commit 7ad9d06

Please sign in to comment.