Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/app/services/teacherProjectService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('TeacherProjectService', () => {
registerNewProject();
isNodeIdUsed();
isNodeIdToInsertTargetNotSpecified();
testDeleteTransition();
testGetNodeIdAfter();
testCreateNodeAfter();
shouldGetTheBranchLetter();
Expand Down Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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();
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/assets/wise5/common/Node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -15,6 +18,7 @@ describe('Node', () => {
{ id: componentId1, prompt: 'a' },
{ id: componentId2, prompt: 'b' }
];
node.transitionLogic = node1TransitionLogic;
});
copyComponents();
deleteComponent();
Expand All @@ -23,6 +27,7 @@ describe('Node', () => {
moveComponents();
replaceComponent();
getAllRelatedComponents();
deleteTransition();
});

function copyComponents() {
Expand Down Expand Up @@ -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');
});
});
}
15 changes: 15 additions & 0 deletions src/assets/wise5/common/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
1 change: 1 addition & 0 deletions src/assets/wise5/common/TransitionLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export interface TransitionLogic {
howToChooseAmongAvailablePaths?: string;
transitions: Transition[];
whenToChoosePath?: string;
maxPathsVisitable?: number;
}
15 changes: 0 additions & 15 deletions src/assets/wise5/services/teacherProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12045,14 +12045,14 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
<source>Are you sure you want to delete this requirement?</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/node/advanced/path/node-advanced-path-authoring.component.ts</context>
<context context-type="linenumber">135</context>
<context context-type="linenumber">138</context>
</context-group>
</trans-unit>
<trans-unit id="9161423248419359552" datatype="html">
<source>Are you sure you want to delete this path to &quot;<x id="PH" equiv-text="stepTitle"/>&quot;?</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/node/advanced/path/node-advanced-path-authoring.component.ts</context>
<context context-type="linenumber">203</context>
<context context-type="linenumber">206</context>
</context-group>
</trans-unit>
<trans-unit id="cf11597f80309219c947fba6c22b94290f6371d2" datatype="html">
Expand Down