Index: lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -176,6 +176,6 @@ label.use.select.leader.tool.output =Use leaders from Select Leader tool label.group.leader =Group leader: {0} button.submitActivity =Finish +label.all.groups.total =All groups total - #======= End labels: Exported 171 labels for en AU ===== Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/SessionDTO.java =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/SessionDTO.java (.../SessionDTO.java) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/SessionDTO.java (.../SessionDTO.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -35,15 +35,17 @@ * @author Ozgur Demirtas */ public class SessionDTO implements Comparable { - private String sessionUserCount; - private String completedSessionUserCount; + private int sessionUserCount; + private int completedSessionUserCount; private String sessionId; private String sessionName; - private Map mapStandardNominationsContent; private Map mapStandardNominationsHTMLedContent; - private Map mapStandardQuestionUid; private Map mapStandardToolSessionUid; + private boolean existsOpenVote; + private Map mapStandardUserCount; + private Map mapStandardRatesContent; + private List openVotes; /** * @return Returns the mapStandardQuestionUid. @@ -75,24 +77,20 @@ this.mapStandardToolSessionUid = mapStandardToolSessionUid; } - private Map mapStandardUserCount; - private Map mapStandardRatesContent; - private List listUserEntries; - private String existsOpenVote; /** - * @return Returns the listUserEntries. + * @return Returns the openVotes. */ - public List getListUserEntries() { - return listUserEntries; + public List getOpenVotes() { + return openVotes; } /** - * @param listUserEntries - * The listUserEntries to set. + * @param openVotes + * The openVotes to set. */ - public void setListUserEntries(List listUserEntries) { - this.listUserEntries = listUserEntries; + public void setOpenVotes(List openVotes) { + this.openVotes = openVotes; } /** @@ -113,15 +111,15 @@ /** * @return Returns the mapStandardUserCount. */ - public Map getMapStandardUserCount() { + public Map getMapStandardUserCount() { return mapStandardUserCount; } /** * @param mapStandardUserCount * The mapStandardUserCount to set. */ - public void setMapStandardUserCount(Map mapStandardUserCount) { + public void setMapStandardUserCount(Map mapStandardUserCount) { this.mapStandardUserCount = mapStandardUserCount; } @@ -141,15 +139,15 @@ /** * @return Returns the completedSessionUserCount. */ - public String getCompletedSessionUserCount() { + public int getCompletedSessionUserCount() { return completedSessionUserCount; } /** * @param completedSessionUserCount * The completedSessionUserCount to set. */ - public void setCompletedSessionUserCount(String completedSessionUserCount) { + public void setCompletedSessionUserCount(int completedSessionUserCount) { this.completedSessionUserCount = completedSessionUserCount; } @@ -171,34 +169,19 @@ /** * @return Returns the sessionUserCount. */ - public String getSessionUserCount() { + public int getSessionUserCount() { return sessionUserCount; } /** * @param sessionUserCount * The sessionUserCount to set. */ - public void setSessionUserCount(String sessionUserCount) { + public void setSessionUserCount(int sessionUserCount) { this.sessionUserCount = sessionUserCount; } /** - * @return Returns the mapStandardNominationsContent. - */ - public Map getMapStandardNominationsContent() { - return mapStandardNominationsContent; - } - - /** - * @param mapStandardNominationsContent - * The mapStandardNominationsContent to set. - */ - public void setMapStandardNominationsContent(Map mapStandardNominationsContent) { - this.mapStandardNominationsContent = mapStandardNominationsContent; - } - - /** * @return Returns the mapStandardNominationsHTMLedContent. */ public Map getMapStandardNominationsHTMLedContent() { @@ -216,15 +199,15 @@ /** * @return Returns the existsOpenVote. */ - public String getExistsOpenVote() { + public boolean getExistsOpenVote() { return existsOpenVote; } /** * @param existsOpenVote * The existsOpenVote to set. */ - public void setExistsOpenVote(String existsOpenVote) { + public void setExistsOpenVote(boolean existsOpenVote) { this.existsOpenVote = existsOpenVote; } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteComparator.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteComparator.java (.../VoteComparator.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteComparator.java (.../VoteComparator.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -26,24 +26,36 @@ import java.util.Comparator; /** - * @author Ozgur Demirtas - * A comparator implementation that can be used as a constructor to collections. - * The TreeMap in the web layer makes use of it. + * @author Ozgur Demirtas A comparator implementation that can be used as a constructor to collections. The TreeMap in + * the web layer makes use of it. * */ public class VoteComparator implements Comparator, Serializable { + + public int compare(Object o1, Object o2) { - public int compare(Object o1, Object o2) { - String s1 = (String)o1; - String s2 = (String)o2; - - int key1=new Long(s1).intValue(); - int key2=new Long(s2).intValue(); - return key1 - key2; - } + int key1; + int key2; + + if (o1 instanceof Long) { + Long s1 = (Long) o1; + Long s2 = (Long) o2; - public boolean equals(Object o) { - String s = (String)o; - return compare(this, o)==0; - } + key1 = s1.intValue(); + key2 = s2.intValue(); + + } else { + String s1 = (String) o1; + String s2 = (String) o2; + + key1 = new Long(s1).intValue(); + key2 = new Long(s2).intValue(); + } + + return key1 - key2; + } + + public boolean equals(Object o) { + return compare(this, o) == 0; + } } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java =================================================================== diff -u -r96866054a8598fbe1b6719c40ea9a5ed898f5daf -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java (.../IVoteUsrAttemptDAO.java) (revision 96866054a8598fbe1b6719c40ea9a5ed898f5daf) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java (.../IVoteUsrAttemptDAO.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -59,7 +59,7 @@ int getSessionEntriesCount(final Long voteSessionId); - int getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId, final Long voteContentUid); + List getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId); int getAttemptsForQuestionContent(final Long voteQueContentId); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java =================================================================== diff -u -r96866054a8598fbe1b6719c40ea9a5ed898f5daf -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java (.../VoteUsrAttemptDAO.java) (revision 96866054a8598fbe1b6719c40ea9a5ed898f5daf) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java (.../VoteUsrAttemptDAO.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -196,24 +196,11 @@ } - public int getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId, final Long voteContentUid) { + public List getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId) { List list = getSession().createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_QUESTION_CONTENT).setLong( "voteQueContentId", voteQueContentId.longValue()).list(); + return list; - List userEntries = new ArrayList(); - if (list != null && list.size() > 0) { - Iterator listIterator = list.iterator(); - while (listIterator.hasNext()) { - VoteUsrAttempt attempt = (VoteUsrAttempt) listIterator.next(); - - if (attempt.getVoteQueUsr().getVoteSession().getVoteContent().getUid().toString().equals( - voteContentUid.toString())) { - userEntries.add(attempt); - } - } - } - return userEntries.size(); - } public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long voteQueContentId) { Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -158,7 +158,7 @@ Set getUserEntries() throws VoteApplicationException; - int getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId, final Long voteContentUid); + List getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId); List getSessionUserEntries(final Long voteSessionId) throws VoteApplicationException; Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -554,10 +554,9 @@ } } - public int getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId, final Long voteContentUid) { + public List getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId) { try { - return voteUsrAttemptDAO.getStandardAttemptsForQuestionContentAndContentUid(voteQueContentId, - voteContentUid); + return voteUsrAttemptDAO.getStandardAttemptsForQuestionContentAndContentUid(voteQueContentId); } catch (DataAccessException e) { throw new VoteApplicationException( "Exception occured when lams is getting all standard attempts entries count: " + e.getMessage(), e); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -385,19 +385,6 @@ return map; } - public static double calculateTotal(Map mapVoteRatesContent) { - double total = 0d; - Iterator itMap = mapVoteRatesContent.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry) itMap.next(); - - if (pairs.getValue() != null) { - total = total + new Double(pairs.getValue().toString()).doubleValue(); - } - } - return total; - } - public static Map convertToMap(List list) { Map map = new TreeMap(new VoteComparator()); @@ -510,17 +497,9 @@ int mapVoteRatesSize = mapVoteRatesContent.size(); mapIndex = new Long(mapVoteRatesSize + 1); - double total = MonitoringUtil.calculateTotal(mapVoteRatesContent); - double share = 100 - total; - int userEnteredVotesCount = entriesCount - totalStandardVotesCount; + double share = (userEnteredVotesCount != 0) ? ((userEnteredVotesCount * 100) / entriesCount) : 0; - if (userEnteredVotesCount != 0) { - share = ((userEnteredVotesCount * 100) / entriesCount); - } else { - share = 0; - } - if (voteContent.isAllowText()) { mapStandardNominationsContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); mapStandardNominationsHTMLedContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -37,6 +37,7 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.apache.commons.lang.StringUtils; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; @@ -203,11 +204,11 @@ } - public static List processUserEnteredNominations(IVoteService voteService, VoteContent voteContent, + public static List processUserEnteredNominations(IVoteService voteService, VoteContent voteContent, String currentSessionId, boolean showUserEntriesBySession, String userId, boolean showUserEntriesByUserId) { Set userEntries = voteService.getUserEntries(); - List listUserEntries = new LinkedList(); + List listUserEntries = new LinkedList(); Iterator itListNominations = userEntries.iterator(); while (itListNominations.hasNext()) { @@ -305,12 +306,7 @@ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; -// voteMonitoringForm.setVoteService(voteService); -// VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - -// repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - String currentUid = voteMonitoringForm.getCurrentUid(); VoteUsrAttempt voteUsrAttempt = voteService.getAttemptByUID(new Long(currentUid)); @@ -320,75 +316,19 @@ voteService.hideOpenVote(voteUsrAttempt); String toolContentID = voteMonitoringForm.getToolContentID(); -// VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); -// initSummaryContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); -// initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); -// refreshSummaryData(request, voteContent, voteService, true, false, null, null, true, -// null, voteGeneralMonitoringDTO, null); -// -// voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); -// -// if (voteService.studentActivityOccurredGlobal(voteContent)) { -// voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); -// } else { -// voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); -// } -// -// request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); -// -// request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); -// -// if (voteContent != null) { -// // prepareReflectionData(request, voteContent, voteService, null,false); -// prepareReflectionData(request, voteContent, voteService, null, false); -// -// EditActivityDTO editActivityDTO = new EditActivityDTO(); -// boolean isContentInUse = VoteUtils.isContentInUse(voteContent); -// if (isContentInUse == true) { -// editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); -// } -// request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); -// } -// -// /* find out if there are any reflection entries, from here */ -// boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); -// -// if (notebookEntriesExist) { -// request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); -// -// String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); -// -// if (userExceptionNoToolSessions.equals("true")) { -// request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); -// } -// } else { -// request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); -// } -// /* ... till here */ -// -// MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); ActionRedirect redirect = new ActionRedirect( mapping.findForwardConfig(VoteAppConstants.MONITORING_STARTER_REDIRECT)); redirect.addParameter(AttributeNames.PARAM_TOOL_CONTENT_ID, toolContentID); return redirect; -// -// -// return submitSession(mapping, form, request, response, voteService, getMessageService(), -// voteGeneralMonitoringDTO); } public ActionForward showOpenVote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, ToolException { IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; -// voteMonitoringForm.setVoteService(voteService); -// VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - -// repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - String currentUid = voteMonitoringForm.getCurrentUid(); VoteUsrAttempt voteUsrAttempt = voteService.getAttemptByUID(new Long(currentUid)); @@ -398,56 +338,6 @@ voteService.showOpenVote(voteUsrAttempt); String toolContentID = voteMonitoringForm.getToolContentID(); - -// VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); -// -// initSummaryContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); -// -// initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); -// -// refreshSummaryData(request, voteContent, voteService, true, false, null, null, true, -// null, voteGeneralMonitoringDTO, null); -// -// voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); -// -// if (voteService.studentActivityOccurredGlobal(voteContent)) { -// voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); -// } else { -// voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); -// } -// -// request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); -// -// if (voteContent != null) { -// // prepareReflectionData(request, voteContent, voteService, null,false); -// prepareReflectionData(request, voteContent, voteService, null, false); -// -// EditActivityDTO editActivityDTO = new EditActivityDTO(); -// boolean isContentInUse = VoteUtils.isContentInUse(voteContent); -// if (isContentInUse == true) { -// editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); -// } -// request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); -// } -// -// /* find out if there are any reflection entries, from here */ -// boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); -// if (notebookEntriesExist) { -// request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); -// -// String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); -// -// if (userExceptionNoToolSessions.equals("true")) { -// request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); -// } -// } else { -// request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); -// } -// /* ... till here */ -// -// MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); -// return submitSession(mapping, form, request, response, voteService, getMessageService(), -// voteGeneralMonitoringDTO); ActionRedirect redirect = new ActionRedirect( mapping.findForwardConfig(VoteAppConstants.MONITORING_STARTER_REDIRECT)); @@ -469,12 +359,21 @@ String questionUid = request.getParameter("questionUid"); String sessionUid = request.getParameter("sessionUid"); - List userNames = voteService.getStandardAttemptUsersForQuestionContentAndSessionUid(new Long(questionUid), - new Long(sessionUid)); + List userAttempts; + //in regular case when we need info for particular session + if (StringUtils.isNotBlank(sessionUid)) { + userAttempts = voteService.getStandardAttemptUsersForQuestionContentAndSessionUid(new Long(questionUid), + new Long(sessionUid)); + + //in case of All sessions + } else { + userAttempts = voteService.getStandardAttemptsForQuestionContentAndContentUid(new Long(questionUid)); + } + List listVotedLearnersDTO = new LinkedList(); VoteContent voteContent = null; - Iterator userIterator = userNames.iterator(); + Iterator userIterator = userAttempts.iterator(); while (userIterator.hasNext()) { VoteUsrAttempt voteUsrAttempt = (VoteUsrAttempt) userIterator.next(); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -23,6 +23,7 @@ package org.lamsfoundation.lams.tool.vote.web; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -49,6 +50,7 @@ import org.lamsfoundation.lams.tool.vote.VoteComparator; import org.lamsfoundation.lams.tool.vote.VoteGeneralAuthoringDTO; import org.lamsfoundation.lams.tool.vote.VoteGeneralMonitoringDTO; +import org.lamsfoundation.lams.tool.vote.VoteMonitoredAnswersDTO; import org.lamsfoundation.lams.tool.vote.VoteNominationContentDTO; import org.lamsfoundation.lams.tool.vote.VoteUtils; import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; @@ -250,125 +252,161 @@ private static List getSessionDTOs(HttpServletRequest request, IVoteService voteService, VoteMonitoringForm voteMonitoringForm, Long toolContentID, MessageService messageService) { - List sessionsDTOs = new LinkedList(); + LinkedList sessionDTOs = new LinkedList(); VoteContent voteContent = voteService.retrieveVote(toolContentID); + for (VoteSession session: (Set)voteContent.getVoteSessions()) { - Iterator itListSessions = voteContent.getVoteSessions().iterator(); - while (itListSessions.hasNext()) { - VoteSession voteSession = (VoteSession) itListSessions.next(); + SessionDTO sessionDTO = new SessionDTO(); + sessionDTO.setSessionId(session.getVoteSessionId().toString()); + sessionDTO.setSessionName(session.getSession_name()); - Map mapOptionsContent = new TreeMap(new VoteComparator()); - Map mapVoteRatesContent = new TreeMap(new VoteComparator()); + int entriesCount = voteService.getSessionEntriesCount(session.getUid()); - SessionDTO sessionDTO = new SessionDTO(); - sessionDTO.setSessionId(voteSession.getVoteSessionId().toString()); - sessionDTO.setSessionName(voteSession.getSession_name()); + // potentialUserCount + int potentialUserCount = voteService.getVoteSessionPotentialLearnersCount(session.getUid()); + sessionDTO.setSessionUserCount(potentialUserCount); - int entriesCount = voteService.getSessionEntriesCount(voteSession.getUid()); - Set userEntries = voteService.getSessionUserEntriesSet(voteSession.getUid()); + //completedSessionUserCount + int completedSessionUserCount = voteService.getCompletedVoteUserBySessionUid(session.getUid()); + sessionDTO.setCompletedSessionUserCount(completedSessionUserCount); - int potentialUserCount = voteService.getVoteSessionPotentialLearnersCount(voteSession.getUid()); - sessionDTO.setSessionUserCount(Integer.toString(potentialUserCount)); + Long mapIndex = 1L; + int totalStandardVotesCount = 0; - int completedSessionUserCount = voteService.getCompletedVoteUserBySessionUid(voteSession.getUid()); - sessionDTO.setCompletedSessionUserCount(new Integer(completedSessionUserCount).toString()); + Map mapVoteRates = new TreeMap(new VoteComparator()); + Map mapStandardUserCount = new TreeMap(new VoteComparator()); + Map mapStandardNominationsHTMLedContent = new TreeMap(new VoteComparator()); + Map mapStandardQuestionUid = new TreeMap(new VoteComparator()); + Map mapStandardToolSessionUid = new TreeMap(new VoteComparator()); - Map mapStandardUserCount = new TreeMap(new VoteComparator()); + for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) { + mapStandardNominationsHTMLedContent.put(mapIndex, question.getQuestion()); - mapOptionsContent.clear(); - Iterator queIterator = voteContent.getVoteQueContents().iterator(); - Long mapIndex = new Long(1); - int totalStandardVotesCount = 0; + int votesCount = voteService.getStandardAttemptsForQuestionContentAndSessionUid(question.getUid(), + session.getUid()); + totalStandardVotesCount += votesCount; + mapStandardUserCount.put(mapIndex, new Long(votesCount)); - Map mapStandardNominationsHTMLedContent = new TreeMap(new VoteComparator()); - Map mapStandardQuestionUid = new TreeMap(new VoteComparator()); - Map mapStandardToolSessionUid = new TreeMap(new VoteComparator()); + mapStandardQuestionUid.put(mapIndex, question.getUid()); + mapStandardToolSessionUid.put(mapIndex, session.getUid()); - while (queIterator.hasNext()) { - VoteQueContent question = (VoteQueContent) queIterator.next(); - if (question != null) { - mapStandardNominationsHTMLedContent.put(mapIndex.toString(), question.getQuestion()); - String noHTMLNomination = VoteUtils.stripHTML(question.getQuestion()); - mapOptionsContent.put(mapIndex.toString(), noHTMLNomination); + Double voteRate = (entriesCount != 0) ? ((votesCount * 100) / entriesCount) : 0d; + mapVoteRates.put(mapIndex, voteRate); + + // mapIndex++ + mapIndex = new Long(mapIndex + 1); + } - int votesCount = 0; - votesCount = voteService.getStandardAttemptsForQuestionContentAndSessionUid( - question.getUid(), voteSession.getUid()); + //open votes + if (voteContent.isAllowText()) { + int userEnteredVotesCount = entriesCount - totalStandardVotesCount; + Double voteRate = (userEnteredVotesCount != 0) ? ((userEnteredVotesCount * 100) / entriesCount) : 0d; + mapVoteRates.put(mapIndex, voteRate); + + mapStandardNominationsHTMLedContent.put(mapIndex, messageService.getMessage("label.open.vote")); + mapStandardUserCount.put(mapIndex, new Long(userEnteredVotesCount)); + /** following are needed just for proper iteration in the summary jsp */ + mapStandardQuestionUid.put(mapIndex, 1L); + mapStandardToolSessionUid.put(mapIndex, 1L); + } - mapStandardQuestionUid.put(mapIndex.toString(), question.getUid().toString()); - mapStandardToolSessionUid.put(mapIndex.toString(), voteSession.getUid()); + sessionDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); + sessionDTO.setMapStandardUserCount(mapStandardUserCount); + sessionDTO.setMapStandardRatesContent(mapVoteRates); + sessionDTO.setMapStandardQuestionUid(mapStandardQuestionUid); + sessionDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); - mapStandardUserCount.put(mapIndex.toString(), new Integer(votesCount).toString()); - totalStandardVotesCount = totalStandardVotesCount + votesCount; + List openVotes = VoteMonitoringAction.processUserEnteredNominations(voteService, voteContent, + session.getVoteSessionId().toString(), true, null, false); + sessionDTO.setOpenVotes(openVotes); + boolean isExistsOpenVote = openVotes.size() > 0; + sessionDTO.setExistsOpenVote(isExistsOpenVote); - double voteRate = 0d; - double doubleVotesCount = votesCount * 1d; - double doubleEntriesCount = entriesCount * 1d; + sessionDTOs.add(sessionDTO); + } + + //All groups total + if (sessionDTOs.size() > 1) { + SessionDTO totalSessionDTO = new SessionDTO(); + totalSessionDTO.setSessionId("0"); + totalSessionDTO.setSessionName(messageService.getMessage("label.all.groups.total")); - if (entriesCount != 0) { - voteRate = ((doubleVotesCount * 100) / doubleEntriesCount); - } - String stringVoteRate = new Double(voteRate).toString(); - int lengthVoteRate = stringVoteRate.length(); - if (lengthVoteRate > 5) - stringVoteRate = stringVoteRate.substring(0, 6); + List totalOpenVotes = new ArrayList(); + int totalPotentialUserCount = 0; + int totalCompletedSessionUserCount = 0; + int allSessionsVotesCount = 0; + Map totalMapStandardUserCount = new TreeMap(new VoteComparator()); + for (SessionDTO sessionDTO : sessionDTOs) { - mapVoteRatesContent.put(mapIndex.toString(), stringVoteRate); - mapIndex = new Long(mapIndex.longValue() + 1); + totalPotentialUserCount += sessionDTO.getSessionUserCount(); + totalCompletedSessionUserCount += sessionDTO.getCompletedSessionUserCount(); + + Long mapIndex = 1L; + for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) { + Long votesCount = sessionDTO.getMapStandardUserCount().get(mapIndex); + Long oldTotalVotesCount = (totalMapStandardUserCount.get(mapIndex) != null) ? totalMapStandardUserCount + .get(mapIndex) : 0; + totalMapStandardUserCount.put(mapIndex, oldTotalVotesCount + votesCount); + + allSessionsVotesCount += votesCount; + + // mapIndex++ + mapIndex = new Long(mapIndex + 1); } + + //open votes + if (voteContent.isAllowText()) { + Long votesCount = sessionDTO.getMapStandardUserCount().get(mapIndex); + Long oldTotalVotesCount = (totalMapStandardUserCount.get(mapIndex) != null) ? totalMapStandardUserCount + .get(mapIndex) : 0; + totalMapStandardUserCount.put(mapIndex, oldTotalVotesCount + votesCount); + + allSessionsVotesCount += votesCount; + } + + totalOpenVotes.addAll(sessionDTO.getOpenVotes()); } - Map mapStandardNominationsContent = new TreeMap(new VoteComparator()); - mapStandardNominationsContent = mapOptionsContent; + totalSessionDTO.setSessionUserCount(totalPotentialUserCount); + totalSessionDTO.setCompletedSessionUserCount(totalCompletedSessionUserCount); + totalSessionDTO.setOpenVotes(totalOpenVotes); + boolean isExistsOpenVote = totalOpenVotes.size() > 0; + totalSessionDTO.setExistsOpenVote(isExistsOpenVote); + totalSessionDTO.setMapStandardNominationsHTMLedContent(sessionDTOs.get(0) + .getMapStandardNominationsHTMLedContent()); + totalSessionDTO.setMapStandardQuestionUid(sessionDTOs.get(0).getMapStandardQuestionUid()); + totalSessionDTO.setMapStandardToolSessionUid(sessionDTOs.get(0).getMapStandardToolSessionUid()); + totalSessionDTO.setMapStandardUserCount(totalMapStandardUserCount); - Map mapStandardRatesContent = new TreeMap(new VoteComparator()); - mapStandardRatesContent = mapVoteRatesContent; + // All groups total -- totalMapVoteRates part + Long mapIndex = 1L; + Map totalMapVoteRates = new TreeMap(new VoteComparator()); + int totalStandardVotesCount = 0; + for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) { - Iterator itListQuestions = userEntries.iterator(); - int mapVoteRatesSize = mapVoteRatesContent.size(); - mapIndex = new Long(mapVoteRatesSize + 1); + Long votesCount = totalMapStandardUserCount.get(mapIndex); - double total = MonitoringUtil.calculateTotal(mapVoteRatesContent); - double share = 100d - total; - int userEnteredVotesCount = entriesCount - totalStandardVotesCount; + double voteRate = (allSessionsVotesCount != 0) ? ((votesCount * 100) / allSessionsVotesCount) : 0d; + totalMapVoteRates.put(mapIndex, voteRate); + + totalStandardVotesCount += votesCount; - if (userEnteredVotesCount != 0) { - share = ((userEnteredVotesCount * 100) / entriesCount); - } else { - share = 0; + // mapIndex++ + mapIndex = new Long(mapIndex + 1); } - + // open votes if (voteContent.isAllowText()) { - mapStandardNominationsContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); - mapStandardNominationsHTMLedContent.put(mapIndex.toString(), - messageService.getMessage("label.open.vote")); + int userEnteredVotesCount = allSessionsVotesCount - totalStandardVotesCount; + double voteRate = (userEnteredVotesCount != 0) ? ((userEnteredVotesCount * 100) / allSessionsVotesCount) + : 0; + totalMapVoteRates.put(mapIndex, voteRate); } - mapStandardRatesContent.put(mapIndex.toString(), new Double(share).toString()); - mapStandardUserCount.put(mapIndex.toString(), new Integer(userEnteredVotesCount).toString()); - /** following are needed just for proper iteration in the summary jsp */ - mapStandardQuestionUid.put(mapIndex.toString(), "1"); - mapStandardToolSessionUid.put(mapIndex.toString(), "1"); + totalSessionDTO.setMapStandardRatesContent(totalMapVoteRates); - sessionDTO.setMapStandardNominationsContent(mapStandardNominationsContent); - sessionDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); - sessionDTO.setMapStandardUserCount(mapStandardUserCount); - sessionDTO.setMapStandardRatesContent(mapStandardRatesContent); - sessionDTO.setMapStandardQuestionUid(mapStandardQuestionUid); - sessionDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); - - List listUserEntries = VoteMonitoringAction.processUserEnteredNominations(voteService, voteContent, - voteSession.getVoteSessionId().toString(), true, null, false); - sessionDTO.setListUserEntries(listUserEntries); - - if (listUserEntries.size() > 0) - sessionDTO.setExistsOpenVote(new Boolean(true).toString()); - else - sessionDTO.setExistsOpenVote(new Boolean(false).toString()); - - sessionsDTOs.add(sessionDTO); + sessionDTOs.addFirst(totalSessionDTO); } - return sessionsDTOs; + return sessionDTOs; } private boolean initialiseMonitoringData(ActionMapping mapping, ActionForm form, HttpServletRequest request, Index: lams_tool_vote/web/monitoring/AllSessionsSummary.jsp =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/web/monitoring/AllSessionsSummary.jsp (.../AllSessionsSummary.jsp) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/web/monitoring/AllSessionsSummary.jsp (.../AllSessionsSummary.jsp) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -10,9 +10,9 @@ -

- -

+

+ +


@@ -44,9 +44,18 @@ - + + + + + + + + + + - monitoring.do?dispatch=getVoteNomination&questionUid=${currentQuestionUid.value}&sessionUid=${currentSessionUid.value} + monitoring.do?dispatch=getVoteNomination&questionUid=${currentQuestionUid.value}&sessionUid=${sessionUidParam} @@ -67,41 +76,41 @@ - +
-  ( ) +  ( ) - + - - + + - - + +
- + Index: lams_tool_vote/web/monitoring/SummaryContent.jsp =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -re4da02a26c682a8b710501b48f3da29dd07e0bc0 --- lams_tool_vote/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) @@ -20,8 +20,10 @@ $(document).ready(function(){ + drawChart('bar', ${currentDto.sessionId}0, {'currentSessionId' : '${currentDto.sessionId}'}); drawChart('pie', ${currentDto.sessionId}1, {'currentSessionId' : '${currentDto.sessionId}'}); + });