Skip to content

Commit

Permalink
Upgrade more services to Angular 8 - IV (oppia#7223)
Browse files Browse the repository at this point in the history
* Untested work on PlaythroughIssueObjectFactory.ts

* Revert "Untested work on PlaythroughIssueObjectFactory.ts"

This reverts commit 13424bf.

* TopicRightsObjectFactory

* Lint fix

* Removed unnecessary constructor statement

* ClassifierObjectFactory

* AnswerClassificationResultObjectFactory

* PredictionResultObjectFactory

* WrittenTranslationObjectFactory

* RuleObjectFactory

* AudioTranslationObjectFactory

* ExplorationDraftObjectFactory

* Fix failing FE in TopicRightsObjectFactory

* Add force bootstrap to all pages

* function() -> () =>

* boilerplate

* FeedbackMessageSummaryObjectFactory

* FeedbackThreadObjectFactory

* FeedbackThreadSummaryObjectFactory

FeedbackThreadSummaryObjectFactory

* Merge ser-up-more

* SuggestionObjectFactory

* AudioFileObjectFactory

* AudioLanguageObjectFactory

* ImageFileObjectFactory

* FileDownloadRequestObjectFactory

* AutogeneratedAudioLanguageObjectFactory

* SkillSummaryObjectFactory

* SkillRightsObjectFactory

* MisconceptionObjectFactory

* LearnerDashboardActivityIdsObjectFactory

LearnerDashboardActivityIdsObjectFactory

* UserInfoObjectFactory

* PageTitleService

* Merge proper

* Merge proper

* UtilsService

* Revert "UtilsService"

This reverts commit dc009f9.

* IdGenerationService Fail FE

* Revert "IdGenerationService Fail FE"

This reverts commit 2406979.

* SchemaUndefinedLastElementService

* AutoplayedVideosService

* EditabilityService

* CodeNormalizerService

* SchemaDefaultValueService

* ImprovementsService

* SuggestionModalService

* CurrentInteractionService

* VoiceoverObjectFactory

* AudioTranslationManagerService

* Fix tests

* Fix tests

* PlayerCorrectnessFeedbackEnabledService

* Update mocking method

* Fix lint

* Fix test

* NumberAttemptsService

* AngularNameService

* SolutionValidityService

* Fix lint

Fix lint

* AdminTaskManagerService

* RatingComputationService

* ContinueRulesService

* AnswerStatsObjectFactory

* More typing

* Audit and newline

* Merge

* ParamTypeObjectFactory

* Stronger typing

* Fix FE

* Address comments

* Remove newlines, TODO for imports, modify MockOutcome

* Fix matcher case, modify TODO for imports

* Fix FE

* Fix FE

* Stronger typing in RuleObjectFactory

* Fix lint

* ParamChangeObjectFactory

* Fix e2e

* ChangeObjectFactory

* Fix AJAX errors in Karma

* Fix FE

* Add comment in csrftoken

* SkillDifficultyObjectFactory

* Stronger typing

Stronger typing

* Fix FE?

* CreatorDashboardBackendApiService

* Fix FE?

* Stronger typing

* Fix FE?

* PlaythroughIssueObjectFactory

* Fix lint

* ImprovementActionButtonObjectFactory

* Fixed e2e but FE?

* WinnowingPreprocessingService

* CollectionPlaythroughObjectFactory

* CollectionRightsObjectFactory

* GuestCollectionProgressObjectFactory

* LearnerDashboardBackendApiService

* Fix lint

* LearnerDashboardIdsBackendApiService

* ImageClickInputRulesService

* EndExplorationRulesService

* GraphDetailService

* Fix e2e

* Fix CreatorDashboardBackendApiService

* GraphUtilsService

* MathExpressionInputRulesService

* Fix FE?

* Fix FE?

* Fix FE?

* Fix interactions

* Fix e2e

* Fix Karma for good

* LearnerParamsService

* Lint

* Wrap

* Minor nit

* Minor nit

* Minor nit

* EmailDashboardDataService

* Address review

* Address review

* Address review

* Address review

* Address review

* Address review

* Address review

* Address review

* Added comments and types

* Added comments and types

* Narrowed types

* Lint

* Revert EmailDashboardDataService

* Address review

* Address review

* Address review

* Stronger typing

* NIT

* NIT

* Adress review

* Address review

* InteractionDetailsCacheService

* AnswerGroupsCacheService

* ThreadStatusDisplayService

* VersionTreeService

* Address Review

* Address review

* Some minor nit

* Address review

* Address review

* Fix e2e
  • Loading branch information
YashJipkate authored and seanlip committed Jul 26, 2019
1 parent 88e062c commit 8d68e39
Show file tree
Hide file tree
Showing 141 changed files with 2,148 additions and 1,428 deletions.
4 changes: 3 additions & 1 deletion core/templates/dev/head/AppInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'zone.js';
import { Component, NgModule, StaticProvider } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { downgradeComponent } from '@angular/upgrade/static';
import { HttpClientModule } from '@angular/common/http';

// This component is needed to force-bootstrap Angular at the beginning of the
// app.
Expand All @@ -33,7 +34,8 @@ export class ServiceBootstrapComponent {}

@NgModule({
imports: [
BrowserModule
BrowserModule,
HttpClientModule
],
declarations: [
ServiceBootstrapComponent
Expand Down
6 changes: 5 additions & 1 deletion core/templates/dev/head/AppSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* @fileoverview Unit tests for generic services.
*/

// TODO(YashJipkate): Remove the following block of unnnecessary imports once
// TODO(#7222): Remove the following block of unnnecessary imports once
// App.ts is upgraded to Angular 8.
import { ParamChangeObjectFactory } from
'domain/exploration/ParamChangeObjectFactory.ts';
import { RuleObjectFactory } from 'domain/exploration/RuleObjectFactory.ts';
import { VoiceoverObjectFactory } from
'domain/exploration/VoiceoverObjectFactory.ts';
Expand All @@ -28,6 +30,8 @@ import { WrittenTranslationObjectFactory } from
describe('Constants Generating', function() {
beforeEach(angular.mock.module('oppia'));
beforeEach(angular.mock.module('oppia', function($provide) {
$provide.value(
'ParamChangeObjectFactory', new ParamChangeObjectFactory());
$provide.value('RuleObjectFactory', new RuleObjectFactory());
$provide.value('VoiceoverObjectFactory', new VoiceoverObjectFactory());
$provide.value(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* @fileoverview Unit tests for the question player state service.
*/

// TODO(YashJipkate): Remove the following block of unnnecessary imports once
// TODO(#7222): Remove the following block of unnnecessary imports once
// question-player-state.service.ts is upgraded to Angular 8.
import { ParamChangeObjectFactory } from
'domain/exploration/ParamChangeObjectFactory.ts';
import { RuleObjectFactory } from 'domain/exploration/RuleObjectFactory.ts';
import { VoiceoverObjectFactory } from
'domain/exploration/VoiceoverObjectFactory.ts';
Expand All @@ -38,6 +40,7 @@ describe('Question player state service', function() {

beforeEach(angular.mock.module('oppia'));
beforeEach(angular.mock.module('oppia', function($provide) {
$provide.value('ParamChangeObjectFactory', new ParamChangeObjectFactory());
$provide.value('RuleObjectFactory', new RuleObjectFactory());
$provide.value('VoiceoverObjectFactory', new VoiceoverObjectFactory());
$provide.value(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* editor page.
*/

// TODO(YashJipkate): Remove the following block of unnnecessary imports once
// TODO(#7222): Remove the following block of unnnecessary imports once
// state-property.service.ts is upgraded to Angular 8.
import { ExplorationDraftObjectFactory } from
'domain/exploration/ExplorationDraftObjectFactory.ts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @fileoverview Unit tests for the controller of 'State Interactions'.
*/

// TODO(YashJipkate): Remove the following block of unnnecessary imports once
// TODO(#7222): Remove the following block of unnnecessary imports once
// state-interaction-editor.directive.ts is upgraded to Angular 8.
import { ExplorationFeaturesService } from
'services/ExplorationFeaturesService.ts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,79 +17,86 @@
* collection playthrough domain objects.
*/

var oppia = require('AppInit.ts').module;
import * as cloneDeep from 'lodash/cloneDeep';

oppia.factory('CollectionPlaythroughObjectFactory', [function() {
// TODO(bhenning): Add setters for some of these properties. Setters allow
// the collection editor to setup specifically configured playthrough
// sessions of the collection player through this object (for example, the
// editor would be able to fake which explorations were completed to see how
// that particular configuration would look for a learner).
import { downgradeInjectable } from '@angular/upgrade/static';
import { Injectable } from '@angular/core';

export class CollectionPlaythrough {
_nextExplorationId: string;
_completedExplorationIds: string[];

// Stores information about a current playthrough of a collection for a
// user.
var CollectionPlaythrough = function(
nextExplorationId, completedExplorationIds) {
constructor(nextExplorationId: string, completedExplorationIds: string[]) {
this._nextExplorationId = nextExplorationId;
this._completedExplorationIds = completedExplorationIds;
};
}

// Returns the upcoming exploration ID. Changes to this are not
// reflected in the collection.
CollectionPlaythrough.prototype.getNextExplorationId = function() {
getNextExplorationId(): string {
return this._nextExplorationId;
};
}

CollectionPlaythrough.prototype.getNextRecommendedCollectionNodeCount =
function() {
// As the collection is linear, only a single node would be available,
// after any node.
return 1;
};

// TODO(ankita240796): Remove the bracket notation once Angular2 gets in.
/* eslint-disable dot-notation */
CollectionPlaythrough['hasFinishedCollection'] = function() {
/* eslint-enable dot-notation */
return this._nextExplorationId === null;
};
getNextRecommendedCollectionNodeCount(): number {
// As the collection is linear, only a single node would be available,
// after any node.
return 1;
}

// Returns a list of explorations completed that are related to this
// collection. Changes to this list are not reflected in this collection.
CollectionPlaythrough.prototype.getCompletedExplorationIds = function() {
return angular.copy(this._completedExplorationIds);
};
getCompletedExplorationIds(): string[] {
return cloneDeep(this._completedExplorationIds);
}

CollectionPlaythrough.prototype.getCompletedExplorationNodeCount =
function() {
return this._completedExplorationIds.length;
};
getCompletedExplorationNodeCount(): number {
return this._completedExplorationIds.length;
}

CollectionPlaythrough.prototype.hasStartedCollection = function() {
hasStartedCollection(): boolean {
return this._completedExplorationIds.length !== 0;
};
}

// TODO(bhenning): Add setters for some of these properties. Setters allow
// the collection editor to setup specifically configured playthrough
// sessions of the collection player through this object (for example, the
// editor would be able to fake which explorations were completed to see how
// that particular configuration would look for a learner).
hasFinishedCollection(): boolean {
return this._nextExplorationId === null;
}
}

@Injectable({
providedIn: 'root'
})
export class CollectionPlaythroughObjectFactory {
// Static class methods. Note that "this" is not available in static
// contexts. This function takes a JSON object which represents a backend
// collection playthrough python dict.
// TODO(ankita240796): Remove the bracket notation once Angular2 gets in.
/* eslint-disable dot-notation */
CollectionPlaythrough['createFromBackendObject'] = function(
/* eslint-enable dot-notation */
collectionPlaythroughBackendObject) {
// TODO(#7176): Replace 'any' with the exact type. This has been kept as
// 'any' because 'collectionPlaythroughBackendObject' is a dict with
// underscore_cased keys which give tslint errors against underscore_casing
// in favor of camelCasing.
createFromBackendObject(
collectionPlaythroughBackendObject: any): CollectionPlaythrough {
return new CollectionPlaythrough(
collectionPlaythroughBackendObject.next_exploration_id,
collectionPlaythroughBackendObject.completed_exploration_ids);
};
}

// TODO(ankita240796): Remove the bracket notation once Angular2 gets in.
/* eslint-disable dot-notation */
CollectionPlaythrough['create'] = function(
/* eslint-enable dot-notation */
nextExplorationId, completedExplorationIds) {
create(
nextExplorationId: string,
completedExplorationIds: string[]): CollectionPlaythrough {
return new CollectionPlaythrough(
nextExplorationId, angular.copy(completedExplorationIds));
};
nextExplorationId, cloneDeep(completedExplorationIds));
}
}

var oppia = require('AppInit.ts').module;

return CollectionPlaythrough;
}]);
oppia.factory(
'CollectionPlaythroughObjectFactory',
downgradeInjectable(CollectionPlaythroughObjectFactory));
Loading

0 comments on commit 8d68e39

Please sign in to comment.