Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/forumApplicationContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/forumApplicationContext.xml,v diff -u -r1.12 -r1.13 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/forumApplicationContext.xml 29 Aug 2006 04:36:24 -0000 1.12 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/forumApplicationContext.xml 29 Aug 2006 05:01:48 -0000 1.13 @@ -138,6 +138,7 @@ PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception + PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception @@ -147,4 +148,4 @@ - + \ No newline at end of file Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java,v diff -u -r1.20 -r1.21 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java 9 Aug 2006 07:09:27 -0000 1.20 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java 29 Aug 2006 05:01:47 -0000 1.21 @@ -39,6 +39,9 @@ private static final String SQL_QUERY_FIND_TOPICS_FROM_AUTHOR = "from " + Message.class.getName() + " where is_authored = true and forum_uid=? order by create_date"; + private static final String SQL_QUERY_COUNT_SESSION_TOPICS_FROM_AUTHOR = "select count(*) from " + Message.class.getName() + + " as m where m.isAuthored = true and m.toolSession.uid=?"; + private static final String SQL_QUERY_FIND_CHILDREN = "from " + Message.class.getName() + " where parent=?"; @@ -127,5 +130,12 @@ else return 0; } + public boolean hasAuthoredTopics(Long sessionId) { + List list = this.getHibernateTemplate().find(SQL_QUERY_COUNT_SESSION_TOPICS_FROM_AUTHOR,new Object[]{sessionId}); + if(list != null && list.size() > 0) + return ((Integer)list.get(0)).intValue() > 0 ? true:false; + else + return false; + } } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java,v diff -u -r1.66 -r1.67 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java 29 Aug 2006 04:36:24 -0000 1.66 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java 29 Aug 2006 05:01:47 -0000 1.67 @@ -459,7 +459,25 @@ currentUser.setSessionFinished(true); forumUserDao.save(currentUser); } - + + public void cloneContentTopics(Long contentID, Long sessionID) { + //only session does not have content topcis + if(!messageDao.hasAuthoredTopics(sessionID)){ + Forum forum = (Forum) forumDao.getByContentId(contentID); + Set contentTopcis = forum.getMessages(); + + //only forum has content topics, clone happens + if(contentTopcis != null && contentTopcis.size() > 0){ + Iterator iter = contentTopcis.iterator(); + ForumToolSession session = forumToolSessionDao.getBySessionId(sessionID); + while(iter.hasNext()){ + Message msg = (Message) iter.next(); + msg.setToolSession(session); + messageDao.update(msg); + } + } + } + } //*************************************************************************************************************** // Private methods //*************************************************************************************************************** @@ -583,6 +601,7 @@ continue; msg.setReplyNumber(0); msg.setCreated(new Date()); + msg.setUpdated(new Date()); msg.setLastReplyDate(new Date()); msg.setHideFlag(false); msg.setForum(toContent); @@ -718,34 +737,11 @@ Forum forum = forumDao.getByContentId(toolContentId); session.setForum(forum); forumToolSessionDao.saveOrUpdate(session); - - //also clone author created topic from this forum tool content!!! - //this can avoid topic record information conflict when multiple sessions are against same tool content - //for example, the reply number maybe various for different sessions. - List topicsFromAuthor = messageDao.getTopicsFromAuthor(session.getForum().getUid()); - - //sorted by last post date - Message msg; - SortedMap map = new TreeMap(new DateComparator()); - Iterator iter = topicsFromAuthor.iterator(); - while(iter.hasNext()){ - msg = (Message) iter.next(); - //Don't copy other session's topic, only from tool content!!!. - if(msg.getToolSession() != null) - continue; - //set this message forum Uid as toContent - if(!msg.getIsAuthored()) - continue; - Message newMsg = (Message) msg.clone(); - //reset some value. - newMsg.setReplyNumber(0); - newMsg.setHideFlag(false); - //it should be new message - newMsg.setUid(null); - //!!! set current session to authored message - newMsg.setToolSession(session); - createRootTopic(toolContentId,null,newMsg); - } + + //Update(29/08/2006): Do not clone author topic BUG: LDEV-649. +// also clone author created topic from this forum tool content!!! +// this can avoid topic record information conflict when multiple sessions are against same tool content +// for example, the reply number maybe various for different sessions. } public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { @@ -1030,4 +1026,6 @@ this.forumReportDAO = forumReportDAO; } + + } \ No newline at end of file Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java,v diff -u -r1.32 -r1.33 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java 23 Aug 2006 06:54:01 -0000 1.32 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java 29 Aug 2006 05:01:47 -0000 1.33 @@ -90,6 +90,18 @@ * @throws PersistenceException */ public void deleteForumAttachment(Long attachmentId) throws PersistenceException; + + /** + * Clone topics from tool content and give these new topics with given SessionID if + * this session has not such topics yet. + * This method will be called once learner page open. Program does not + * clone content topics when createToolSession() is called, the reason is define later + * page could change content topics. For more detail see LDEV-649. + * + * @param contentID + * @param sessionID + */ + public void cloneContentTopics(Long contentID, Long sessionID); //************************************************************************************ //Topic Method //************************************************************************************ Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java,v diff -u -r1.51 -r1.52 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java 29 Aug 2006 01:10:05 -0000 1.51 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java 29 Aug 2006 05:01:47 -0000 1.52 @@ -178,7 +178,7 @@ //get back the topic list and display them on page forumService = getForumManager(); - List topics = null; + List topics = null; Forum forum = null; try { forum = forumService.getForumByContentId(contentId); @@ -213,7 +213,7 @@ //set back STRUTS component value //init it to avoid null exception in following handling if(topics == null) - topics = new ArrayList(); + topics = new ArrayList(); sessionMap.put(ForumConstants.AUTHORING_TOPICS_LIST, topics); return mapping.findForward("success"); Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java,v diff -u -r1.42 -r1.43 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java 24 Aug 2006 00:05:20 -0000 1.42 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java 29 Aug 2006 05:01:47 -0000 1.43 @@ -127,10 +127,11 @@ /** * Display root topics of a forum. This page will be the initial page of * Learner page. + * @throws Exception * */ private ActionForward viewForm(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) { + HttpServletRequest request, HttpServletResponse response) throws Exception { //initial Session Map String sessionMapID = request.getParameter(ForumConstants.ATTR_SESSION_MAP_ID); @@ -161,11 +162,12 @@ // Try to get ForumID according to sessionId forumService = getForumManager(); ForumToolSession session = forumService.getSessionBySessionId(sessionId); + if (session == null || session.getForum() == null) { log.error("Failed on getting session by given sessionID:" + sessionId); - return mapping.findForward("error"); + throw new Exception("Failed on getting session by given sessionID:" + sessionId); } - + Forum forum = session.getForum(); //lock on finish ForumUser forumUser = getCurrentUser(request,sessionId); @@ -180,6 +182,12 @@ return mapping.findForward("runOffline"); } + + //try to clone topics from :See bug LDEV-649 + Long contentId = forum.getContentId(); + forumService.cloneContentTopics(contentId, sessionId); + + //set some option flag to HttpSession Long forumId = forum.getUid(); Boolean allowRichEditor = new Boolean(forum.isAllowRichEditor()); int allowNumber = forum.getLimitedChar();