Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r19a9225d5d9ba59e2600b57c3c8e968ffc9ee351 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java =================================================================== diff -u -re6c40cd7e49ffdad935a0d6f896bb58c6393ec3a -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision e6c40cd7e49ffdad935a0d6f896bb58c6393ec3a) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -401,7 +401,7 @@ // now process the "parts" of the learning design parseGroupings((Vector)table.get(WDDXTAGS.GROUPINGS)); parseActivities((Vector)table.get(WDDXTAGS.ACTIVITIES)); - parseActivitiesToMatchUpParentActivityByParentUIID((Vector)table.get(WDDXTAGS.ACTIVITIES)); + parseActivitiesToMatchUpParentandInputActivities((Vector)table.get(WDDXTAGS.ACTIVITIES)); parseTransitions((Vector)table.get(WDDXTAGS.TRANSITIONS)); parseBranchMappings((Vector)table.get(WDDXTAGS.BRANCH_MAPPINGS)); progressFirstActivityWithinSequence(); @@ -428,7 +428,7 @@ +") referred to in First Child to Sequence map."; throw new WDDXProcessorConversionException(msg); } else { - sequence.setFirstActivity(childActivity); + sequence.setDefaultActivity(childActivity); } } @@ -683,16 +683,15 @@ /** * Because the activities list was processed before by the method parseActivities, it is assumed that - * all activities have already been saved into the database. Because the parent activity is already - * created and saved, this method will go through the activity list and will match up the parentActivityID - * based on the parentUIID. + * all activities have already been saved into the database. So now we can go through and find the any parent + * activity or input activities for an activity. * * @param activitiesList * @param learningDesign * @throws WDDXProcessorConversionException * @throws ObjectExtractorException */ - private void parseActivitiesToMatchUpParentActivityByParentUIID(List activitiesList) throws WDDXProcessorConversionException, ObjectExtractorException + private void parseActivitiesToMatchUpParentandInputActivities(List activitiesList) throws WDDXProcessorConversionException, ObjectExtractorException { if (activitiesList != null) { @@ -703,7 +702,8 @@ Integer activityUUID = WDDXProcessor.convertToInteger(activityDetails,WDDXTAGS.ACTIVITY_UIID); Activity existingActivity = newActivityMap.get(activityUUID); - //match up id to parent based on UIID + + // match up activity to parent based on UIID if (keyExists(activityDetails, WDDXTAGS.PARENT_UIID)) { Integer parentUIID = WDDXProcessor.convertToInteger(activityDetails, WDDXTAGS.PARENT_UIID); @@ -725,6 +725,22 @@ existingActivity.setOrderId(null); // top level activities don't have order ids. } } + + // match up activity to input activities based on UIID + existingActivity.getInputActivities().clear(); + if ( keyExists(activityDetails, WDDXTAGS.INPUT_ACTIVITIES) ) { + List inputActivities = (List) activityDetails.get(WDDXTAGS.INPUT_ACTIVITIES); + Iterator iter = inputActivities.iterator(); + while ( iter.hasNext() ) { + Integer inputActivityUIID = (Integer) iter.next(); + Activity inputActivity = newActivityMap.get(inputActivityUIID); + if ( inputActivity == null ) { + throw new ObjectExtractorException("Input activity "+inputActivityUIID+" missing for activity "+existingActivity.getTitle()+": "+existingActivity.getActivityUIID()); + } + existingActivity.getInputActivities().add(inputActivity); + } + } + activityDAO.update(existingActivity); } Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== diff -u -rd66ffc2bf657d1fe25183aa727b110ed42048d59 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision d66ffc2bf657d1fe25183aa727b110ed42048d59) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -34,7 +34,6 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.TreeSet; import java.util.Vector; import java.util.Date; @@ -46,8 +45,8 @@ import org.lamsfoundation.lams.authoring.IObjectExtractor; import org.lamsfoundation.lams.dao.hibernate.BaseDAO; import org.lamsfoundation.lams.learningdesign.Activity; -import org.lamsfoundation.lams.learningdesign.ActivityOrderComparator; import org.lamsfoundation.lams.learningdesign.BranchingActivity; +import org.lamsfoundation.lams.learningdesign.ComplexActivity; import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.GroupBranchActivityEntry; @@ -785,17 +784,19 @@ } } - // fix up any old "first activity" in the sequence activities + // fix up any old "default activity" in the complex activities and the input activities for ( Activity activity : activities) { - if ( activity.isSequenceActivity() ) { - SequenceActivity newSeq = (SequenceActivity) activity; - Activity oldFirstActivity = newSeq.getFirstActivity(); - if ( oldFirstActivity != null ) { - Activity newFirstActivity = newActivities.get(oldFirstActivity.getActivityUIID()); - newSeq.setFirstActivity(newFirstActivity); + if ( activity.isComplexActivity() ) { + ComplexActivity newComplex = (ComplexActivity) activity; + Activity oldDefaultActivity = newComplex.getDefaultActivity(); + if ( oldDefaultActivity != null ) { + Activity newDefaultActivity = newActivities.get(oldDefaultActivity.getActivityUIID()); + newComplex.setDefaultActivity(newDefaultActivity); } } } + + // fix up the input activities // Now go back and fix any branch mapping entries - they will still be pointing to old activities. // Need to check if the sets are not null as these are new objects and Hibernate may not have Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml =================================================================== diff -u -r725717c8db7287e639f58135c179133d18e85adb -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml (.../Activity.hbm.xml) (revision 725717c8db7287e639f58135c179133d18e85adb) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml (.../Activity.hbm.xml) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -130,6 +130,11 @@ + + + + + @hibernate.class @@ -240,6 +245,14 @@ + + + @hibernate.many-to-one not-null="false" + @hibernate.column name="default_activity_id" + + + + @hibernate.class @@ -261,14 +274,6 @@ @hibernate.class - - - @hibernate.many-to-one not-null="false" - @hibernate.column name="first_activity_id" - - - - @hibernate.set lazy="true" inverse="true" cascade="none" @hibernate.collection-key column="sequence_activity_id" Index: lams_common/db/model/lams_11.clay =================================================================== diff -u -r725717c8db7287e639f58135c179133d18e85adb -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision 725717c8db7287e639f58135c179133d18e85adb) +++ lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -634,7 +634,7 @@ - + @@ -5497,6 +5497,65 @@ + +A LAMS learning activity may have one or more input activities. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Index: lams_common/db/sql/create_lams_11_tables.sql =================================================================== diff -u -r725717c8db7287e639f58135c179133d18e85adb -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 725717c8db7287e639f58135c179133d18e85adb) +++ lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -517,7 +517,7 @@ , system_tool_id BIGINT(20) , read_only TINYINT DEFAULT 0 , initialised TINYINT DEFAULT 0 - , first_activity_id BIGINT(20) + , default_activity_id BIGINT(20) , start_xcoord INT(11) , start_ycoord INT(11) , end_xcoord INT(11) @@ -562,6 +562,18 @@ REFERENCES lams_system_tool (system_tool_id) )TYPE=InnoDB; +CREATE TABLE lams_input_activity ( + activity_id BIGINT(20) NOT NULL + , input_activity_id BIGINT(20) NOT NULL + , UNIQUE UQ_lams_input_activity_1 (activity_id, input_activity_id) + , INDEX (activity_id) + , CONSTRAINT FK_lams_input_activity_1 FOREIGN KEY (activity_id) + REFERENCES lams_learning_activity (activity_id) ON DELETE NO ACTION ON UPDATE NO ACTION + , INDEX (activity_id) + , CONSTRAINT FK_lams_input_activity_2 FOREIGN KEY (activity_id) + REFERENCES lams_learning_activity (activity_id) +)TYPE=InnoDB; + CREATE TABLE lams_group_branch_activity ( entry_id BIGINT(20) NOT NULL AUTO_INCREMENT , entry_ui_id INT(11) Index: lams_common/db/sql/updatescripts/alter_21_branching.sql =================================================================== diff -u -r725717c8db7287e639f58135c179133d18e85adb -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/db/sql/updatescripts/alter_21_branching.sql (.../alter_21_branching.sql) (revision 725717c8db7287e639f58135c179133d18e85adb) +++ lams_common/db/sql/updatescripts/alter_21_branching.sql (.../alter_21_branching.sql) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -4,6 +4,19 @@ ALTER TABLE lams_group ADD COLUMN group_ui_id INT(11); +CREATE TABLE lams_input_activity ( + activity_id BIGINT(20) NOT NULL + , input_activity_id BIGINT(20) NOT NULL + , UNIQUE UQ_lams_input_activity_1 (activity_id, input_activity_id) + , INDEX (activity_id) + , CONSTRAINT FK_lams_input_activity_1 FOREIGN KEY (activity_id) + REFERENCES lams_learning_activity (activity_id) ON DELETE NO ACTION ON UPDATE NO ACTION + , INDEX (activity_id) + , CONSTRAINT FK_lams_input_activity_2 FOREIGN KEY (activity_id) + REFERENCES lams_learning_activity (activity_id) +)TYPE=InnoDB; + + CREATE TABLE lams_group_branch_activity ( entry_id BIGINT(20) NOT NULL AUTO_INCREMENT , entry_ui_id INT(11) @@ -24,7 +37,7 @@ )TYPE=InnoDB; ALTER TABLE lams_learning_activity -ADD COLUMN first_activity_id BIGINT(20) +ADD COLUMN default_activity_id BIGINT(20) ,ADD COLUMN start_xcoord INT(11) ,ADD COLUMN start_ycoord INT(11) ,ADD COLUMN end_xcoord INT(11) @@ -68,3 +81,6 @@ ALTER TABLE lams_tool ADD COLUMN admin_url TEXT; ALTER TABLE lams_system_tool ADD COLUMN admin_url TEXT; + + +- \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java (.../Activity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java (.../Activity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -25,6 +25,7 @@ import java.io.Serializable; import java.util.Date; +import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.SortedSet; @@ -140,7 +141,7 @@ private Integer orderId; /** Indicates whether the content of this activity - * would be defined later in the monitoring enviornment or not.*/ + * would be defined later in the monitoring environment or not.*/ private Boolean defineLater; /** Indicates whether this activity is available offline*/ @@ -215,6 +216,13 @@ * final activity of a design does not necessarily have this set - the progress engine will just * stop when it runs out of transitions to follow. */ private Boolean stopAfterActivity; + + /** + * The activities that supplied inputs to this activity. + */ + private Set inputActivities; + + //--------------------------------------------------------------------- // Object constructors //--------------------------------------------------------------------- @@ -244,7 +252,8 @@ Transition transitionTo, Transition transitionFrom, String languageFile, - Boolean stopAfterActivity) { + Boolean stopAfterActivity, + Set inputActivities) { this.activityId = activityId; this.activityUIID = id; this.description = description; @@ -267,6 +276,7 @@ this.readOnly = false; this.initialised = false; this.stopAfterActivity = stopAfterActivity; + this.inputActivities = inputActivities; } /** default constructor */ public Activity() { @@ -600,6 +610,23 @@ this.stopAfterActivity = stopAfterActivity; } + /** + * @return Returns the inputActivities. + */ + public Set getInputActivities() + { + if(this.inputActivities == null) + this.setInputActivities(new HashSet()); + return inputActivities; + } + /** + * @param InputActivities The InputActivities to set. + */ + public void setInputActivities(Set inputActivities) + { + this.inputActivities = inputActivities; + } + public String toString() { return new ToStringBuilder(this) .append("activityId", activityId) @@ -1007,6 +1034,7 @@ newActivity.setOrderId(this.getOrderId()); newActivity.setReadOnly(this.getReadOnly()); newActivity.setStopAfterActivity(this.isStopAfterActivity()); + } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/BranchingActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/BranchingActivity.java (.../BranchingActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/BranchingActivity.java (.../BranchingActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -73,7 +73,9 @@ Integer endXcoord, Integer endYcoord, Boolean stopAfterActivity, + Set inputActivities, Set activities, + Activity defaultActivity, SystemTool systemTool) { super(activityId, id, @@ -95,7 +97,9 @@ transitionFrom, languageFile, stopAfterActivity, - activities); + inputActivities, + activities, + defaultActivity); super.activityStrategy = new BranchingActivityStrategy(this); this.systemTool = systemTool; this.startXcoord = startXcoord; @@ -205,6 +209,8 @@ newBranchingActivity.startYcoord = this.startYcoord; newBranchingActivity.endXcoord = this.endXcoord; newBranchingActivity.endYcoord = this.endYcoord; + newBranchingActivity.defaultActivity = this.defaultActivity; } + } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ChosenBranchingActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ChosenBranchingActivity.java (.../ChosenBranchingActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ChosenBranchingActivity.java (.../ChosenBranchingActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -64,7 +64,9 @@ Integer endXcoord, Integer endYcoord, Boolean stopAfterActivity, - Set activities, + Set inputActivities, + Set activities, + Activity defaultActivity, SystemTool systemTool) { super(activityId, id, @@ -90,7 +92,9 @@ endXcoord, endYcoord, stopAfterActivity, + inputActivities, activities, + defaultActivity, systemTool); } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ComplexActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ComplexActivity.java (.../ComplexActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ComplexActivity.java (.../ComplexActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -46,7 +46,11 @@ protected ComplexActivityStrategy activityStrategy; /** persistent field */ private Set activities; + + /** nullable persistent field */ + protected Activity defaultActivity; + /** full constructor */ public ComplexActivity( Long activityId, @@ -69,11 +73,13 @@ Transition transitionFrom, String languageFile, Boolean stopAfterActivity, - Set activities) { + Set inputActivities, + Set activities, + Activity defaultActivity) { super(activityId, id, description, title, xcoord, ycoord, orderId, defineLater, createDateTime, learningLibrary, parentActivity, libraryActivity,parentUIID,learningDesign, grouping, - activityTypeId, transitionTo,transitionFrom, languageFile, stopAfterActivity); + activityTypeId, transitionTo,transitionFrom, languageFile, stopAfterActivity, inputActivities); this.activities = activities; } @@ -118,6 +124,28 @@ return this.activities; } + /** Get the first activity in the sequence,or the default branch for a branching activity. + *

