Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v diff -u -r1.145 -r1.146 --- lams_central/conf/language/lams/ApplicationResources.properties 31 Oct 2014 12:52:56 -0000 1.145 +++ lams_central/conf/language/lams/ApplicationResources.properties 31 Oct 2014 13:45:40 -0000 1.146 @@ -512,6 +512,7 @@ authoring.fla.paste.error =Sorry, you can not paste this type of activity authoring.fla.preview.error =Error while initialising lesson for preview authoring.fla.cross.branching.error =Cross-branching transitions are not allowed +authoring.fla.end.match.error =: a branch that ends in this branching does not start in it authoring.fla.ok.button =OK authoring.fla.cancel.button =Cancel authoring.fla.clear.all.button =Clear all Index: lams_central/web/authoring/authoring.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/authoring/authoring.jsp,v diff -u -r1.11 -r1.12 --- lams_central/web/authoring/authoring.jsp 31 Oct 2014 12:52:56 -0000 1.11 +++ lams_central/web/authoring/authoring.jsp 31 Oct 2014 13:45:40 -0000 1.12 @@ -112,7 +112,9 @@ PASTE_ERROR : '', PREVIEW_ERROR : '', CROSS_BRANCHING_ERROR : '', + END_MATCH_ERROR : '', + // PropertyLib OK_BUTTON : '', CANCEL_BUTTON : '', Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/authoring/authoringGeneral.js,v diff -u -r1.57 -r1.58 --- lams_central/web/includes/javascript/authoring/authoringGeneral.js 25 Oct 2014 17:14:24 -0000 1.57 +++ lams_central/web/includes/javascript/authoring/authoringGeneral.js 31 Oct 2014 13:45:40 -0000 1.58 @@ -2030,8 +2030,8 @@ $.each(layout.activities, function(){ // add all branch activities for iteration and saving if (this instanceof ActivityDefs.BranchingEdgeActivity){ + var branchingActivity = this.branchingActivity; if (this.isStart){ - var branchingActivity = this.branchingActivity; branchingActivity.defaultActivityUIID = null; layoutActivityDefs.push(branchingActivity); @@ -2078,12 +2078,55 @@ branchingActivity.defaultActivityUIID = branchingActivity.branches[0].uiid; branchingActivity.branches[0].defaultBranch = true; } + } else { + // validate if all branches start and end in the same branching + $.each(this.transitions.to, function(){ + error = true; + var activity = this.fromActivity; + do { + if (activity instanceof ActivityDefs.BranchingEdgeActivity) { + if (activity.isStart) { + if (branchingActivity == activity.branchingActivity) { + // found out that the branch starts in the proper point + error = false; + break; + } + // the branch is shared between two branchings + // it should have been detected when adding a transition + alert(LABELS.CROSS_BRANCHING_ERROR); + return false; + } + // a nested branching encountered when crawling, just jump over it + activity = activity.branchingActivity.start; + } + + // keep crawling + if (activity.transitions && activity.transitions.to.length > 0) { + activity = activity.transitions.to[0].fromActivity; + } else { + activity = null; + } + } while (activity); + + if (error) { + alert(branchingActivity.title + LABELS.END_MATCH_ERROR); + return false; + } + }); + + if (error) { + return false; + } } } else { layoutActivityDefs.push(this); } }); + if (error) { + return false; + } + if (layout.floatingActivity){ layoutActivityDefs.push(layout.floatingActivity); }