This repository has been archived by the owner on Jun 12, 2018. It is now read-only.
forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix part of oppia#3826: Change and rename graphDataService in pages/e…
…xploration_editor/EditorServices.js (oppia#4490)
- Loading branch information
1 parent
5ed7fa6
commit df5b03e
Showing
9 changed files
with
81 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
core/templates/dev/head/pages/exploration_editor/GraphDataService.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// 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 Service for computing graph data. | ||
*/ | ||
|
||
oppia.factory('GraphDataService', [ | ||
'explorationStatesService', 'explorationInitStateNameService', | ||
'ComputeGraphService', | ||
function( | ||
explorationStatesService, explorationInitStateNameService, | ||
ComputeGraphService) { | ||
var _graphData = null; | ||
|
||
// Returns an object which can be treated as the input to a visualization | ||
// for a directed graph. The returned object has the following keys: | ||
// - nodes: an object whose keys are node ids (equal to node names) and | ||
// whose values are node names | ||
// - links: a list of objects. Each object represents a directed link | ||
// between two nodes, and has keys 'source' and 'target', the values | ||
// of which are the names of the corresponding nodes. | ||
// - initStateName: the name of the initial state. | ||
// - finalStateName: the name of the final state. | ||
var _recomputeGraphData = function() { | ||
if (!explorationInitStateNameService.savedMemento) { | ||
return; | ||
} | ||
|
||
var states = explorationStatesService.getStates(); | ||
var initStateId = explorationInitStateNameService.savedMemento; | ||
_graphData = ComputeGraphService.compute(initStateId, states); | ||
}; | ||
|
||
return { | ||
recompute: function() { | ||
_recomputeGraphData(); | ||
}, | ||
getGraphData: function() { | ||
return angular.copy(_graphData); | ||
} | ||
}; | ||
} | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters