Index: lams_tool_chat/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/conf/language/lams/ApplicationResources.properties,v diff -u -r1.30.2.5 -r1.30.2.6 --- lams_tool_chat/conf/language/lams/ApplicationResources.properties 19 Sep 2016 09:38:24 -0000 1.30.2.5 +++ lams_tool_chat/conf/language/lams/ApplicationResources.properties 30 Sep 2016 05:06:26 -0000 1.30.2.6 @@ -106,6 +106,7 @@ error.condition.name.blank =Condition name can not be blank. error.condition.duplicated.name =Duplicated name. Please choose unique one. error.condition =Error creating condition. +output.desc.learner.number.of.posts =Learner's number of postings in the Chat output.desc.text.search.output.definition.chat =Messages contain certain words text.search.output.definition.chat.default.condition =Messages contain word "LAMS" textsearch.heading =Messages that... Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/dao/IChatMessageDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/dao/IChatMessageDAO.java,v diff -u -r1.5.12.3 -r1.5.12.4 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/dao/IChatMessageDAO.java 11 May 2016 07:14:22 -0000 1.5.12.3 +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/dao/IChatMessageDAO.java 30 Sep 2016 05:11:26 -0000 1.5.12.4 @@ -21,8 +21,6 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.chat.dao; import java.util.List; @@ -52,4 +50,13 @@ Map getCountByFromUser(Long sessionUID); List getSentByUser(Long userUid); + + /** + * Return how many post from this user and session. DOES NOT include posts from author. + * + * @param userID + * @param sessionId + * @return + */ + int getTopicsNum(Long userID, Long sessionId); } \ No newline at end of file Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/dao/hibernate/ChatMessageDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/dao/hibernate/ChatMessageDAO.java,v diff -u -r1.7.2.6 -r1.7.2.7 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/dao/hibernate/ChatMessageDAO.java 11 May 2016 07:14:22 -0000 1.7.2.6 +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/dao/hibernate/ChatMessageDAO.java 30 Sep 2016 05:10:02 -0000 1.7.2.7 @@ -21,8 +21,6 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.chat.dao.hibernate; import java.util.HashMap; @@ -68,6 +66,8 @@ public static final String SQL_QUERY_FIND_MESSAGES_SENT_BY_USER = "FROM " + ChatMessage.class.getName() + " AS f WHERE f.fromUser.uid=?"; + private static final String SQL_QUERY_TOPICS_NUMBER_BY_USER_SESSION = "select count(*) from " + + ChatMessage.class.getName() + " m " + " where m.fromUser.userId=? and m.chatSession.sessionId=?"; @Override public void saveOrUpdate(ChatMessage chatMessage) { @@ -140,4 +140,14 @@ return (List) doFind(ChatMessageDAO.SQL_QUERY_FIND_MESSAGES_SENT_BY_USER, new Object[] { userUid }); } + + @Override + public int getTopicsNum(Long userID, Long sessionId) { + List list = this.doFind(SQL_QUERY_TOPICS_NUMBER_BY_USER_SESSION, new Object[] { userID, sessionId }); + if ((list != null) && (list.size() > 0)) { + return ((Number) list.get(0)).intValue(); + } else { + return 0; + } + } } Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java,v diff -u -r1.6.2.4 -r1.6.2.5 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java 19 Sep 2016 09:38:24 -0000 1.6.2.4 +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java 30 Sep 2016 05:13:56 -0000 1.6.2.5 @@ -53,12 +53,9 @@ public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { SortedMap definitionMap = new TreeMap(); - + Class stringArrayClass = new String[] {}.getClass(); switch (definitionType) { case ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION: - break; - case ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_DATA_FLOW: - Class stringArrayClass = new String[] {}.getClass(); if (toolContentObject != null) { ToolOutputDefinition chatMessagesDefinition = buildComplexOutputDefinition( ChatConstants.USER_MESSAGES_DEFINITION_NAME, stringArrayClass); @@ -67,7 +64,11 @@ chatMessagesDefinition.setDefaultConditions(new ArrayList(chat.getConditions())); definitionMap.put(ChatConstants.USER_MESSAGES_DEFINITION_NAME, chatMessagesDefinition); } - + ToolOutputDefinition numberOfPostsDefinition = buildRangeDefinition( + ChatConstants.LEARNER_NUM_POSTS_DEFINITION_NAME, new Long(0), null); + definitionMap.put(ChatConstants.LEARNER_NUM_POSTS_DEFINITION_NAME, numberOfPostsDefinition); + break; + case ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_DATA_FLOW: ToolOutputDefinition allUsersMessagesDefinition = buildComplexOutputDefinition( ChatConstants.ALL_USERS_MESSAGES_DEFINITION_NAME, stringArrayClass); definitionMap.put(ChatConstants.ALL_USERS_MESSAGES_DEFINITION_NAME, allUsersMessagesDefinition); @@ -119,6 +120,10 @@ } } } + if ((names == null) || names.contains(ChatConstants.LEARNER_NUM_POSTS_DEFINITION_NAME)) { + outputs.put(ChatConstants.LEARNER_NUM_POSTS_DEFINITION_NAME, + getNumPosts(chatService, learnerId, toolSessionId)); + } return outputs; } @@ -143,6 +148,8 @@ return new ToolOutput(name, getI18NText(ChatConstants.USER_MESSAGES_DEFINITION_NAME, true), textMessages, false); + } else if (ChatConstants.LEARNER_NUM_POSTS_DEFINITION_NAME.equals(nameParts[0])) { + return getNumPosts(chatService, learnerId, toolSessionId); } else if (ChatConstants.ALL_USERS_MESSAGES_DEFINITION_NAME.equals(nameParts[0])) { Set users = chatService.getSessionBySessionId(toolSessionId).getChatUsers(); String[] usersMessages = new String[users.size()]; @@ -165,6 +172,12 @@ return null; } + private ToolOutput getNumPosts(IChatService chatService, Long learnerId, Long toolSessionId) { + int num = chatService.getTopicsNum(learnerId, toolSessionId); + return new ToolOutput(ChatConstants.LEARNER_NUM_POSTS_DEFINITION_NAME, + getI18NText(ChatConstants.LEARNER_NUM_POSTS_DEFINITION_NAME, true), new Long(num)); + } + @Override protected String[] splitConditionName(String conditionName) { return super.splitConditionName(conditionName); Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java,v diff -u -r1.63.2.10 -r1.63.2.11 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java 9 Sep 2016 07:24:13 -0000 1.63.2.10 +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java 30 Sep 2016 05:12:49 -0000 1.63.2.11 @@ -172,6 +172,11 @@ } @Override + public int getTopicsNum(Long userID, Long sessionId) { + return chatMessageDAO.getTopicsNum(userID, sessionId); + } + + @Override public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException { // TODO Auto-generated method stub Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/IChatService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/IChatService.java,v diff -u -r1.21.2.3 -r1.21.2.4 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/IChatService.java 11 May 2016 07:14:21 -0000 1.21.2.3 +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/IChatService.java 30 Sep 2016 05:12:12 -0000 1.21.2.4 @@ -21,7 +21,6 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.chat.service; import java.util.Collection; @@ -118,6 +117,15 @@ */ public ChatUser getUserByNicknameAndSessionID(String nickname, 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 + */ + int getTopicsNum(Long userID, Long sessionId); + public void updateUserPresence(Long toolSessionId, Set activeUsers); /** Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/util/ChatConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/util/ChatConstants.java,v diff -u -r1.18.2.3 -r1.18.2.4 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/util/ChatConstants.java 11 May 2016 07:14:22 -0000 1.18.2.3 +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/util/ChatConstants.java 30 Sep 2016 05:14:32 -0000 1.18.2.4 @@ -21,7 +21,6 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.chat.util; public interface ChatConstants { @@ -57,6 +56,7 @@ public static final String USER_MESSAGES_DEFINITION_NAME = "user.messages.output.definition.chat"; public static final String USER_MESSAGES_DEFAULT_CONDITION_DISPLAY_NAME_KEY = "user.messages.output.definition.chat.default.condition"; public static final String ALL_USERS_MESSAGES_DEFINITION_NAME = "all.users.messages.output.definition.chat"; + public final static String LEARNER_NUM_POSTS_DEFINITION_NAME = "learner.number.of.posts"; public static final String TEXT_SEARCH_DEFINITION_NAME = "text.search.output.definition.chat"; public static final String TEXT_SEARCH_DEFAULT_CONDITION_DISPLAY_NAME_KEY = "text.search.output.definition.chat.default.condition";