Skip to content

Commit 0b7b271

Browse files
refactor(TeacherProjectService): Move branch description functions to ProjectAuthoringStepComponent (#1906)
1 parent f32035e commit 0b7b271

File tree

3 files changed

+31
-48
lines changed

3 files changed

+31
-48
lines changed

src/assets/wise5/authoringTool/project-authoring-step/project-authoring-step.component.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,39 @@ export class ProjectAuthoringStepComponent {
4848
}
4949

5050
protected getNumberOfBranchPaths(nodeId: string): number {
51-
return this.projectService.getNumberOfBranchPaths(nodeId);
51+
return this.projectService.getTransitionsByFromNodeId(nodeId).length;
5252
}
5353

54+
/**
55+
* If this step is a branch point, we will return the criteria that is used
56+
* to determine which path the student gets assigned to.
57+
* @param nodeId The node id of the branch point.
58+
* @returns A human readable string containing the criteria of how students
59+
* are assigned branch paths on this branch point.
60+
*/
5461
protected getBranchCriteriaDescription(nodeId: string): string {
55-
return this.projectService.getBranchCriteriaDescription(nodeId);
62+
const transitionLogic = this.projectService.getNode(nodeId).getTransitionLogic();
63+
for (const transition of transitionLogic.transitions) {
64+
if (transition.criteria != null && transition.criteria.length > 0) {
65+
for (const singleCriteria of transition.criteria) {
66+
if (singleCriteria.name === 'choiceChosen') {
67+
return 'multiple choice';
68+
} else if (singleCriteria.name === 'score') {
69+
return 'score';
70+
}
71+
}
72+
}
73+
}
74+
75+
/*
76+
* None of the transitions had a specific criteria so the branching is just
77+
* based on the howToChooseAmongAvailablePaths field.
78+
*/
79+
if (transitionLogic.howToChooseAmongAvailablePaths === 'workgroupId') {
80+
return 'workgroup ID';
81+
} else if (transitionLogic.howToChooseAmongAvailablePaths === 'random') {
82+
return 'random assignment';
83+
}
5684
}
5785

5886
protected getStepBackgroundColor(nodeId: string): string {

src/assets/wise5/services/teacherProjectService.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -310,51 +310,6 @@ export class TeacherProjectService extends ProjectService {
310310
this.project.rubric = html;
311311
}
312312

313-
/**
314-
* Get the number of branch paths. This is assuming the node is a branch point.
315-
* @param nodeId The node id of the branch point node.
316-
* @return The number of branch paths for this branch point.
317-
*/
318-
getNumberOfBranchPaths(nodeId) {
319-
const transitions = this.getTransitionsByFromNodeId(nodeId);
320-
if (transitions != null) {
321-
return transitions.length;
322-
}
323-
return 0;
324-
}
325-
326-
/**
327-
* If this step is a branch point, we will return the criteria that is used
328-
* to determine which path the student gets assigned to.
329-
* @param nodeId The node id of the branch point.
330-
* @returns A human readable string containing the criteria of how students
331-
* are assigned branch paths on this branch point.
332-
*/
333-
getBranchCriteriaDescription(nodeId) {
334-
const transitionLogic = this.getNode(nodeId).getTransitionLogic();
335-
for (const transition of transitionLogic.transitions) {
336-
if (transition.criteria != null && transition.criteria.length > 0) {
337-
for (const singleCriteria of transition.criteria) {
338-
if (singleCriteria.name === 'choiceChosen') {
339-
return 'multiple choice';
340-
} else if (singleCriteria.name === 'score') {
341-
return 'score';
342-
}
343-
}
344-
}
345-
}
346-
347-
/*
348-
* None of the transitions had a specific criteria so the branching is just
349-
* based on the howToChooseAmongAvailablePaths field.
350-
*/
351-
if (transitionLogic.howToChooseAmongAvailablePaths === 'workgroupId') {
352-
return 'workgroup ID';
353-
} else if (transitionLogic.howToChooseAmongAvailablePaths === 'random') {
354-
return 'random assignment';
355-
}
356-
}
357-
358313
setProjectScriptFilename(scriptFilename) {
359314
this.project.script = scriptFilename;
360315
}

src/messages.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12809,7 +12809,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
1280912809
<source>Are you sure you want to delete this step?</source>
1281012810
<context-group purpose="location">
1281112811
<context context-type="sourcefile">src/assets/wise5/authoringTool/project-authoring-step/project-authoring-step.component.ts</context>
12812-
<context context-type="linenumber">112</context>
12812+
<context context-type="linenumber">140</context>
1281312813
</context-group>
1281412814
</trans-unit>
1281512815
<trans-unit id="57cf305f9bfd681c70dc26e914108d06384ade9f" datatype="html">

0 commit comments

Comments
 (0)