+ * A Sequence activity is like a little learning design, and while is it being + * drawn all the the contained activities may not have transitions between them. So Flash needs to know what the first + * activity is! + *

+ * A tool based branching activity has to have a default branch in case the conditions don't + * match to any other branch. + * + * @hibernate.many-to-one not-null="false" + * @hibernate.column name="default_activity_id" + */ + public Activity getDefaultActivity() { + return defaultActivity; + } + + + public void setDefaultActivity(Activity defaultActivity) { + this.defaultActivity = defaultActivity; + } + + public void setActivities(Set activities) { this.activities=activities; } @@ -159,8 +187,8 @@ * within the parent activity.

* * Note: The logic of what is the next activity here is progress - * enigne specific now. Please see the ActivityStrategy - * for details explaination of what is next. + * engine specific now. Please see the ActivityStrategy + * for details explanation of what is next. * * @return the next activity within a parent activity */ Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/GateActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/GateActivity.java (.../GateActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/GateActivity.java (.../GateActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -81,6 +81,7 @@ Transition transitionFrom, String languageFile, Boolean stopAfterActivity, + Set inputActivities, Integer gateActivityLevelId, Set waitingLearners, SystemTool sysTool) @@ -104,7 +105,8 @@ transitionTo, transitionFrom, languageFile, - stopAfterActivity); + stopAfterActivity, + inputActivities); this.gateActivityLevelId = gateActivityLevelId; this.waitingLearners = waitingLearners; this.systemTool = sysTool; Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/GroupBranchingActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/GroupBranchingActivity.java (.../GroupBranchingActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/GroupBranchingActivity.java (.../GroupBranchingActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -64,7 +64,9 @@ Integer endXcoord, Integer endYcoord, Boolean stopAfterActivity, + Set inputActivities, Set activities, + Activity defaultActivity, SystemTool systemTool) { super(activityId, id, @@ -90,7 +92,9 @@ endXcoord, endYcoord, stopAfterActivity, + inputActivities, activities, + defaultActivity, systemTool); } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/GroupingActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/GroupingActivity.java (.../GroupingActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/GroupingActivity.java (.../GroupingActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -24,6 +24,7 @@ package org.lamsfoundation.lams.learningdesign; import java.io.Serializable; +import java.util.Set; import org.apache.commons.lang.builder.ToStringBuilder; import org.lamsfoundation.lams.learningdesign.strategy.GroupingActivityStrategy; @@ -71,6 +72,7 @@ Integer create_grouping_ui_id, String languageFile, Boolean stopAfterActivity, + Set inputActivities, SystemTool sysTool) { super(activityId, @@ -92,7 +94,8 @@ transitionTo, transitionFrom, languageFile, - stopAfterActivity); + stopAfterActivity, + inputActivities); this.createGrouping = createGrouping; this.createGroupingUIID = create_grouping_ui_id; this.systemTool = sysTool; Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/OptionsActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/OptionsActivity.java (.../OptionsActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/OptionsActivity.java (.../OptionsActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -67,7 +67,9 @@ Transition transitionFrom, String languageFile, Boolean stopAfterActivity, - Set activities, + Set inputActivities, + Set activities, + Activity defaultActivity, Integer maxNumberOfOptions, Integer minNumberOfOptions, String options_instructions) { @@ -91,7 +93,9 @@ transitionFrom, languageFile, stopAfterActivity, - activities); + inputActivities, + activities, + defaultActivity); this.maxNumberOfOptions = maxNumberOfOptions; this.minNumberOfOptions = minNumberOfOptions; this.optionsInstructions = options_instructions; Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ParallelActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ParallelActivity.java (.../ParallelActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ParallelActivity.java (.../ParallelActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -57,7 +57,9 @@ Transition transitionFrom, String languageFile, Boolean stopAfterActivity, - Set activities) { + Set inputActivities, + Set activities, + Activity defaultActivity) { super(activityId, id, description, @@ -78,7 +80,9 @@ transitionFrom, languageFile, stopAfterActivity, - activities); + inputActivities, + activities, + defaultActivity); super.activityStrategy = new ParallelActivityStrategy(this); } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/PermissionGateActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/PermissionGateActivity.java (.../PermissionGateActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/PermissionGateActivity.java (.../PermissionGateActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -60,6 +60,7 @@ Transition transitionFrom, String languageFile, Boolean stopAfterActivity, + Set inputActivities, Integer gateActivityLevelId, Set waitingLearners, SystemTool sysTool) @@ -84,6 +85,7 @@ transitionFrom, languageFile, stopAfterActivity, + inputActivities, gateActivityLevelId, waitingLearners, sysTool); Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ScheduleGateActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ScheduleGateActivity.java (.../ScheduleGateActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ScheduleGateActivity.java (.../ScheduleGateActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -106,6 +106,7 @@ Transition transitionFrom, String languageFile, Boolean stopAfterActivity, + Set inputActivities, Integer gateActivityLevelId, Long gateStartTimeOffset, Long gateEndTimeOffset, @@ -131,6 +132,7 @@ transitionFrom, languageFile, stopAfterActivity, + inputActivities, gateActivityLevelId, waitingLearners, sysTool); Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java (.../SequenceActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java (.../SequenceActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -42,9 +42,6 @@ private static Logger log = Logger.getLogger(SequenceActivity.class); - /** nullable persistent field */ - private Activity firstActivity; - private Set branchEntries; /** full constructor */ @@ -67,8 +64,10 @@ Transition transitionTo, Transition transitionFrom, String languageFile, - SortedSet activities, Boolean stopAfterActivity, + Set inputActivities, + Set activities, + Activity defaultActivity, Set branchEntries) { super(activityId, id, @@ -90,7 +89,9 @@ transitionFrom, languageFile, stopAfterActivity, - activities); + inputActivities, + activities, + defaultActivity); super.activityStrategy = new SequenceActivityStrategy(this); this.branchEntries = branchEntries; @@ -135,7 +136,7 @@ public Activity createCopy(){ SequenceActivity newSequenceActivity = new SequenceActivity(); copyToNewActivity(newSequenceActivity); - newSequenceActivity.firstActivity = this.firstActivity; + newSequenceActivity.defaultActivity = this.defaultActivity; return newSequenceActivity; } @@ -154,21 +155,6 @@ return false; } - /** Get the first activity in the sequence. A Sequence activity is like a little learning design, and while is it being - * drawn all the the contained activities may not have transitions between them. So Flash needs to know what the first - * activity is! - * @hibernate.many-to-one not-null="false" - * @hibernate.column name="first_activity_id" - */ - public Activity getFirstActivity() { - return firstActivity; - } - - - public void setFirstActivity(Activity firstActivity) { - this.firstActivity = firstActivity; - } - /** * Get the set of the branch to group mappings used for this branching activity. The set contains GroupBranchActivityEntry entries * Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SimpleActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SimpleActivity.java (.../SimpleActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SimpleActivity.java (.../SimpleActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -25,6 +25,7 @@ import java.io.Serializable; import java.util.Date; +import java.util.Set; import org.apache.commons.lang.builder.ToStringBuilder; import org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy; @@ -57,7 +58,8 @@ Integer activityTypeId, Transition transitionTo, Transition transitionFrom, String languageFile, - Boolean stopAfterActivity){ + Boolean stopAfterActivity, + Set inputActivities){ super(activityId, id, description, @@ -77,7 +79,8 @@ transitionTo, transitionFrom, languageFile, - stopAfterActivity); + stopAfterActivity, + inputActivities); } /** default constructor */ Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SynchGateActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SynchGateActivity.java (.../SynchGateActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SynchGateActivity.java (.../SynchGateActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -59,6 +59,7 @@ Transition transitionFrom, String languageFile, Boolean stopAfterActivity, + Set inputActivities, Integer gateActivityLevelId, Set waitingLearners, SystemTool sysTool) { @@ -82,6 +83,7 @@ transitionFrom, languageFile, stopAfterActivity, + inputActivities, gateActivityLevelId, waitingLearners, sysTool); Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SystemGateActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SystemGateActivity.java (.../SystemGateActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SystemGateActivity.java (.../SystemGateActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -59,6 +59,7 @@ Transition transitionFrom, String languageFile, Boolean stopAfterActivity, + Set inputActivities, Integer gateActivityLevelId, Set waitingLearners, SystemTool sysTool) { @@ -82,6 +83,7 @@ transitionFrom, languageFile, stopAfterActivity, + inputActivities, gateActivityLevelId, waitingLearners, sysTool); Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolActivity.java (.../ToolActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolActivity.java (.../ToolActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -81,6 +81,7 @@ Transition transitionFrom, String languageFile, Boolean stopAfterActivity, + Set inputActivities, Tool tool, Long toolContentId) { @@ -103,7 +104,8 @@ transitionTo, transitionFrom, languageFile, - stopAfterActivity); + stopAfterActivity, + inputActivities); this.tool = tool; this.toolContentId = toolContentId; super.simpleActivityStrategy = new ToolActivityStrategy(this); Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolBranchingActivity.java =================================================================== diff -u -r2c26811b29dbe08f4d569c720f86b25925260fc0 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolBranchingActivity.java (.../ToolBranchingActivity.java) (revision 2c26811b29dbe08f4d569c720f86b25925260fc0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ToolBranchingActivity.java (.../ToolBranchingActivity.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -64,7 +64,9 @@ Integer endXcoord, Integer endYcoord, Boolean stopAfterActivity, - Set activities, + Set inputActivities, + Set activities, + Activity defaultActivity, SystemTool systemTool) { super(activityId, id, @@ -90,7 +92,9 @@ endXcoord, endYcoord, stopAfterActivity, + inputActivities, activities, + defaultActivity, systemTool); } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/AuthoringActivityDTO.java =================================================================== diff -u -r725717c8db7287e639f58135c179133d18e85adb -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/AuthoringActivityDTO.java (.../AuthoringActivityDTO.java) (revision 725717c8db7287e639f58135c179133d18e85adb) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/AuthoringActivityDTO.java (.../AuthoringActivityDTO.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -23,7 +23,9 @@ /* $$Id$$ */ package org.lamsfoundation.lams.learningdesign.dto; +import java.util.ArrayList; import java.util.Date; +import java.util.Iterator; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.BranchingActivity; @@ -102,7 +104,7 @@ private Integer orderID; /** Indicates whether the content of this activity - * would be defined later in the monitoring enviornment or not.*/ + * would be defined later in the monitoring environment or not.*/ private Boolean defineLater; /** The LearningDesign to which this activity belongs*/ @@ -214,8 +216,12 @@ * this activity. e.g. org.lamsfoundation.lams.tool.sbmt.SbmtResources.properties. */ private String languageFile; - /** Used by a sequence activity to determine the start of the transition based sequence */ - private Integer firstActivityUIID; + /** List of the UIIDs of the activities that are input activities for this activity */ + private ArrayList inputActivities; + + /** Used by a sequence activity to determine the start of the transition based sequence and used by tool + * based branching to determine the default branch. */ + private Integer defaultActivityUIID; private Integer startXCoord; private Integer startYCoord; @@ -243,7 +249,7 @@ Boolean applyGrouping,Integer groupingSupportType, Integer groupingType,GroupingDTO groupingDTO, Boolean readOnly, Boolean initialised, Boolean stopAfterActivity, - Integer firstActivityUIID, + ArrayList inputActivities, Integer defaultActivityUIID, Integer startXCoord, Integer startYCoord, Integer endXCoord, Integer endYCoord) { super(); this.activityID = activityID; @@ -289,8 +295,9 @@ this.readOnly = readOnly; this.initialised = initialised; this.stopAfterActivity=stopAfterActivity; - // Sequence Activity field - this.firstActivityUIID = firstActivityUIID; + this.inputActivities=inputActivities; + // Complex Activity field + this.defaultActivityUIID = defaultActivityUIID; // Branching Activity fields this.startXCoord = startXCoord; this.startYCoord = startYCoord; @@ -339,6 +346,16 @@ this.readOnly = activity.getReadOnly(); this.initialised = activity.isInitialised(); this.stopAfterActivity = activity.isStopAfterActivity(); + + if ( activity.getInputActivities() != null && activity.getInputActivities().size() > 0 ) { + ArrayList list = new ArrayList(); + Iterator iter = activity.getInputActivities().iterator(); + while ( iter.hasNext() ) { + Activity inputAct = (Activity) iter.next(); + list.add(inputAct.getActivityUIID()); + } + this.inputActivities = list; + } } @@ -387,8 +404,8 @@ this.endYCoord = activity.getEndYcoord(); } private void addSequenceActivityAttributes(SequenceActivity activity){ - if ( activity.getFirstActivity() != null ) - firstActivityUIID = activity.getFirstActivity().getActivityUIID(); + if ( activity.getDefaultActivity() != null ) + defaultActivityUIID = activity.getDefaultActivity().getActivityUIID(); } private void addToolActivityAttributes(ToolActivity toolActivity){ this.toolContentID = toolActivity.getToolContentId(); @@ -704,9 +721,9 @@ public Integer getGroupingType() { return groupingType; } - /** Get the UI ID of the first activity within a sequence activity */ - public Integer getFirstActivityUIID() { - return firstActivityUIID; + /** Get the UI ID of the first activity within a sequence activity or default branch in tool based branching */ + public Integer getDefaultActivityUIID() { + return defaultActivityUIID; } /** * @return Returns the xcoord of the end hub for a branching activity @@ -1032,9 +1049,9 @@ public void setStopAfterActivity(Boolean stopAfterActivity) { this.stopAfterActivity = stopAfterActivity; } - public void setFirstActivityUIID(Integer firstActivityUIID) { - if(!firstActivityUIID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) - this.firstActivityUIID = firstActivityUIID; + public void setDefaultActivityUIID(Integer defaultActivityUIID) { + if(!defaultActivityUIID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) + this.defaultActivityUIID = defaultActivityUIID; } public void setEndXCoord(Integer endXCoord) { if(!endXCoord.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) @@ -1058,4 +1075,10 @@ public void setAdminURL(String adminURL) { this.adminURL = adminURL; } + public ArrayList getInputActivities() { + return inputActivities; + } + public void setInputActivities(ArrayList inputActivities) { + this.inputActivities = inputActivities; + } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java =================================================================== diff -u -r20a2c3a6cd80bcf92989b3fa1e566ab93fa99afa -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 20a2c3a6cd80bcf92989b3fa1e566ab93fa99afa) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -1364,7 +1364,7 @@ +"The first activity should be reset up in authoring " +"otherwise the progress engine will just do the best it can."); } else { - sequence.setFirstActivity(childActivity); + sequence.setDefaultActivity(childActivity); } } } @@ -1774,8 +1774,8 @@ ((OptionsActivity)act).setOptionsInstructions(actDto.getOptionsInstructions()); break; case Activity.SEQUENCE_ACTIVITY_TYPE: - if ( actDto.getFirstActivityUIID() != null ) { - firstChildUIIDToSequenceMapper.put(actDto.getFirstActivityUIID(), (SequenceActivity)act); + if ( actDto.getDefaultActivityUIID() != null ) { + firstChildUIIDToSequenceMapper.put(actDto.getDefaultActivityUIID(), (SequenceActivity)act); } break; case Activity.CHOSEN_BRANCHING_ACTIVITY_TYPE: Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SequenceActivityStrategy.java =================================================================== diff -u -rd66ffc2bf657d1fe25183aa727b110ed42048d59 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SequenceActivityStrategy.java (.../SequenceActivityStrategy.java) (revision d66ffc2bf657d1fe25183aa727b110ed42048d59) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SequenceActivityStrategy.java (.../SequenceActivityStrategy.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -24,12 +24,9 @@ package org.lamsfoundation.lams.learningdesign.strategy; import java.util.Iterator; -import java.util.Set; -import java.util.TreeSet; import org.apache.log4j.Logger; import org.lamsfoundation.lams.learningdesign.Activity; -import org.lamsfoundation.lams.learningdesign.ActivityOrderComparator; import org.lamsfoundation.lams.learningdesign.ComplexActivity; import org.lamsfoundation.lams.learningdesign.NullActivity; import org.lamsfoundation.lams.learningdesign.SequenceActivity; @@ -70,7 +67,7 @@ */ public Activity getNextActivityByParent(ComplexActivity parent, Activity currentChild) { - Activity firstActivity = sequenceActivity.getFirstActivity(); + Activity firstActivity = sequenceActivity.getDefaultActivity(); if ( firstActivity != null ) { return (currentChild==null || currentChild.isNull() ) ? firstActivity : new NullActivity(); } Index: lams_common/src/java/org/lamsfoundation/lams/tool/OutputType.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/tool/OutputType.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/tool/OutputType.java (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -0,0 +1,33 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool; + +/** + * Output Types define the type of object that will be returned as output. + * OUTPUT_NUMERIC includes both integers and floating point numbers. + */ +public enum OutputType { + + OUTPUT_LONG, OUTPUT_DOUBLE, OUTPUT_BOOLEAN, OUTPUT_STRING, OUTPUT_COMPLEX +} Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutput.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutput.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutput.java (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -0,0 +1,147 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool; + +/** + * An output for a tool. + * + */ +public class ToolOutput { + + private String name; + private String description; + private ToolOutputValue value; + + /** Create a ToolOutput based on a Boolean. This will create a value of type OUTPUT_BOOLEAN + * @param name mandatory + * @param description mandatory + * @param val mandatory + */ + public ToolOutput(String name, String description, Boolean val) { + this.name = name; + this.description = description; + this.value = new ToolOutputValue(val); + } + + /** Create a ToolOutput based on a Long. This will create a value of type OUTPUT_LONG. + * @param name mandatory + * @param description mandatory + * @param val mandatory + */ + public ToolOutput(String name, String description, Long val) { + this.name = name; + this.description = description; + this.value = new ToolOutputValue(val); + } + + /** Create a ToolOutput based on a Integer. This will create a value of type OUTPUT_LONG. + * @param name mandatory + * @param description mandatory + * @param val mandatory + */ + public ToolOutput(String name, String description, Integer val) { + this.name = name; + this.description = description; + this.value = new ToolOutputValue(val); + } + + /** Create a ToolOutput based on a Double. This will create a value of type OUTPUT_DOUBLE. + * @param name mandatory + * @param description mandatory + * @param val mandatory + */ + public ToolOutput(String name, String description, Double val) { + this.name = name; + this.description = description; + this.value = new ToolOutputValue(val); + } + + /** Create a ToolOutput based on a Integer. This will create a value of type OUTPUT_DOUBLE. + * @param name mandatory + * @param description mandatory + * @param val mandatory + */ + public ToolOutput(String name, String description, Float val) { + this.name = name; + this.description = description; + this.value = new ToolOutputValue(val); + } + + /** Create a ToolOutput based on a String. This will create a value of type OUTPUT_STRING. + * @param name mandatory + * @param description mandatory + * @param val mandatory + */ + public ToolOutput(String name, String description, String val) { + this.name = name; + this.description = description; + this.value = new ToolOutputValue(val); + } + + /** Create a ToolOutput based on a String. It tries to convert it to the type defined by the type. + * @throws ToolOutputFormatException If unable to convert the value to the requested type. + * @param name mandatory + * @param description mandatory + * @param val mandatory + */ + public ToolOutput(String name, String description, String val, OutputType type) { + this.name = name; + this.description = description; + this.value = new ToolOutputValue(val, type); + } + + /** Create a Complex ToolOutput based on an Object. This will create a value of type OUTPUT_COMPLEX. The + * junk parameter is to ensure this method isn't "accidently" in place of one of the other constructors. ie to stop + * accidental bugs! + * + * @param name mandatory + * @param description mandatory + * @param val mandatory + * @param junk ignored + */ + public ToolOutput(String name, String description, Object val, Boolean junk) { + this.name = name; + this.description = description; + this.value = new ToolOutputValue(val, junk); + } + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public ToolOutputValue getValue() { + return value; + } + public void setValue(ToolOutputValue value) { + this.value = value; + } +} Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputDefinition.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputDefinition.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputDefinition.java (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -0,0 +1,150 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Each tool that has outputs will define a set of output definitions. Some definitions will be + * "predefined" for a tool, e.g. "Learner's Mark". Others may be created for a specific tool activity, + * via a Conditions/Output tab in monitoring, e.g. Second answer contains the word "Mercury". + *

+ * If the tool contains generated definitions, then they must be copied when the tool content is copied, + * as the conditions may be modified via Live Edit. This must not modify the original design. + *

+ * For 2.1, we will not deal with complex outputs, so for now we will not define how a complex definition + * is defined. The field is placed in the object so that we have the place for it when we do design the + * complex output definitions. + *

+ * Sample ToolOutputDefinition: + * ToolOutputDefinition { + * name = "LEARNERS_MARK", + * description = "Mark for an individual learner"; + * type = "NUMERIC"; + * startValue = "0.0"; + * endValue = "10.0"; + * complexDefinition = null; + * } + */ +public class ToolOutputDefinition { + + private String name; + private String description; + private OutputType type; + private Object startValue; + private Object endValue; + private Object complexDefinition; + + /** Name must be unique within the current tool content. This will be used to identify the output. + * If the definition is a predefined definition then the name will always be the same (e.g. LEARNER_MARK) but + * if it is defined in authoring then it will need to made unique for this tool content (e.g. ANSWER_2_CONTAINS_1). + * At lesson time, the tool will be given back the name and will need to be able to uniquely identify the required + * output based on name, the tool session id and possibly the learner's user id. + */ + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + /** Description: Description is an internationalised text string which is displayed to the + * user as the output "name". It is the responsibility of the tool to internationalise the + * string. We suggest that the key for each predefined definition follow the convention + * OUTPUT_DESC_ + */ + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + /** + * The type of the output value. + */ + public OutputType getType() { + return type; + } + public void setType(OutputType type) { + this.type = type; + } + /** If the output value may be compared to a range, then startValue and endValue are the inclusive start values and end values + * for the range. This may be used to customise fixed definitions to ranges appropriate for the current data. + */ + public Object getStartValue() { + return startValue; + } + public void setStartValue(Object startValue) { + this.startValue = startValue; + } + /** See getStartValue() */ + public Object getEndValue() { + return endValue; + } + public void setEndValue(Object endValue) { + this.endValue = endValue; + } + public Object getComplexDefinition() { + return complexDefinition; + } + public void setComplexDefinition(Object complexDefinition) { + this.complexDefinition = complexDefinition; + } + + public String toString() { + return new ToStringBuilder(this) + .append("name", name) + .append("description", description) + .append("type", type) + .append("startValue", startValue) + .append("endValue", endValue) + .toString(); + } + + public boolean equals(Object other) { + if ( (this == other ) ) return true; + if ( !(other instanceof ToolOutputDefinition) ) return false; + ToolOutputDefinition castOther = (ToolOutputDefinition) other; + return new EqualsBuilder() + .append(this.name, castOther.name) + .append(this.description, castOther.description) + .append(this.type, castOther.type) + .append(this.startValue, castOther.startValue) + .append(this.endValue, castOther.endValue) + .isEquals(); + } + + public int hashCode() { + return new HashCodeBuilder() + .append(name) + .append(description) + .append(type) + .append(startValue) + .append(endValue) + .toHashCode(); + } + + +} Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputFormatException.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputFormatException.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputFormatException.java (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -0,0 +1,69 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool; +/** + * Thrown when we try to get a output as the wrong type. + */ +public class ToolOutputFormatException extends RuntimeException { + /** + * Constructs a new instance of this class. + */ + public ToolOutputFormatException() { + this("Tried to get value in the wrong format."); + } + + /** + * Constructs a new instance of this class given a message describing the + * failure cause. + * + * @param s description + */ + public ToolOutputFormatException(String s) { + super(s); + } + + /** + * Constructs a new instance of this class given a message describing the + * failure and a root throwable. + * + * @param s description + * @param cause root throwable cause + */ + public ToolOutputFormatException(String s, Throwable cause) { + super(s,cause); + + } + + /** + * Constructs a new instance of this class given a root throwable. + * + * @param cause root failure cause + */ + public ToolOutputFormatException(Throwable cause) { + this("Tried to get value in the wrong format.", cause); + } + + +} Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputValue.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputValue.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputValue.java (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -0,0 +1,258 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool; + +/** + * The ToolOutputValue is the actual output data from the tool, as wrapped up in a + * ToolOutput object and defined by a ToolOutputDefinition. + */ +public class ToolOutputValue { + private OutputType type; + private Object value; + + /** Create a ToolOutputValue based on a Boolean. This will create a value of type OUTPUT_BOOLEAN + * @param val mandatory + */ + public ToolOutputValue(Boolean val) { + this.type = OutputType.OUTPUT_BOOLEAN; + this.value = val; + } + + /** Create a ToolOutputValue based on a Long. This will create a value of type OUTPUT_LONG. + * @param val mandatory + */ + public ToolOutputValue(Long val) { + this.type = OutputType.OUTPUT_LONG; + this.value = val; + } + + /** Create a ToolOutputValue based on a Integer. This will create a value of type OUTPUT_LONG. + * @param val mandatory + */ + public ToolOutputValue(Integer val) { + this.type = OutputType.OUTPUT_LONG; + this.value = new Long(val.longValue()); + } + + /** Create a ToolOutputValue based on a Double. This will create a value of type OUTPUT_DOUBLE. + * @param val mandatory + */ + public ToolOutputValue(Double val) { + this.type = OutputType.OUTPUT_DOUBLE; + this.value = val; + } + + /** Create a ToolOutputValue based on a Integer. This will create a value of type OUTPUT_DOUBLE. + * @param val mandatory + */ + public ToolOutputValue(Float val) { + this.type = OutputType.OUTPUT_DOUBLE; + this.value = new Double(val.doubleValue()); + } + + /** Create a ToolOutputValue based on a String. This will create a value of type OUTPUT_STRING. + * @param val mandatory + */ + public ToolOutputValue(String val) { + this.type = OutputType.OUTPUT_STRING; + this.value = val; + } + + /** Create a ToolOutputValue based on a String. It tries to convert it to the type defined by the type. + * @throws ToolOutputFormatException If unable to convert the value to the requested type. + * @param val mandatory + */ + public ToolOutputValue(String val, OutputType type) { + this.type = type; + try { + switch (type) { + case OUTPUT_LONG: + this.value = Long.parseLong(val); + break; + + case OUTPUT_DOUBLE: + this.value = Double.parseDouble(val); + break; + + case OUTPUT_BOOLEAN: + this.value = Boolean.parseBoolean(val); + break; + + case OUTPUT_STRING: + case OUTPUT_COMPLEX: + default: + this.value = val; + } + } catch ( Exception e ) { + throw new ToolOutputFormatException("Unable to convert value "+value+" to Long.",e); + } + } + + /** Create a Complex ToolOutputValue based on an Object. This will create a value of type OUTPUT_COMPLEX. The + * junk parameter is to ensure this method isn't "accidently" in place of one of the other constructors. ie to stop + * accidental bugs! + * + * @param val mandatory + * @param junk ignored + */ + public ToolOutputValue(Object val, Boolean junk) { + type = OutputType.OUTPUT_COMPLEX; + value = val; + } + + /** + * @return the type of this Value. + */ + public OutputType getType() { + return type; + } + + /** + * Get the raw value. Useful if you want to know about its type or you have some other code will look at the + * object's class directly. Normally you would use getString(), getLong(), etc as all the mucking around + * with types is done for you. + */ + public Object getValue() { + return value; + } + + /** + * Returns a string representation of the value. Available for any type of output. + * @throws ToolOutputFormatException If unable to convert the value to a string. + */ + public String getString() throws ToolOutputFormatException { + return OutputType.OUTPUT_STRING.equals(type) ? (String) value : value.toString(); + } + + /** + * Returns a Long representation of the value. This should always work for OUTPUT_LONG + * and we will try to convert other types but that isn't guaranteed. A boolean value will convert to 1 or 0. + * A double value may round. + * + * @throws ToolOutputFormatException If unable to convert the value to a Long. + */ + public Long getLong() throws ToolOutputFormatException { + + try { + switch (type) { + case OUTPUT_LONG: + return (Long)value; + + case OUTPUT_DOUBLE: + return new Long(((Double)value).longValue()); + + case OUTPUT_BOOLEAN: + return ((Boolean)value).booleanValue() ? new Long(1) : new Long(0); + + case OUTPUT_STRING: + return Long.parseLong((String) value); + + case OUTPUT_COMPLEX: + throw new ToolOutputFormatException("Unable to convert value "+value+" to Long."); + + default: + throw new ToolOutputFormatException("Unable to convert value "+value+" to Long."); + } + } catch ( Exception e ) { + throw new ToolOutputFormatException("Unable to convert value "+value+" to Long.",e); + } + + } + + /** + * Returns a Double representation of the value. This should always work for OUTPUT_DOUBLE + * and we will try to convert other types but that isn't guaranteed. A boolean value will convert to 1 or 0. + * + * @throws ToolOutputFormatException If unable to convert the value to a Double. + */ + public Double getDouble() throws ToolOutputFormatException { + + try { + switch (type) { + case OUTPUT_LONG: + return new Double(((Long)value).doubleValue()); + + case OUTPUT_DOUBLE: + return (Double) value; + + case OUTPUT_BOOLEAN: + return ((Boolean)value).booleanValue() ? new Double(1) : new Double(0); + + case OUTPUT_STRING: + return Double.parseDouble((String) value); + + case OUTPUT_COMPLEX: + throw new ToolOutputFormatException("Unable to convert value "+value+" to Double."); + + default: + throw new ToolOutputFormatException("Unable to convert value "+value+" to Double."); + } + } catch ( Exception e ) { + throw new ToolOutputFormatException("Unable to convert value "+value+" to Double.",e); + } + + } + + /** + * Returns a boolean representation of the value. This should always work for OUTPUT_BOOLEAN + * and we will try to convert other types but that isn't guaranteed. A numeric of 1 will be converted to true, + * otherwise false. + * + * @throws ToolOutputFormatException If unable to convert the value to a boolean. + */ + public Boolean getBoolean() throws ToolOutputFormatException { + + try { + switch (type) { + case OUTPUT_LONG: + return ((Long)value).longValue() == 1; + + case OUTPUT_DOUBLE: + return ((Double)value).longValue() == 1; + + case OUTPUT_BOOLEAN: + return (Boolean)value; + + case OUTPUT_STRING: + return Boolean.parseBoolean((String) value); + + case OUTPUT_COMPLEX: + throw new ToolOutputFormatException("Unable to convert value "+value+" to Boolean."); + + default: + throw new ToolOutputFormatException("Unable to convert value "+value+" to Boolean."); + } + } catch ( Exception e ) { + throw new ToolOutputFormatException("Unable to convert value "+value+" to Boolean.",e); + } + + } + + /** + * Complex isn't handled for 2.1, so just return the value unchanged. Currently does that same thing as getValue + */ + public Object getComplex() throws ToolOutputFormatException { + return value; + } +} Index: lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java =================================================================== diff -u -r41e315233a61119bce6a93c44ec404d1ddf6d630 -r09048f91f2dcbb6b63449f3c1fb9e1a09221a35e --- lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java (.../WDDXTAGS.java) (revision 41e315233a61119bce6a93c44ec404d1ddf6d630) +++ lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java (.../WDDXTAGS.java) (revision 09048f91f2dcbb6b63449f3c1fb9e1a09221a35e) @@ -95,6 +95,7 @@ public static final String APPLY_GROUPING = "applyGrouping"; public static final String GROUPING_SUPPORT_TYPE = "groupingSupportType"; public static final String STOP_AFTER_ACTIVITY = "stopAfterActivity"; + public static final String INPUT_ACTIVITIES = "inputActivities"; /** OptionsActivity specific tags*/ public static final String MAX_OPTIONS="maxOptions"; @@ -182,6 +183,7 @@ /**ComplexActivity specific tags */ public static final String CHILD_ACTIVITIES ="childActivities"; + public static final String DEFAULT_ACTIVITY_UIID ="defaultActivityUIID"; /** Crash Dump Specific Tags */ public static final String CRASH_DUMP_BATCH="crashDataBatch";