Index: lams_central/conf/language/lams/ApplicationResources.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v
diff -u -r1.138.2.52 -r1.138.2.53
--- lams_central/conf/language/lams/ApplicationResources.properties 14 Mar 2017 04:18:51 -0000 1.138.2.52
+++ lams_central/conf/language/lams/ApplicationResources.properties 29 Mar 2017 05:07:56 -0000 1.138.2.53
@@ -579,6 +579,10 @@
authoring.fla.branch.mapping.gate.header =Gate
authoring.fla.branch.mapping.branches.header =Branches
authoring.fla.branch.mapping.branch.header =Branch
+authoring.fla.conditions.mapping.broken =Conditions in the activity were changed. Please review following activities as they referred the modified conditions:
+authoring.fla.activity.unnamed.description =unnamed
+authoring.fla.activity.gate.description =gate
+authoring.fla.activity.branching.description =branching
authoring.fla.gate.state.mapping.dialog.title =Map gate conditions
authoring.fla.branch.mapping.dialog.title =Match conditions to branches
authoring.fla.gate.state.open =open
Index: lams_central/web/authoring/authoring.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/authoring/authoring.jsp,v
diff -u -r1.6.2.49 -r1.6.2.50
--- lams_central/web/authoring/authoring.jsp 10 Mar 2017 08:27:51 -0000 1.6.2.49
+++ lams_central/web/authoring/authoring.jsp 29 Mar 2017 05:07:56 -0000 1.6.2.50
@@ -237,6 +237,12 @@
LESS_CONDITION_DESCRIPTION : '',
GREATER_CONDITION_DESCRIPTION : '',
+
+ ACTIVITY_UNNAMED_DESCRIPTION : decoderDiv.html('').text(),
+
+ ACTIVITY_GATE_DESCRIPTION : decoderDiv.html('').text(),
+
+ ACTIVITY_BRANCHING_DESCRIPTION : decoderDiv.html('').text(),
DEFAULT_RANGE_CONDITION_TITLE_PREFIX : '',
@@ -256,7 +262,9 @@
RANGE_CONDITION_ADD_END_ERROR : decoderDiv.html('').text(),
- GROUP_TITLE_VALIDATION_ERORR : decoderDiv.html('').text()
+ GROUP_TITLE_VALIDATION_ERORR : decoderDiv.html('').text(),
+
+ CONDITIONS_MAPPING_BROKEN_ERROR : decoderDiv.html('').text()
},
isReadOnlyMode = false,
Index: lams_central/web/includes/javascript/authoring/authoringActivity.js
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/authoring/authoringActivity.js,v
diff -u -r1.38.2.35 -r1.38.2.36
--- lams_central/web/includes/javascript/authoring/authoringActivity.js 27 Feb 2017 09:15:32 -0000 1.38.2.35
+++ lams_central/web/includes/javascript/authoring/authoringActivity.js 29 Mar 2017 05:07:56 -0000 1.38.2.36
@@ -1359,6 +1359,10 @@
return false;
}
},
+ 'close' : function(){
+ $(this).remove();
+ PropertyLib.validateConditionMappings(activity);
+ },
'open' : function() {
var dialog = $(this);
// load contents after opening the dialog
Index: lams_central/web/includes/javascript/authoring/authoringProperty.js
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/authoring/authoringProperty.js,v
diff -u -r1.25.2.17 -r1.25.2.18
--- lams_central/web/includes/javascript/authoring/authoringProperty.js 10 Mar 2017 08:27:51 -0000 1.25.2.17
+++ lams_central/web/includes/javascript/authoring/authoringProperty.js 29 Mar 2017 05:07:56 -0000 1.25.2.18
@@ -1686,7 +1686,7 @@
// fill the branches list
$.each(branches, function(){
var branchTitle = (isGate ? (this == 'open' ? LABELS.GATE_STATE_OPEN : LABELS.GATE_STATE_CLOSED) : this.title)
- + (this == defaultBranch ? LABELS.BRANCH_MAPPING_DEFAULT_BRANCH_SUFFIX : ''),
+ + (this == defaultBranch ? ' ' + LABELS.BRANCH_MAPPING_DEFAULT_BRANCH_SUFFIX : ''),
branchElem = $('
').click(PropertyLib.selectBranchMappingListItem).appendTo(branchesCell).text(branchTitle);
if (isGate) {
branchElem.attr('gateState', this);
@@ -1870,5 +1870,63 @@
selectedItem.removeData('boundItem');
selectedBranch.remove();
$('.branchMappingFreeItemCell', dialog).append(selectedItem);
+ },
+
+ /**
+ * Checks whether conditions changed in a tool activity.
+ * If so, it checks if it did not break existing mappings.
+ */
+ validateConditionMappings : function(activity) {
+ var conditionIDs = null,
+ brokenActivities = [];
+
+ // look for broken mappings
+ $.each(layout.activities, function() {
+ var consumer = this.branchingActivity || this;
+ // check if the modified activity is an input for a gate or branching activity
+ if (activity == consumer.input && consumer.conditionsToBranches.length > 0) {
+ if (conditionIDs == null) {
+ // refresh conditions in the modified activity
+ conditionIDs = [];
+ ActivityLib.getOutputDefinitions(activity);
+ $.each(activity.outputDefinitions, function(){
+ if (this.conditions) {
+ $.each(this.conditions, function(){
+ conditionIDs.push(this.conditionId);
+ });
+ }
+ });
+ }
+
+ var isBroken = false,
+ newMapping = [];
+ $.each(consumer.conditionsToBranches, function(){
+ // a mapped condition is now missing
+ // remove it and inform the user
+ if (conditionIDs.indexOf(this.condition.conditionID) == -1) {
+ isBroken = true;
+ } else {
+ newMapping.push(this);
+ }
+ });
+ if (isBroken) {
+ consumer.conditionsToBranches = newMapping;
+ brokenActivities.push(consumer);
+ }
+ }
+ });
+
+ // build a message
+ if (brokenActivities.length > 0) {
+ var message = LABELS.CONDITIONS_MAPPING_BROKEN_ERROR + ' ';
+ $.each(brokenActivities, function(){
+ message += (this.title ? '"' + this.title + '"' : LABELS.ACTIVITY_UNNAMED_DESCRIPTION) + ' ' +
+ (this instanceof ActivityDefs.GateActivity ?
+ LABELS.ACTIVITY_GATE_DESCRIPTION : LABELS.ACTIVITY_BRANCHING_DESCRIPTION)
+ + ', ';
+ });
+ message = message.substring(0, message.length - 2);
+ alert(message);
+ }
}
};
\ No newline at end of file