Skip to content

Commit

Permalink
Fix part of oppia#6732: Migrate interactions and classifiers to webpa…
Browse files Browse the repository at this point in the history
…ck (oppia#6939)

* rist few files

* batch of work

* Added requires in other interactions

* Fix lint

* Added to interation requires

* finish interactions

* tests

* tests

* tests

* fix tests and errors

* fix backend test

* fix according to comments

* fixes
  • Loading branch information
vojtechjelinek authored and seanlip committed Jun 20, 2019
1 parent c1c2c00 commit 1f65946
Show file tree
Hide file tree
Showing 171 changed files with 1,091 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
/core/templates/dev/head/services/CodeNormalizerService*.ts @kevinlee12
/extensions/dependencies/ @seanlip
/extensions/domain*.py @seanlip
/extensions/interactions/ @kevinlee12
/extensions/interactions/ @kevinlee12 @vojtechjelinek
/extensions/objects/ @aks681
/extensions/value_generators/ @seanlip
/extensions/__init__.py @kevinlee12
Expand Down
6 changes: 3 additions & 3 deletions core/domain/interaction_registry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ def test_deduplication_of_dependency_ids(self):
self.assertItemsEqual(
interaction_registry.Registry.get_deduplicated_dependency_ids(
['CodeRepl']),
['skulpt', 'codemirror', 'code_repl_prediction'])
['skulpt', 'codemirror'])

self.assertItemsEqual(
interaction_registry.Registry.get_deduplicated_dependency_ids(
['CodeRepl', 'CodeRepl', 'CodeRepl']),
['skulpt', 'codemirror', 'code_repl_prediction'])
['skulpt', 'codemirror'])

self.assertItemsEqual(
interaction_registry.Registry.get_deduplicated_dependency_ids(
['CodeRepl', 'LogicProof']),
['skulpt', 'codemirror', 'logic_proof', 'code_repl_prediction'])
['skulpt', 'codemirror', 'logic_proof'])


