Index: lams_tool_forum/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r5b3d4f5da53c310a16fe0498fc1e95261569c67b -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 5b3d4f5da53c310a16fe0498fc1e95261569c67b) +++ lams_tool_forum/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -241,4 +241,8 @@ label.show.replies=Show Replies label.hide.replies=Hide Replies label.showhide.prompt=Show/Hide Replies +message.complete.or.cancel.reply=Please complete or cancel the current reply before starting a new reply. +message.complete.or.cancel.edit=Please complete or cancel the current edit before starting a new edit. +error.cannot.redisplay.please.refresh=Your changes have been saved but cannot be redisplayed. Please select refresh to reload the forum messages. + #======= End labels: Exported 232 labels for en AU ===== Index: lams_tool_forum/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r5b3d4f5da53c310a16fe0498fc1e95261569c67b -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 5b3d4f5da53c310a16fe0498fc1e95261569c67b) +++ lams_tool_forum/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -241,6 +241,9 @@ label.show.replies=Show Replies label.hide.replies=Hide Replies label.showhide.prompt=Show/Hide Replies +message.complete.or.cancel.reply=Please complete or cancel the current reply before starting a new reply. +message.complete.or.cancel.edit=Please complete or cancel the current edit before starting a new edit. +error.cannot.redisplay.please.refresh=Your changes have been saved but cannot be redisplayed. Please select refresh to reload the forum messages. #======= End labels: Exported 232 labels for en AU ===== Index: lams_tool_forum/conf/xdoclet/struts-actions.xml =================================================================== diff -u -refef5787566da02898fc3cb31a876749d3a0f368 -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision efef5787566da02898fc3cb31a876749d3a0f368) +++ lams_tool_forum/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -187,6 +187,11 @@ parameter="viewTopicThread" scope="request"> + + + - + + + + 1"; private static final String SQL_QUERY_GET_COMPLETE_THREAD = "from " + MessageSeq.class.getName() + " where thread_message_uid = ?"; + private static final String SQL_QUERY_GET_SEQ_BY_MESSAGE = "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.uid=?"; private static final String SQL_QUERY_NUM_POSTS_BY_ROOT_MESSAGE_AND_DATE = "SELECT count(*) FROM " + MessageSeq.class.getName() + " seq WHERE seq.rootMessage.uid = ? AND seq.message.updated > ?"; + private static final Logger log = Logger.getLogger(MessageSeqDao.class); + public MessageSeq getById(Long messageSeqId) { return (MessageSeq) getHibernateTemplate().get(MessageSeq.class, messageSeqId); } + public MessageSeq getByMessageId(Long messageId) { + HibernateTemplate template = this.getHibernateTemplate(); + List list = template.find(SQL_QUERY_GET_SEQ_BY_MESSAGE, messageId); + if (list != null ) { + if ( list.size() > 1) { + log.warn("Looking up message seq by message id="+messageId+". More than one message seq found!"+list.toString()); + } + return (MessageSeq) list.get(0); + } else { + return null; + } + } + public List getCompleteTopic(Long rootTopicId) { return this.getHibernateTemplate().find(SQL_QUERY_FIND_COMPLETE_TOPIC, rootTopicId); } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== diff -u -refef5787566da02898fc3cb31a876749d3a0f368 -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision efef5787566da02898fc3cb31a876749d3a0f368) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -26,7 +26,6 @@ import java.io.FileNotFoundException; import java.io.IOException; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -46,6 +45,8 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts.upload.FormFile; +import org.apache.tomcat.util.json.JSONException; +import org.apache.tomcat.util.json.JSONObject; import org.lamsfoundation.lams.contentrepository.AccessDeniedException; import org.lamsfoundation.lams.contentrepository.ICredentials; import org.lamsfoundation.lams.contentrepository.ITicket; @@ -272,6 +273,15 @@ return message; } + + public List getMessageAsDTO(Long messageUid) throws PersistenceException { + + MessageSeq msgSeq = messageSeqDao.getByMessageId(messageUid); + List msgDtoList = new ArrayList(); + msgDtoList.add(makeDTOSetRating(msgSeq, msgSeq.getMessage())); + return msgDtoList; + } + public void updateContainedReport(Message message) { messageDao.saveOrUpdate(message); } @@ -685,22 +695,25 @@ Map.Entry entry = (Entry) iter.next(); msgSeq = (MessageSeq) entry.getKey(); message = (Message) entry.getValue(); - MessageDTO dto = MessageDTO.getMessageDTO(message); - dto.setLevel(msgSeq.getMessageLevel()); - - //set averageRating - if (message.getForum().isAllowRateMessages()) { - AverageRatingDTO averageRating = getAverageRatingDTOByMessage(message.getUid()); - dto.setAverageRating(averageRating.getRating()); - dto.setNumberOfVotes(averageRating.getNumberOfVotes()); - } - - msgDtoList.add(dto); + msgDtoList.add(makeDTOSetRating(msgSeq, message)); } return msgDtoList; } + private MessageDTO makeDTOSetRating(MessageSeq msgSeq, Message message) { + MessageDTO dto = MessageDTO.getMessageDTO(message); + dto.setLevel(msgSeq.getMessageLevel()); + + //set averageRating + if (message.getForum().isAllowRateMessages()) { + AverageRatingDTO averageRating = getAverageRatingDTOByMessage(message.getUid()); + dto.setAverageRating(averageRating.getRating()); + dto.setNumberOfVotes(averageRating.getNumberOfVotes()); + } + return dto; + } + /** * Process an uploaded file. * @@ -1572,4 +1585,7 @@ public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { return getForumOutputFactory().getSupportedDefinitionClasses(definitionType); } + + // ****************** REST methods ************************* + } \ No newline at end of file Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java =================================================================== diff -u -refef5787566da02898fc3cb31a876749d3a0f368 -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision efef5787566da02898fc3cb31a876749d3a0f368) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -237,6 +237,15 @@ Message getMessage(Long messageUid) throws PersistenceException; /** + * Get message by given message UID, wrapped up in the usual DTO list that is used for the view code in learner. + * + * @param messageUid + * @return Message + * @throws PersistenceException + */ + List getMessageAsDTO(Long messageUid) throws PersistenceException; + + /** * Get message list posted by given user. Note that the return type is DTO. * * @param userId Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java =================================================================== diff -u -refef5787566da02898fc3cb31a876749d3a0f368 -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision efef5787566da02898fc3cb31a876749d3a0f368) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -116,6 +116,9 @@ if (param.equals("viewTopicThread")) { return viewTopicThread(mapping, form, request, response); } + if (param.equals("viewMessage")) { + return viewMessage(mapping, form, request, response); + } if (param.equals("newTopic")) { return newTopic(mapping, form, request, response); } @@ -137,6 +140,9 @@ if (param.equals("updateTopic")) { return updateTopic(mapping, form, request, response); } + if (param.equals("updateTopicInline")) { + return updateTopicInline(mapping, form, request, response); + } if (param.equals("deleteAttachment")) { return deleteAttachment(mapping, form, request, response); } @@ -584,6 +590,52 @@ } /** + * Display a single message. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward viewMessage(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + forumService = getForumManager(); + + Long rootTopicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); + Long messageUid = WebUtil.readLongParam(request, ForumConstants.ATTR_MESS_ID, true); + + 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(); + + List msgDtoList = forumService.getMessageAsDTO(messageUid); + updateMesssageFlag(msgDtoList); + request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); + + // check if we can still make posts in this topic + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), rootTopicId); + boolean noMorePosts = forum.getMaximumReply() != 0 && numOfPosts >= forum.getMaximumReply() + && !forum.isAllowNewTopic() ? Boolean.TRUE : Boolean.FALSE; + request.setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts); + request.setAttribute(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts); + request.setAttribute(ForumConstants.ATTR_NO_MORE_PAGES, true); + + if ( messageUid != null ) { + request.setAttribute(ForumConstants.ATTR_MESS_ID, messageUid); + } + // transfer SessionMapID as well + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + + return mapping.findForward("success"); + } + + /** * Display empty page for a new topic in forum * * @param mapping @@ -908,6 +960,19 @@ Long topicId = (Long) sessionMap.get(ForumConstants.ATTR_TOPIC_ID); Message message = messageForm.getMessage(); + doUpdateTopic(request, messageForm, sessionMap, topicId, message); + + // echo back this topic thread into page + Long rootTopicId = forumService.getRootTopicId(topicId); + ForumUser forumUser = getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)); + Forum forum = forumUser.getSession().getForum(); + setupViewTopicPagedDTOList(request, rootTopicId, messageForm.getSessionMapID(), forumUser, forum, null, null); + + return mapping.findForward("success"); + } + + private void doUpdateTopic(HttpServletRequest request, MessageForm messageForm, SessionMap sessionMap, + Long topicId, Message message) { boolean makeAuditEntry = ToolAccessMode.TEACHER.equals(sessionMap.get(AttributeNames.ATTR_MODE)); String oldMessageString = null; @@ -936,14 +1001,40 @@ // save message into database // if we are in monitoring then we are probably editing some else's entry so log the change. forumService.updateTopic(messagePO); + } - // echo back this topic thread into page + /** + * Update a topic. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws PersistenceException + * @throws JSONException + * @throws IOException + */ + public ActionForward updateTopicInline(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws PersistenceException, JSONException, IOException { + + forumService = getForumManager(); + + MessageForm messageForm = (MessageForm) form; + SessionMap sessionMap = getSessionMap(request, messageForm); + Long topicId = (Long) sessionMap.get(ForumConstants.ATTR_TOPIC_ID); + Message message = messageForm.getMessage(); + + doUpdateTopic(request, messageForm, sessionMap, topicId, message); + + JSONObject JSONObject = new JSONObject(); + JSONObject.put(ForumConstants.ATTR_MESS_ID, topicId); + JSONObject.put(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID()); Long rootTopicId = forumService.getRootTopicId(topicId); - ForumUser forumUser = getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)); - Forum forum = forumUser.getSession().getForum(); - setupViewTopicPagedDTOList(request, rootTopicId, messageForm.getSessionMapID(), forumUser, forum, null, null); - - return mapping.findForward("success"); + JSONObject.put(ForumConstants.ATTR_ROOT_TOPIC_UID, rootTopicId); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(JSONObject); + return null; } /** Index: lams_tool_forum/web/WEB-INF/tiles-defs.xml =================================================================== diff -u -r72a3c5dbc0b2b0f1b3304d50cdd8798d6616aef8 -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/web/WEB-INF/tiles-defs.xml (.../tiles-defs.xml) (revision 72a3c5dbc0b2b0f1b3304d50cdd8798d6616aef8) +++ lams_tool_forum/web/WEB-INF/tiles-defs.xml (.../tiles-defs.xml) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -76,6 +76,7 @@ + Index: lams_tool_forum/web/jsps/learning/edit.jsp =================================================================== diff -u -rc4854959d539a3b2d18dc30be9a11f7c127050aa -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/web/jsps/learning/edit.jsp (.../edit.jsp) (revision c4854959d539a3b2d18dc30be9a11f7c127050aa) +++ lams_tool_forum/web/jsps/learning/edit.jsp (.../edit.jsp) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -1,6 +1,64 @@ <%@ include file="/common/taglibs.jsp"%> - + + + + Index: lams_tool_forum/web/jsps/learning/message/msgview.jsp =================================================================== diff -u --- lams_tool_forum/web/jsps/learning/message/msgview.jsp (revision 0) +++ lams_tool_forum/web/jsps/learning/message/msgview.jsp (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -0,0 +1,186 @@ +<%@ page import="org.lamsfoundation.lams.tool.forum.util.ForumConstants"%> +<%@ include file="/common/taglibs.jsp"%> + + + + + + + + + + + + + + + + +
px;" class="highlight" > + + +
px;" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + - + + +
+ + + + + + + + +
+
+ " class="space-left float-left"> + + + + + + + + + + + + +
+
+ + +
+ +
+ + +
+ + + + + + + + +
+
+ + <%@ include file="/jsps/learning/ratingStars.jsp"%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Index: lams_tool_forum/web/jsps/learning/message/msgviewwrapper.jsp =================================================================== diff -u --- lams_tool_forum/web/jsps/learning/message/msgviewwrapper.jsp (revision 0) +++ lams_tool_forum/web/jsps/learning/message/msgviewwrapper.jsp (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -0,0 +1,30 @@ + + + + +<%@ include file="/common/taglibs.jsp"%> + + + + + + + + <%@ include file="msgview.jsp"%> + + Index: lams_tool_forum/web/jsps/learning/message/topiceditform.jsp =================================================================== diff -u -r0bcc23651fc301918c997e707e5e28e604db70ac -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/web/jsps/learning/message/topiceditform.jsp (.../topiceditform.jsp) (revision 0bcc23651fc301918c997e707e5e28e604db70ac) +++ lams_tool_forum/web/jsps/learning/message/topiceditform.jsp (.../topiceditform.jsp) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -30,13 +30,7 @@
- - - - + Index: lams_tool_forum/web/jsps/learning/message/topicview.jsp =================================================================== diff -u -r946e908eb73ec1bd60053456ceeec557bdf02980 -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/web/jsps/learning/message/topicview.jsp (.../topicview.jsp) (revision 946e908eb73ec1bd60053456ceeec557bdf02980) +++ lams_tool_forum/web/jsps/learning/message/topicview.jsp (.../topicview.jsp) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -22,30 +22,49 @@ @@ -59,10 +78,7 @@ - - - - + <%-- same test & command appears at bottom of script --%> @@ -72,189 +88,17 @@
- -
+
Index: lams_tool_forum/web/jsps/learning/reply.jsp =================================================================== diff -u -r946e908eb73ec1bd60053456ceeec557bdf02980 -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/web/jsps/learning/reply.jsp (.../reply.jsp) (revision 946e908eb73ec1bd60053456ceeec557bdf02980) +++ lams_tool_forum/web/jsps/learning/reply.jsp (.../reply.jsp) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -35,7 +35,6 @@ if ( rootUid ) { if ( ! threadDiv) { // must have replied to the top level, so show the posting at the top. - // even if it was an actual error, the top is as good a place as any to show it! var threadDiv = document.getElementById('reply'); threadDiv.id = 'thread'+messageUid; } else { @@ -45,8 +44,7 @@ } if ( ! threadDiv) { -// I18N - alert("Your reply is saved but we cannot redisplay it. Please select refresh to reload the forum messages."); + alert(''); } else { var loadString = '' + rootUid + "&sessionMapID=" + response.sessionMapID + "&threadUid=" + threadUid+"&messageUid="+messageUid; $(threadDiv).load(loadString, function() { @@ -75,7 +73,7 @@ }); function cancelReply() { - $('.replydiv').remove(); + $('#reply').remove(); } Index: lams_tool_forum/web/jsps/learning/viewtopic.jsp =================================================================== diff -u -rbc38faacb837ce6243961a3ca13f61b62ca0e594 -r3f65546d337cbe98aea623132d1835a770e6d1c8 --- lams_tool_forum/web/jsps/learning/viewtopic.jsp (.../viewtopic.jsp) (revision bc38faacb837ce6243961a3ca13f61b62ca0e594) +++ lams_tool_forum/web/jsps/learning/viewtopic.jsp (.../viewtopic.jsp) (revision 3f65546d337cbe98aea623132d1835a770e6d1c8) @@ -47,7 +47,11 @@ @@ -191,7 +195,7 @@
-
- - -
px;" class="highlight" > - - -
px;" > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - -
-
- " class="space-left float-left"> - - - - - - - - - - - - -
-
- - -
- -
- - -
- - - - - - - - -
-
- - <%@ include file="/jsps/learning/ratingStars.jsp"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- + <%@ include file="msgview.jsp"%> +