Index: lams_tool_forum/conf/language/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/conf/language/Attic/ApplicationResources.properties,v diff -u -r1.15 -r1.16 --- lams_tool_forum/conf/language/ApplicationResources.properties 9 Aug 2006 04:41:59 -0000 1.15 +++ lams_tool_forum/conf/language/ApplicationResources.properties 9 Aug 2006 07:09:27 -0000 1.16 @@ -154,4 +154,5 @@ label.authoring.advance.no.minimum=No minimum label.authoring.advance.no.maximum=No maximum error.min.less.max=The maximum number of posts must be greater than or equal to the minimum number of posts. -error.limit.char.less.zero=Limitation of input characters must be greater zero. \ No newline at end of file +error.limit.char.less.zero=Limitation of input characters must be greater zero. +error.less.mini.post=You must contribute at least {0} posts before finish. \ No newline at end of file Index: lams_tool_forum/conf/xdoclet/struts-actions.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/conf/xdoclet/struts-actions.xml,v diff -u -r1.36 -r1.37 --- lams_tool_forum/conf/xdoclet/struts-actions.xml 8 Aug 2006 01:56:34 -0000 1.36 +++ lams_tool_forum/conf/xdoclet/struts-actions.xml 9 Aug 2006 07:09:27 -0000 1.37 @@ -222,6 +222,7 @@ + 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.19 -r1.20 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java 15 Jun 2006 04:04:37 -0000 1.19 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java 9 Aug 2006 07:09:27 -0000 1.20 @@ -48,6 +48,10 @@ private static final String SQL_QUERY_BY_SESSION = "from " + Message.class.getName() + " m " + " where m.toolSession.sessionId=?"; + private static final String SQL_QUERY_TOPICS_NUMBER_BY_USER_SESSION = "select count(*) from " + Message.class.getName() + " m " + + " where m.createdBy.userId=? and m.toolSession.sessionId=? and m.isAuthored = false"; + + public void saveOrUpdate(Message message) { message.updateModificationData(); this.getHibernateTemplate().saveOrUpdate(message); @@ -95,12 +99,12 @@ } /** * Get all messages according to special user and session. - * @param userId + * @param userUid * @param sessionId * @return */ - public List getByUserAndSession(Long userId, Long sessionId) { - return this.getHibernateTemplate().find(SQL_QUERY_BY_USER_SESSION, new Object[]{userId,sessionId}); + public List getByUserAndSession(Long userUid, Long sessionId) { + return this.getHibernateTemplate().find(SQL_QUERY_BY_USER_SESSION, new Object[]{userUid,sessionId}); } /** * Get all messages according to special session. @@ -110,7 +114,18 @@ public List getBySession(Long sessionId) { return this.getHibernateTemplate().find(SQL_QUERY_BY_SESSION, sessionId); } - + /** + * Return how many post from this user and session. DOES NOT include posts from author. + * @param userID + * @param sessionId + * @return + */ + public int getTopicsNum(Long userID, Long sessionId) { + List list = this.getHibernateTemplate().find(SQL_QUERY_TOPICS_NUMBER_BY_USER_SESSION,new Object[]{userID,sessionId}); + if(list != null && list.size() > 0) + return ((Integer)list.get(0)).intValue(); + else + return 0; + } - } 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.60 -r1.61 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java 8 Aug 2006 01:56:34 -0000 1.60 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java 9 Aug 2006 07:09:27 -0000 1.61 @@ -356,6 +356,10 @@ } + public int getTopicsNum(Long userID, Long sessionId) { + return messageDao.getTopicsNum(userID,sessionId); + } + public ForumUser getUserByID(Long userId) { return forumUserDao.getByUserId(userId); } 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.30 -r1.31 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java 8 Aug 2006 01:56:34 -0000 1.30 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java 9 Aug 2006 07:09:27 -0000 1.31 @@ -202,6 +202,14 @@ * @return */ public List getMessagesByUserUid(Long userId, Long sessionId); + /** + * Get how many post of this user post in a special session. DOES NOT include posts from author. + * @param userID + * @param sessionId + * @return + */ + public int getTopicsNum(Long userID, Long sessionId); + //************************************************************************************ // Session Method //************************************************************************************ Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java,v diff -u -r1.33 -r1.34 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java 9 Aug 2006 05:17:32 -0000 1.33 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java 9 Aug 2006 07:09:27 -0000 1.34 @@ -54,6 +54,7 @@ public static final int SESSION_STATUS_FINISHED = 1; public static final String ALLOW_EDIT = "allowEdit"; public static final String ATTR_ALLOW_UPLOAD = "allowUpload"; + public static final String ATTR_ALLOW_NEW_TOPICS = "allowNewTopics"; public static final String ALLOW_RICH_EDITOR = "allowRichEditor"; public static final String LIMITED_CHARS = "limitedChars"; @@ -92,6 +93,9 @@ public static final String PARAM_UPDATE_MODE = "updateMode"; + public static final String ATTR_NO_MORE_POSTS = "noMorePosts"; + + } 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.37 -r1.38 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java 9 Aug 2006 05:17:32 -0000 1.37 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java 9 Aug 2006 07:09:27 -0000 1.38 @@ -42,6 +42,8 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; @@ -191,6 +193,7 @@ request.getSession().setAttribute(ForumConstants.FORUM_ID, forumId); request.getSession().setAttribute(ForumConstants.ALLOW_EDIT, forum.isAllowEdit()); request.getSession().setAttribute(ForumConstants.ATTR_ALLOW_UPLOAD,forum.isAllowUpload()); + request.getSession().setAttribute(ForumConstants.ATTR_ALLOW_NEW_TOPICS,forum.isAllowNewTopic()); request.getSession().setAttribute(ForumConstants.ALLOW_RICH_EDITOR, allowRichEditor); @@ -252,26 +255,32 @@ ToolAccessMode mode = (ToolAccessMode) request.getSession() .getAttribute(AttributeNames.ATTR_MODE); - ForumToolSession session = null; + forumService = getForumManager(); + ForumToolSession session = forumService.getSessionBySessionId(sessionId); if (mode == ToolAccessMode.LEARNER || mode==ToolAccessMode.AUTHOR) { - // get sessionId from HttpServletRequest - forumService = getForumManager(); - session = forumService - .getSessionBySessionId(sessionId); - session.setStatus(ForumConstants.SESSION_STATUS_FINISHED); - forumService.updateSession(session); - - ToolSessionManager sessionMgrService = ForumServiceProxy - .getToolSessionManager(getServlet().getServletContext()); - - // get back login user DTO + Forum forum = session.getForum(); // get session from shared session. HttpSession ss = SessionManager.getSession(); UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); Long userID = new Long(user.getUserID().longValue()); + if(!forum.getRunOffline() && !forum.isAllowNewTopic()){ + int postNum = forumService.getTopicsNum(userID,sessionId); + if(postNum < forum.getMinimumReply()){ + ActionMessages errors = new ActionMessages(); + errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("error.less.mini.post",(forum.getMinimumReply() - postNum))); + saveErrors(request, errors); + // get all root topic to display on init page + request.setAttribute(ForumConstants.ATTR_FORUM_TITLE,forum.getTitle()); + request.setAttribute(ForumConstants.ATTR_FORUM_INSTRCUTION,forum.getInstructions()); + List rootTopics = forumService.getRootTopics(sessionId); + request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); + return mapping.findForward("success"); + } + } String nextActivityUrl; try { + ToolSessionManager sessionMgrService = ForumServiceProxy.getToolSessionManager(getServlet().getServletContext()); nextActivityUrl = sessionMgrService.leaveToolSession(sessionId, userID); response.sendRedirect(nextActivityUrl); @@ -440,7 +449,6 @@ forumService.replyTopic(parentId, sessionId, message); // echo back this topic thread into page - forumService = getForumManager(); Long rootTopicId = forumService.getRootTopicId(parentId); List msgDtoList = forumService.getTopicThread(rootTopicId); setAuthorMark(msgDtoList); @@ -449,7 +457,17 @@ String title = getForumTitle(msgDtoList); request.setAttribute(ForumConstants.FORUM_TITLE,title); - + + //check whether allow more posts for this user + ForumToolSession session = forumService.getSessionBySessionId(sessionId); + Forum forum = session.getForum(); + if(forum != null){ + if(!forum.isAllowNewTopic()){ + int posts = forumService.getTopicsNum(forumUser.getUserId(), sessionId); + if(posts >= forum.getMaximumReply()) + request.getSession().setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, Boolean.TRUE); + } + } return mapping.findForward("success"); } Index: lams_tool_forum/web/WEB-INF/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/WEB-INF/Attic/struts-config.xml,v diff -u -r1.41 -r1.42 --- lams_tool_forum/web/WEB-INF/struts-config.xml 8 Aug 2006 02:32:47 -0000 1.41 +++ lams_tool_forum/web/WEB-INF/struts-config.xml 9 Aug 2006 07:09:27 -0000 1.42 @@ -256,6 +256,7 @@ + Index: lams_tool_forum/web/jsps/authoring/advance.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/authoring/advance.jsp,v diff -u -r1.14 -r1.15 --- lams_tool_forum/web/jsps/authoring/advance.jsp 9 Aug 2006 04:41:59 -0000 1.14 +++ lams_tool_forum/web/jsps/authoring/advance.jsp 9 Aug 2006 07:09:27 -0000 1.15 @@ -45,13 +45,27 @@ 1 2 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 1 2 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 Index: lams_tool_forum/web/jsps/learning/viewforum.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/viewforum.jsp,v diff -u -r1.8 -r1.9 --- lams_tool_forum/web/jsps/learning/viewforum.jsp 2 Jul 2006 04:14:27 -0000 1.8 +++ lams_tool_forum/web/jsps/learning/viewforum.jsp 9 Aug 2006 07:09:27 -0000 1.9 @@ -1,4 +1,4 @@ -<%@ include file="/includes/taglibs.jsp"%> +<%@ include file="/common/taglibs.jsp"%>

@@ -16,11 +16,17 @@ + + + <%@ include file="/common/messages.jsp"%> + + <%@ include file="/jsps/learning/message/topiclist.jsp"%> +
@@ -36,7 +42,7 @@
- + Index: lams_tool_forum/web/jsps/learning/message/topicview.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/message/topicview.jsp,v diff -u -r1.11 -r1.12 --- lams_tool_forum/web/jsps/learning/message/topicview.jsp 8 Aug 2006 02:32:47 -0000 1.11 +++ lams_tool_forum/web/jsps/learning/message/topicview.jsp 9 Aug 2006 07:09:27 -0000 1.12 @@ -114,7 +114,7 @@ - +