Index: lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml,v
diff -u -r1.1 -r1.2
--- lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml 14 Apr 2006 06:42:53 -0000 1.1
+++ lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml 4 May 2006 07:01:24 -0000 1.2
@@ -58,6 +58,7 @@
+
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java,v
diff -u -r1.46 -r1.47
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java 3 Apr 2006 23:36:52 -0000 1.46
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java 4 May 2006 07:01:24 -0000 1.47
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/ContributionTypes.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/ContributionTypes.java 4 May 2006 07:01:24 -0000 1.1
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/LearningDesignProcessor.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/LearningDesignProcessor.java 4 May 2006 07:01:24 -0000 1.1
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/SimpleActivity.java,v
diff -u -r1.13 -r1.14
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SimpleActivity.java 3 Apr 2006 23:36:52 -0000 1.13
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SimpleActivity.java 4 May 2006 07:01:24 -0000 1.14
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GroupingActivityStrategy.java,v
diff -u -r1.6 -r1.7
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GroupingActivityStrategy.java 3 Apr 2006 23:36:53 -0000 1.6
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/GroupingActivityStrategy.java 4 May 2006 07:01:24 -0000 1.7
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java,v
diff -u -r1.8 -r1.9
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java 3 Apr 2006 23:36:53 -0000 1.8
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/PermissionGateActivityStrategy.java 4 May 2006 07:01:24 -0000 1.9
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ScheduleGateActivityStrategy.java,v
diff -u -r1.6 -r1.7
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ScheduleGateActivityStrategy.java 3 Apr 2006 23:36:53 -0000 1.6
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ScheduleGateActivityStrategy.java 4 May 2006 07:01:24 -0000 1.7
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SimpleActivityStrategy.java,v
diff -u -r1.7 -r1.8
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SimpleActivityStrategy.java 3 Apr 2006 23:36:53 -0000 1.7
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SimpleActivityStrategy.java 4 May 2006 07:01:24 -0000 1.8
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SynchGateActivityStrategy.java,v
diff -u -r1.5 -r1.6
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SynchGateActivityStrategy.java 3 Apr 2006 23:36:53 -0000 1.5
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/SynchGateActivityStrategy.java 4 May 2006 07:01:24 -0000 1.6
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ToolActivityStrategy.java,v
diff -u -r1.7 -r1.8
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ToolActivityStrategy.java 3 Apr 2006 23:36:53 -0000 1.7
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/strategy/ToolActivityStrategy.java 4 May 2006 07:01:24 -0000 1.8
@@ -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/usermanagement/dto/OrganisationDTO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/OrganisationDTO.java,v
diff -u -r1.6 -r1.7
--- lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/OrganisationDTO.java 2 May 2006 05:35:27 -0000 1.6
+++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/OrganisationDTO.java 4 May 2006 07:01:40 -0000 1.7
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_documents/lams_monitoring/Monitoring.doc,v
diff -u -r1.17 -r1.18
Binary files differ
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeActivityDTO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/Attic/ContributeActivityDTO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeActivityDTO.java 4 May 2006 06:58:23 -0000 1.1
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeDTOFactory.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/ContributeDTOFactory.java 4 May 2006 06:58:23 -0000 1.1
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java,v
diff -u -r1.43 -r1.44
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 26 Apr 2006 06:17:09 -0000 1.43
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 4 May 2006 06:58:23 -0000 1.44
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java,v
diff -u -r1.63 -r1.64
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 26 Apr 2006 06:17:09 -0000 1.63
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 4 May 2006 06:58:23 -0000 1.64
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java,v
diff -u -r1.26 -r1.27
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 26 Apr 2006 06:17:09 -0000 1.26
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 4 May 2006 06:58:23 -0000 1.27
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/Attic/TestMonitoringService.java,v
diff -u -r1.34 -r1.35
--- lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java 26 Apr 2006 06:17:09 -0000 1.34
+++ lams_monitoring/test/java/org/lamsfoundation/lams/monitoring/service/TestMonitoringService.java 4 May 2006 06:58:23 -0000 1.35
@@ -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);