diff --git a/src/app/services/teacherProjectService.spec.ts b/src/app/services/teacherProjectService.spec.ts
index 9c710ea1617..8e6e8d962d5 100644
--- a/src/app/services/teacherProjectService.spec.ts
+++ b/src/app/services/teacherProjectService.spec.ts
@@ -52,7 +52,6 @@ describe('TeacherProjectService', () => {
registerNewProject();
isNodeIdUsed();
isNodeIdToInsertTargetNotSpecified();
- testDeleteTransition();
testGetNodeIdAfter();
testCreateNodeAfter();
shouldGetTheBranchLetter();
@@ -168,18 +167,6 @@ function isNodeIdToInsertTargetNotSpecified() {
});
}
-function testDeleteTransition() {
- describe('deleteTransition', () => {
- it('should delete existing transition from the node', () => {
- service.setProject(demoProjectJSON);
- const node1 = service.getNodeById('node1');
- expect(service.nodeHasTransitionToNodeId(node1, 'node2')).toBeTruthy();
- service.deleteTransition(node1, node1.transitionLogic.transitions[0]);
- expect(service.nodeHasTransitionToNodeId(node1, 'node2')).toBeFalsy();
- });
- });
-}
-
function testGetNodeIdAfter() {
describe('getNodeIdAfter', () => {
it('should return the next node in the sequence', () => {
diff --git a/src/assets/wise5/authoringTool/node/advanced/path/node-advanced-path-authoring.component.ts b/src/assets/wise5/authoringTool/node/advanced/path/node-advanced-path-authoring.component.ts
index 96847430699..484434df5c4 100644
--- a/src/assets/wise5/authoringTool/node/advanced/path/node-advanced-path-authoring.component.ts
+++ b/src/assets/wise5/authoringTool/node/advanced/path/node-advanced-path-authoring.component.ts
@@ -57,7 +57,10 @@ export class NodeAdvancedPathAuthoringComponent implements OnInit {
{ value: 'studentDataChanged', text: $localize`Student Data Changed` }
];
- constructor(private projectService: TeacherProjectService, private route: ActivatedRoute) {}
+ constructor(
+ private projectService: TeacherProjectService,
+ private route: ActivatedRoute
+ ) {}
ngOnInit() {
this.route.parent.parent.params.subscribe((params) => {
@@ -198,11 +201,11 @@ export class NodeAdvancedPathAuthoringComponent implements OnInit {
this.saveProject();
}
- deleteTransition(transition): void {
+ deleteTransition(transition: any): void {
const stepTitle = this.projectService.getNodePositionAndTitle(transition.to);
const answer = confirm($localize`Are you sure you want to delete this path to "${stepTitle}"?`);
if (answer) {
- this.projectService.deleteTransition(this.node, transition);
+ this.projectService.getNode(this.node.id).deleteTransition(transition);
this.saveProject();
}
}
diff --git a/src/assets/wise5/common/Node.spec.ts b/src/assets/wise5/common/Node.spec.ts
index 2bfd2c15e5a..29943b3b23b 100644
--- a/src/assets/wise5/common/Node.spec.ts
+++ b/src/assets/wise5/common/Node.spec.ts
@@ -6,6 +6,9 @@ const componentId2 = 'c2';
let node: Node;
const nodeId1 = 'node1';
const nodeId2 = 'node2';
+const node1TransitionLogic = {
+ transitions: [{ to: 'node2' }, { to: 'node3' }]
+};
describe('Node', () => {
beforeEach(() => {
@@ -15,6 +18,7 @@ describe('Node', () => {
{ id: componentId1, prompt: 'a' },
{ id: componentId2, prompt: 'b' }
];
+ node.transitionLogic = node1TransitionLogic;
});
copyComponents();
deleteComponent();
@@ -23,6 +27,7 @@ describe('Node', () => {
moveComponents();
replaceComponent();
getAllRelatedComponents();
+ deleteTransition();
});
function copyComponents() {
@@ -198,3 +203,14 @@ function getAllRelatedComponents_stepHasDiscussionWithConnectedComponent_getsRel
});
});
}
+
+function deleteTransition() {
+ describe('deleteTransition', () => {
+ it('should delete existing transition from the node', () => {
+ expect(node.getTransitionLogic().transitions.length).toEqual(2);
+ node.deleteTransition(node1TransitionLogic.transitions[0]);
+ expect(node.getTransitionLogic().transitions.length).toEqual(1);
+ expect(node.getTransitionLogic().transitions[0].to).toEqual('node3');
+ });
+ });
+}
diff --git a/src/assets/wise5/common/Node.ts b/src/assets/wise5/common/Node.ts
index 6976bd0655d..941adf3d221 100644
--- a/src/assets/wise5/common/Node.ts
+++ b/src/assets/wise5/common/Node.ts
@@ -200,4 +200,19 @@ export class Node {
getConstraints(): any[] {
return this.constraints;
}
+
+ deleteTransition(transition: any): void {
+ const transitions = this.transitionLogic.transitions;
+ const index = transitions.indexOf(transition);
+ if (index > -1) {
+ transitions.splice(index, 1);
+ }
+ if (transitions.length <= 1) {
+ // these settings only apply when there are multiple transitions
+ this.transitionLogic.howToChooseAmongAvailablePaths = null;
+ this.transitionLogic.whenToChoosePath = null;
+ this.transitionLogic.canChangePath = null;
+ this.transitionLogic.maxPathsVisitable = null;
+ }
+ }
}
diff --git a/src/assets/wise5/common/TransitionLogic.ts b/src/assets/wise5/common/TransitionLogic.ts
index e48e614a1c5..d7b8a2004f8 100644
--- a/src/assets/wise5/common/TransitionLogic.ts
+++ b/src/assets/wise5/common/TransitionLogic.ts
@@ -5,4 +5,5 @@ export interface TransitionLogic {
howToChooseAmongAvailablePaths?: string;
transitions: Transition[];
whenToChoosePath?: string;
+ maxPathsVisitable?: number;
}
diff --git a/src/assets/wise5/services/teacherProjectService.ts b/src/assets/wise5/services/teacherProjectService.ts
index 7cd6fe6c573..415b8ce614f 100644
--- a/src/assets/wise5/services/teacherProjectService.ts
+++ b/src/assets/wise5/services/teacherProjectService.ts
@@ -412,21 +412,6 @@ export class TeacherProjectService extends ProjectService {
return numRubrics;
}
- deleteTransition(node, transition) {
- const nodeTransitions = node.transitionLogic.transitions;
- const index = nodeTransitions.indexOf(transition);
- if (index > -1) {
- nodeTransitions.splice(index, 1);
- }
- if (nodeTransitions.length <= 1) {
- // these settings only apply when there are multiple transitions
- node.transitionLogic.howToChooseAmongAvailablePaths = null;
- node.transitionLogic.whenToChoosePath = null;
- node.transitionLogic.canChangePath = null;
- node.transitionLogic.maxPathsVisitable = null;
- }
- }
-
getBackgroundColor(nodeId: string): string {
const branchPathLetter = this.nodeIdToBranchPathLetter[nodeId];
if (branchPathLetter != null) {
diff --git a/src/messages.xlf b/src/messages.xlf
index 880c5422d20..879b7d278e6 100644
--- a/src/messages.xlf
+++ b/src/messages.xlf
@@ -12045,14 +12045,14 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.Are you sure you want to delete this requirement?
src/assets/wise5/authoringTool/node/advanced/path/node-advanced-path-authoring.component.ts
- 135
+ 138
Are you sure you want to delete this path to ""?
src/assets/wise5/authoringTool/node/advanced/path/node-advanced-path-authoring.component.ts
- 203
+ 206