Index: lams_tool_forum/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -rc84b00e3adf4644ca9ed77b63dbb97f3e7ded04a -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision c84b00e3adf4644ca9ed77b63dbb97f3e7ded04a) +++ lams_tool_forum/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -238,9 +238,10 @@ label.upload.info =Uploaded file must not be executable and not exceed size of {0} output.desc.all.users.answers.definition.forum =Each learner's posts sent in the Forum label.submit =Finish -label.rateLimits.forum.reminder =Rating limitation: Minimum {0} and Maximum {1} per thread. +label.rateLimits.forum.reminder =Rating limitation: Minimum {0} and Maximum {1}. label.rateLimits.forum.reminder.min =You must rate at least {0} postings. label.rateLimits.forum.reminder.max =You can only rate up to {0} postings. +label.rateLimits.topic.reminder =You have rated {0} postings already. js.error.validate.number =There is an error with the minimum and/or maximum set for ratings. Please check and try again. Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageRatingDAO.java =================================================================== diff -u -r8a8c14627918cc58fa845c2369937bc482d2f6b9 -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageRatingDAO.java (.../MessageRatingDAO.java) (revision 8a8c14627918cc58fa845c2369937bc482d2f6b9) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageRatingDAO.java (.../MessageRatingDAO.java) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -46,7 +46,10 @@ private static final String FIND_AVERAGE_RATING_BY_MESSAGE = "SELECT AVG(r.rating), COUNT(*) from " + MessageRating.class.getName() + " as r where r.message.uid=?"; - + + private static final String FIND_COUNT_RATING_BY_USER_AND_FORUM = "SELECT COUNT(*) from " + MessageRating.class.getName() + + " as r where r.user.uid = ? and r.message.forum.uid=?"; + /** * Return responseRating by the given imageUid and userId. * @@ -90,6 +93,22 @@ String numberOfVotes = (results[1] == null) ? "0" : String.valueOf(results[1]); return new AverageRatingDTO(averageRating, numberOfVotes); } + + /** + * Return total number of posts done by current user in this forum activity + * + * @param userUid + * @param forumUid + * @return + */ + public int getNumOfRatingsByUserAndForum(Long userUid, Long forumUid) { + List list = this.getHibernateTemplate().find(FIND_COUNT_RATING_BY_USER_AND_FORUM, + new Object[] { userUid, forumUid }); + if (list != null && list.size() > 0) + return ((Number) list.get(0)).intValue(); + else + return 0; + } /** * Generic method to save an object - handles both update and insert. Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== diff -u -r567af22fafd6a56534cc071f3650eda4495d05ef -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 567af22fafd6a56534cc071f3650eda4495d05ef) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -325,10 +325,12 @@ messageDao.delete(topicUid); } + @Override public void deleteCondition(ForumCondition condition) throws PersistenceException { forumDao.deleteCondition(condition); } + @Override public Message replyTopic(Long parentId, Long sessionId, Message replyMessage) throws PersistenceException { // set parent Message parent = this.getMessage(parentId); @@ -362,6 +364,7 @@ return replyMessage; } + @Override public Attachment uploadAttachment(FormFile uploadFile) throws PersistenceException { if (uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) { throw new ForumException("Could not find upload file: " + uploadFile); @@ -376,6 +379,7 @@ return file; } + @Override public List getTopicThread(Long rootTopicId) { List unsortedThread = messageSeqDao.getTopicThread(rootTopicId); @@ -389,6 +393,7 @@ return getSortedMessageDTO(map); } + @Override public List getRootTopics(Long sessionId) { ForumToolSession session = getSessionBySessionId(sessionId); if (session == null || session.getForum() == null) { @@ -408,30 +413,37 @@ return topicsBySession; } + @Override public int getTopicsNum(Long userID, Long sessionId) { return messageDao.getTopicsNum(userID, sessionId); } + @Override public int getNumOfPostsByTopic(Long userId, Long topicId) { return messageSeqDao.getNumOfPostsByTopic(userId, topicId); } + @Override public ForumUser getUserByID(Long userId) { return forumUserDao.getByUserId(userId); } + @Override public ForumUser getUserByUserAndSession(Long userId, Long sessionId) { return forumUserDao.getByUserIdAndSessionId(userId, sessionId); } + @Override public void createUser(ForumUser forumUser) { forumUserDao.save(forumUser); } + @Override public ForumToolSession getSessionBySessionId(Long sessionId) { return forumToolSessionDao.getBySessionId(sessionId); } + @Override public Long getRootTopicId(Long topicId) { MessageSeq seq = messageSeqDao.getByTopicId(topicId); if (seq == null || seq.getRootMessage() == null) { @@ -441,6 +453,7 @@ return seq.getRootMessage().getUid(); } + @Override public List getAuthoredTopics(Long forumUid) { List list = messageDao.getTopicsFromAuthor(forumUid); @@ -456,34 +469,29 @@ return MessageDTO.getMessageDTO(new ArrayList(map.values())); } - public Long getToolDefaultContentIdBySignature(String toolSignature) { - Long contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); - if (contentId.equals(0L)) { - String error = "Could not retrieve default content id for this tool"; - ForumService.log.error(error); - throw new ForumException(error); - } - return contentId; - } - + @Override public List getSessionsByContentId(Long contentID) { return forumToolSessionDao.getByContentId(contentID); } + @Override public List getUsersBySessionId(Long sessionID) { return forumUserDao.getBySessionId(sessionID); } + @Override public List getMessagesByUserUid(Long userId, Long sessionId) { List list = messageDao.getByUserAndSession(userId, sessionId); return MessageDTO.getMessageDTO(list); } + @Override public ForumUser getUser(Long userUid) { return forumUserDao.getByUid(userUid); } + @Override public void releaseMarksForSession(Long sessionID) { // udate release mark date for each message. List list = messageDao.getBySession(sessionID); @@ -546,11 +554,13 @@ } + @Override public void finishUserSession(ForumUser currentUser) { currentUser.setSessionFinished(true); forumUserDao.save(currentUser); } + @Override public AverageRatingDTO rateMessage(Long messageId, Long userId, Long toolSessionID, float rating) { ForumUser imageGalleryUser = getUserByUserAndSession(userId, toolSessionID); MessageRating messageRating = messageRatingDao.getRatingByMessageAndUser(messageId, userId); @@ -569,9 +579,15 @@ return messageRatingDao.getAverageRatingDTOByMessage(messageId); } + @Override public AverageRatingDTO getAverageRatingDTOByMessage(Long messageId) { return messageRatingDao.getAverageRatingDTOByMessage(messageId); } + + @Override + public int getNumOfRatingsByUserAndForum(Long userUid, Long forumUid) { + return messageRatingDao.getNumOfRatingsByUserAndForum(userUid, forumUid); + } // *************************************************************************************************************** // Private methods @@ -659,7 +675,13 @@ } private Forum getDefaultForum() { - Long defaultForumId = getToolDefaultContentIdBySignature(ForumConstants.TOOL_SIGNATURE); + Long defaultForumId = new Long(toolService.getToolDefaultContentIdBySignature(ForumConstants.TOOL_SIGNATURE)); + if (defaultForumId.equals(0L)) { + String error = "Could not retrieve default content id for this tool"; + ForumService.log.error(error); + throw new ForumException(error); + } + Forum defaultForum = getForumByContentId(defaultForumId); if (defaultForum == null) { String error = "Could not retrieve default content record for this tool"; Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -412,5 +412,14 @@ AverageRatingDTO rateMessage(Long messageId, Long userId, Long toolSessionID, float rating); AverageRatingDTO getAverageRatingDTOByMessage(Long responseId); + + /** + * Return total number of posts done by current user in this forum activity + * + * @param userUid + * @param forumUid + * @return + */ + int getNumOfRatingsByUserAndForum(Long userUid, Long forumUid); } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java (.../ForumConstants.java) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java (.../ForumConstants.java) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -65,7 +65,9 @@ // TODO:hard code!!! need to read from config public static final String TOOL_URL_BASE = "/lams/tool/lafrum11/"; - public static final String FORUM_ID = "forum_id"; + public static final String ATTR_FORUM_ID = "forum_id"; + + public static final String ATTR_FORUM_UID = "forumUid"; public static final String ATTR_ALLOW_EDIT = "allowEdit"; @@ -131,6 +133,12 @@ public static final String ATTR_NO_MORE_POSTS = "noMorePosts"; public static final String ATTR_NUM_OF_POSTS = "numOfPosts"; + + public static final String ATTR_NO_MORE_RATINGSS = "noMoreRatings"; + + public static final String ATTR_NUM_OF_RATINGS = "numOfRatings"; + + public static final String ATTR_IS_MIN_RATINGS_COMPLETED = "isMinRatingsCompleted"; public static final String ATTR_SESSION_MAP_ID = "sessionMapID"; Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java =================================================================== diff -u -r883c4cc054a636dc8017da1b244b89bdaf0ff974 -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision 883c4cc054a636dc8017da1b244b89bdaf0ff974) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -215,8 +215,10 @@ Boolean allowRichEditor = new Boolean(forum.isAllowRichEditor()); int allowNumber = forum.isLimitedInput() || forum.isAllowRichEditor() ? forum.getLimitedChar() : 0; - sessionMap.put(ForumConstants.FORUM_ID, forumId); sessionMap.put(AttributeNames.ATTR_MODE, mode); + sessionMap.put(ForumConstants.ATTR_FORUM_ID, forumId); + sessionMap.put(ForumConstants.ATTR_FORUM_UID, forum.getUid()); + sessionMap.put(ForumConstants.ATTR_USER_UID, forumUser.getUid()); sessionMap.put(ForumConstants.ATTR_FINISHED_LOCK, new Boolean(lock)); sessionMap.put(ForumConstants.ATTR_LOCK_WHEN_FINISHED, forum.getLockWhenFinished()); sessionMap.put(ForumConstants.ATTR_USER_FINISHED, forumUser.isSessionFinished()); @@ -240,6 +242,15 @@ request, getServlet().getServletContext()); sessionMap.put(AttributeNames.ATTR_ACTIVITY_POSITION, activityPosition); + int numOfRatings = forumService.getNumOfRatingsByUserAndForum(forumUser.getUid(), forum.getUid()); + boolean noMoreRatings = (forum.getMaximumRate() != 0) && (numOfRatings >= forum.getMaximumRate()) + && forum.isAllowRateMessages(); + boolean isMinRatingsCompleted = (forum.getMinimumRate() == 0) || (numOfRatings >= forum.getMinimumRate()) + && forum.isAllowRateMessages(); + sessionMap.put(ForumConstants.ATTR_NO_MORE_RATINGSS, noMoreRatings); + sessionMap.put(ForumConstants.ATTR_IS_MIN_RATINGS_COMPLETED, isMinRatingsCompleted); + sessionMap.put(ForumConstants.ATTR_NUM_OF_RATINGS, numOfRatings); + // 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. // Need to constantly past this value on, rather than hiding just the once, as the View Forum @@ -542,7 +553,7 @@ MessageForm messageForm = (MessageForm) form; SessionMap sessionMap = getSessionMap(request, messageForm); - Long forumId = (Long) sessionMap.get(ForumConstants.FORUM_ID); + Long forumId = (Long) sessionMap.get(ForumConstants.ATTR_FORUM_ID); Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); List rootTopics = forumService.getRootTopics(sessionId); @@ -699,7 +710,7 @@ forumService.saveTimestamp(rootTopicId, forumUser); // notify learners and teachers - Long forumId = (Long) sessionMap.get(ForumConstants.FORUM_ID); + Long forumId = (Long) sessionMap.get(ForumConstants.ATTR_FORUM_ID); forumService.sendNotificationsOnNewPosting(forumId, sessionId, message); return mapping.findForward("success"); @@ -894,27 +905,43 @@ * @param request * @param response * @return - * @throws JSONException - * @throws IOException - * @throws ServletException - * @throws ToolException */ public ActionForward rateMessage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws JSONException, IOException { forumService = getForumManager(); - + String sessionMapId = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapId); + Long forumUid = (Long) sessionMap.get(ForumConstants.ATTR_FORUM_UID); + Long userUid = (Long) sessionMap.get(ForumConstants.ATTR_USER_UID); + boolean isAllowRateMessages = (Boolean) sessionMap.get(ForumConstants.ATTR_ALLOW_RATE_MESSAGES); + int forumMaximumRate = (Integer) sessionMap.get(ForumConstants.ATTR_MAXIMUM_RATE); + int forumMinimumRate = (Integer) sessionMap.get(ForumConstants.ATTR_MINIMUM_RATE); + float rating = Float.parseFloat((String) request.getParameter("rate")); Long responseId = WebUtil.readLongParam(request, "idBox"); Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); Long userId = new Long(user.getUserID().intValue()); AverageRatingDTO averageRatingDTO = forumService.rateMessage(responseId, userId, toolSessionID, rating); + + //refresh numOfRatings and noMoreRatings + int numOfRatings = forumService.getNumOfRatingsByUserAndForum(userUid, forumUid); + boolean noMoreRatings = (forumMaximumRate != 0) && (numOfRatings >= forumMaximumRate) + && isAllowRateMessages; + boolean isMinRatingsCompleted = (forumMinimumRate != 0) && (numOfRatings >= forumMinimumRate) + && isAllowRateMessages; + sessionMap.put(ForumConstants.ATTR_NO_MORE_RATINGSS, noMoreRatings); + sessionMap.put(ForumConstants.ATTR_IS_MIN_RATINGS_COMPLETED, isMinRatingsCompleted); + sessionMap.put(ForumConstants.ATTR_NUM_OF_RATINGS, numOfRatings); JSONObject JSONObject = new JSONObject(); JSONObject.put("averageRating", averageRatingDTO.getRating()); JSONObject.put("numberOfVotes", averageRatingDTO.getNumberOfVotes()); + JSONObject.put(ForumConstants.ATTR_NO_MORE_RATINGSS, noMoreRatings); + JSONObject.put(ForumConstants.ATTR_NUM_OF_RATINGS, numOfRatings); response.setContentType("application/json;charset=utf-8"); response.getWriter().print(JSONObject); return null; Index: lams_tool_forum/web/common/tabbedheader.jsp =================================================================== diff -u -r0762d2ed47bda6daf6a2ae4eca9b3409b7c3b3ea -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/web/common/tabbedheader.jsp (.../tabbedheader.jsp) (revision 0762d2ed47bda6daf6a2ae4eca9b3409b7c3b3ea) +++ lams_tool_forum/web/common/tabbedheader.jsp (.../tabbedheader.jsp) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -7,7 +7,6 @@ - @@ -18,7 +17,6 @@ - Index: lams_tool_forum/web/jsps/authoring/advance.jsp =================================================================== diff -u -rf1e0b7ce7d91dd9bb8c03647456beec2be16b612 -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/web/jsps/authoring/advance.jsp (.../advance.jsp) (revision f1e0b7ce7d91dd9bb8c03647456beec2be16b612) +++ lams_tool_forum/web/jsps/authoring/advance.jsp (.../advance.jsp) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -4,8 +4,6 @@ - -

