Index: lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/ForumToolSession.hbm.xml
===================================================================
diff -u -r920894ca746cba5e080023c5cc80167d64d1653d -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/ForumToolSession.hbm.xml (.../ForumToolSession.hbm.xml) (revision 920894ca746cba5e080023c5cc80167d64d1653d)
+++ lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/ForumToolSession.hbm.xml (.../ForumToolSession.hbm.xml) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -25,6 +25,12 @@
+
+
hibernateFilter
- org.lamsfoundation.lams.util.CustomizedOpenSessionInViewFilter
+ org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
sessionFactoryBeanName
Index: lams_tool_forum/db/sql/create_lams_tool_forum.sql
===================================================================
diff -u -r2700025047410d38f40b3bd7c56966a9fc08bb29 -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/db/sql/create_lams_tool_forum.sql (.../create_lams_tool_forum.sql) (revision 2700025047410d38f40b3bd7c56966a9fc08bb29)
+++ lams_tool_forum/db/sql/create_lams_tool_forum.sql (.../create_lams_tool_forum.sql) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -91,6 +91,7 @@
)TYPE=InnoDB;
create table tl_lafrum11_tool_session (
uid bigint not null auto_increment,
+ version integer not null,
session_end_date datetime,
session_start_date datetime,
status integer,
@@ -116,9 +117,9 @@
INSERT INTO tl_lafrum11_forum (uid,title,instructions,online_instructions,offline_instructions,content_id,allow_anonym,run_offline,lock_on_finished,content_in_use,define_later,allow_edit,allow_rich_editor, allow_new_topic,allow_upload,maximum_reply, minimum_reply,limited_input_flag,limited_of_chars,reflect_on_activity)
-VALUES(1,"LAMS Forum","Instruction","Online instruction","Offline instruction",${default_content_id},0,0,0,0,0,1,0,1,1,0,0,1,5000,0);
+VALUES(1,"Forum","Instructions",null,null,${default_content_id},0,0,0,0,0,1,0,1,1,1,0,1,5000,0);
INSERT INTO `tl_lafrum11_message` (`uid`, `create_date`, `last_reply_date`, `update_date`, `create_by`, `modified_by`, `subject`, `body`, `is_authored`, `is_anonymous`, `forum_session_uid`, `parent_uid`, `forum_uid`, `reply_number`, `hide_flag`, `report_id`) VALUES
- (1,NOW(),NOW(),NOW(),null,null,'Topic Title','Topic message',1,0,NULL,NULL,1,0,0,NULL);
+ (1,NOW(),NOW(),NOW(),null,null,'Topic Heading','Topic message',1,0,NULL,NULL,1,0,0,NULL);
SET FOREIGN_KEY_CHECKS=1;
\ No newline at end of file
Index: lams_tool_forum/db/sql/table-schema.sql
===================================================================
diff -u -r77e263b43c7aed360e8dcc46af273db55123bc83 -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/db/sql/table-schema.sql (.../table-schema.sql) (revision 77e263b43c7aed360e8dcc46af273db55123bc83)
+++ lams_tool_forum/db/sql/table-schema.sql (.../table-schema.sql) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -24,7 +24,7 @@
create table tl_lafrum11_message (uid bigint not null auto_increment, create_date datetime, last_reply_date datetime, update_date datetime, create_by bigint, modified_by bigint, subject varchar(255), body text, is_authored bit, is_anonymous bit, forum_session_uid bigint, parent_uid bigint, forum_uid bigint, reply_number integer, hide_flag bit, report_id bigint, primary key (uid));
create table tl_lafrum11_message_seq (uid bigint not null auto_increment, root_message_uid bigint, message_uid bigint, message_level smallint, primary key (uid));
create table tl_lafrum11_report (uid bigint not null auto_increment, comment text, release_date datetime, mark float, primary key (uid));
-create table tl_lafrum11_tool_session (uid bigint not null auto_increment, session_end_date datetime, session_start_date datetime, status integer, forum_uid bigint, session_id bigint, session_name varchar(250), mark_released bit, primary key (uid));
+create table tl_lafrum11_tool_session (uid bigint not null auto_increment, version integer not null, session_end_date datetime, session_start_date datetime, status integer, forum_uid bigint, session_id bigint, session_name varchar(250), mark_released bit, primary key (uid));
alter table tl_lafrum11_attachment add index FK389AD9A2FE939F2A (message_uid), add constraint FK389AD9A2FE939F2A foreign key (message_uid) references tl_lafrum11_message (uid);
alter table tl_lafrum11_attachment add index FK389AD9A2131CE31E (forum_uid), add constraint FK389AD9A2131CE31E foreign key (forum_uid) references tl_lafrum11_forum (uid);
alter table tl_lafrum11_forum add index FK87917942E42F4351 (create_by), add constraint FK87917942E42F4351 foreign key (create_by) references tl_lafrum11_forum_user (uid);
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java (.../ForumDao.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java (.../ForumDao.java) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -40,7 +40,6 @@
public void saveOrUpdate(Forum forum) {
forum.updateModificationData();
this.getHibernateTemplate().saveOrUpdate(forum);
- this.getHibernateTemplate().flush();
}
public Forum getById(Long forumId) {
@@ -56,7 +55,6 @@
*/
public void delete(Forum forum) {
this.getHibernateTemplate().delete(forum);
- this.getHibernateTemplate().flush();
}
public Forum getByContentId(Long contentID) {
@@ -66,8 +64,4 @@
else
return null;
}
- public void flush() {
- this.getHibernateTemplate().flush();
- }
-
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumToolSession.hbm.xml
===================================================================
diff -u -r920894ca746cba5e080023c5cc80167d64d1653d -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumToolSession.hbm.xml (.../ForumToolSession.hbm.xml) (revision 920894ca746cba5e080023c5cc80167d64d1653d)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumToolSession.hbm.xml (.../ForumToolSession.hbm.xml) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -25,6 +25,12 @@
+
+
0)
- return ((Number)list.get(0)).longValue() > 0 ? true:false;
- else
- return false;
- }
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java
===================================================================
diff -u -r40632908af1b31e1af4f1607b0ee4031ab098a84 -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 40632908af1b31e1af4f1607b0ee4031ab098a84)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -418,9 +418,6 @@
return MessageDTO.getMessageDTO(new ArrayList(map.values()));
}
- public void updateSession(ForumToolSession session) {
- forumToolSessionDao.saveOrUpdate(session);
- }
public Long getToolDefaultContentIdBySignature(String toolSignature)
{
@@ -478,7 +475,10 @@
public void cloneContentTopics(Long contentID, Long sessionID) {
//only session does not have content topcis
- if(!messageDao.hasAuthoredTopics(sessionID)){
+ ForumToolSession session = forumToolSessionDao.getBySessionId(sessionID);
+
+ if(session.getStatus() != ForumConstants.STATUS_CONTENT_COPYED){
+
log.debug("Clone tool content [" + contentID +"] topics for session [" + sessionID + "]");
Forum forum = (Forum) forumDao.getByContentId(contentID);
@@ -493,6 +493,10 @@
}
}
}
+ //update status to avoid duplicate clone when next learner get in.
+ session.setStatus(ForumConstants.STATUS_CONTENT_COPYED);
+ forumToolSessionDao.saveOrUpdate(session);
+
}
}
//***************************************************************************************************************
@@ -643,7 +647,6 @@
}
forum.setDefineLater(true);
forum.setContentInUse(false);
- forumDao.flush();
}
public void setAsRunOffline(Long toolContentId) throws DataMissingException, ToolException {
@@ -652,7 +655,7 @@
throw new ToolException("No found tool content by given content ID:" + toolContentId);
}
forum.setRunOffline(true);
- forumDao.flush();
+
}
public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException {
@@ -785,7 +788,6 @@
ForumToolSession session = forumToolSessionDao.getBySessionId(toolSessionId);
if(session != null){
- session.setStatus(ForumConstants.COMPLETED);
forumToolSessionDao.saveOrUpdate(session);
}else{
log.error("Fail to leave tool Session.Could not find submit file " +
@@ -1081,4 +1083,5 @@
this.coreNotebookService = coreNotebookService;
}
+
}
\ No newline at end of file
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -233,12 +233,8 @@
* @return
*/
public ForumToolSession getSessionBySessionId(Long sessionId);
+
/**
- * Update Forum Tool Session record in database.
- * @param session
- */
- public void updateSession(ForumToolSession session);
- /**
* Get session list according to content ID.
* @param contentID
* @return List
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java
===================================================================
diff -u -re32edf3f59266506e8fdbd10f7b61175111fc4dc -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java (.../ForumConstants.java) (revision e32edf3f59266506e8fdbd10f7b61175111fc4dc)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java (.../ForumConstants.java) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -40,7 +40,7 @@
// should be at the top, reply date will descide the order etc.
public static final boolean OLD_FORUM_STYLE = true;
- public static final int COMPLETED = 1;
+ public static final int STATUS_CONTENT_COPYED = 1;
public static final int SESSION_STATUS_FINISHED = 1;
public final static int MAX_FILE_SIZE = 250 * 1000;
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java
===================================================================
diff -u -rd2ad9c74c4bc96de33e1a85c99b458e573afa60d -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision d2ad9c74c4bc96de33e1a85c99b458e573afa60d)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -67,6 +67,7 @@
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
import org.lamsfoundation.lams.web.util.SessionMap;
+import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
@@ -189,7 +190,11 @@
//try to clone topics from :See bug LDEV-649
Long contentId = forum.getContentId();
- forumService.cloneContentTopics(contentId, sessionId);
+ try {
+ forumService.cloneContentTopics(contentId, sessionId);
+ } catch (ObjectOptimisticLockingFailureException e) {
+ log.debug("Multiple learner get into forum simultaneously. Duplicated content root topics cloning skipped.");
+ }
//set some option flag to HttpSession
Long forumId = forum.getUid();
@@ -458,8 +463,10 @@
MessageDTO topic = getTopic(parentId);
if (topic != null && topic.getMessage() != null) {
+ String reTitle = topic.getMessage().getSubject();
// echo back current topic subject to web page
- msgForm.getMessage().setSubject("Re:" + topic.getMessage().getSubject());
+ if(reTitle != null && !reTitle.trim().startsWith("Re:"))
+ msgForm.getMessage().setSubject("Re:" + reTitle);
}
SessionMap sessionMap = getSessionMap(request, msgForm);
sessionMap.put(ForumConstants.ATTR_PARENT_TOPIC_ID, parentId);
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/service/ForumServiceTest.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/service/ForumServiceTest.java (.../ForumServiceTest.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/service/ForumServiceTest.java (.../ForumServiceTest.java) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -193,15 +193,7 @@
forumDao.delete(forum);
forumUserDao.delete(user);
}
- public void testUpdateSession() throws DataMissingException, ToolException{
- ForumToolSession sessionA = TestUtils.getSessionA();
- forumService.updateSession(sessionA);
- ForumToolSession session = forumService.getSessionBySessionId(sessionA.getSessionId());
- assertEquals(session,sessionA);
-
- //remove test data.
- sessionManager.removeToolSession(sessionA.getSessionId());
- }
+
public void testCreateUser(){
ForumUser userA = TestUtils.getUserA();
forumService.createUser(userA);
Index: lams_tool_forum/web/WEB-INF/web.xml
===================================================================
diff -u -r48ecaca457cd67a79a45aa681613f2d9f058e0d0 -r4526bc668178760326017e561b75a0358e10b4fb
--- lams_tool_forum/web/WEB-INF/web.xml (.../web.xml) (revision 48ecaca457cd67a79a45aa681613f2d9f058e0d0)
+++ lams_tool_forum/web/WEB-INF/web.xml (.../web.xml) (revision 4526bc668178760326017e561b75a0358e10b4fb)
@@ -30,7 +30,7 @@
hibernateFilter
- org.lamsfoundation.lams.util.CustomizedOpenSessionInViewFilter
+ org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
sessionFactoryBeanName
@@ -241,7 +241,6 @@
AUTHOR
ADMIN
SYSADMIN
- AUTHOR ADMIN
@@ -252,8 +251,6 @@
AUTHOR
- AUTHOR ADMIN
- SYSADMIN
@@ -284,7 +281,6 @@
ADMIN
- AUTHOR ADMIN
@@ -307,7 +303,6 @@
MONITOR
TEACHER
ADMIN
- AUTHOR ADMIN
SYSADMIN
@@ -343,10 +338,6 @@
Can add/remove users to the system, set up classes of users for sessions
SYSADMIN
-
- Can create/modify a learning design and edit default tool content
- AUTHOR ADMIN
-
FORM