Index: lams_tool_forum/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/conf/language/lams/ApplicationResources.properties,v diff -u -r1.15 -r1.16 --- lams_tool_forum/conf/language/lams/ApplicationResources.properties 9 May 2008 04:23:34 -0000 1.15 +++ lams_tool_forum/conf/language/lams/ApplicationResources.properties 9 May 2008 04:26:53 -0000 1.16 @@ -152,7 +152,7 @@ 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. -error.less.mini.post =You must contribute at least {0} posts before finish. +error.less.mini.post =You must contribute at least {0} posts in each topic before finish. error.must.have.topic =Please add at least 1 topic when "allow learners to create new topics" option is off. msg.mark.released =Marks in {0} have been released. label.authoring.advance.allow.new.topics =Allow learners to create new topics @@ -175,6 +175,8 @@ label.attachments =Attachments error.mark.needNumber =Mark must be a number monitoring.marked.question =Marked? +label.postingLimits.forum.reminder = Posting for this forum: Minimum {0} and Maximum {1}. +label.postingLimits.topic.reminder = Posting for this thread: Minimum {0} and Maximum {1}. You have posted {2} message. You must post {3} more. #======= End labels: Exported 169 labels for en AU ===== Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dto/MessageDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dto/MessageDTO.java,v diff -u -r1.16 -r1.17 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dto/MessageDTO.java 10 Oct 2006 04:19:50 -0000 1.16 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dto/MessageDTO.java 9 May 2008 04:21:31 -0000 1.17 @@ -45,6 +45,10 @@ private String comment; private boolean released; + // number of posts the learner has made in this topic. + // used when this message is a root topic. + private int numOfPosts; + //2 fields use for export portfolio function private String attachmentName; private String attachmentLocalUrl; @@ -190,5 +194,12 @@ this.attachmentName = attachmentName; } - + public int getNumOfPosts() { + return numOfPosts; + } + + public void setNumOfPosts(int numOfPosts) { + this.numOfPosts = numOfPosts; + } + } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageSeqDao.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageSeqDao.java,v diff -u -r1.4 -r1.5 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageSeqDao.java 17 Sep 2006 06:22:30 -0000 1.4 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageSeqDao.java 9 May 2008 04:21:31 -0000 1.5 @@ -34,7 +34,10 @@ + " where root_message_uid = ?"; private static final String SQL_QUERY_FIND_TOPIC_ID = "from " + MessageSeq.class.getName() + " where message_uid = ?"; - + + private static final String SQL_QUERY_NUM_POSTS_BY_TOPIC = "select count(*) from " + + MessageSeq.class.getName() + " ms where ms.message.createdBy.userId=? and ms.message.isAuthored = false and ms.rootMessage=?"; + public List getTopicThread(Long rootTopicId) { return this.getHibernateTemplate().find(SQL_QUERY_FIND_TOPIC_THREAD,rootTopicId); } @@ -55,6 +58,14 @@ if(seq != null) this.getHibernateTemplate().delete(seq); } + + public int getNumOfPostsByTopic(Long userID, Long topicID) { + List list = this.getHibernateTemplate().find(SQL_QUERY_NUM_POSTS_BY_TOPIC, new Object[]{userID,topicID}); + if(list != null && list.size() > 0) + return ((Number)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.92 -r1.93 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java 2 May 2008 09:00:10 -0000 1.92 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java 9 May 2008 04:21:31 -0000 1.93 @@ -400,6 +400,10 @@ public int getTopicsNum(Long userID, Long sessionId) { return messageDao.getTopicsNum(userID,sessionId); } + + public int getNumOfPostsByTopic(Long userId, Long topicId) { + return messageSeqDao.getNumOfPostsByTopic(userId, topicId); + } 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.39 -r1.40 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java 20 Feb 2008 04:07:04 -0000 1.39 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java 9 May 2008 04:21:31 -0000 1.40 @@ -212,6 +212,13 @@ * @return */ public int getTopicsNum(Long userID, Long sessionId); + /** + * Returns the number of posts this user has made in this topic. + * @param userId + * @param topicId + * @return + */ + public int getNumOfPostsByTopic(Long userId, Long topicId); //************************************************************************************ // 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.48 -r1.49 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java 7 May 2008 06:33:46 -0000 1.48 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java 9 May 2008 04:21:32 -0000 1.49 @@ -102,6 +102,7 @@ public static final String PARAM_UPDATE_MODE = "updateMode"; public static final String ATTR_NO_MORE_POSTS = "noMorePosts"; + public static final String ATTR_NUM_OF_POSTS = "numOfPosts"; public static final String ATTR_SESSION_MAP_ID = "sessionMapID"; @@ -114,6 +115,9 @@ public static final String ATTR_REFLECTION_ON = "reflectOn"; public static final String ATTR_REFLECTION_INSTRUCTION = "reflectInstructions"; public static final String ATTR_REFLECTION_ENTRY = "reflectEntry"; + + public static final String ATTR_MINIMUM_REPLY = "minimumReply"; + public static final String ATTR_MAXIMUM_REPLY = "maximumReply"; public static final String MARK_UPDATE_FROM_SESSION = "listAllMarks"; public static final String MARK_UPDATE_FROM_USER = "listMarks"; @@ -122,6 +126,7 @@ public static final String ATTR_HIDE_REFLECTION = "hideReflection"; + } 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.61 -r1.62 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java 7 May 2008 06:33:44 -0000 1.61 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java 9 May 2008 04:21:31 -0000 1.62 @@ -68,7 +68,6 @@ 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; @@ -88,7 +87,7 @@ String param = mapping.getParameter(); // --------------Forum Level ------------------ if (param.equals("viewForum")) { - return viewForm(mapping, form, request, response); + return viewForum(mapping, form, request, response); } if (param.equals("finish")) { return finish(mapping, form, request, response); @@ -146,7 +145,7 @@ * @throws Exception * */ - private ActionForward viewForm(ActionMapping mapping, ActionForm form, + private ActionForward viewForum(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //initial Session Map @@ -210,6 +209,8 @@ sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId); sessionMap.put(ForumConstants.ATTR_FORUM_TITLE,forum.getTitle()); sessionMap.put(ForumConstants.ATTR_FORUM_INSTRCUTION,forum.getInstructions()); + sessionMap.put(ForumConstants.ATTR_MINIMUM_REPLY, forum.getMinimumReply()); + sessionMap.put(ForumConstants.ATTR_MAXIMUM_REPLY, forum.getMaximumReply()); // Should we show the reflection or not? We shouldn't show it when the screen is accessed // from the Monitoring Summary screen, but we should when accessed from the Learner Progress screen. @@ -248,11 +249,22 @@ // get all root topic to display on init page List rootTopics = forumService.getRootTopics(sessionId); + if (!forum.isAllowNewTopic()) { + // add the number post the learner has made for each topic. + updateNumOfPosts(rootTopics, forumUser); + } request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); return mapping.findForward("success"); } + private void updateNumOfPosts(List rootTopics, ForumUser forumUser) { + for (Iterator iterator = rootTopics.iterator(); iterator.hasNext();) { + MessageDTO messageDTO = (MessageDTO) iterator.next(); + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), messageDTO.getMessage().getUid()); + messageDTO.setNumOfPosts(numOfPosts); + } + } /** * Learner click "finish" button in forum page, this method will turn on @@ -400,16 +412,28 @@ private ActionForward viewTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long rootTopicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); forumService = getForumManager(); + + Long rootTopicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); + + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + sessionMap.put(ForumConstants.ATTR_ROOT_TOPIC_UID, rootTopicId); + + // get forum user and forum + ForumUser forumUser = getCurrentUser(request, (Long)sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)); + Forum forum = forumUser.getSession().getForum(); + // get root topic list List msgDtoList = forumService.getTopicThread(rootTopicId); updateMesssageFlag(msgDtoList); request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); - String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); - sessionMap.put(ForumConstants.ATTR_ROOT_TOPIC_UID, rootTopicId); + // check if we can still make posts in this topic + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), ((MessageDTO)msgDtoList.get(0)).getMessage().getUid()); + boolean noMorePosts = (numOfPosts >= forum.getMaximumReply())?Boolean.TRUE:Boolean.FALSE; + request.setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts); + request.setAttribute(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts); //transfer SessionMapID as well request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); @@ -581,13 +605,11 @@ //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(forum.getMaximumReply() != 0 && (posts >= forum.getMaximumReply())) - sessionMap.put(ForumConstants.ATTR_NO_MORE_POSTS, Boolean.TRUE); - } - } + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), ((MessageDTO)msgDtoList.get(0)).getMessage().getUid()); + boolean noMorePosts = (numOfPosts >= forum.getMaximumReply())?Boolean.TRUE:Boolean.FALSE; + request.setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts); + request.setAttribute(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts); + sessionMap.remove(ForumConstants.ATTR_ORIGINAL_MESSAGE); return mapping.findForward("success"); @@ -711,6 +733,14 @@ List msgDtoList = forumService.getTopicThread(rootTopicId); updateMesssageFlag(msgDtoList); + // check if we can still make posts in this topic + ForumUser forumUser = getCurrentUser(request, (Long)sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)); + Forum forum = forumUser.getSession().getForum(); + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), ((MessageDTO)msgDtoList.get(0)).getMessage().getUid()); + boolean noMorePosts = (numOfPosts >= forum.getMaximumReply())?Boolean.TRUE:Boolean.FALSE; + request.setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts); + request.setAttribute(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts); + request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID,messageForm.getSessionMapID()); @@ -752,15 +782,14 @@ // log.info(currentUser + "does not have permission to hide/show postings in forum: " + forum.getUid()); // log.info("Forum created by :" + forumCreatedBy.getUid() + ", Current User is: " + currentUser.getUid()); // } - // echo back this topic thread into page Long rootTopicId = forumService.getRootTopicId(msgId); List msgDtoList = forumService.getTopicThread(rootTopicId); updateMesssageFlag(msgDtoList); request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID,WebUtil.readStrParam(request,ForumConstants.ATTR_SESSION_MAP_ID)); - + return mapping.findForward("success"); } @@ -781,18 +810,24 @@ 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()){ - //create error - 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 - List rootTopics = forumService.getRootTopics(sessionId); - request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); - request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID ); - return false; + + List list = forumService.getRootTopics(sessionId); + for (MessageDTO msgDto: list) { + Long topicId = msgDto.getMessage().getUid(); + int numOfPostsInTopic = forumService.getNumOfPostsByTopic(userID, topicId); + if (numOfPostsInTopic < forum.getMinimumReply()) { + //create error + ActionMessages errors = new ActionMessages(); + errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("error.less.mini.post",(forum.getMinimumReply()))); + saveErrors(request, errors); + + // get all root topic to display on init page + List rootTopics = forumService.getRootTopics(sessionId); + request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID ); + return false; + } + } } return true; 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.26 -r1.27 --- lams_tool_forum/web/jsps/learning/viewforum.jsp 7 May 2008 06:34:30 -0000 1.26 +++ lams_tool_forum/web/jsps/learning/viewforum.jsp 9 May 2008 04:21:42 -0000 1.27 @@ -1,5 +1,6 @@ <%@ include file="/common/taglibs.jsp"%> - +
@@ -12,20 +13,32 @@
- - -
- - - - - - - - -
+ + +
+ + + + + + + + +
+
+ + +
+ + + + +
+
+
-
<%@ include file="/common/messages.jsp"%> @@ -72,7 +85,8 @@ - +

