Index: lams_central/web/author2.jsp =================================================================== diff -u -r606ff1b9f1cfb78e79cc6f592a695402dcda1391 -r0c6420bdd69cc98d068e5a8124a599548f68c753 --- lams_central/web/author2.jsp (.../author2.jsp) (revision 606ff1b9f1cfb78e79cc6f592a695402dcda1391) +++ lams_central/web/author2.jsp (.../author2.jsp) (revision 0c6420bdd69cc98d068e5a8124a599548f68c753) @@ -406,6 +406,7 @@ + @@ -430,6 +431,22 @@
Match Groups to Branches
+ + + Min sequences: + + + + + + + + Max sequences: + + + + + Index: lams_central/web/includes/javascript/authoring/authoringActivity.js =================================================================== diff -u -r606ff1b9f1cfb78e79cc6f592a695402dcda1391 -r0c6420bdd69cc98d068e5a8124a599548f68c753 --- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision 606ff1b9f1cfb78e79cc6f592a695402dcda1391) +++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision 0c6420bdd69cc98d068e5a8124a599548f68c753) @@ -8,7 +8,7 @@ * Constructor for a Transition */ Transition : function(id, uiid, fromActivity, toActivity, title) { - this.id = +id; + this.id = +id || null; this.uiid = +uiid || ++layout.ld.maxUIID; this.fromActivity = fromActivity; this.toActivity = toActivity; @@ -32,7 +32,7 @@ */ ToolActivity : function(id, uiid, toolContentID, toolID, learningLibraryID, authorURL, x, y, title, supportsOutputs) { - this.id = +id; + this.id = +id || null; this.uiid = +uiid || ++layout.ld.maxUIID; this.toolContentID = toolContentID; this.toolID = +toolID; @@ -56,8 +56,8 @@ */ GroupingActivity : function(id, uiid, x, y, title, groupingID, groupingUIID, groupingType, groupDivide, groupCount, learnerCount, equalSizes, viewLearners, groups) { - this.id = +id; - this.groupingID = +groupingID; + this.id = +id || null; + this.groupingID = +groupingID || null; this.groupingUIID = +groupingUIID || ++layout.ld.maxUIID; this.uiid = +uiid || ++layout.ld.maxUIID; this.title = title || 'Grouping'; @@ -83,7 +83,7 @@ * Constructor for a Gate Activity. */ GateActivity : function(id, uiid, x, y, gateType, startTimeOffset, gateActivityCompletionBased) { - this.id = +id; + this.id = +id || null; this.uiid = +uiid || ++layout.ld.maxUIID; this.gateType = gateType || 'permission'; if (gateType == 'schedule') { @@ -140,20 +140,23 @@ * Represents a set of branches. It is not displayed on canvas. */ BranchingActivity : function(id, uiid, branchingEdgeStart) { - this.id = +id; + this.id = +id || null; this.uiid = +uiid || ++layout.ld.maxUIID; this.start = branchingEdgeStart; this.branches = []; // mapping between groups and branches, if applicable this.groupsToBranches = []; + + this.minOptions = 0; + this.maxOptions = 0; }, /** * Represents a subsequence of activities. It is not displayed on canvas. */ BranchActivity : function(id, uiid, title, branchingActivity, transitionFrom) { - this.id = +id; + this.id = +id || null; this.uiid = +uiid || ++layout.ld.maxUIID; this.title = title || ('Branch ' + (branchingActivity.branches.length + 1)); this.branchingActivity = branchingActivity; @@ -164,7 +167,7 @@ ParallelActivity : function(id, uiid, learningLibraryID, x, y, title, childActivities){ DecorationLib.Container.call(this, id, uiid, title); - this.id = +id; + this.id = +id || null; this.uiid = +uiid || ++layout.ld.maxUIID; this.learningLibraryID = +learningLibraryID; this.transitions = { @@ -184,13 +187,13 @@ /** * Constructor for an Optional Activity. */ - OptionalActivity : function(id, uiid, x, y, title, minActivities, maxActivities) { + OptionalActivity : function(id, uiid, x, y, title, minOptions, maxOptions) { DecorationLib.Container.call(this, id, uiid, title || 'Optional Activity'); - this.id = +id; + this.id = +id || null; this.uiid = +uiid || ++layout.ld.maxUIID; - this.minActivities = minActivities || 0; - this.maxActivities = maxActivities || 0; + this.minOptions = minOptions || 0; + this.maxOptions = maxOptions || 0; this.transitions = { 'from' : [], 'to' : [] @@ -448,16 +451,19 @@ // draw one by one, vertically var activityY = y + 30, allElements = paper.set(), - optionalActivity = this; + optionalActivity = this, + box = this.items.shape.getBBox(); $.each(this.childActivities, function(orderID){ this.parentActivity = optionalActivity; this.orderID = orderID + 1; - this.draw(x + 20, activityY); - activityY = this.items.shape.getBBox().y2 + 10; + var childBox = this.items.shape.getBBox(); + this.draw(x + Math.max(20, (box.width - childBox.width)/2), activityY); + childBox = this.items.shape.getBBox(); + activityY = childBox.y2 + 10; allElements.push(this.items.shape); }); // area containing all drawn child activities - var box = allElements.getBBox(); + box = allElements.getBBox(); this.drawContainer(x, y, box.x2 + 20, box.y2 + 20, layout.colors.optionalActivity); } else { @@ -487,16 +493,19 @@ // draw one by one, horizontally var activityX = x + 20, allElements = paper.set(), - floatingActivity = this; + floatingActivity = this, + box = this.items.shape.getBBox(); $.each(this.childActivities, function(orderID){ this.parentActivity = floatingActivity; this.orderID = orderID; - this.draw(activityX, y + 30); - activityX = this.items.shape.getBBox().x2 + 10; + var childBox = this.items.shape.getBBox(); + this.draw(activityX, y + Math.max(30, (box.height - childBox.height)/2)); + childBox = this.items.shape.getBBox(); + activityX = childBox.x2 + 10; allElements.push(this.items.shape); }); // area containing all drawn child activities - var box = allElements.getBBox(); + box = allElements.getBBox(); this.drawContainer(x, y, box.x2 + 20, box.y2 + 20, layout.colors.optionalActivity); } else { @@ -580,12 +589,11 @@ // remove the activity from parent activity if (activity.parentActivity && activity.parentActivity instanceof DecorationLib.Container) { - activity.parentActivity.childActivities.splice(layout.parentActivity.childActivities.indexOf(activity), 1); + activity.parentActivity.childActivities.splice(activity.parentActivity.childActivities.indexOf(activity), 1); } // remove child activities - if (activity instanceof ActivityLib.OptionalActivity - || activity instanceof ActivityLib.FloatingActivity) { + if (activity instanceof DecorationLib.Container) { $.each(activity.childActivities, function(){ ActivityLib.removeActivity(this); }); @@ -889,7 +897,7 @@ * Drop the dragged activity on the canvas. */ dropActivity : function(activity, x, y) { - if (!(activity instanceof DecorationLib.Container)) { + if (!(activity instanceof ActivityLib.OptionalActivity || activity instanceof ActivityLib.FloatingActivity)) { // check if it was removed from an Optional or Floating Activity if (activity.parentActivity && activity.parentActivity instanceof DecorationLib.Container) { var childActivities = DecorationLib.getChildActivities(activity.parentActivity.items.shape); @@ -901,11 +909,13 @@ } // check if it was added to an Optional or Floating Activity - var container = layout.floatingActivity && layout.floatingActivity.items.shape.isPointInside(x, y) + var container = layout.floatingActivity + && Raphael.isPointInsideBBox(layout.floatingActivity.items.getBBox(),x,y) ? layout.floatingActivity : null; if (!container) { $.each(layout.activities, function(){ - if (this instanceof ActivityLib.OptionalActivity && this.items.shape.isPointInside(x, y)) { + if (this instanceof ActivityLib.OptionalActivity + && Raphael.isPointInsideBBox(this.items.getBBox(),x,y)) { container = this; return false; } Index: lams_central/web/includes/javascript/authoring/authoringDecoration.js =================================================================== diff -u -rdec21a402fc7b42adcf84c15b644228d46a140c7 -r0c6420bdd69cc98d068e5a8124a599548f68c753 --- lams_central/web/includes/javascript/authoring/authoringDecoration.js (.../authoringDecoration.js) (revision dec21a402fc7b42adcf84c15b644228d46a140c7) +++ lams_central/web/includes/javascript/authoring/authoringDecoration.js (.../authoringDecoration.js) (revision 0c6420bdd69cc98d068e5a8124a599548f68c753) @@ -8,7 +8,7 @@ * Abstract class for Region, Optional and Floating Activities. */ Container : function(id, uiid, title) { - this.id = +id; + this.id = +id || null; this.uiid = +uiid || (layout.ld ? ++layout.ld.maxUIID : null); this.title = title; this.childActivities = []; @@ -36,7 +36,7 @@ * Constructor for label annotation. */ Label : function(id, uiid, x, y, title){ - this.id = +id; + this.id = +id || null; this.uiid = +uiid || ++layout.ld.maxUIID; // set a default title, if none provided this.title = title || 'Label'; @@ -210,10 +210,11 @@ var result = []; $.each(layout.activities, function(){ if (shape != this.items.shape) { - var activityBox = this.items.shape.getBBox(); + var activityBox = this.items.shape.getBBox(), + shapeBox = shape.getBBox(); - if (shape.isPointInside(activityBox.x, activityBox.y) - && shape.isPointInside(activityBox.x2, activityBox.y2)) { + if (Raphael.isPointInsideBBox(shapeBox,activityBox.x, activityBox.y) + && Raphael.isPointInsideBBox(shapeBox, activityBox.x2, activityBox.y2)) { result.push(this); } } Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js =================================================================== diff -u -r606ff1b9f1cfb78e79cc6f592a695402dcda1391 -r0c6420bdd69cc98d068e5a8124a599548f68c753 --- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 606ff1b9f1cfb78e79cc6f592a695402dcda1391) +++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 0c6420bdd69cc98d068e5a8124a599548f68c753) @@ -572,10 +572,11 @@ // Branching Activity case 10: var branchingType = 'chosen'; case 11: var branchingType = branchingType || 'group'; - case 12: + case 12: var branchingType = branchingType || 'tool'; + case 13: // draw both edge points straight away and mark the whole canvas for auto reaarange arrangeNeeded = true; - var branchingType = branchingType || 'tool', + var branchingType = branchingType || 'optional', branchingEdge = new ActivityLib.BranchingEdgeActivity(activityData.activityID, activityData.activityUIID, 0, 0, @@ -588,6 +589,11 @@ branchingEdge = new ActivityLib.BranchingEdgeActivity( null, null, 0, 0, null, null, branchingEdge.branchingActivity); layout.activities.push(branchingEdge); + + if (branchingType == 'optional'){ + branchingEdge.branchingActivity.minOptions = activityData.minOptions; + branchingEdge.branchingActivity.maxOptions = activityData.maxOptions; + } break; @@ -1002,6 +1008,7 @@ break; case 'tool' : activityTypeID = 12; break; + case 'optional' : activityTypeID = 13; break; } } else if (activity instanceof ActivityLib.BranchActivity){ activityTypeID = 8; @@ -1041,6 +1048,8 @@ 'gateStartTimeOffset' : activity.gateType == 'schedule' ? activity.offsetDay*24*60 + activity.offsetHour*60 + activity.offsetMinute : null, 'gateActivityCompletionBased' : activity.gateActivityCompletionBased, + 'minOptions' : activity.minOptions, + 'maxOptions' : activity.maxOptions, 'gradebookToolOutputDefinitionName' : null, 'helpText' : null, @@ -1181,7 +1190,7 @@ $.each(layout.activities, function(){ var isBranching = this instanceof ActivityLib.BranchingEdgeActivity, found = false; - if (isBranching && !isStart) { + if (isBranching && !this.isStart) { return true; } @@ -1207,7 +1216,7 @@ var existingTransition = this; $.each(response.ld.transitions, function(){ if (existingTransition.uiid == +this.transitionUIID) { - existingTransition.id = +this.transitionID; + existingTransition.id = +this.transitionID || null; return false; } }); Index: lams_central/web/includes/javascript/authoring/authoringHandler.js =================================================================== diff -u -r8a39e73cf38d5f62bf4be88f765da4a23da49fff -r0c6420bdd69cc98d068e5a8124a599548f68c753 --- lams_central/web/includes/javascript/authoring/authoringHandler.js (.../authoringHandler.js) (revision 8a39e73cf38d5f62bf4be88f765da4a23da49fff) +++ lams_central/web/includes/javascript/authoring/authoringHandler.js (.../authoringHandler.js) (revision 0c6420bdd69cc98d068e5a8124a599548f68c753) @@ -84,6 +84,8 @@ if (items.dragStarter) { // prevent confusion when double clicking clearTimeout(items.dragStarter); + items.dragStarter = null; + return; } if (layout.drawMode || (event.originalEvent ? @@ -109,9 +111,16 @@ sticky = parentObject && (parentObject instanceof ActivityLib.ParallelActivity || parentObject instanceof ActivityLib.OptionalActivity || parentObject instanceof ActivityLib.FloatingActivity); + + // hide child activities while moving the parent around if (sticky) { $.each(parentObject.childActivities, function(){ this.items.hide(); + if (this.childActivities) { + $.each(this.childActivities, function() { + this.items.hide(); + }); + } }); } @@ -167,7 +176,6 @@ drawTransitionStartHandler : function(activity, event, x, y) { if (activity.fromTransition && !(activity instanceof ActivityLib.BranchingEdgeActivity)) { alert('Transition from this activity already exists'); - return; } HandlerLib.resetCanvasMode(); Index: lams_central/web/includes/javascript/authoring/authoringProperty.js =================================================================== diff -u -r606ff1b9f1cfb78e79cc6f592a695402dcda1391 -r0c6420bdd69cc98d068e5a8124a599548f68c753 --- lams_central/web/includes/javascript/authoring/authoringProperty.js (.../authoringProperty.js) (revision 606ff1b9f1cfb78e79cc6f592a695402dcda1391) +++ lams_central/web/includes/javascript/authoring/authoringProperty.js (.../authoringProperty.js) (revision 0c6420bdd69cc98d068e5a8124a599548f68c753) @@ -454,15 +454,25 @@ */ branchingProperties : function() { var activity = this, - content = activity.propertiesContent; + content = activity.propertiesContent, + fillWidgetsFunction = function(){ + $('.propertiesContentFieldTitle', content).val(activity.branchingActivity.title); + $('.propertiesContentFieldBranchingType', content).val(activity.branchingActivity.branchingType); + PropertyLib.fillGroupingDropdown(content, activity.branchingActivity.grouping); + PropertyLib.fillToolInputDropdown(content, activity.branchingActivity.input); + + $('.propertiesContentFieldOptionalSequenceMin', content).spinner('value', + activity.branchingActivity.minOptions) + .spinner('option', 'max', + activity.branchingActivity.branches.length); + $('.propertiesContentFieldOptionalSequenceMax', content).spinner('value', + activity.branchingActivity.maxOptions) + .spinner('option', { + 'min' : activity.branchingActivity.minOptions, + 'max' : activity.branchingActivity.branches.length + }); + } - var fillWidgetsFunction = function(){ - $('.propertiesContentFieldTitle', content).val(activity.branchingActivity.title); - $('.propertiesContentFieldBranchingType', content).val(activity.branchingActivity.branchingType); - PropertyLib.fillGroupingDropdown(content, activity.branchingActivity.grouping); - PropertyLib.fillToolInputDropdown(content, activity.branchingActivity.input); - } - if (!content) { // first run, create the content content = activity.propertiesContent = $('#propertiesContentBranching').clone().attr('id', null) @@ -507,6 +517,13 @@ inputRow.hide(); branchingActivity.input = null; } + + var optionalSequenceRows = $('.spinner', content).closest('tr'); + if (branchingActivity.branchingType == 'optional') { + optionalSequenceRows.show(); + } else { + optionalSequenceRows.hide(); + } if (redrawNeeded) { branchingActivity.start.draw(); @@ -517,11 +534,35 @@ setModified(true); } + $('.propertiesContentFieldOptionalSequenceMin', content).spinner({'min' : 0}) + .on('spinchange', function(){ + var value = +$(this).val(); + activity.branchingActivity.minOptions = Math.min(value, activity.branchingActivity.branches.length); + if (value != activity.branchingActivity.minOptions) { + $(this, content).spinner('value', activity.branchingActivity.minOptions); + } + if (activity.branchingActivity.minOptions > activity.branchingActivity.maxOptions) { + $('.propertiesContentFieldOptionalSequenceMax', content).spinner('value', value); + } + $('.propertiesContentFieldOptionalSequenceMax', content).spinner('option', 'min', value); + }); + + + $('.propertiesContentFieldOptionalSequenceMax', content).spinner({'min' : 0}) + .on('spinchange', function(){ + var value = +$(this).val(); + activity.branchingActivity.maxOptions = Math.min(value, activity.branchingActivity.branches.length); + if (value != activity.branchingActivity.maxOptions) { + $(this, content).spinner('value', activity.branchingActivity.maxOptions); + } + }); + $('input, select', content).change(changeFunction); fillWidgetsFunction(); changeFunction.call(content); } + fillWidgetsFunction(); }, @@ -579,8 +620,8 @@ var activity = this, content = activity.propertiesContent; - activity.minActivities = Math.min(activity.minActivities, activity.childActivities.length); - activity.maxActivities = Math.min(activity.maxActivities, activity.childActivities.length); + activity.minOptions = Math.min(activity.minOptions, activity.childActivities.length); + activity.maxOptions = Math.min(activity.maxOptions, activity.childActivities.length); if (!content) { // first run, create the content @@ -608,11 +649,11 @@ $('.propertiesContentFieldOptionalActivityMin', content).spinner({'min' : 0}) .on('spinchange', function(){ var value = +$(this).val(); - activity.minActivities = Math.min(value, activity.childActivities.length); - if (value != activity.minActivities) { - $(this, content).spinner('value', activity.minActivities); + activity.minOptions = Math.min(value, activity.childActivities.length); + if (value != activity.minOptions) { + $(this, content).spinner('value', activity.minOptions); } - if (activity.minActivities > activity.maxActivities) { + if (activity.minOptions > activity.maxOptions) { $('.propertiesContentFieldOptionalActivityMax', content).spinner('value', value); } $('.propertiesContentFieldOptionalActivityMax', content).spinner('option', 'min', value); @@ -622,18 +663,18 @@ $('.propertiesContentFieldOptionalActivityMax', content).spinner({'min' : 0}) .on('spinchange', function(){ var value = +$(this).val(); - activity.maxActivities = Math.min(value, activity.childActivities.length); - if (value != activity.maxActivities) { - $(this, content).spinner('value', activity.maxActivities); + activity.maxOptions = Math.min(value, activity.childActivities.length); + if (value != activity.maxOptions) { + $(this, content).spinner('value', activity.maxOptions); } }); } - $('.propertiesContentFieldOptionalActivityMin', content).spinner('value', activity.minActivities) + $('.propertiesContentFieldOptionalActivityMin', content).spinner('value', activity.minOptions) .spinner('option', 'max', activity.childActivities.length); - $('.propertiesContentFieldOptionalActivityMax', content).spinner('value', activity.maxActivities) + $('.propertiesContentFieldOptionalActivityMax', content).spinner('value', activity.maxOptions) .spinner('option', { - 'min' : activity.minActivities, + 'min' : activity.minOptions, 'max' : activity.childActivities.length }); }, Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/AuthoringActivityDTO.java =================================================================== diff -u -raead34144651a924f76d7bca8645327e6820d226 -r0c6420bdd69cc98d068e5a8124a599548f68c753 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/AuthoringActivityDTO.java (.../AuthoringActivityDTO.java) (revision aead34144651a924f76d7bca8645327e6820d226) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/AuthoringActivityDTO.java (.../AuthoringActivityDTO.java) (revision 0c6420bdd69cc98d068e5a8124a599548f68c753) @@ -378,10 +378,12 @@ Activity parentActivity = activity.getParentActivity(); Integer toolActivityUIID = parentActivity == null ? null : parentActivity.getToolInputActivityUIID(); - Iterator iter = activity.getBranchEntries().iterator(); - while (iter.hasNext()) { - BranchActivityEntry ba = (BranchActivityEntry) iter.next(); - branchMappings.add(ba.getBranchActivityEntryDTO(toolActivityUIID)); + if (activity.getBranchEntries() != null) { + Iterator iter = activity.getBranchEntries().iterator(); + while (iter.hasNext()) { + BranchActivityEntry ba = (BranchActivityEntry) iter.next(); + branchMappings.add(ba.getBranchActivityEntryDTO(toolActivityUIID)); + } } }