class InteractionRegistryUnitTests(test_utils.GenericTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ require(
'components/state-directives/solution-editor/' +
'solution-explanation-editor.directive.ts');
require('components/forms/custom-forms-directives/html-select.directive.ts');
require('services/AutoplayedVideosService.ts');
// ^^^ this block of requires should be removed ^^^

require(
Expand All @@ -141,6 +140,9 @@ require(
'pages/exploration-editor-page/feedback-tab/thread-table/' +
'thread-table.directive.ts');

require('interactions/interactionsRequires.ts');
require('objects/objectComponentsRequires.ts');

require('components/entity-creation-services/exploration-creation.service.ts');
require('components/ratings/rating-computation/rating-computation.service.ts');
require('domain/creator_dashboard/CreatorDashboardBackendApiService.ts');
Expand All @@ -149,18 +151,14 @@ require('domain/suggestion/SuggestionObjectFactory.ts');
require('domain/suggestion/SuggestionThreadObjectFactory.ts');
require(
'domain/topics_and_skills_dashboard/' +
'TopicsAndSkillsDashboardBackendApiService.ts'
);

require('objects/objectComponentsRequires.ts');

require(
'pages/exploration-editor-page/feedback-tab/services/' +
'thread-status-display.service.ts');
'TopicsAndSkillsDashboardBackendApiService.ts');
require('domain/utilities/UrlInterpolationService.ts');
require(
'pages/creator-dashboard-page/suggestion-modal-for-creator-view/' +
'suggestion-modal-for-creator-view.service.ts');
require('domain/utilities/UrlInterpolationService.ts');
require(
'pages/exploration-editor-page/feedback-tab/services/' +
'thread-status-display.service.ts');
require('services/AlertsService.ts');
require('services/DateTimeFormatService.ts');
require('services/UserService.ts');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<script src="/templates/dev/head/mathjaxConfig.js"></script>
<script src="/third_party/static/MathJax-2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

<script src="/extensions/interactions/baseInteractionValidationService.js"></script>
<!-- This code is used for inserting webpack bundles
https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates -->
<% for (var chunk in htmlWebpackPlugin.files.js) { %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ require(
require(
'pages/exploration-editor-page/suggestion-modal-for-editor-view/' +
'suggestion-modal-for-exploration-editor.service.ts');
require('services/AutoplayedVideosService.ts');
require('services/CodeNormalizerService.ts');
// ^^^ this block of requires should be removed ^^^

require(
Expand Down Expand Up @@ -197,6 +195,7 @@ require(
'exploration-footer.directive.ts');
require('value_generators/valueGeneratorsRequires.ts');

require('interactions/interactionsRequires.ts');
require('objects/objectComponentsRequires.ts');

require('domain/exploration/ParamChangesObjectFactory.ts');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@
<script src="/templates/dev/head/mathjaxConfig.js"></script>
<script src="/third_party/static/MathJax-2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

<script src="/extensions/interactions/baseInteractionValidationService.js"></script>

<!-- This code is used for inserting webpack bundles
https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates -->
<% for (var chunk in htmlWebpackPlugin.files.js) { %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ require('components/ck-editor-helpers/ck-editor-rte.directive.ts');
require('components/ck-editor-helpers/ck-editor-widgets.initializer.ts');
require('directives/AngularHtmlBindDirective.ts');
require('directives/MathjaxBindDirective.ts');
require('filters/convert-unicode-with-params-to-html.filter.ts');
require('filters/convert-html-to-unicode.filter.ts');
require('filters/convert-unicode-to-html.filter.ts');
require('components/forms/validators/is-at-least.filter.ts');
require('components/forms/validators/is-at-most.filter.ts');
require('components/forms/validators/is-float.filter.ts');
Expand Down Expand Up @@ -78,9 +75,6 @@ require(
require(
'components/forms/schema-viewers/schema-based-unicode-viewer.directive.ts');
require('components/forms/schema-viewers/schema-based-viewer.directive.ts');
require('filters/string-utility-filters/normalize-whitespace.filter.ts');
require('services/AutoplayedVideosService.ts');
require('services/CodeNormalizerService.ts');
// ^^^ this block of requires should be removed ^^^

require(
Expand All @@ -102,10 +96,10 @@ require(
'pages/exploration-player-page/layout-directives/' +
'learner-view-info.directive.ts');

require('domain/exploration/ReadOnlyExplorationBackendApiService.ts');

require('interactions/interactionsRequires.ts');
require('objects/objectComponentsRequiresForPlayers.ts');

require('domain/exploration/ReadOnlyExplorationBackendApiService.ts');
require('services/ContextService.ts');
require('services/PageTitleService.ts');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require(
'components/question-directives/question-player/' +
'question-player.directive.ts');

require('interactions/interactionsQuestionsRequires.ts');
require('objects/objectComponentsRequiresForPlayers.ts');

require('services/AlertsService.ts');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,16 @@ require('directives/MathjaxBindDirective.ts');
require('filters/string-utility-filters/normalize-whitespace.filter.ts');
// ^^^ this block of requires should be removed ^^^

require('interactions/interactionsQuestionsRequires.ts');
require('objects/objectComponentsRequires.ts');

require(
'pages/skill-editor-page/editor-tab/skill-editor-main-tab.directive.ts');
require('pages/skill-editor-page/navbar/skill-editor-navbar.directive.ts');
require(
'pages/skill-editor-page/navbar/skill-editor-navbar-breadcrumb.directive.ts');
require(
'pages/skill-editor-page/editor-tab/skill-editor-main-tab.directive.ts');
require('pages/skill-editor-page/questions-tab/questions-tab.directive.ts');

require('domain/utilities/LanguageUtilService.ts');
require('domain/utilities/AudioLanguageObjectFactory.ts');
require('domain/utilities/AutogeneratedAudioLanguageObjectFactory.ts');
require('domain/utilities/BrowserCheckerService.ts');

require('pages/skill-editor-page/skill-editor-page.constants.ts');
require('pages/interaction-specs.constants.ts');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<script src="/templates/dev/head/mathjaxConfig.js"></script>
<script src="/third_party/static/MathJax-2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

<script src="/extensions/interactions/baseInteractionValidationService.js"></script>
<!-- This code is used for inserting webpack bundles
https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates -->
<% for (var chunk in htmlWebpackPlugin.files.js) { %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ require(
'components/state-directives/solution-editor/' +
'solution-explanation-editor.directive.ts');
require('filters/string-utility-filters/normalize-whitespace.filter.ts');
require('services/AutoplayedVideosService.ts');
// ^^^ this block of requires should be removed ^^^

require('interactions/interactionsQuestionsRequires.ts');
require('objects/objectComponentsRequires.ts');

require(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<script src="/templates/dev/head/mathjaxConfig.js"></script>
<script src="/third_party/static/MathJax-2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

<script src="/extensions/interactions/baseInteractionValidationService.js"></script>
<!-- This code is used for inserting webpack bundles
https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates -->
<% for (var chunk in htmlWebpackPlugin.files.js) { %>
Expand Down
10 changes: 6 additions & 4 deletions core/tests/karma.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ module.exports = function(config) {
'core/templates/dev/head/**/*_directive.html',
'core/templates/dev/head/**/*.directive.html',
'core/templates/dev/head/**/*.template.html',
'local_compiled_js/extensions/**/*.js',
'core/templates/dev/head/**/*Spec.ts',
'core/templates/dev/head/*Spec.ts',
'core/templates/dev/head/**/*.spec.ts',
'core/templates/dev/head/*.spec.ts',
'local_compiled_js/core/templates/dev/head/**/*.js',
'local_compiled_js/extensions/**/*.js',
'extensions/**/*Spec.ts',
{
pattern: 'extensions/**/*.png',
watched: false,
Expand All @@ -61,8 +61,7 @@ module.exports = function(config) {
'local_compiled_js/extensions/**/protractor.js',
'backend_prod_files/extensions/**',
// TODO(vojtechjelinek): add these back after the templateCache
// is repaired, the templateCache is broken due to the fact that
// webpack is not yet implemented for /extensions (#6732)
// is repaired (#6960)
'core/templates/dev/head/components/RatingDisplayDirectiveSpec.js',
('core/templates/dev/head/pages/exploration-editor-page/editor-tab/' +
'services/solution-verification.service.spec.ts'),
Expand All @@ -72,6 +71,8 @@ module.exports = function(config) {
'state-content-editor.directive.spec.ts'),
('core/templates/dev/head/components/state-editor/' +
'state-interaction-editor/state-interaction-editor.directive.spec.ts'),
('extensions/interactions/MusicNotesInput/directives/' +
'MusicNotesInputSpec.ts')
],
proxies: {
// Karma serves files under the /base directory.
Expand All @@ -83,6 +84,7 @@ module.exports = function(config) {
preprocessors: {
'core/templates/dev/head/*.ts': ['webpack'],
'core/templates/dev/head/**/*.ts': ['webpack'],
'extensions/**/*.ts': ['webpack'],
'core/templates/dev/head/!(*Spec).js': ['coverage'],
'core/templates/dev/head/**/!(*Spec).js': ['coverage'],
'core/templates/dev/head/!(*.spec).js': ['coverage'],
Expand Down
2 changes: 2 additions & 0 deletions extensions/classifiers/SVMPredictionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
* https://github.com/arnaudsj/libsvm/blob/master/svm.cpp#L2481
*/

require('domain/classifier/PredictionResultObjectFactory.ts');

oppia.factory('SVMPredictionService', [
'$log', 'PredictionResultObjectFactory',
function($log, PredictionResultObjectFactory) {
Expand Down
6 changes: 0 additions & 6 deletions extensions/dependencies/code_repl_prediction.html

This file was deleted.

5 changes: 0 additions & 5 deletions extensions/dependencies/text_input_prediction.html

This file was deleted.

7 changes: 0 additions & 7 deletions extensions/interactions/CodeRepl/CodeRepl.html
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
<link rel="stylesheet" type="text/css" href="/extensions/interactions/CodeRepl/static/code_repl.css">

<script src="/templates/dev/head/filters/string-utility-filters/truncate-at-first-line.filter.js"></script>
<script src="/extensions/interactions/CodeRepl/directives/OppiaInteractiveCodeReplDirective.js"></script>
<script src="/extensions/interactions/CodeRepl/directives/OppiaResponseCodeReplDirective.js"></script>
<script src="/extensions/interactions/CodeRepl/directives/OppiaShortResponseCodeReplDirective.js"></script>
<script src="/extensions/interactions/CodeRepl/directives/CodeReplRulesService.js"></script>
<script src="/extensions/interactions/CodeRepl/directives/CodeReplValidationService.js"></script>
2 changes: 1 addition & 1 deletion extensions/interactions/CodeRepl/CodeRepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CodeRepl(base.BaseInteraction):
description = 'Allows learners to enter code and get it evaluated.'
display_mode = base.DISPLAY_MODE_SUPPLEMENTAL
is_trainable = True
_dependency_ids = ['skulpt', 'codemirror', 'code_repl_prediction']
_dependency_ids = ['skulpt', 'codemirror']
answer_type = 'CodeEvaluation'
instructions = 'Type code in the editor'
narrow_instructions = 'Go to code editor'
Expand Down
27 changes: 27 additions & 0 deletions extensions/interactions/CodeRepl/CodeRepl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2019 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 Requires for CodeRepl interaction.
*/

require('interactions/CodeRepl/CodeReplPredictionService.ts');

require('interactions/CodeRepl/directives/CodeReplRulesService.ts');
require('interactions/CodeRepl/directives/CodeReplValidationService.ts');
require(
'interactions/CodeRepl/directives/OppiaInteractiveCodeReplDirective.ts');
require('interactions/CodeRepl/directives/OppiaResponseCodeReplDirective.ts');
require(
'interactions/CodeRepl/directives/OppiaShortResponseCodeReplDirective.ts');
5 changes: 5 additions & 0 deletions extensions/interactions/CodeRepl/CodeReplPredictionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
* function on Oppia-ml.
*/

require('classifiers/CountVectorizerService.ts');
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @fileoverview Rules service for the interaction.
*/

require('filters/string-utility-filters/normalize-whitespace.filter.ts');
require('services/CodeNormalizerService.ts');

oppia.factory('CodeReplRulesService', [
'$filter', 'CodeNormalizerService',
function($filter, CodeNormalizerService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* @fileoverview Unit tests for Code REPL rules.
*/

require('interactions/CodeRepl/directives/CodeReplRulesService.ts');

describe('Code REPL rules service', function() {
beforeEach(angular.mock.module('oppia'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* @fileoverview Validator service for the interaction.
*/

require('interactions/baseInteractionValidationService.ts');

oppia.factory('CodeReplValidationService', [
'baseInteractionValidationService', 'WARNING_TYPES',
function(baseInteractionValidationService, WARNING_TYPES) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @fileoverview Unit tests for code repl input validation service.
*/

require('interactions/CodeRepl/directives/CodeReplValidationService.ts');
describe('CodeReplValidationService', function() {
var WARNING_TYPES, validatorService;
var currentState, customizationArguments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
* followed by the name of the arg.
*/

require('domain/utilities/UrlInterpolationService.ts');
require('interactions/CodeRepl/directives/CodeReplRulesService.ts');
require(
'pages/exploration-player-page/services/current-interaction.service.ts');
require('services/HtmlEscaperService.ts');
require('services/contextual/WindowDimensionsService.ts');

oppia.directive('oppiaInteractiveCodeRepl', [
'CodeReplRulesService', 'HtmlEscaperService', 'UrlInterpolationService',
'EVENT_NEW_CARD_AVAILABLE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
* followed by the name of the arg.
*/

require('domain/utilities/UrlInterpolationService.ts');
require('services/HtmlEscaperService.ts');
require('services/stateful/FocusManagerService.ts');

oppia.directive('oppiaResponseCodeRepl', [
'HtmlEscaperService', 'UrlInterpolationService',
function(HtmlEscaperService, UrlInterpolationService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
* followed by the name of the arg.
*/

require('filters/string-utility-filters/truncate-at-first-line.filter.ts');

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

oppia.directive('oppiaShortResponseCodeRepl', [
'HtmlEscaperService', 'UrlInterpolationService',
function(HtmlEscaperService, UrlInterpolationService) {
Expand Down
5 changes: 0 additions & 5 deletions extensions/interactions/Continue/Continue.html
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
<script src="/extensions/interactions/Continue/directives/OppiaInteractiveContinueDirective.js"></script>
<script src="/extensions/interactions/Continue/directives/OppiaResponseContinueDirective.js"></script>
<script src="/extensions/interactions/Continue/directives/OppiaShortResponseContinueDirective.js"></script>
<script src="/extensions/interactions/Continue/directives/ContinueRulesService.js"></script>
<script src="/extensions/interactions/Continue/directives/ContinueValidationService.js"></script>
Loading

0 comments on commit 1f65946

Please sign in to comment.