Index: lams_build/lib/lams/lams.jar
===================================================================
diff -u -r009fbce36f45d0929f8007c4bbc798242f57d3af -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
Binary files differ
Index: lams_central/src/java/org/lamsfoundation/lams/authoring/authoringApplicationContext.xml
===================================================================
diff -u -r2f21856ec2ab85b47c93cfcc3fa2c8769be65077 -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_central/src/java/org/lamsfoundation/lams/authoring/authoringApplicationContext.xml (.../authoringApplicationContext.xml) (revision 2f21856ec2ab85b47c93cfcc3fa2c8769be65077)
+++ lams_central/src/java/org/lamsfoundation/lams/authoring/authoringApplicationContext.xml (.../authoringApplicationContext.xml) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -58,7 +58,7 @@
-
+
Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java
===================================================================
diff -u -r0d3db10064dce04801de82511dda34780ddccc52 -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 0d3db10064dce04801de82511dda34780ddccc52)
+++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -78,6 +78,8 @@
import org.lamsfoundation.lams.learningdesign.service.ILearningDesignService;
import org.lamsfoundation.lams.lesson.Lesson;
import org.lamsfoundation.lams.lesson.service.ILessonService;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.service.ILogEventService;
import org.lamsfoundation.lams.monitoring.service.IMonitoringService;
import org.lamsfoundation.lams.monitoring.service.MonitoringServiceException;
import org.lamsfoundation.lams.planner.dao.PedagogicalPlannerDAO;
@@ -157,6 +159,8 @@
protected IWorkspaceManagementService workspaceManagementService;
+ protected ILogEventService logEventService;
+
protected ToolContentIDGenerator contentIDGenerator;
/** The bean factory is used to create ObjectExtractor objects */
@@ -332,6 +336,10 @@
this.workspaceManagementService = workspaceManagementService;
}
+ public void setLogEventService(ILogEventService logEventService) {
+ this.logEventService = logEventService;
+ }
+
/**
* @param contentIDGenerator
* The contentIDGenerator to set.
@@ -1846,6 +1854,8 @@
.getCopyTypeID(), customCSV);
}
+
+ logEventService.logEvent(LogEvent.TYPE_TEACHER_LEARNING_DESIGN_CREATE, userID, design.getLearningDesignId(), null, null);
return design.getLearningDesignId();
}
Index: lams_common/build.xml
===================================================================
diff -u -r009fbce36f45d0929f8007c4bbc798242f57d3af -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_common/build.xml (.../build.xml) (revision 009fbce36f45d0929f8007c4bbc798242f57d3af)
+++ lams_common/build.xml (.../build.xml) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -434,6 +434,8 @@
+
+
Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/logevent/LogEvent.hbm.xml
===================================================================
diff -u
--- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/logevent/LogEvent.hbm.xml (revision 0)
+++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/logevent/LogEvent.hbm.xml (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_common/db/sql/create_lams_11_tables.sql
===================================================================
diff -u -r009fbce36f45d0929f8007c4bbc798242f57d3af -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 009fbce36f45d0929f8007c4bbc798242f57d3af)
+++ lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -877,16 +877,26 @@
)TYPE=InnoDB;
CREATE TABLE lams_log_event (
- log_event_id BIGINT(20) NOT NULL AUTO_INCREMENT
+ id BIGINT(20) NOT NULL AUTO_INCREMENT
, log_event_type_id INT(5) NOT NULL
- , user_id BIGINT(20)
- , timestamp DATETIME NOT NULL
- , ref_id BIGINT(20)
- , message VARCHAR(255)
- , PRIMARY KEY (log_event_id)
- , INDEX (log_event_type_id)
+ , user_id BIGINT(20) NOT NULL
+ , occurred_date_time DATETIME NOT NULL
+ , learning_design_id BIGINT(20)
+ , lesson_id BIGINT(20)
+ , activity_id BIGINT(20)
+ , PRIMARY KEY (id)
+ , INDEX (occurred_date_time)
, CONSTRAINT FK_lams_event_log_1 FOREIGN KEY (log_event_type_id)
REFERENCES lams_log_event_type (log_event_type_id)
+ , INDEX (user_id)
+ , CONSTRAINT FK_lams_event_log_2 FOREIGN KEY (user_id)
+ REFERENCES lams_user (user_id)
+ , CONSTRAINT FK_lams_event_log_3 FOREIGN KEY (learning_design_id)
+ REFERENCES lams_learning_design (learning_design_id)
+ , CONSTRAINT FK_lams_event_log_4 FOREIGN KEY (lesson_id)
+ REFERENCES lams_lesson (lesson_id)
+ , CONSTRAINT FK_lams_event_log_5 FOREIGN KEY (activity_id)
+ REFERENCES lams_learning_activity (activity_id)
)TYPE=InnoDB;
CREATE TABLE lams_workspace_folder_content (
Index: lams_common/db/sql/insert_types_data.sql
===================================================================
diff -u -r009fbce36f45d0929f8007c4bbc798242f57d3af -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision 009fbce36f45d0929f8007c4bbc798242f57d3af)
+++ lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -130,12 +130,12 @@
INSERT INTO lams_grouping_support_type VALUES (2 ,'OPTIONAL');
INSERT INTO lams_grouping_support_type VALUES (3 ,'REQUIRED');
-INSERT INTO lams_log_event_type VALUES (1, 'LEARNER_LESSON_START');
-INSERT INTO lams_log_event_type VALUES (2, 'LEARNER_LESSON_FINISH');
-INSERT INTO lams_log_event_type VALUES (3, 'LEARNER_LESSON_EXIT');
-INSERT INTO lams_log_event_type VALUES (4, 'LEARNER_LESSON_RESUME');
-INSERT INTO lams_log_event_type VALUES (5, 'LEARNER_ACTIVITY_START');
-INSERT INTO lams_log_event_type VALUES (6, 'LEARNER_ACTIVITY_FINISH');
+INSERT INTO lams_log_event_type VALUES (1, 'TYPE_TEACHER_LEARNING_DESIGN_CREATE');
+INSERT INTO lams_log_event_type VALUES (2, 'TYPE_TEACHER_LESSON_CREATE');
+INSERT INTO lams_log_event_type VALUES (3, 'TYPE_TEACHER_LESSON_START');
+INSERT INTO lams_log_event_type VALUES (4, 'TYPE_TEACHER_LESSON_CHANGE_STATE');
+INSERT INTO lams_log_event_type VALUES (5, 'TYPE_LEARNER_ACTIVITY_START');
+INSERT INTO lams_log_event_type VALUES (6, 'TYPE_LEARNER_ACTIVITY_FINISH');
INSERT INTO lams_wkspc_fld_content_type VALUES (1,'FILE');
INSERT INTO lams_wkspc_fld_content_type VALUES (2,'PACKAGE');
Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml
===================================================================
diff -u -r009fbce36f45d0929f8007c4bbc798242f57d3af -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 009fbce36f45d0929f8007c4bbc798242f57d3af)
+++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -69,6 +69,8 @@
classpath:org/lamsfoundation/lams/events/Event.hbm.xml
classpath:org/lamsfoundation/lams/events/Subscription.hbm.xml
+
+ classpath:org/lamsfoundation/lams/logevent/LogEvent.hbm.xml
classpath:org/lamsfoundation/lams/config/ConfigurationItem.hbm.xml
classpath:org/lamsfoundation/lams/config/Registration.hbm.xml
@@ -499,6 +501,25 @@
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+
+
+
+
@@ -570,6 +591,11 @@
+
+
+
+
+
Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040006.sql
===================================================================
diff -u -r009fbce36f45d0929f8007c4bbc798242f57d3af -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040006.sql (.../patch02040006.sql) (revision 009fbce36f45d0929f8007c4bbc798242f57d3af)
+++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040006.sql (.../patch02040006.sql) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -85,5 +85,40 @@
UPDATE lams_user SET timezone='Etc/GMT-11' WHERE timezone='29';
UPDATE lams_user SET timezone='Pacific/Auckland' WHERE timezone='30';
+-- LDEV-2550
+
+DROP TABLE IF EXISTS lams_log_event;
+CREATE TABLE lams_log_event (
+ id BIGINT(20) NOT NULL AUTO_INCREMENT
+ , log_event_type_id INT(5) NOT NULL
+ , user_id BIGINT(20) NOT NULL
+ , occurred_date_time DATETIME NOT NULL
+ , learning_design_id BIGINT(20)
+ , lesson_id BIGINT(20)
+ , activity_id BIGINT(20)
+ , PRIMARY KEY (id)
+ , INDEX (occurred_date_time)
+ , CONSTRAINT FK_lams_event_log_1 FOREIGN KEY (log_event_type_id)
+ REFERENCES lams_log_event_type (log_event_type_id)
+ , INDEX (user_id)
+ , CONSTRAINT FK_lams_event_log_2 FOREIGN KEY (user_id)
+ REFERENCES lams_user (user_id)
+ , CONSTRAINT FK_lams_event_log_3 FOREIGN KEY (learning_design_id)
+ REFERENCES lams_learning_design (learning_design_id)
+ , CONSTRAINT FK_lams_event_log_4 FOREIGN KEY (lesson_id)
+ REFERENCES lams_lesson (lesson_id)
+ , CONSTRAINT FK_lams_event_log_5 FOREIGN KEY (activity_id)
+ REFERENCES lams_learning_activity (activity_id)
+)TYPE=InnoDB;
+
+DELETE FROM lams_log_event_type;
+INSERT INTO lams_log_event_type VALUES (1, 'TYPE_TEACHER_LEARNING_DESIGN_CREATE');
+INSERT INTO lams_log_event_type VALUES (2, 'TYPE_TEACHER_LESSON_CREATE');
+INSERT INTO lams_log_event_type VALUES (3, 'TYPE_TEACHER_LESSON_START');
+INSERT INTO lams_log_event_type VALUES (4, 'TYPE_TEACHER_LESSON_CHANGE_STATE');
+INSERT INTO lams_log_event_type VALUES (5, 'TYPE_LEARNER_ACTIVITY_START');
+INSERT INTO lams_log_event_type VALUES (6, 'TYPE_LEARNER_ACTIVITY_FINISH');
+
+
COMMIT;
SET AUTOCOMMIT = 1;
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/logevent/LogEvent.java
===================================================================
diff -u
--- lams_common/src/java/org/lamsfoundation/lams/logevent/LogEvent.java (revision 0)
+++ lams_common/src/java/org/lamsfoundation/lams/logevent/LogEvent.java (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -0,0 +1,157 @@
+/****************************************************************
+ * 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.logevent;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.lamsfoundation.lams.usermanagement.User;
+
+/**
+ * Base class for all activities. If you add another subclass, you must update
+ * ActivityDAO.getActivityByActivityId() and add a ACTIVITY_TYPE constant.
+ *
+ * @hibernate.class table="lams_log_event"
+ */
+public class LogEvent implements Serializable {
+
+ private static final long serialVersionUID = 5275008411348257866L;
+
+ /***************************************************************************
+ * static final variables indicating the type of events
+ **************************************************************************/
+ public static final int TYPE_TEACHER_LEARNING_DESIGN_CREATE = 1;
+ public static final int TYPE_TEACHER_LESSON_CREATE = 2;
+ public static final int TYPE_TEACHER_LESSON_START = 3;
+ public static final int TYPE_TEACHER_LESSON_CHANGE_STATE = 4;
+ public static final int TYPE_LEARNER_ACTIVITY_START = 5;
+ public static final int TYPE_LEARNER_ACTIVITY_FINISH = 6;
+ /** *************************************************************** */
+
+ /** identifier field */
+ private Long id;
+
+ /** */
+ private Integer logEventTypeId;
+
+ /** persistent field */
+ //TODO perhaps make this field possible to be null
+ private User user;
+
+ /** Date this activity was created */
+ private Date occurredDateTime;
+
+ /** */
+ private Long learningDesignId;
+
+ /** */
+ private Long lessonId;
+
+ /** */
+ private Long activityId;
+
+ /*
+ * For the occurredDateTime fields, if the value is null, then it will default to the current time.
+ */
+
+ /** default constructor */
+ public LogEvent() {
+ occurredDateTime = new Date(); // default value is set to when the object is created
+ }
+
+ // ---------------------------------------------------------------------
+ // Getters and Setters
+ // ---------------------------------------------------------------------
+ /**
+ * @hibernate.id generator-class="native" type="java.lang.Long" column="id"
+ */
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * @hibernate.property column="log_event_type_id" length="5"
+ */
+ public Integer getLogEventTypeId() {
+ return logEventTypeId;
+ }
+ public void setLogEventTypeId(Integer logEventTypeId) {
+ this.logEventTypeId = logEventTypeId;
+ }
+
+ /**
+ * @hibernate.many-to-one not-null="true"
+ * @hibernate.column name="user_id"
+ */
+ public User getUser() {
+ return this.user;
+ }
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ /**
+ * @hibernate.property column="occurred_date_time" length="19" not-null="true"
+ */
+ public Date getOccurredDateTime() {
+ return occurredDateTime;
+ }
+ /* If occurredDateTime is null, then it will default to the current date/time */
+ public void setOccurredDateTime(Date occurredDateTime) {
+ this.occurredDateTime = occurredDateTime != null ? occurredDateTime : new Date();
+ }
+
+ /**
+ * @hibernate.property column="learning_design_id"
+ */
+ public Long getLearningDesignId() {
+ return learningDesignId;
+ }
+ public void setLearningDesignId(Long learningDesignId) {
+ this.learningDesignId = learningDesignId;
+ }
+
+ /**
+ * @hibernate.property column="lesson_id"
+ */
+ public Long getLessonId() {
+ return lessonId;
+ }
+ public void setLessonId(Long lessonId) {
+ this.lessonId = lessonId;
+ }
+
+ /**
+ * @hibernate.property column="activity_id"
+ */
+ public Long getActivityId() {
+ return activityId;
+ }
+ public void setActivityId(Long activityId) {
+ this.activityId = activityId;
+ }
+}
Index: lams_common/src/java/org/lamsfoundation/lams/logevent/dao/ILogEventDAO.java
===================================================================
diff -u
--- lams_common/src/java/org/lamsfoundation/lams/logevent/dao/ILogEventDAO.java (revision 0)
+++ lams_common/src/java/org/lamsfoundation/lams/logevent/dao/ILogEventDAO.java (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -0,0 +1,70 @@
+/****************************************************************
+ * 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.logevent.dao;
+
+import java.util.Date;
+import java.util.List;
+
+import org.lamsfoundation.lams.logevent.LogEvent;
+
+/**
+ * DAO interface for LogEvent
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.logevent.LogEvent
+ */
+public interface ILogEventDAO {
+
+ /**
+ * Records occurred event in database.
+ *
+ * @param logEvent occurred event
+ */
+ void save(LogEvent logEvent);
+
+ /**
+ * Returns event by the given id.
+ *
+ * @return
+ */
+ LogEvent getById(Long logEventId);
+
+ /**
+ * Returns all events initiated by user
+ *
+ * @param userId
+ * @return
+ */
+ List getByUser(Integer userId);
+
+ /**
+ * Returns all events occurred between specified dates
+ *
+ * @param startDate
+ * @param finishDate
+ * @return
+ */
+ List getEventsOccurredBetween(Date startDate, Date finishDate);
+
+}
Index: lams_common/src/java/org/lamsfoundation/lams/logevent/dao/hibernate/LogEventDAO.java
===================================================================
diff -u
--- lams_common/src/java/org/lamsfoundation/lams/logevent/dao/hibernate/LogEventDAO.java (revision 0)
+++ lams_common/src/java/org/lamsfoundation/lams/logevent/dao/hibernate/LogEventDAO.java (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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.logevent.dao.hibernate;
+
+import java.util.Date;
+import java.util.List;
+
+import org.lamsfoundation.lams.dao.hibernate.BaseDAO;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.dao.ILogEventDAO;
+
+/**
+ * Hibernate implementation of ILogEventDAO
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.timezone.dao.ILogEventDAO
+ */
+public class LogEventDAO extends BaseDAO implements ILogEventDAO {
+
+ private static final String GET_LOG_EVENT_BY_ID = "from " + LogEvent.class.getName()
+ + "where id = ?";
+
+ private static final String GET_LOG_EVENT_BY_USER = "from " + LogEvent.class.getName()
+ + " where user_id = ? order by occurred_date_time asc";
+
+ private static final String GET_LOG_EVENTS_OCCURED_BETWEEN_DATES = "from " + LogEvent.class.getName()
+ + " where occurred_date_time > ? and occurred_date_time <= ? order by occurred_date_time asc";
+
+ public void save(LogEvent logEvent) {
+ super.insert(logEvent);
+ }
+
+ public LogEvent getById(Long logEventId) {
+ List list = getHibernateTemplate().find(GET_LOG_EVENT_BY_ID, logEventId);
+ if (list.size() > 0) {
+ return (LogEvent) list.get(0);
+ } else {
+ return null;
+ }
+ }
+
+ public List getByUser(Integer userId) {
+ return getHibernateTemplate().find(GET_LOG_EVENT_BY_USER, userId);
+ }
+
+ public List getEventsOccurredBetween(Date startDate, Date finishDate) {
+ return getHibernateTemplate().find(GET_LOG_EVENTS_OCCURED_BETWEEN_DATES, new Date[] { startDate, finishDate });
+ }
+
+}
Index: lams_common/src/java/org/lamsfoundation/lams/logevent/service/ILogEventService.java
===================================================================
diff -u
--- lams_common/src/java/org/lamsfoundation/lams/logevent/service/ILogEventService.java (revision 0)
+++ lams_common/src/java/org/lamsfoundation/lams/logevent/service/ILogEventService.java (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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.logevent.service;
+
+import java.util.Date;
+import java.util.List;
+
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.usermanagement.User;
+
+/**
+ * Manages LogEvent
s.
+ *
+ * @author Andrey Balan
+ */
+public interface ILogEventService {
+
+ /**
+ * Records event of specified type in database.
+ *
+ * @param logEventTypeId
+ * @param userId
+ */
+ void logEvent(Integer logEventTypeId, Integer userId, Long learningDesignId, Long lessonId, Long activityId);
+
+ /**
+ * Returns event by the given id.
+ *
+ * @return
+ */
+ LogEvent getLogEventById(Long logEventId);
+
+ /**
+ * Returns all events initiated by user
+ *
+ * @param userId
+ * @return
+ */
+ List getLogEventByUser(Integer userId);
+
+ /**
+ * Returns all events occurred between specified dates
+ *
+ * @param startDate the first date
+ * @param finishDate the second date
+ * @return
+ */
+ List getEventsOccurredBetween(Date startDate, Date finishDate);
+
+}
Index: lams_common/src/java/org/lamsfoundation/lams/logevent/service/LogEventService.java
===================================================================
diff -u
--- lams_common/src/java/org/lamsfoundation/lams/logevent/service/LogEventService.java (revision 0)
+++ lams_common/src/java/org/lamsfoundation/lams/logevent/service/LogEventService.java (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -0,0 +1,127 @@
+/****************************************************************
+ * 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.logevent.service;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.events.IEventNotificationService;
+import org.lamsfoundation.lams.events.ResendMessagesJob;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.dao.ILogEventDAO;
+import org.lamsfoundation.lams.logevent.dao.hibernate.LogEventDAO;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.exception.UserException;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.usermanagement.service.UserManagementService;
+import org.quartz.JobDetail;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerException;
+import org.quartz.SimpleTrigger;
+import org.quartz.Trigger;
+
+/**
+ * Class implements ILogEventService
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.timezone.service.ILogEventService
+ */
+public class LogEventService implements ILogEventService{
+
+ private Logger log = Logger.getLogger(LogEventService.class);
+
+ /**
+ * The only instance of this class, since it is a singleton.
+ */
+ private static LogEventService instance;
+
+ private ILogEventDAO logEventDAO;
+ private IUserManagementService userManagementService;
+
+ /**
+ * Default constructor. Should be called only once, since this class in a singleton.
+ *
+ */
+ public LogEventService() {
+ if (LogEventService.instance == null) {
+ LogEventService.instance = this;
+ }
+ }
+
+ /**
+ * Gets the only existing instance of the class.
+ *
+ * @return instance of this class
+ */
+ public static LogEventService getInstance() {
+ return LogEventService.instance;
+ }
+
+ public void logEvent(Integer logEventTypeId, Integer userId, Long learningDesignId, Long lessonId, Long activityId) {
+ User user = (userId != null) ? (User) userManagementService.findById(User.class, userId) : null;
+ if (user == null) {
+ throw new RuntimeException("User can't be null");
+ }
+ LogEvent logEvent = new LogEvent();
+ logEvent.setLogEventTypeId(logEventTypeId);
+ logEvent.setUser(user);
+ logEvent.setLearningDesignId(learningDesignId);
+ logEvent.setLessonId(lessonId);
+ logEvent.setActivityId(activityId);
+ logEventDAO.save(logEvent);
+ }
+
+ public LogEvent getLogEventById(Long logEventId) {
+ return logEventDAO.getById(logEventId);
+ }
+
+ public List getLogEventByUser(Integer userId) {
+ return logEventDAO.getByUser(userId);
+ }
+
+ public List getEventsOccurredBetween(Date startDate, Date finishDate) {
+ return logEventDAO.getEventsOccurredBetween(startDate, finishDate);
+ }
+
+ /**
+ *
+ * @param logEventDAO
+ * The logEventDAO to set.
+ */
+ public void setLogEventDAO(LogEventDAO logEventDAO) {
+ this.logEventDAO = logEventDAO;
+ }
+
+ /**
+ *
+ * @param logEventDAO
+ * The logEventDAO to set.
+ */
+ public void setUserManagementService(IUserManagementService userManagementService) {
+ this.userManagementService = userManagementService;
+ }
+
+}
+
Index: lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml
===================================================================
diff -u -rea79f29aed5c764a223234e456442bc1e49fcf85 -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision ea79f29aed5c764a223234e456442bc1e49fcf85)
+++ lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -38,6 +38,7 @@
+
@@ -91,6 +92,7 @@
+
Index: lams_learning/src/java/org/lamsfoundation/lams/learning/progress/ProgressEngine.java
===================================================================
diff -u -racc8d2acf5b6b0002e0c8129947040a779ab4077 -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_learning/src/java/org/lamsfoundation/lams/learning/progress/ProgressEngine.java (.../ProgressEngine.java) (revision acc8d2acf5b6b0002e0c8129947040a779ab4077)
+++ lams_learning/src/java/org/lamsfoundation/lams/learning/progress/ProgressEngine.java (.../ProgressEngine.java) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -39,6 +39,8 @@
import org.lamsfoundation.lams.lesson.LearnerProgress;
import org.lamsfoundation.lams.lesson.Lesson;
import org.lamsfoundation.lams.lesson.ParallelWaitActivity;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.service.ILogEventService;
import org.lamsfoundation.lams.usermanagement.User;
/**
@@ -53,6 +55,7 @@
protected Logger log = Logger.getLogger(ProgressEngine.class);
private IActivityDAO activityDAO;
+ private ILogEventService logEventService;
/**
* Method determines next step for a learner based on the activity they have
@@ -222,6 +225,10 @@
}
}
+ logEventService.logEvent(LogEvent.TYPE_LEARNER_ACTIVITY_START, progress.getUser().getUserId(), activity
+ .getLearningDesign().getLearningDesignId(), progress.getLesson().getLessonId(), activity
+ .getActivityId());
+
// update activity
activityDAO.insertOrUpdate(activity);
}
@@ -409,5 +416,9 @@
public void setActivityDAO(IActivityDAO activityDAO) {
this.activityDAO = activityDAO;
}
+
+ public void setLogEventService(ILogEventService logEventService) {
+ this.logEventService = logEventService;
+ }
}
\ No newline at end of file
Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java
===================================================================
diff -u -r42213adc78e31e453830ee5c64fcc2716d6e46c1 -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java (.../LearnerService.java) (revision 42213adc78e31e453830ee5c64fcc2716d6e46c1)
+++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java (.../LearnerService.java) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -69,6 +69,8 @@
import org.lamsfoundation.lams.lesson.dto.LessonDTO;
import org.lamsfoundation.lams.lesson.service.ILessonService;
import org.lamsfoundation.lams.lesson.service.LessonServiceException;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.service.ILogEventService;
import org.lamsfoundation.lams.tool.ToolOutput;
import org.lamsfoundation.lams.tool.ToolOutputValue;
import org.lamsfoundation.lams.tool.ToolSession;
@@ -106,6 +108,7 @@
private static HashMap syncMap = new HashMap();
protected MessageService messageService;
private IGradebookService gradebookService;
+ private ILogEventService logEventService;
// ---------------------------------------------------------------------
// Inversion of Control Methods - Constructor injection
@@ -207,6 +210,10 @@
public void setLessonService(ILessonService lessonService) {
this.lessonService = lessonService;
}
+
+ public void setLogEventService(ILogEventService logEventService) {
+ this.logEventService = logEventService;
+ }
// ---------------------------------------------------------------------
// Service Methods
@@ -598,6 +605,9 @@
}
}
// }
+ logEventService.logEvent(LogEvent.TYPE_LEARNER_ACTIVITY_FINISH, learnerId, activity.getLearningDesign()
+ .getLearningDesignId(), progress.getLesson().getLessonId(), activity.getActivityId());
+
return nextLearnerProgress;
}
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml
===================================================================
diff -u -r6678c46bc0f79572b284532c43c9ddcfc4a39b33 -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml (.../monitoringApplicationContext.xml) (revision 6678c46bc0f79572b284532c43c9ddcfc4a39b33)
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml (.../monitoringApplicationContext.xml) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -41,7 +41,8 @@
-
+
+
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java
===================================================================
diff -u -r009fbce36f45d0929f8007c4bbc798242f57d3af -r8cbd631849cddfbfc7fb887e8a847894e5baaefa
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 009fbce36f45d0929f8007c4bbc798242f57d3af)
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 8cbd631849cddfbfc7fb887e8a847894e5baaefa)
@@ -78,6 +78,8 @@
import org.lamsfoundation.lams.lesson.dto.LessonDetailsDTO;
import org.lamsfoundation.lams.lesson.service.ILessonService;
import org.lamsfoundation.lams.lesson.service.LessonServiceException;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.service.ILogEventService;
import org.lamsfoundation.lams.monitoring.LearnerProgressBatchDTO;
import org.lamsfoundation.lams.monitoring.MonitoringConstants;
import org.lamsfoundation.lams.tool.ToolSession;
@@ -184,6 +186,8 @@
private MessageService messageService;
private AuditService auditService;
+
+ private ILogEventService logEventService;
/** Message keys */
private static final String FORCE_COMPLETE_STOP_MESSAGE_ACTIVITY_DONE = "force.complete.stop.message.activity.done";
@@ -342,6 +346,10 @@
public void setAuditService(AuditService auditService) {
this.auditService = auditService;
}
+
+ public void setLogEventService(ILogEventService logEventService) {
+ this.logEventService = logEventService;
+ }
// ---------------------------------------------------------------------
// Service Methods
@@ -422,9 +430,13 @@
}
User user = userID != null ? (User) baseDAO.find(User.class, userID) : null;
- return initializeLesson(lessonName, lessonDescription, learnerExportAvailable, originalLearningDesign, user,
+ Lesson initializedLesson = initializeLesson(lessonName, lessonDescription, learnerExportAvailable, originalLearningDesign, user,
runSeqFolder, LearningDesign.COPY_TYPE_LESSON, customCSV, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled);
-
+
+ Long initializedLearningDesignId = initializedLesson.getLearningDesign().getLearningDesignId();
+ logEventService.logEvent(LogEvent.TYPE_TEACHER_LESSON_CREATE, userID, initializedLearningDesignId, initializedLesson.getLessonId(), null);
+
+ return initializedLesson;
}
/**
@@ -852,6 +864,7 @@
if (MonitoringService.log.isDebugEnabled()) {
MonitoringService.log.debug("=============Lesson " + lessonId + " started===============");
}
+ logEventService.logEvent(LogEvent.TYPE_TEACHER_LESSON_START, userId, null, lessonId, null);
}
/**
@@ -1052,6 +1065,8 @@
requestedLesson.setPreviousLessonStateId(requestedLesson.getLessonStateId());
requestedLesson.setLessonStateId(status);
lessonDAO.updateLesson(requestedLesson);
+ logEventService.logEvent(LogEvent.TYPE_TEACHER_LESSON_CHANGE_STATE, requestedLesson.getUser().getUserId(),
+ null, requestedLesson.getLessonId(), null);
}
/**
@@ -1090,6 +1105,9 @@
requestedLesson.setPreviousLessonStateId(currentStatus);
}
lessonDAO.updateLesson(requestedLesson);
+
+ logEventService.logEvent(LogEvent.TYPE_TEACHER_LESSON_CHANGE_STATE, requestedLesson.getUser().getUserId(),
+ null, requestedLesson.getLessonId(), null);
}
/**