Index: lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml =================================================================== diff -u -rfd1d19665518ba6781ce9e3851889c077e8efff4 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml (.../Attachment.hbm.xml) (revision fd1d19665518ba6781ce9e3851889c077e8efff4) +++ lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml (.../Attachment.hbm.xml) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -73,11 +73,4 @@ - - - Index: lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml =================================================================== diff -u -r6847f3627bbb8393b88988cae6c3cd8ad97f1600 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml (.../Forum.hbm.xml) (revision 6847f3627bbb8393b88988cae6c3cd8ad97f1600) +++ lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml (.../Forum.hbm.xml) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -194,11 +194,4 @@ - - - Index: lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml =================================================================== diff -u -r2a57d40ab3cf7e13403891bc612cd599217da234 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml (.../Message.hbm.xml) (revision 2a57d40ab3cf7e13403891bc612cd599217da234) +++ lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml (.../Message.hbm.xml) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -185,14 +185,4 @@ - - - - Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml =================================================================== diff -u -rfd1d19665518ba6781ce9e3851889c077e8efff4 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml (.../Attachment.hbm.xml) (revision fd1d19665518ba6781ce9e3851889c077e8efff4) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml (.../Attachment.hbm.xml) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -73,11 +73,4 @@ - - - Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.java =================================================================== diff -u -r62402371ee899b9b20c61c988149efbec1cc00bd -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.java (.../Attachment.java) (revision 62402371ee899b9b20c61c988149efbec1cc00bd) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.java (.../Attachment.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -15,8 +15,6 @@ * * @hibernate.class table="tl_lafrum11_attachment" * - * @hibernate.query name="allAttachments" query="from Attachment attachment" - * @hibernate.query name="getAttachmentbyType" query="from Attachment attachment where file_type = ?" */ public class Attachment implements Cloneable{ private static final Logger log = Logger.getLogger(Attachment.class); Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentDao.java =================================================================== diff -u -raaca44f485c3bacc6c866f7df28c0511061473d6 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentDao.java (.../AttachmentDao.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentDao.java (.../AttachmentDao.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -1,7 +1,5 @@ package org.lamsfoundation.lams.tool.forum.persistence; -import java.util.List; - import org.hibernate.HibernateException; import org.hibernate.Session; import org.springframework.orm.hibernate3.HibernateCallback; @@ -30,9 +28,4 @@ }); return entity; } - - - public List findByNamedQuery(String name) { - return this.getHibernateTemplate().findByNamedQuery(name); - } } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml =================================================================== diff -u -r6847f3627bbb8393b88988cae6c3cd8ad97f1600 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml (.../Forum.hbm.xml) (revision 6847f3627bbb8393b88988cae6c3cd8ad97f1600) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml (.../Forum.hbm.xml) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -194,11 +194,4 @@ - - - Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.java =================================================================== diff -u -r1a5fe7ba5d0193d7c80351af38dd8959ac31d964 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.java (.../Forum.java) (revision 1a5fe7ba5d0193d7c80351af38dd8959ac31d964) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.java (.../Forum.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -19,8 +19,6 @@ * * @hibernate.class table="tl_lafrum11_forum" * - * @hibernate.query name="allForums" query="from Forum forum" - * @hibernate.query name="forumByContentId" query="from Forum forum where forum.contentId=?" */ public class Forum implements Cloneable{ Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java =================================================================== diff -u -rc0758b4553e9608cf15b7722e371efbdc6246908 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java (.../ForumDao.java) (revision c0758b4553e9608cf15b7722e371efbdc6246908) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java (.../ForumDao.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -15,6 +15,7 @@ public class ForumDao extends HibernateDaoSupport { private static final String FIND_INSTRUCTION_FILE = "from " + Attachment.class.getName() + " as i where forum_uid=? and i.fileUuid=? and i.fileVersionId=? and i.fileType=?"; + private static final String FIND_FORUM_BY_CONTENTID = "from Forum forum where forum.contentId=?"; public void saveOrUpdate(Forum forum) { forum.updateModificationData(); @@ -37,18 +38,21 @@ this.getHibernateTemplate().delete(forum); } - public List findByNamedQuery(String name) { - return this.getHibernateTemplate().findByNamedQuery(name); - } - public Forum getByContentId(Long contentID) { - List list = getHibernateTemplate().findByNamedQuery("forumByContentId",contentID); + List list = getHibernateTemplate().find(FIND_FORUM_BY_CONTENTID,contentID); if(list != null && list.size() > 0) return (Forum) list.get(0); else return null; } - + /** + * Delete content instruction files according to contentID, file version ID and its type. + * + * @param contentID + * @param uuid + * @param versionID + * @param type + */ public void deleteInstrcutionFile(Long contentID, Long uuid, Long versionID, String type) { HibernateTemplate templ = this.getHibernateTemplate(); if ( contentID != null && uuid != null && versionID != null ) { @@ -67,11 +71,6 @@ } } - public void save(Forum content) { - this.getHibernateTemplate().save(content); - this.getHibernateTemplate().flush(); - } - public void flush() { this.getHibernateTemplate().flush(); } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumException.java =================================================================== diff -u -r1ef94892cf45b63377deb39499047080a4cf2d8c -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumException.java (.../ForumException.java) (revision 1ef94892cf45b63377deb39499047080a4cf2d8c) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumException.java (.../ForumException.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -1,6 +1,5 @@ package org.lamsfoundation.lams.tool.forum.persistence; -import java.io.IOException; /** * User: conradb Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumToolSessionDao.java =================================================================== diff -u -rc0758b4553e9608cf15b7722e371efbdc6246908 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumToolSessionDao.java (.../ForumToolSessionDao.java) (revision c0758b4553e9608cf15b7722e371efbdc6246908) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumToolSessionDao.java (.../ForumToolSessionDao.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -48,7 +48,7 @@ return list; } - public void remove(Long sessionId) { + public void delete(Long sessionId) { ForumToolSession session = getBySessionId(sessionId); this.getHibernateTemplate().delete(session); this.getHibernateTemplate().flush(); Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml =================================================================== diff -u -r2a57d40ab3cf7e13403891bc612cd599217da234 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml (.../Message.hbm.xml) (revision 2a57d40ab3cf7e13403891bc612cd599217da234) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml (.../Message.hbm.xml) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -185,14 +185,4 @@ - - - - Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java =================================================================== diff -u -r1a5fe7ba5d0193d7c80351af38dd8959ac31d964 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java (.../Message.java) (revision 1a5fe7ba5d0193d7c80351af38dd8959ac31d964) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java (.../Message.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -18,9 +18,6 @@ * * @hibernate.class table="tl_lafrum11_message" * - * @hibernate.query name="allMessages" query="from Message m" - * @hibernate.query name="allMessagesByForum" query="from Message m where forum_uid=? order by create_date" - * @hibernate.query name="allAuthoredMessagesOfForum" query="from Message m where is_authored=true and forum_uid=? order by create_date" */ public class Message implements Cloneable{ Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java =================================================================== diff -u -rf2dc26e95cad64b7d5c55b483a0fbb32691d7f13 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java (.../MessageDao.java) (revision f2dc26e95cad64b7d5c55b483a0fbb32691d7f13) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java (.../MessageDao.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -18,7 +18,7 @@ + " where parent_uid is null and m.toolSession.sessionId=?"; private static final String SQL_QUERY_FIND_TOPICS_FROM_AUTHOR = "from " + Message.class.getName() - + " where is_authored = true and forum_uid=?"; + + " where is_authored = true and forum_uid=? order by create_date"; private static final String SQL_QUERY_FIND_CHILDREN = "from " + Message.class.getName() + " where parent=?"; @@ -35,38 +35,10 @@ this.getHibernateTemplate().flush(); } - public void save(Message message) { - message.updateModificationData(); - this.getHibernateTemplate().save(message); - this.getHibernateTemplate().flush(); - } public Message getById(Long messageId) { return (Message) getHibernateTemplate().get(Message.class,messageId); - } - public void delete(Message message) { - this.getHibernateTemplate().delete(message); - } - - public List findByNamedQuery(String name, Long forumId) { - return this.getHibernateTemplate().findByNamedQuery(name, forumId); - } - - /** - * Delete all messages in special forum. - * @param forumUuid - * The forum UUID which messages will be deleted in this method. - */ - public void deleteForumMessage(Long forumUuid) { - List list = findByNamedQuery("allMessagesByForum",forumUuid); - this.getHibernateTemplate().deleteAll(list); - } - - public List getAuthoredMessage(Long forumId) { - return findByNamedQuery("allAuthoredMessagesOfForum", forumId); - } - public List getRootTopics(Long sessionId) { return this.getHibernateTemplate().find(SQL_QUERY_FIND_ROOT_TOPICS, sessionId); } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== diff -u -rfdf58a248bcf525bca58e551675d0dc412ccb579 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision fdf58a248bcf525bca58e551675d0dc412ccb579) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -305,7 +305,7 @@ } public List getAuthoredTopics(Long forumUid) { - List list = messageDao.getAuthoredMessage(forumUid); + List list = messageDao.getTopicsFromAuthor(forumUid); TreeMap map = new TreeMap(new DateComparator()); //sorted by create date @@ -470,7 +470,7 @@ fromContent = getDefaultContent(fromContentId); } Forum toContent = Forum.newInstance(fromContent,toContentId,forumToolContentHandler); - forumDao.save(toContent); + forumDao.saveOrUpdate(toContent); //save topics in this forum Set topics = toContent.getMessages(); @@ -557,7 +557,7 @@ } public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { - forumToolSessionDao.remove(toolSessionId); + forumToolSessionDao.delete(toolSessionId); } /* (non-Javadoc) Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java =================================================================== diff -u -rde672e5125377cd876df4bf2e9e624ffcfac30a4 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision de672e5125377cd876df4bf2e9e624ffcfac30a4) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -99,9 +99,18 @@ */ private ActionForward viewForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - //set the mode into http session - ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE,MODE_OPTIONAL); - request.getSession().setAttribute(AttributeNames.ATTR_MODE, mode); + //set the mode into http session + ToolAccessMode mode = null; + try{ + mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE,MODE_OPTIONAL); + request.getSession().setAttribute(AttributeNames.ATTR_MODE, mode); + }catch(Exception exp){ + //check wether it already existed in Session + mode = (ToolAccessMode) request.getSession().getAttribute(AttributeNames.ATTR_MODE); + } + if(mode == null){ + throw new ForumException("Mode is required."); + } //get sessionId from HttpServletRequest String sessionIdStr = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); @@ -216,25 +225,13 @@ //get root topic list List msgDtoList = forumService.getTopicThread(topicId); - //set current user to web page, so that can display "edit" button correct. Only author alow to edit. - HttpSession ss = SessionManager.getSession(); - //get back login user DTO - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - Long currUserId = new Long(user.getUserID().intValue()); - Iterator iter = msgDtoList.iterator(); - while(iter.hasNext()){ - MessageDTO dto = (MessageDTO) iter.next(); - if(dto.getMessage().getCreatedBy() != null - && currUserId.equals(dto.getMessage().getCreatedBy().getUserId())) - dto.setAuthor(true); - else - dto.setAuthor(false); - } + setAuthorMark(msgDtoList); request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD,msgDtoList); return mapping.findForward("success"); } + /** * Create a new root topic. * @@ -331,6 +328,7 @@ forumService = getForumManager(); Long rootTopicId = forumService.getRootTopicId(parentId); List msgDtoList = forumService.getTopicThread(rootTopicId); + setAuthorMark(msgDtoList); request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD,msgDtoList); return mapping.findForward("success"); @@ -432,6 +430,28 @@ // Utility methods //========================================================================================== /** + * If this topic is created by current login user, then set Author mark true. + * + * @param msgDtoList + */ + private void setAuthorMark(List msgDtoList) { + //set current user to web page, so that can display "edit" button correct. Only author alow to edit. + HttpSession ss = SessionManager.getSession(); + //get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + + Long currUserId = new Long(user.getUserID().intValue()); + Iterator iter = msgDtoList.iterator(); + while(iter.hasNext()){ + MessageDTO dto = (MessageDTO) iter.next(); + if(dto.getMessage().getCreatedBy() != null + && currUserId.equals(dto.getMessage().getCreatedBy().getUserId())) + dto.setAuthor(true); + else + dto.setAuthor(false); + } + } + /** * @param topicId * @return */ Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java =================================================================== diff -u -r709b860212062b10fd3bb86cafdbf8ec273cde4c -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 709b860212062b10fd3bb86cafdbf8ec273cde4c) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -128,25 +128,14 @@ */ private ActionForward listContentUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + Long contentID =new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); + request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,contentID); + //get content ID from URL - Long contentID =new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); - - forumService = getForumService(); - List sessionsList = forumService.getSessionsByContentId(contentID); - - Map sessionUserMap = new HashMap(); - //build a map with all users in the submitFilesSessionList - Iterator it = sessionsList.iterator(); - while(it.hasNext()){ - Long sessionID = ((ForumToolSession)it.next()).getUid(); - List userList = forumService.getUsersBySessionId(sessionID); - sessionUserMap.put(sessionID, userList); - } - - //request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID,sessionID); - request.setAttribute("sessionUserMap",sessionUserMap); - return mapping.findForward("success"); + return userList(mapping, request); } + + /** * View all user marks for a special Session ID * @param mapping @@ -186,7 +175,8 @@ forumService = getForumService(); forumService.releaseMarksForSession(sessionID); - return mapping.findForward("success"); + //echo back message to web page + return userList(mapping,request); } /** * Download marks for all users in a speical session. @@ -409,7 +399,7 @@ */ private ActionForward viewActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long contentId = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); + Long contentId =(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); forumService = getForumService(); Forum forum = forumService.getForumByContentId(contentId); //if can not find out forum, echo back error message @@ -422,7 +412,6 @@ String title = forum.getTitle(); String instruction = forum.getInstructions(); - request.setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,contentId); request.setAttribute("title",title); request.setAttribute("instruction",instruction); return mapping.findForward("success"); @@ -437,8 +426,7 @@ */ private ActionForward editActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - - Long contentId = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); + Long contentId =(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); forumService = getForumService(); Forum forum = forumService.getForumByContentId(contentId); //if can not find out forum, echo back error message @@ -447,15 +435,13 @@ errors.add("activity.globel", new ActionMessage("error.fail.get.forum")); this.addErrors(request,errors); //echo back to screen - request.setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,contentId); return mapping.getInputForward(); } String title = forum.getTitle(); String instruction = forum.getInstructions(); request.setAttribute("title",title); request.setAttribute("instruction",instruction); - request.setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,contentId); return mapping.findForward("success"); } /** @@ -468,7 +454,7 @@ */ private ActionForward updateActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long contentId = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); + Long contentId =(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); String title = request.getParameter("title"); String instruction = request.getParameter("instruction"); @@ -483,7 +469,6 @@ errors.add("activity.title", new ActionMessage("error.title.empty")); } //echo back to screen - request.setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,contentId); request.setAttribute("title",title); request.setAttribute("instruction",instruction); if(!errors.isEmpty()){ @@ -506,7 +491,7 @@ */ private ActionForward viewInstructions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long contentId = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); + Long contentId =(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); forumService = getForumService(); Forum forum = forumService.getForumByContentId(contentId); @@ -534,38 +519,50 @@ */ private ActionForward statistic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long sessionId = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_SESSION_ID)); - + Long contentID = (Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); + forumService = getForumService(); - List topicList = forumService.getRootTopics(sessionId); - Iterator iter = topicList.iterator(); - int totalMsg = 0; - int msgNum; - float totalMsgMarkSum = 0; - float msgMarkSum = 0; - for(;iter.hasNext();){ - MessageDTO msgDto = (MessageDTO) iter.next(); - //get all message under this topic - List topicThread = forumService.getTopicThread(msgDto.getMessage().getUid()); - //loop all message under this topic - msgMarkSum = 0; - Iterator threadIter = topicThread.iterator(); - for(msgNum=0;threadIter.hasNext();msgNum++){ - MessageDTO dto = (MessageDTO) threadIter.next(); - if(dto.getMark() != null) - msgMarkSum += dto.getMark().floatValue(); - } - //summary to total mark - totalMsgMarkSum += msgMarkSum; - //set average mark to topic message DTO for display use - msgDto.setMark(getAverageFormat(msgMarkSum/(float)msgNum)); - totalMsg += msgNum; - } + Map sessionTopicsMap = new HashMap(); + Map sessionAvaMarkMap = new HashMap(); + Map sessionTotalMsgMap = new HashMap(); - float averMark = totalMsg == 0 ? 0: (totalMsgMarkSum/(float)totalMsg); - request.setAttribute("topicList",topicList); - request.setAttribute("markAverage",getAverageFormat(averMark)); - request.setAttribute("totalMessage",new Integer(totalMsg)); + List sessList = forumService.getSessionsByContentId(contentID); + Iterator sessIter = sessList.iterator(); + while(sessIter.hasNext()){ + ForumToolSession session = (ForumToolSession) sessIter.next(); + List topicList = forumService.getRootTopics(session.getSessionId()); + Iterator iter = topicList.iterator(); + int totalMsg = 0; + int msgNum; + float totalMsgMarkSum = 0; + float msgMarkSum = 0; + for(;iter.hasNext();){ + MessageDTO msgDto = (MessageDTO) iter.next(); + //get all message under this topic + List topicThread = forumService.getTopicThread(msgDto.getMessage().getUid()); + //loop all message under this topic + msgMarkSum = 0; + Iterator threadIter = topicThread.iterator(); + for(msgNum=0;threadIter.hasNext();msgNum++){ + MessageDTO dto = (MessageDTO) threadIter.next(); + if(dto.getMark() != null) + msgMarkSum += dto.getMark().floatValue(); + } + //summary to total mark + totalMsgMarkSum += msgMarkSum; + //set average mark to topic message DTO for display use + msgDto.setMark(getAverageFormat(msgMarkSum/(float)msgNum)); + totalMsg += msgNum; + } + + float averMark = totalMsg == 0 ? 0: (totalMsgMarkSum/(float)totalMsg); + sessionTopicsMap.put(session.getSessionId(),topicList); + sessionAvaMarkMap.put(session.getSessionId(),getAverageFormat(averMark)); + sessionTotalMsgMap.put(session.getSessionId(),new Integer(totalMsg)); + } + request.setAttribute("topicList",sessionTopicsMap); + request.setAttribute("markAverage",sessionAvaMarkMap); + request.setAttribute("totalMessage",sessionTotalMsgMap); return mapping.findForward("success"); } @@ -594,6 +591,31 @@ // Utility methods //========================================================================================== /** + * Show all users in a ToolContentID. + * @param mapping + * @param request + * @return + */ + private ActionForward userList(ActionMapping mapping, HttpServletRequest request) { + Long contentID =(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); + + forumService = getForumService(); + List sessionsList = forumService.getSessionsByContentId(contentID); + + Map sessionUserMap = new HashMap(); + //build a map with all users in the submitFilesSessionList + Iterator it = sessionsList.iterator(); + while(it.hasNext()){ + Long sessionID = ((ForumToolSession)it.next()).getUid(); + List userList = forumService.getUsersBySessionId(sessionID); + sessionUserMap.put(sessionID, userList); + } + + //request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID,sessionID); + request.setAttribute("sessionUserMap",sessionUserMap); + return mapping.findForward("success"); + } + /** * Get Forum Service. * * @return Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentTest.java =================================================================== diff -u -rc109ffd9f84d13dabeeb31bafe8484c0f3a26b40 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentTest.java (.../AttachmentTest.java) (revision c109ffd9f84d13dabeeb31bafe8484c0f3a26b40) +++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentTest.java (.../AttachmentTest.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -1,8 +1,5 @@ package org.lamsfoundation.lams.tool.forum.persistence; -import org.lamsfoundation.lams.tool.forum.core.FactoryException; -import org.lamsfoundation.lams.tool.forum.core.GenericObjectFactoryImpl; - import java.util.List; import junit.framework.TestCase; @@ -19,13 +16,13 @@ super.setUp(); } - public void testCreateAndDeleteForum() throws FactoryException { + public void testCreateAndDeleteForum() { //Populate an Attachment entity for test purposes - AttachmentDao attachmentDao = (AttachmentDao) GenericObjectFactoryImpl.getTestInstance().lookup(AttachmentDao.class); + AttachmentDao attachmentDao = new AttachmentDao(); Attachment instructions = new Attachment(); attachmentDao.saveOrUpdate(instructions); - AttachmentDao dao = (AttachmentDao) GenericObjectFactoryImpl.getTestInstance().lookup(AttachmentDao.class); + AttachmentDao dao = new AttachmentDao(); dao.saveOrUpdate(instructions); assertNotNull(instructions.getUid()); Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/ForumTest.java =================================================================== diff -u -rfd1d19665518ba6781ce9e3851889c077e8efff4 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/ForumTest.java (.../ForumTest.java) (revision fd1d19665518ba6781ce9e3851889c077e8efff4) +++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/ForumTest.java (.../ForumTest.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -6,23 +6,18 @@ import junit.framework.TestCase; -import org.lamsfoundation.lams.tool.forum.core.FactoryException; -import org.lamsfoundation.lams.tool.forum.core.GenericObjectFactoryImpl; - /** - * Created by IntelliJ IDEA. * User: conradb * Date: 7/06/2005 * Time: 10:38:21 - * To change this template use File | Settings | File Templates. */ public class ForumTest extends TestCase { protected void setUp() throws Exception { super.setUp(); } - public void testCreateAndDeleteForum() throws FactoryException { + public void testCreateAndDeleteForum() { //Populate a Forum entity for test purposes Forum entity = new Forum(); entity.setTitle("Lams Forum"); @@ -33,7 +28,7 @@ Set attachments = new HashSet(); - AttachmentDao attachmentDao = (AttachmentDao) GenericObjectFactoryImpl.getTestInstance().lookup(AttachmentDao.class); + AttachmentDao attachmentDao = new AttachmentDao(); Attachment instructions = new Attachment(); //instructions.setType(true); attachments.add(instructions); @@ -42,7 +37,7 @@ entity.setAttachments(attachments); //save - ForumDao dao = (ForumDao) GenericObjectFactoryImpl.getTestInstance().lookup(ForumDao.class); + ForumDao dao = new ForumDao(); dao.saveOrUpdate(entity); assertNotNull(entity.getUid()); assertNotNull("date created is null", entity.getCreated()); Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/MessageTest.java =================================================================== diff -u -r0653e8df3351a6178f4dcb842f4eda25a3d2341b -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/MessageTest.java (.../MessageTest.java) (revision 0653e8df3351a6178f4dcb842f4eda25a3d2341b) +++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/MessageTest.java (.../MessageTest.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -1,33 +1,32 @@ package org.lamsfoundation.lams.tool.forum.persistence; -import org.lamsfoundation.lams.tool.forum.core.FactoryException; -import org.lamsfoundation.lams.tool.forum.core.GenericObjectFactoryImpl; - +import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.HashSet; import junit.framework.TestCase; /** - * Created by IntelliJ IDEA. * User: conradb * Date: 7/06/2005 * Time: 12:42:05 - * To change this template use File | Settings | File Templates. */ public class MessageTest extends TestCase { protected void setUp() throws Exception { super.setUp(); } - public void testCreateAndDeleteMessage() throws FactoryException { + public void testCreateAndDeleteMessage() { //Populate a Forum entity for test purposes Forum forum = new Forum(); + ForumUser createUser = new ForumUser(); + createUser.setFirstName("creator"); + ForumUser modifyUser = new ForumUser(); + modifyUser.setFirstName("updator"); //save - ForumDao dao = (ForumDao) GenericObjectFactoryImpl.getTestInstance().lookup(ForumDao.class); + ForumDao dao = new ForumDao(); dao.saveOrUpdate(forum); Message message = new Message(); @@ -37,10 +36,11 @@ // message.setToolSession(forum); message.setIsAnonymous(false); message.setIsAuthored(true); - message.setCreatedBy(new Long(1000)); - message.setModifiedBy(new Long(1002)); + message.setCreatedBy(createUser); + + message.setModifiedBy(modifyUser); - MessageDao messageDao = (MessageDao) GenericObjectFactoryImpl.getTestInstance().lookup(MessageDao.class); + MessageDao messageDao = new MessageDao(); messageDao.saveOrUpdate(message); assertNotNull(message.getUid()); @@ -69,8 +69,8 @@ // message.setToolSession(forum); message2.setIsAnonymous(true); message2.setIsAuthored(true); - message2.setCreatedBy(new Long(1005)); - message2.setModifiedBy(new Long(1006)); + message2.setCreatedBy(createUser); + message2.setModifiedBy(modifyUser); messageDao.saveOrUpdate(message2); Message reloaded2 = (Message) messageDao.getById(message2.getUid()); @@ -99,11 +99,11 @@ // message.setToolSession(forum); message3.setIsAnonymous(true); message3.setIsAuthored(true); - message3.setCreatedBy(new Long(1005)); - message3.setModifiedBy(new Long(1006)); + message3.setCreatedBy(createUser); + message3.setModifiedBy(modifyUser); Set replies = new HashSet(); replies.add(message3); - reloaded.setReplies(replies); + reloaded.set(replies); messageDao.saveOrUpdate(reloaded); Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/service/ForumManagerImplTest.java =================================================================== diff -u -r97f2318395de13f34d37cec08c50bc379b7ece13 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/service/ForumManagerImplTest.java (.../ForumManagerImplTest.java) (revision 97f2318395de13f34d37cec08c50bc379b7ece13) +++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/service/ForumManagerImplTest.java (.../ForumManagerImplTest.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -5,6 +5,7 @@ import junit.framework.TestCase; +import org.lamsfoundation.lams.test.AbstractLamsTestCase; import org.lamsfoundation.lams.tool.forum.core.GenericObjectFactoryImpl; import org.lamsfoundation.lams.tool.forum.persistence.Attachment; import org.lamsfoundation.lams.tool.forum.persistence.Forum; @@ -16,12 +17,17 @@ * Date: 9/06/2005 * Time: 10:59:06 */ -public class ForumManagerImplTest extends TestCase { - protected IForumService forumManager; +public class ForumManagerImplTest extends AbstractLamsTestCase { + protected IForumService forumManager; + + public ForumManagerImplTest(String name) { + super(name); + + } protected void setUp() throws Exception { super.setUp(); - forumManager = (IForumService) GenericObjectFactoryImpl.getTestInstance().lookup("forumManager"); + forumManager = (IForumService)context.getBean("forumService"); } public void testCreateAndDeleteForum() throws PersistenceException { @@ -222,4 +228,17 @@ return message; } + protected String[] getContextConfigLocation() { + return new String[] {"org/lamsfoundation/lams/localApplicationContext.xml", + "org/lamsfoundation/lams/tool/sbmt/submitFilesApplicationContext.xml", + "org/lamsfoundation/lams/contentrepository/applicationContext.xml", + "org/lamsfoundation/lams/lesson/lessonApplicationContext.xml", + "org/lamsfoundation/lams/learning/learningApplicationContext.xml", + "org/lamsfoundation/lams/tool/toolApplicationContext.xml"}; + } + + protected String getHibernateSessionFactoryName() { + return "fourmSessionFactory"; + } + } Index: lams_tool_forum/web/WEB-INF/struts/tiles-defs.xml =================================================================== diff -u -rbbe88a48d8e196a1c6df3d8d915142c19857b052 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/web/WEB-INF/struts/tiles-defs.xml (.../tiles-defs.xml) (revision bbe88a48d8e196a1c6df3d8d915142c19857b052) +++ lams_tool_forum/web/WEB-INF/struts/tiles-defs.xml (.../tiles-defs.xml) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -16,6 +16,14 @@ + + + + + + + + @@ -74,41 +82,41 @@ - + - + - + - + - + - + - + - + - + Index: lams_tool_forum/web/includes/tablayout.jsp =================================================================== diff -u --- lams_tool_forum/web/includes/tablayout.jsp (revision 0) +++ lams_tool_forum/web/includes/tablayout.jsp (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -0,0 +1,21 @@ +<%@ include file="/includes/taglibs.jsp"%> +<%@ taglib uri="tags-tiles" prefix="tiles"%> + + + + + + + + + + + + + + + + + + + Index: lams_tool_forum/web/jsps/monitoring/editactivity.jsp =================================================================== diff -u -r1079ea24a56ed171c7d70985cf72de279765d386 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/web/jsps/monitoring/editactivity.jsp (.../editactivity.jsp) (revision 1079ea24a56ed171c7d70985cf72de279765d386) +++ lams_tool_forum/web/jsps/monitoring/editactivity.jsp (.../editactivity.jsp) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -5,9 +5,6 @@ - - : Index: lams_tool_forum/web/jsps/monitoring/statistic.jsp =================================================================== diff -u -rbbe88a48d8e196a1c6df3d8d915142c19857b052 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/web/jsps/monitoring/statistic.jsp (.../statistic.jsp) (revision bbe88a48d8e196a1c6df3d8d915142c19857b052) +++ lams_tool_forum/web/jsps/monitoring/statistic.jsp (.../statistic.jsp) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -2,47 +2,64 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + Session ID: + + + + + + + - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: lams_tool_forum/web/jsps/monitoring/tabmenu.jsp =================================================================== diff -u --- lams_tool_forum/web/jsps/monitoring/tabmenu.jsp (revision 0) +++ lams_tool_forum/web/jsps/monitoring/tabmenu.jsp (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -0,0 +1,22 @@ +<%@ include file="/includes/taglibs.jsp"%> + + + + + + + Monitoring + Logon + Monitoring + Instructions + Edit + Activity + Monitoring + Statistic + + + Index: lams_tool_forum/web/jsps/monitoring/viewactivity.jsp =================================================================== diff -u -r1079ea24a56ed171c7d70985cf72de279765d386 -rbb86b2d50b113e03e7ead098db991c1ae922d99c --- lams_tool_forum/web/jsps/monitoring/viewactivity.jsp (.../viewactivity.jsp) (revision 1079ea24a56ed171c7d70985cf72de279765d386) +++ lams_tool_forum/web/jsps/monitoring/viewactivity.jsp (.../viewactivity.jsp) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c) @@ -5,8 +5,6 @@ - - :