${sessionMap.reflectInstructions} Index: lams_tool_forum/web/jsps/learning/viewtopic.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/viewtopic.jsp,v diff -u -r1.16 -r1.17 --- lams_tool_forum/web/jsps/learning/viewtopic.jsp 7 May 2008 06:34:30 -0000 1.16 +++ lams_tool_forum/web/jsps/learning/viewtopic.jsp 9 May 2008 04:21:42 -0000 1.17 @@ -14,6 +14,7 @@

${sessionMap.title}

+
@@ -25,15 +26,29 @@ styleClass="button"> -

- + + +
+ + + + + + +
+
+
+
+ <%@ include file="message/topicview.jsp"%> @@ -50,14 +65,10 @@ styleClass="button"> -
- - - Index: lams_tool_forum/web/jsps/learning/message/topiclist.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/message/topiclist.jsp,v diff -u -r1.13 -r1.14 --- lams_tool_forum/web/jsps/learning/message/topiclist.jsp 7 May 2008 06:34:30 -0000 1.13 +++ lams_tool_forum/web/jsps/learning/message/topiclist.jsp 9 May 2008 04:21:42 -0000 1.14 @@ -15,6 +15,12 @@ + + +   + + @@ -45,6 +51,12 @@ + + + ${topic.numOfPosts} / ${sessionMap.minimumReply} + + 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.27 -r1.28 --- lams_tool_forum/web/jsps/learning/message/topicview.jsp 7 May 2008 06:34:30 -0000 1.27 +++ lams_tool_forum/web/jsps/learning/message/topicview.jsp 9 May 2008 04:21:42 -0000 1.28 @@ -62,7 +62,6 @@ -
@@ -147,7 +146,7 @@ + test="${(not sessionMap.finishedLock) && (not noMorePosts) && (sessionMap.mode ne 'teacher')}">