Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js =================================================================== diff -u -r06c23b644b04fb1b9cad5b7e2b4ef1b957afb937 -ra2205b107dfd14d2ee5f5527ef0528b6c16bf014 --- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 06c23b644b04fb1b9cad5b7e2b4ef1b957afb937) +++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision a2205b107dfd14d2ee5f5527ef0528b6c16bf014) @@ -1119,10 +1119,8 @@ // find the longes branch to find the new paper size $.each(activities, function(){ if (this instanceof ActivityDefs.BranchingEdgeActivity && this.isStart) { - // refresh branching metadata - ActivityLib.updateBranchesLength(this.branchingActivity); - // add start and end edges to the result - var longestBranchLength = this.branchingActivity.longestBranchLength + 2; + // add start and end edges to the longest branch length in the branching + var longestBranchLength = ActivityLib.updateBranchesLength(this.branchingActivity) + 2; if (longestBranchLength > subsequenceMaxLength) { subsequenceMaxLength = longestBranchLength; } @@ -1628,6 +1626,7 @@ layout.activities.push(branchingEdge); // for later reference activityData.activity = branchingEdge; + activity = branchingEdge.branchingActivity; branchingEdge = new ActivityDefs.BranchingEdgeActivity( null, null, @@ -1678,7 +1677,8 @@ return true; } - if (!(activity instanceof ActivityDefs.FloatingActivity)) { + if (!(activity instanceof ActivityDefs.FloatingActivity) + && !(activity instanceof ActivityDefs.BranchingActivity)) { layout.activities.push(activity); } @@ -1870,14 +1870,22 @@ $.each(branches, function(){ var branch = this, - branchData = branchToActivityDefs[branch.id]; + branchData = branchToActivityDefs[branch.id], + firstActivity = branchData.firstActivity || branchingActivity.end, + lastActivity = branchData.stopAfterActivity ? null : branchData.lastActivity; + // check for nested branching + if (firstActivity instanceof ActivityDefs.BranchingActivity) { + firstActivity = firstActivity.start; + } + if (lastActivity && lastActivity instanceof ActivityDefs.BranchingActivity){ + lastActivity = lastActivity.end; + } + // add reference to the transition inside branch - ActivityLib.addTransition(branchingActivity.start, - branchData.firstActivity || branchingActivity.end, - true, null, null, branch); - if (branchData.lastActivity && !branchData.stopAfterActivity) { - ActivityLib.addTransition(branchData.lastActivity, branchingActivity.end, true); + ActivityLib.addTransition(branchingActivity.start, firstActivity, true, null, null, branch); + if (lastActivity) { + ActivityLib.addTransition(lastActivity, branchingActivity.end, true); } }); } @@ -1925,7 +1933,7 @@ if (arrangeNeeded) { - GeneralLib.arrangeActivities(); + GeneralLib.arrangeActivities(); } else { GeneralLib.resizePaper(); } @@ -2040,14 +2048,24 @@ var childActivity = this.transitionFrom.toActivity, orderID = 1; while (!(childActivity instanceof ActivityDefs.BranchingEdgeActivity - && !childActivity.isStart)) { + && !childActivity.isStart + && childActivity.branchingActivity == branchingActivity)) { + if (childActivity instanceof ActivityDefs.BranchingEdgeActivity) { + // it's a nested branching + childActivity = childActivity.branchingActivity; + } + childActivity.parentActivity = this; childActivity.orderID = orderID; if (orderID == 1){ this.defaultActivityUIID = childActivity.uiid; } orderID++; + if (childActivity instanceof ActivityDefs.BranchingActivity){ + // it is a nested branching, so move to the end + childActivity = childActivity.end; + } if (childActivity.transitions.from.length == 0) { this.stopAfterActivity = true; break;