@@ -35,7 +33,7 @@

- + @@ -51,9 +49,8 @@ 10 - - + @@ -68,10 +65,8 @@ 9 10 -

-

@@ -287,16 +282,21 @@ } checkRating(); - function validateRatings() { + function validateRatings(isMinimunRateDropdownUsed) { var minRateDropDown = document.getElementById("minimumRate"); - var minRatings = minRateDropDown.options[minRateDropDown.selectedIndex].value; + var minRatings = parseInt(minRateDropDown.options[minRateDropDown.selectedIndex].value); var maxRateDropDown = document.getElementById("maximumRate"); - var maxRatings = maxRateDropDown.options[maxRateDropDown.selectedIndex].value; + var maxRatings = parseInt(maxRateDropDown.options[maxRateDropDown.selectedIndex].value); if((minRatings > maxRatings) && !(maxRatings == 0)){ + if (isMinimunRateDropdownUsed) { + minRateDropDown.selectedIndex = maxRateDropDown.selectedIndex; + } else { + maxRateDropDown.selectedIndex = minRateDropDown.selectedIndex; + } + alert(''); } - } function checkReflection(){ @@ -309,5 +309,3 @@ } } - - Index: lams_tool_forum/web/jsps/authoring/authoring.jsp =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/web/jsps/authoring/authoring.jsp (.../authoring.jsp) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_forum/web/jsps/authoring/authoring.jsp (.../authoring.jsp) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -1,8 +1,24 @@ <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.forum.util.ForumConstants"%> + + + styleId="authoringForm" enctype="multipart/form-data" onsubmit="return verifyAllowRateMessagesCheckbox();"> Index: lams_tool_forum/web/jsps/learning/ratingStars.jsp =================================================================== diff -u -rf7d806b0ab4f783c2dd89e920d7f6edf370c04db -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/web/jsps/learning/ratingStars.jsp (.../ratingStars.jsp) (revision f7d806b0ab4f783c2dd89e920d7f6edf370c04db) +++ lams_tool_forum/web/jsps/learning/ratingStars.jsp (.../ratingStars.jsp) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -1,7 +1,7 @@ <%@ include file="/common/taglibs.jsp"%> - + Index: lams_tool_forum/web/jsps/learning/submissionDeadline.jsp =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/web/jsps/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_forum/web/jsps/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -57,5 +57,3 @@ - - Index: lams_tool_forum/web/jsps/learning/viewforum.jsp =================================================================== diff -u -re52d467fe486dbe4f918436e7abe5e88f3b5eabd -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/web/jsps/learning/viewforum.jsp (.../viewforum.jsp) (revision e52d467fe486dbe4f918436e7abe5e88f3b5eabd) +++ lams_tool_forum/web/jsps/learning/viewforum.jsp (.../viewforum.jsp) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -1,14 +1,26 @@ <%@ include file="/common/taglibs.jsp"%> - + + + + + + + + + +

-
@@ -20,8 +32,7 @@
- +
@@ -38,70 +49,65 @@
- - + +
- +
- +
- - -
- - - - -
-
+ -
- - - + + + + + + + + + + + + + + + + + + + + +
+ + + +
-
- - -
- - - -
-
- + +
<%@ include file="/common/messages.jsp"%> - - - - - - - -
@@ -116,8 +122,7 @@ - +
@@ -133,8 +138,7 @@ - +

${sessionMap.reflectInstructions} @@ -163,18 +167,10 @@

- -
- + - + @@ -183,8 +179,7 @@ - + Index: lams_tool_forum/web/jsps/learning/viewtopic.jsp =================================================================== diff -u -rf7d806b0ab4f783c2dd89e920d7f6edf370c04db -r281244f5d518e88719ffc871ac71bb03136cb03e --- lams_tool_forum/web/jsps/learning/viewtopic.jsp (.../viewtopic.jsp) (revision f7d806b0ab4f783c2dd89e920d7f6edf370c04db) +++ lams_tool_forum/web/jsps/learning/viewtopic.jsp (.../viewtopic.jsp) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) @@ -1,5 +1,4 @@ - + <%@ include file="/common/taglibs.jsp"%> @@ -41,12 +40,20 @@