Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java =================================================================== diff -u -r34b959260a0f8f8285793a4481a95ca3580eabc5 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java (.../Activity.java) (revision 34b959260a0f8f8285793a4481a95ca3580eabc5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java (.../Activity.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -37,14 +37,11 @@ import org.apache.commons.lang.builder.ToStringBuilder; import org.lamsfoundation.lams.learningdesign.dto.AuthoringActivityDTO; import org.lamsfoundation.lams.learningdesign.dto.LibraryActivityDTO; -import org.lamsfoundation.lams.learningdesign.dto.MonitoringActivityDTO; import org.lamsfoundation.lams.learningdesign.dto.ProgressActivityDTO; -import org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy; import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.Nullable; -import org.lamsfoundation.lams.util.MessageService; - /** * Base class for all activities. If you add another subclass, * you must update ActivityDAO.getActivityByActivityId() and add a @@ -199,8 +196,6 @@ * this activity. e.g. org.lamsfoundation.lams.tool.sbmt.SbmtResources.properties. */ private String languageFile; - protected SimpleActivityStrategy simpleActivityStrategy; - //--------------------------------------------------------------------- // Object constructors //--------------------------------------------------------------------- @@ -794,15 +789,6 @@ } - /** Get the monitoring DTO for this activity. Overridden by SimpleActivity - * to include the contribution types */ - public Set getMonitoringActivityDTO() - { - HashSet dtoSet = new HashSet(); - dtoSet.add(new MonitoringActivityDTO(this,null)); - return dtoSet; - } - /** Get the authoring DTO for this activity. Overidden by ComplexActivity. */ public Set getAuthoringActivityDTOSet() Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/ContributionTypes.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/ContributionTypes.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ContributionTypes.java (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -0,0 +1,41 @@ +/**************************************************************** + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.learningdesign; + +public class ContributionTypes { + + //--------------------------------------------------------------------- + // Class level constants - Contribution types + //--------------------------------------------------------------------- + public static final Integer MODERATION = new Integer(1); + public static final Integer DEFINE_LATER = new Integer(2); + public static final Integer PERMISSION_GATE = new Integer(3); + public static final Integer SYNC_GATE = new Integer(4); + public static final Integer SCHEDULE_GATE = new Integer(5); + public static final Integer CHOSEN_GROUPING = new Integer(6); + public static final Integer CONTRIBUTION = new Integer(7); + + +} Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/LearningDesignProcessor.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/LearningDesignProcessor.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/LearningDesignProcessor.java (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -0,0 +1,125 @@ +/**************************************************************** + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.learningdesign; + +import java.util.Iterator; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.learningdesign.dao.IActivityDAO; + +/** Run through a learning design, in the order of the activities. Process the learning design + * to produce somethings else. + * + * This is an abstract class that implements stepping through the learning design. It is used + * by getAllContributeActivities to build up the list of "todo" activities and can also be used + * by export portfolio and export learning design. The implementing classes will need to implement + * the startBlah and endBlah methods. + * + * @author Fiona Malikoff + * + */ +public abstract class LearningDesignProcessor { + + private static Logger log = Logger.getLogger(LearningDesignProcessor.class); + + private LearningDesign design; + private IActivityDAO activityDAO; + + public LearningDesignProcessor(LearningDesign design, IActivityDAO activityDAO) { + this.design = design; + this.activityDAO = activityDAO; + } + + /** A complex activity has been found. Do any processing needed at the start of the activity */ + public abstract void startComplexActivity(ComplexActivity activity); + + /** Do any processing needed at the end of a complex activity */ + public abstract void endComplexActivity(ComplexActivity activity); + + /** A simple activity has been found. Do any processing needed at the start of the activity */ + public abstract void startSimpleActivity(SimpleActivity activity); + + /** Do any processing needed at the end of a complex activity */ + public abstract void endSimpleActivity(SimpleActivity activity); + + public void parseLearningDesign() { + if ( getDesign() != null ) { + handleActivity(getDesign().getFirstActivity()); + } + } + + protected void handleActivity( Activity activity ) { + if ( activity == null ) { + log.warn("Parsing activity method handleActivity got a null activity. Learning design was "+getDesign()); + } else { + if ( log.isDebugEnabled() ) { + log.debug("Processing activity "+activity.getActivityId()+" "+activity.getTitle()); + } + if ( activity.isComplexActivity() ) { + handleComplexActivity( activity ); + } else { + handleSimpleActivity( activity ); + } + + // if there is a transition to the next one then go to it, + // otherwise just return as we must be either at the end or inside another activity. + if ( activity.getTransitionFrom() != null ) { + handleActivity(activity.getTransitionFrom().getToActivity()); + } + } + } + + protected void handleComplexActivity( Activity activity ) { + // ensure it is a real activity not a CGLIB proxy + ComplexActivity complex = (ComplexActivity) activityDAO.getActivityByActivityId(activity.getActivityId(),SimpleActivity.class); + startComplexActivity(complex); + + // work through all the child activities for this activity, in order id. + Set children = new TreeSet(new ActivityOrderComparator()); + children.addAll(complex.getActivities()); + Iterator i=children.iterator(); + while ( i.hasNext() ) { + handleActivity((Activity)i.next()); + } + + endComplexActivity(complex); + + } + + + protected void handleSimpleActivity( Activity activity ) { + // ensure it is a real activity not a CGLIB proxy + SimpleActivity simple = (SimpleActivity) activityDAO.getActivityByActivityId(activity.getActivityId(),SimpleActivity.class); + startSimpleActivity(simple); + endSimpleActivity(simple); + } + + public LearningDesign getDesign() { + return design; + } +} + Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SimpleActivity.java =================================================================== diff -u -r34b959260a0f8f8285793a4481a95ca3580eabc5 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SimpleActivity.java (.../SimpleActivity.java) (revision 34b959260a0f8f8285793a4481a95ca3580eabc5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SimpleActivity.java (.../SimpleActivity.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -25,11 +25,8 @@ import java.io.Serializable; import java.util.Date; -import java.util.HashSet; -import java.util.Set; import org.apache.commons.lang.builder.ToStringBuilder; -import org.lamsfoundation.lams.learningdesign.dto.MonitoringActivityDTO; import org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy; @@ -115,15 +112,8 @@ .toString(); } - - public Set getMonitoringActivityDTO() - { - HashSet dtoSet = new HashSet(); - Integer[] contributionType = simpleActivityStrategy.getContributionType(); - for(int i=0;i contributionTypes); /** * Get the activity for this strategy. The activity should be set Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GroupingActivityStrategy.java =================================================================== diff -u -r34b959260a0f8f8285793a4481a95ca3580eabc5 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GroupingActivityStrategy.java (.../GroupingActivityStrategy.java) (revision 34b959260a0f8f8285793a4481a95ca3580eabc5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GroupingActivityStrategy.java (.../GroupingActivityStrategy.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -25,6 +25,7 @@ import java.util.ArrayList; import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.ContributionTypes; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; @@ -51,11 +52,11 @@ /** * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) */ - protected void setUpContributionType(ArrayList contributionTypes) + protected void setUpContributionType(ArrayList contributionTypes) { if ( groupingActivity != null ) { - if(groupingActivity.getCreateGrouping().getGroupingTypeId()== Grouping.CHOSEN_GROUPING_TYPE) - contributionTypes.add(CHOSEN_GROUPING); + if( Grouping.CHOSEN_GROUPING_TYPE.equals(groupingActivity.getCreateGrouping().getGroupingTypeId()) ) + contributionTypes.add(ContributionTypes.CHOSEN_GROUPING); } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java =================================================================== diff -u -r34b959260a0f8f8285793a4481a95ca3580eabc5 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java (.../PermissionGateActivityStrategy.java) (revision 34b959260a0f8f8285793a4481a95ca3580eabc5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java (.../PermissionGateActivityStrategy.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.List; +import org.lamsfoundation.lams.learningdesign.ContributionTypes; import org.lamsfoundation.lams.learningdesign.GateActivity; /** @@ -48,9 +49,9 @@ /** * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) */ - protected void setUpContributionType(ArrayList contributionTypes) + protected void setUpContributionType(ArrayList contributionTypes) { - contributionTypes.add(PERMISSION_GATE); + contributionTypes.add(ContributionTypes.PERMISSION_GATE); } /** Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ScheduleGateActivityStrategy.java =================================================================== diff -u -r34b959260a0f8f8285793a4481a95ca3580eabc5 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ScheduleGateActivityStrategy.java (.../ScheduleGateActivityStrategy.java) (revision 34b959260a0f8f8285793a4481a95ca3580eabc5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ScheduleGateActivityStrategy.java (.../ScheduleGateActivityStrategy.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; +import org.lamsfoundation.lams.learningdesign.ContributionTypes; import org.lamsfoundation.lams.learningdesign.GateActivity; @@ -52,9 +53,9 @@ /** * @see org.lamsfoundation.lams.learningdesign.strategy.GateActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) */ - protected void setUpContributionType(ArrayList contributionTypes) + protected void setUpContributionType(ArrayList contributionTypes) { - contributionTypes.add(SCHEDULE_GATE); + contributionTypes.add(ContributionTypes.SCHEDULE_GATE); } /** Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SimpleActivityStrategy.java =================================================================== diff -u -r34b959260a0f8f8285793a4481a95ca3580eabc5 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SimpleActivityStrategy.java (.../SimpleActivityStrategy.java) (revision 34b959260a0f8f8285793a4481a95ca3580eabc5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SimpleActivityStrategy.java (.../SimpleActivityStrategy.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -48,16 +48,6 @@ */ public abstract class SimpleActivityStrategy implements Serializable { - //--------------------------------------------------------------------- - // Class level constants - Contribution types - //--------------------------------------------------------------------- - public static final Integer MODERATION = new Integer(1); - public static final Integer DEFINE_LATER = new Integer(2); - public static final Integer PERMISSION_GATE = new Integer(3); - public static final Integer SYNC_GATE = new Integer(4); - public static final Integer SCHEDULE_GATE = new Integer(5); - public static final Integer CHOSEN_GROUPING = new Integer(6); - public static final Integer CONTRIBUTION = new Integer(7); //--------------------------------------------------------------------- // Template methods @@ -70,9 +60,7 @@ */ public Integer[] getContributionType() { - Activity activity = getActivity(); - - ArrayList contributionTypes = new ArrayList(); + ArrayList contributionTypes = new ArrayList(); //abstract method to polymorphically setup contribute type. setUpContributionType(contributionTypes); @@ -89,7 +77,7 @@ * for. * @param contributionTypes the list that holds contribution types. */ - protected abstract void setUpContributionType(ArrayList contributionTypes); + protected abstract void setUpContributionType(ArrayList contributionTypes); /** * Get the activity for this strategy. The activity should be set Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SynchGateActivityStrategy.java =================================================================== diff -u -r34b959260a0f8f8285793a4481a95ca3580eabc5 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SynchGateActivityStrategy.java (.../SynchGateActivityStrategy.java) (revision 34b959260a0f8f8285793a4481a95ca3580eabc5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SynchGateActivityStrategy.java (.../SynchGateActivityStrategy.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -26,6 +26,7 @@ import java.util.Iterator; import java.util.List; +import org.lamsfoundation.lams.learningdesign.ContributionTypes; import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.usermanagement.User; @@ -78,9 +79,9 @@ /** * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity, java.util.ArrayList) */ - protected void setUpContributionType(ArrayList contributionTypes) + protected void setUpContributionType(ArrayList contributionTypes) { - contributionTypes.add(SYNC_GATE); + contributionTypes.add(ContributionTypes.SYNC_GATE); } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ToolActivityStrategy.java =================================================================== diff -u -r34b959260a0f8f8285793a4481a95ca3580eabc5 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ToolActivityStrategy.java (.../ToolActivityStrategy.java) (revision 34b959260a0f8f8285793a4481a95ca3580eabc5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ToolActivityStrategy.java (.../ToolActivityStrategy.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -25,6 +25,7 @@ import java.util.ArrayList; import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.ContributionTypes; import org.lamsfoundation.lams.learningdesign.ToolActivity; /** @@ -50,15 +51,15 @@ /** * @see org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy#setUpContributionType(org.lamsfoundation.lams.learningdesign.Activity) */ - protected void setUpContributionType(ArrayList contributionTypes) + protected void setUpContributionType(ArrayList contributionTypes) { if ( toolActivity != null ) { if(toolActivity.getTool().getSupportsModeration()) - contributionTypes.add(MODERATION); + contributionTypes.add(ContributionTypes.MODERATION); if(toolActivity.getTool().getSupportsContribute()) - contributionTypes.add(CONTRIBUTION); + contributionTypes.add(ContributionTypes.CONTRIBUTION); if(toolActivity.getDefineLater().booleanValue()) - contributionTypes.add(DEFINE_LATER); + contributionTypes.add(ContributionTypes.DEFINE_LATER); } } Index: lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml =================================================================== diff -u -rbb9853953ff8cc6e70017a866d94fc2cfcb2cc35 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml (.../toolApplicationContext.xml) (revision bb9853953ff8cc6e70017a866d94fc2cfcb2cc35) +++ lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml (.../toolApplicationContext.xml) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -58,6 +58,7 @@ + Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/OrganisationDTO.java =================================================================== diff -u -r50f06594944a995d2cdd0cb10f02d5c56bfdd6de -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/OrganisationDTO.java (.../OrganisationDTO.java) (revision 50f06594944a995d2cdd0cb10f02d5c56bfdd6de) +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/OrganisationDTO.java (.../OrganisationDTO.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -20,9 +20,12 @@ * http://www.gnu.org/licenses/gpl.txt * **************************************************************** */ -/* $$Id$$ */ +/* $Id$ */ package org.lamsfoundation.lams.usermanagement.dto; +import java.util.Collection; +import java.util.TreeMap; + import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.util.wddx.WDDXTAGS; @@ -32,26 +35,30 @@ public class OrganisationDTO { private Integer organisationID; - private Integer parentID; + private TreeMap childOrganisations; private String name; private String description; + private Integer parentID; public OrganisationDTO(){ } - public OrganisationDTO(Integer organisationID, Integer parentID, String name, - String description) { + public OrganisationDTO(Integer organisationID, Integer parentID, String description, String name) { super(); this.organisationID = organisationID; - this.parentID = parentID; this.name = name; this.description = description; + this.childOrganisations = new TreeMap(); + this.parentID = parentID; } + public OrganisationDTO(Organisation organisation){ this.organisationID = organisation.getOrganisationId(); - this.parentID = organisation.getParentOrganisation().getOrganisationId(); this.name = organisation.getName(); this.description = organisation.getDescription(); + this.childOrganisations = new TreeMap(); + if ( organisation.getParentOrganisation() != null ) + this.parentID = organisation.getParentOrganisation().getOrganisationId(); } /** * @return Returns the description. @@ -71,11 +78,19 @@ public Integer getOrganisationID() { return organisationID!=null?organisationID:WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; } + + /** Gets all the child organisations. This is a recursive structure */ + public Collection getChildOrganisations() { + return childOrganisations.values(); + } - /** - * @return Returns the parent organisationID. - */ + /** Add a child organisation. Adds it into a sorted map so that the values always come out + * in the same order. */ + public void addChildOrganisation(OrganisationDTO orgDTO) { + childOrganisations.put(orgDTO.getOrganisationID(),orgDTO); + } public Integer getParentID() { - return parentID!=null?parentID:WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER; + return parentID; } + } Index: lams_documents/lams_monitoring/Monitoring.doc =================================================================== diff -u -r59b57ec46f40c1c279aa88d31661992c832ba35a -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 Binary files differ Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeActivityDTO.java =================================================================== diff -u --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeActivityDTO.java (revision 0) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeActivityDTO.java (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -0,0 +1,148 @@ +/**************************************************************** + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $Id$ */ +package org.lamsfoundation.lams.monitoring; + +import java.util.Vector; + +import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.ContributionTypes; + +/** + * DTO used to return the activity details needed for the contribute activities list + * + * @author Fiona Malikoff + */ +public class ContributeActivityDTO { + + private String title; + private String description; + private Long activityID; + private Integer activityTypeID; + private Integer orderID; + private Long parentActivityID; + private Vector childActivities; + private Vector contributeEntries; + + /** Warning: This does not set childActivities or contribution details !!!!!! */ + public ContributeActivityDTO(Activity activity){ + this.title = activity.getTitle(); + this.description = activity.getDescription(); + this.activityID = activity.getActivityId(); + this.activityTypeID = activity.getActivityTypeId(); + this.orderID = activity.getOrderId(); + if ( activity.getParentActivity() != null ) { + this.parentActivityID = activity.getParentActivity().getActivityId(); + } + this.contributeEntries = new Vector(); + } + /** + * @return Returns the activityID. + */ + public Long getActivityID() { + return activityID; + } + /** + * @return Returns the activityTypeID. + */ + public Integer getActivityTypeID() { + return activityTypeID; + } + /** + * @return Returns the description. + */ + public String getDescription() { + return description; + } + /** + * @return Returns the orderID. + */ + public Integer getOrderID() { + return orderID; + } + /** + * @return Returns the title. + */ + public String getTitle() { + return title; + + } + + public Vector getContributeEntries() { + return contributeEntries; + } + + public void setChildActivities(Vector childActivities) { + this.childActivities = childActivities; + } + + public Vector getChildActivities() { + return childActivities; + } + public Long getParentActivityID() { + return parentActivityID; + } + + public void addContribution(Integer contributionType, String url) { + ContributeEntry entry = new ContributeEntry(); + entry.setContributionType(contributionType); + entry.setURL(url); + contributeEntries.add(entry); + } + + class ContributeEntry { + private Boolean isRequired; + private Integer contributionType; + private String url; + + /** + * @return Returns the contributionType. + */ + public Integer getContributionType() { + return contributionType; + } + public void setContributionType(Integer contributionType) { + this.contributionType = contributionType; + boolean isReq = contributionType!=null && + ( contributionType.equals(ContributionTypes.DEFINE_LATER) || + contributionType.equals(ContributionTypes.PERMISSION_GATE)|| + contributionType.equals(ContributionTypes.CHOSEN_GROUPING) ); + + this.isRequired = new Boolean(isReq); + } + /** + * @return Returns the isRequired. + */ + public Boolean getIsRequired() { + return isRequired; + } + + public String getURL() { + return url; + } + public void setURL(String url) { + this.url = url; + } +} + +} Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeDTOFactory.java =================================================================== diff -u --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeDTOFactory.java (revision 0) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeDTOFactory.java (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -0,0 +1,142 @@ +/**************************************************************** + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.monitoring; + +import java.io.IOException; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.ComplexActivity; +import org.lamsfoundation.lams.learningdesign.ContributionTypes; +import org.lamsfoundation.lams.learningdesign.LearningDesignProcessor; +import org.lamsfoundation.lams.learningdesign.SimpleActivity; +import org.lamsfoundation.lams.learningdesign.ToolActivity; +import org.lamsfoundation.lams.learningdesign.dto.ProgressActivityDTO; +import org.lamsfoundation.lams.learningdesign.strategy.SimpleActivityStrategy; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.util.wddx.FlashMessage; +import org.lamsfoundation.lams.web.util.AttributeNames; + +public class ContributeDTOFactory { + + private static Logger log = Logger.getLogger(LearningDesignProcessor.class); + + /** Get the Contribute DTO for this activity. As a SimpleActivity + * it only returns a contribute DTO if there is a contribution entry. + */ + public static ContributeActivityDTO getContributeActivityDTO(SimpleActivity activity) + { + ContributeActivityDTO dto = null; + SimpleActivityStrategy strategy = activity.getSimpleActivityStrategy(); + if ( strategy != null ) { + Integer[] contributionType = activity.getSimpleActivityStrategy().getContributionType(); + if ( contributionType.length > 0 ) { + dto = new ContributeActivityDTO(activity); + for(int i=0;i mainActivityList; + ArrayStack activityListStack; + Vector currentActivityList; + + public ContributeActivitiesProcessor(LearningDesign design, + IActivityDAO activityDAO) { + super(design, activityDAO); + mainActivityList = new Vector(); + activityListStack = new ArrayStack(5); + currentActivityList = mainActivityList; + } + + public Vector getMainActivityList() { + return mainActivityList; + } + + public void startComplexActivity(ComplexActivity activity) { + + // Create a new current activity list, putting the old current one on the stack. + activityListStack.push(currentActivityList); + currentActivityList = new Vector(); + + } + + public void endComplexActivity(ComplexActivity activity) { + + ContributeActivityDTO dto = null; + if ( currentActivityList.size()>0 ) { + dto = ContributeDTOFactory.getContributeActivityDTO(activity); + dto.setChildActivities(currentActivityList); + } + + currentActivityList = (Vector) activityListStack.pop(); + if ( dto != null ) { + currentActivityList.add(dto); + } + } + + public void startSimpleActivity(SimpleActivity activity) { + // nothing to do - everything done by the end + } + + public void endSimpleActivity(SimpleActivity activity) { + ContributeActivityDTO dto = ContributeDTOFactory.getContributeActivityDTO(activity); + if ( dto != null ) { + currentActivityList.add(dto); + } + } + + +} Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java =================================================================== diff -u -r568197820cd33d3fb1bab3ea4ec180a58800fd65 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 568197820cd33d3fb1bab3ea4ec180a58800fd65) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -299,14 +299,6 @@ */ public String getLearnerActivityURL(Long activityID,Integer userID)throws IOException,LamsToolServiceException; - /** - * This method returns the contribute url for the given activity - * - * @param activityID The activity_id of the Activity whose URL will be returned - * @return String The required information in WDDX format - * @throws IOException - */ - public String getActivityContributionURL(Long activityID)throws IOException; /** * This method returns the define later url for the given activity * Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -r568197820cd33d3fb1bab3ea4ec180a58800fd65 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 568197820cd33d3fb1bab3ea4ec180a58800fd65) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.Date; -import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; @@ -62,6 +61,7 @@ import org.lamsfoundation.lams.lesson.dao.ILessonClassDAO; import org.lamsfoundation.lams.lesson.dao.ILessonDAO; import org.lamsfoundation.lams.lesson.dto.LessonDTO; +import org.lamsfoundation.lams.monitoring.ContributeDTOFactory; import org.lamsfoundation.lams.monitoring.MonitoringConstants; import org.lamsfoundation.lams.tool.ToolSession; import org.lamsfoundation.lams.tool.exception.DataMissingException; @@ -926,8 +926,10 @@ Lesson lesson = lessonDAO.getLesson(lessonID); FlashMessage flashMessage; if(lesson!=null){ - Vector sortedSet = getOrderedActivityTree(lesson.getLearningDesign()); - flashMessage = new FlashMessage("getAllContributeActivities",sortedSet); + ContributeActivitiesProcessor processor = new ContributeActivitiesProcessor(lesson.getLearningDesign(),activityDAO); + processor.parseLearningDesign(); + Vector activities = processor.getMainActivityList(); + flashMessage = new FlashMessage("getAllContributeActivities",activities); }else{ flashMessage = new FlashMessage("getAllContributeActivities", messageService.getMessage("NO.SUCH.LESSON",new Object[]{lessonID}), @@ -963,43 +965,14 @@ } /** * (non-Javadoc) - * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getActivityContributionURL(java.lang.Long) - */ - public String getActivityContributionURL(Long activityID)throws IOException{ - Activity activity = activityDAO.getActivityByActivityId(activityID); - FlashMessage flashMessage = null; - if(activity!=null){ - if(activity.isToolActivity()){ - ToolActivity toolActivity = (ToolActivity)activity; - String contributionURL = toolActivity.getTool().getContributeUrl(); - flashMessage = new FlashMessage("getActivityContributionURL",contributionURL); - } - }else - flashMessage = FlashMessage.getNoSuchActivityExists("getActivityContributionURL",activityID); - - return flashMessage.serializeMessage(); - } - /** - * (non-Javadoc) * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getActivityDefineLaterURL(java.lang.Long) */ public String getActivityDefineLaterURL(Long activityID)throws IOException{ Activity activity = activityDAO.getActivityByActivityId(activityID); FlashMessage flashMessage = null; if(activity!=null){ - if(activity.isToolActivity()){ - ToolActivity toolActivity = (ToolActivity)activity; - String url = toolActivity.getTool().getDefineLaterUrl(); - Long toolContentId = toolActivity.getToolContentId(); - if ( url !=null && toolContentId != null ) { - url = WebUtil.appendParameterToURL(url, - AttributeNames.PARAM_TOOL_CONTENT_ID, - toolActivity.getToolContentId().toString()); - flashMessage = new FlashMessage("getActivityDefineLaterURL",new ProgressActivityDTO(activityID, url)); - } else { - flashMessage = generateDataMissingPacket(activityID, url, "Define Late URL", toolContentId, "Tool Content ID"); - } - } + String url = ContributeDTOFactory.getActivityDefineLaterURL(activity); + flashMessage = new FlashMessage("getActivityDefineLaterURL",new ProgressActivityDTO(activityID, url)); }else flashMessage = FlashMessage.getNoSuchActivityExists("getActivityDefineLaterURL",activityID); @@ -1337,54 +1310,7 @@ FlashMessage flashMessage = new FlashMessage("getAllLessons",lessonObjects); return flashMessage.serializeMessage(); } - /** - * This method assigns an orderID to all the activties in the LearningDesign - * based on the transitions. Once this is done it just packages it in a container - * to be serialized and sent to flash - * - * @param learningDesign The learningdesign whose activities have to be ordered - * @return Vector The activities with orderID assigned. - */ - private Vector getOrderedActivityTree(LearningDesign learningDesign){ - int order = 0; - HashMap activityTree = learningDesign.getActivityTree(); - Vector activityVector = new Vector(); - - Activity nextActivity = learningDesign.getFirstActivity(); - while(nextActivity!=null){ - order = addActivityToVector(order, activityTree, activityVector, nextActivity); - nextActivity = transitionDAO.getNextActivity(nextActivity.getActivityId()); - } - return activityVector; - } - /** - * Used by getOrderedActivityTree(LearningDesign learningDesign) - * - * @param order - * @param activityTree - * @param activityVector - * @param nextActivity - * @return - */ - private int addActivityToVector(int order, HashMap activityTree, Vector activityVector, Activity nextActivity) { - nextActivity.setOrderId(new Integer(order)); - Set childActivities = (Set) activityTree.get(nextActivity.getActivityId()); - if(childActivities.size()!=0){ - Iterator iterator = childActivities.iterator(); - while(iterator.hasNext()){ - Activity simpleActivity= (Activity)iterator.next(); - activityVector.add(simpleActivity.getMonitoringActivityDTO()); - } - }else{ - // we are assuming that this is a simple activity. - // the original code for this branch only added it if it had a valid contribution - // type, but the code for the if branch above didn't. Can add it in - // again later if it causes Flash problems. - activityVector.add(nextActivity.getMonitoringActivityDTO()); - } - return order + 1; - } //--------------------------------------------------------------------- // Helper Methods - scheduling //--------------------------------------------------------------------- Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java =================================================================== diff -u -r568197820cd33d3fb1bab3ea4ec180a58800fd65 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 568197820cd33d3fb1bab3ea4ec180a58800fd65) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -602,17 +602,6 @@ response.sendRedirect(response.encodeRedirectURL(url)); return null; } - public ActionForward getActivityContributionURL(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response)throws IOException{ - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); - Long activityID = new Long(WebUtil.readLongParam(request,"activityID")); - String wddxPacket = monitoringService.getActivityContributionURL(activityID); - PrintWriter writer = response.getWriter(); - writer.println(wddxPacket); - return null; - } public ActionForward moveLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, Index: lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java =================================================================== diff -u -r568197820cd33d3fb1bab3ea4ec180a58800fd65 -r049f9b1332a5f65c5de9d5b4f891b93fe429ae63 --- lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java (.../TestMonitoringService.java) (revision 568197820cd33d3fb1bab3ea4ec180a58800fd65) +++ lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java (.../TestMonitoringService.java) (revision 049f9b1332a5f65c5de9d5b4f891b93fe429ae63) @@ -288,11 +288,6 @@ testOrganisation = usermanageService.getOrganisationById(TEST_ORGANIZATION_ID); } - public void testGetActivityContributionURL() throws IOException{ - String packet = monitoringService.getActivityContributionURL(new Long(29)); - System.out.println(packet); - } - public void testCheckGateStatus() throws IOException { Long syncGateID = new Long(33);