Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -161,9 +161,7 @@ public static final String MAP_VOTERATES_CONTENT = "mapVoteRatesContent"; public static final String MAP_STANDARD_USER_COUNT = "mapStandardUserCount"; public static final String MAP_STANDARD_NOMINATIONS_VISIBILITY = "mapStandardNominationsVisibility"; - public static final String MAP_STANDARD_NOMINATIONS_CONTENT = "mapStandardNominationsContent"; public static final String MAP_STANDARD_NOMINATIONS_HTMLED_CONTENT = "mapStandardNominationsHTMLedContent"; - public static final String MAP_STANDARD_RATES_CONTENT = "mapStandardRatesContent"; public static final String MAP_OPTIONS_CONTENT_FCK = "mapOptionsContentFck"; public static final String MAP_DEFAULTOPTIONS_CONTENT = "mapDefaultOptionsContent"; public static final String MAP_DISABLED_QUESTIONS = "mapDisabledQuestions"; Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteGeneralLearnerFlowDTO.java =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteGeneralLearnerFlowDTO.java (.../VoteGeneralLearnerFlowDTO.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteGeneralLearnerFlowDTO.java (.../VoteGeneralLearnerFlowDTO.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -96,17 +96,17 @@ protected Map mapGeneralCheckedOptionsContent; - protected Map mapStandardNominationsContent; + protected Map mapStandardNominationsContent; - protected Map mapStandardNominationsHTMLedContent; + protected Map mapStandardNominationsHTMLedContent; - protected Map mapStandardRatesContent; + protected Map mapStandardRatesContent; - protected Map mapStandardUserCount; + protected Map mapStandardUserCount; - protected Map mapStandardQuestionUid; + protected Map mapStandardQuestionUid; - protected Map mapStandardToolSessionUid; + protected Map mapStandardToolSessionUid; protected List listMonitoredAnswersContainerDto; @@ -507,60 +507,60 @@ /** * @return Returns the mapStandardNominationsContent. */ - public Map getMapStandardNominationsContent() { + public Map getMapStandardNominationsContent() { return mapStandardNominationsContent; } /** * @param mapStandardNominationsContent * The mapStandardNominationsContent to set. */ - public void setMapStandardNominationsContent(Map mapStandardNominationsContent) { + public void setMapStandardNominationsContent(Map mapStandardNominationsContent) { this.mapStandardNominationsContent = mapStandardNominationsContent; } /** * @return Returns the mapStandardNominationsHTMLedContent. */ - public Map getMapStandardNominationsHTMLedContent() { + public Map getMapStandardNominationsHTMLedContent() { return mapStandardNominationsHTMLedContent; } /** * @param mapStandardNominationsHTMLedContent * The mapStandardNominationsHTMLedContent to set. */ - public void setMapStandardNominationsHTMLedContent(Map mapStandardNominationsHTMLedContent) { + public void setMapStandardNominationsHTMLedContent(Map mapStandardNominationsHTMLedContent) { this.mapStandardNominationsHTMLedContent = mapStandardNominationsHTMLedContent; } /** * @return Returns the mapStandardRatesContent. */ - public Map getMapStandardRatesContent() { + public Map getMapStandardRatesContent() { return mapStandardRatesContent; } /** * @param mapStandardRatesContent * The mapStandardRatesContent to set. */ - public void setMapStandardRatesContent(Map mapStandardRatesContent) { + public void setMapStandardRatesContent(Map mapStandardRatesContent) { this.mapStandardRatesContent = mapStandardRatesContent; } /** * @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; } @@ -597,30 +597,30 @@ /** * @return Returns the mapStandardQuestionUid. */ - public Map getMapStandardQuestionUid() { + public Map getMapStandardQuestionUid() { return mapStandardQuestionUid; } /** * @param mapStandardQuestionUid * The mapStandardQuestionUid to set. */ - public void setMapStandardQuestionUid(Map mapStandardQuestionUid) { + public void setMapStandardQuestionUid(Map mapStandardQuestionUid) { this.mapStandardQuestionUid = mapStandardQuestionUid; } /** * @return Returns the mapStandardToolSessionUid. */ - public Map getMapStandardToolSessionUid() { + public Map getMapStandardToolSessionUid() { return mapStandardToolSessionUid; } /** * @param mapStandardToolSessionUid * The mapStandardToolSessionUid to set. */ - public void setMapStandardToolSessionUid(Map mapStandardToolSessionUid) { + public void setMapStandardToolSessionUid(Map mapStandardToolSessionUid) { this.mapStandardToolSessionUid = mapStandardToolSessionUid; } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java =================================================================== diff -u -re4da02a26c682a8b710501b48f3da29dd07e0bc0 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java (.../IVoteUsrAttemptDAO.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java (.../IVoteUsrAttemptDAO.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -55,8 +55,6 @@ VoteUsrAttempt getAttemptByUID(Long uid); - int getCompletedSessionEntriesCount(final Long voteSessionUid); - int getSessionEntriesCount(final Long voteSessionId); List getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java =================================================================== diff -u -re4da02a26c682a8b710501b48f3da29dd07e0bc0 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java (.../VoteUsrAttemptDAO.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java (.../VoteUsrAttemptDAO.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -312,17 +312,6 @@ return resultLong.intValue(); } - public int getCompletedSessionEntriesCount(final Long voteSessionUid) { - List list = getSessionUserEntries(voteSessionUid); - int completedSessionCount = 0; - for (VoteUsrAttempt att : list) { - String sessionStatus = att.getVoteQueUsr().getVoteSession().getSessionStatus(); - //this is a completed session - ++completedSessionCount; - } - return completedSessionCount; - } - public void updateVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) { this.getSession().setFlushMode(FlushMode.AUTO); this.getHibernateTemplate().update(voteUsrAttempt); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java =================================================================== diff -u -re4da02a26c682a8b710501b48f3da29dd07e0bc0 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -22,9 +22,12 @@ package org.lamsfoundation.lams.tool.vote.service; +import java.util.LinkedList; import java.util.List; import java.util.Set; +import javax.servlet.http.HttpServletRequest; + import org.lamsfoundation.lams.learningdesign.DataFlowObject; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.notebook.model.NotebookEntry; @@ -34,7 +37,9 @@ import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.vote.SessionDTO; import org.lamsfoundation.lams.tool.vote.VoteApplicationException; +import org.lamsfoundation.lams.tool.vote.VoteGeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr; @@ -71,6 +76,25 @@ * @param leader */ void copyAnswersFromLeader(VoteQueUsr user, VoteQueUsr leader); + + /** + * Generates chart data for the learner module and monitoring module Summary tab (Individual Sessions mode) + * + * @param request + * @param voteService + * @param toolContentID + * @param toolSessionUid + */ + VoteGeneralLearnerFlowDTO prepareChartData(HttpServletRequest request, Long toolContentID, Long toolSessionUid, + VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO); + + /** + * Generates data for all sessions in the Monitoring Summary, including all sessions summary. + * + * @param toolContentID + * @return + */ + LinkedList getSessionDTOs(Long toolContentID); void createVote(VoteContent voteContent) throws VoteApplicationException; @@ -130,8 +154,6 @@ int getSessionEntriesCount(final Long voteSessionId) throws VoteApplicationException; - int getCompletedSessionEntriesCount(final Long voteSessionUid) throws VoteApplicationException; - List getAttemptsForUserAndQuestionContent(final Long userUid, final Long questionUid) throws VoteApplicationException; Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java =================================================================== diff -u -re4da02a26c682a8b710501b48f3da29dd07e0bc0 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -22,15 +22,21 @@ package org.lamsfoundation.lams.tool.vote.service; +import java.util.ArrayList; import java.util.Date; import java.util.Hashtable; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.SortedMap; +import java.util.TreeMap; import java.util.TreeSet; import java.util.Vector; +import javax.servlet.http.HttpServletRequest; + import org.apache.log4j.Logger; import org.hibernate.Hibernate; import org.hibernate.proxy.HibernateProxy; @@ -63,8 +69,12 @@ import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsCoreToolService; import org.lamsfoundation.lams.tool.service.ILamsToolService; +import org.lamsfoundation.lams.tool.vote.SessionDTO; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.VoteApplicationException; +import org.lamsfoundation.lams.tool.vote.VoteComparator; +import org.lamsfoundation.lams.tool.vote.VoteGeneralLearnerFlowDTO; +import org.lamsfoundation.lams.tool.vote.VoteMonitoredAnswersDTO; import org.lamsfoundation.lams.tool.vote.VoteUtils; import org.lamsfoundation.lams.tool.vote.dao.IVoteContentDAO; import org.lamsfoundation.lams.tool.vote.dao.IVoteQueContentDAO; @@ -76,6 +86,7 @@ import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr; import org.lamsfoundation.lams.tool.vote.pojos.VoteSession; import org.lamsfoundation.lams.tool.vote.pojos.VoteUsrAttempt; +import org.lamsfoundation.lams.tool.vote.web.VoteMonitoringAction; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; @@ -274,6 +285,237 @@ } } + @Override + public VoteGeneralLearnerFlowDTO prepareChartData(HttpServletRequest request, Long toolContentID, + Long toolSessionUid, VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO) { + + VoteContent voteContent = this.retrieveVote(toolContentID); + + int entriesCount = 0; + Set userEntries = null; + if (toolSessionUid != null) { + entriesCount = this.getSessionEntriesCount(toolSessionUid); + userEntries = this.getSessionUserEntriesSet(toolSessionUid); + } + + Long mapIndex = 1L; + int totalStandardVotesCount = 0; + + 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 mapStandardNominationsContent = new TreeMap(new VoteComparator()); + Map mapVoteRates = new TreeMap(new VoteComparator()); + + for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) { + + mapStandardNominationsHTMLedContent.put(mapIndex, question.getQuestion()); + String noHTMLNomination = VoteUtils.stripHTML(question.getQuestion()); + mapStandardNominationsContent.put(mapIndex, noHTMLNomination); + + int votesCount = this.getStandardAttemptsForQuestionContentAndSessionUid(question.getUid(), toolSessionUid); + totalStandardVotesCount += votesCount; + mapStandardUserCount.put(mapIndex, new Long(votesCount)); + + mapStandardQuestionUid.put(mapIndex, question.getUid()); + mapStandardToolSessionUid.put(mapIndex, toolSessionUid); + + Double voteRate = (entriesCount != 0) ? ((votesCount * 100) / entriesCount) : 0d; + mapVoteRates.put(mapIndex, voteRate); + + // mapIndex++ + mapIndex = new Long(mapIndex + 1); + } + + // open votes + if (voteContent.isAllowText()) { + int userEnteredVotesCount = entriesCount - totalStandardVotesCount; + Double voteRate = (userEnteredVotesCount != 0) ? ((userEnteredVotesCount * 100) / entriesCount) : 0d; + mapVoteRates.put(mapIndex, voteRate); + + mapStandardNominationsContent.put(mapIndex, messageService.getMessage("label.open.vote")); + 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); + } + + voteGeneralLearnerFlowDTO.setMapStandardNominationsContent(mapStandardNominationsContent); + voteGeneralLearnerFlowDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); + voteGeneralLearnerFlowDTO.setMapStandardRatesContent(mapVoteRates); + voteGeneralLearnerFlowDTO.setMapStandardUserCount(mapStandardUserCount); + voteGeneralLearnerFlowDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); + voteGeneralLearnerFlowDTO.setMapStandardQuestionUid(mapStandardQuestionUid); + request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO); + + request.setAttribute(LIST_USER_ENTRIES_CONTENT, userEntries); + + // return value is only used in VoteChartGeneratorAction + return voteGeneralLearnerFlowDTO; + } + + @Override + public LinkedList getSessionDTOs(Long toolContentID) { + + LinkedList sessionDTOs = new LinkedList(); + + VoteContent voteContent = this.retrieveVote(toolContentID); + for (VoteSession session : (Set) voteContent.getVoteSessions()) { + + SessionDTO sessionDTO = new SessionDTO(); + sessionDTO.setSessionId(session.getVoteSessionId().toString()); + sessionDTO.setSessionName(session.getSession_name()); + + int entriesCount = this.getSessionEntriesCount(session.getUid()); + + // potentialUserCount + int potentialUserCount = this.getVoteSessionPotentialLearnersCount(session.getUid()); + sessionDTO.setSessionUserCount(potentialUserCount); + + // completedSessionUserCount + int completedSessionUserCount = this.getCompletedVoteUserBySessionUid(session.getUid()); + sessionDTO.setCompletedSessionUserCount(completedSessionUserCount); + + Long mapIndex = 1L; + int totalStandardVotesCount = 0; + + 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()); + + for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) { + mapStandardNominationsHTMLedContent.put(mapIndex, question.getQuestion()); + + int votesCount = this.getStandardAttemptsForQuestionContentAndSessionUid(question.getUid(), + session.getUid()); + totalStandardVotesCount += votesCount; + mapStandardUserCount.put(mapIndex, new Long(votesCount)); + + mapStandardQuestionUid.put(mapIndex, question.getUid()); + mapStandardToolSessionUid.put(mapIndex, session.getUid()); + + Double voteRate = (entriesCount != 0) ? ((votesCount * 100) / entriesCount) : 0d; + mapVoteRates.put(mapIndex, voteRate); + + // mapIndex++ + mapIndex = new Long(mapIndex + 1); + } + + // 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); + } + + sessionDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); + sessionDTO.setMapStandardUserCount(mapStandardUserCount); + sessionDTO.setMapStandardRatesContent(mapVoteRates); + sessionDTO.setMapStandardQuestionUid(mapStandardQuestionUid); + sessionDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); + + List openVotes = VoteMonitoringAction.processUserEnteredNominations(this, + voteContent, session.getVoteSessionId().toString(), true, null, false); + sessionDTO.setOpenVotes(openVotes); + boolean isExistsOpenVote = openVotes.size() > 0; + sessionDTO.setExistsOpenVote(isExistsOpenVote); + + 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")); + + List totalOpenVotes = new ArrayList(); + int totalPotentialUserCount = 0; + int totalCompletedSessionUserCount = 0; + int allSessionsVotesCount = 0; + Map totalMapStandardUserCount = new TreeMap(new VoteComparator()); + for (SessionDTO sessionDTO : sessionDTOs) { + + 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()); + } + 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); + + // All groups total -- totalMapVoteRates part + Long mapIndex = 1L; + Map totalMapVoteRates = new TreeMap(new VoteComparator()); + int totalStandardVotesCount = 0; + for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) { + + Long votesCount = totalMapStandardUserCount.get(mapIndex); + + double voteRate = (allSessionsVotesCount != 0) ? ((votesCount * 100) / allSessionsVotesCount) : 0d; + totalMapVoteRates.put(mapIndex, voteRate); + + totalStandardVotesCount += votesCount; + + // mapIndex++ + mapIndex = new Long(mapIndex + 1); + } + // open votes + if (voteContent.isAllowText()) { + int userEnteredVotesCount = allSessionsVotesCount - totalStandardVotesCount; + double voteRate = (userEnteredVotesCount != 0) ? ((userEnteredVotesCount * 100) / allSessionsVotesCount) + : 0; + totalMapVoteRates.put(mapIndex, voteRate); + } + totalSessionDTO.setMapStandardRatesContent(totalMapVoteRates); + + sessionDTOs.addFirst(totalSessionDTO); + } + + return sessionDTOs; + } + public void createVote(VoteContent voteContent) throws VoteApplicationException { try { voteContentDAO.saveVoteContent(voteContent); @@ -370,15 +612,6 @@ } - public int getCompletedSessionEntriesCount(final Long voteSessionUid) throws VoteApplicationException { - try { - return voteUsrAttemptDAO.getCompletedSessionEntriesCount(voteSessionUid); - } catch (DataAccessException e) { - throw new VoteApplicationException( - "Exception occured when lams is getting completed session user entries count: " + e.getMessage(), e); - } - } - public List getSessionUserEntries(final Long voteSessionUid) throws VoteApplicationException { try { return voteUsrAttemptDAO.getSessionUserEntries(voteSessionUid); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java =================================================================== diff -u -re4da02a26c682a8b710501b48f3da29dd07e0bc0 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -399,151 +399,10 @@ return map; } - /** - * Generates chart data for the learner module and monitoring module Summary tab (Individual Sessions mode) - * - * @param request - * @param voteService - * @param voteMonitoringForm - * @param toolContentID - * @param toolSessionUid - */ - public static void prepareChartData(HttpServletRequest request, IVoteService voteService, - VoteMonitoringForm voteMonitoringForm, String toolContentID, String toolSessionUid, - VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO, VoteGeneralMonitoringDTO voteGeneralMonitoringDTO, - MessageService messageService) { - VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); - Map mapOptionsContent = new TreeMap(new VoteComparator()); - Map mapVoteRatesContent = new TreeMap(new VoteComparator()); - - List distinctSessionUsers = new ArrayList(); - boolean sessionLevelCharting = true; - int entriesCount = 0; - Set userEntries = null; - if (toolSessionUid != null) { - entriesCount = voteService.getSessionEntriesCount(new Long(toolSessionUid)); - userEntries = voteService.getSessionUserEntriesSet(new Long(toolSessionUid)); - - int completedSessionUserCount = voteService.getCompletedVoteUserBySessionUid(new Long(toolSessionUid)); - - int completedEntriesCount = voteService.getCompletedSessionEntriesCount(new Long(toolSessionUid)); - - if (voteMonitoringForm != null) { - int potentialUserCount = voteService.getVoteSessionPotentialLearnersCount(new Long(toolSessionUid)); - voteMonitoringForm.setSessionUserCount(Integer.toString(potentialUserCount)); - voteMonitoringForm.setCompletedSessionUserCount(new Integer(completedSessionUserCount).toString()); - - if (voteGeneralMonitoringDTO != null) { - voteGeneralMonitoringDTO.setSessionUserCount(Integer.toString(potentialUserCount)); - voteGeneralMonitoringDTO.setCompletedSessionUserCount(new Integer(completedSessionUserCount) - .toString()); - } - } - } - - Map mapStandardUserCount = new TreeMap(new VoteComparator()); - - mapOptionsContent.clear(); - Iterator queIterator = voteContent.getVoteQueContents().iterator(); - Long mapIndex = new Long(1); - int totalStandardVotesCount = 0; - - Map mapStandardNominationsHTMLedContent = new TreeMap(new VoteComparator()); - Map mapStandardQuestionUid = new TreeMap(new VoteComparator()); - Map mapStandardToolSessionUid = new TreeMap(new VoteComparator()); - while (queIterator.hasNext()) { - VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); - if (voteQueContent != null) { - mapStandardNominationsHTMLedContent.put(mapIndex.toString(), voteQueContent.getQuestion()); - String noHTMLNomination = VoteUtils.stripHTML(voteQueContent.getQuestion()); - mapOptionsContent.put(mapIndex.toString(), noHTMLNomination); - - int votesCount = 0; - if (sessionLevelCharting == true) { - votesCount = voteService.getStandardAttemptsForQuestionContentAndSessionUid( - voteQueContent.getUid(), new Long(toolSessionUid)); - - mapStandardQuestionUid.put(mapIndex.toString(), voteQueContent.getUid().toString()); - mapStandardToolSessionUid.put(mapIndex.toString(), toolSessionUid.toString()); - mapStandardUserCount.put(mapIndex.toString(), new Integer(votesCount).toString()); - totalStandardVotesCount = totalStandardVotesCount + votesCount; - } else { - votesCount = voteService.getAttemptsForQuestionContent(voteQueContent.getUid()); - } - - double voteRate = 0d; - double doubleVotesCount = votesCount * 1d; - double doubleEntriesCount = entriesCount * 1d; - 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); - - mapVoteRatesContent.put(mapIndex.toString(), stringVoteRate); - mapIndex = new Long(mapIndex.longValue() + 1); - } - } - - Map mapStandardNominationsContent = new TreeMap(new VoteComparator()); - mapStandardNominationsContent = mapOptionsContent; - - Map mapStandardRatesContent = new TreeMap(new VoteComparator()); - mapStandardRatesContent = mapVoteRatesContent; - - int mapVoteRatesSize = mapVoteRatesContent.size(); - mapIndex = new Long(mapVoteRatesSize + 1); - - int userEnteredVotesCount = entriesCount - totalStandardVotesCount; - double share = (userEnteredVotesCount != 0) ? ((userEnteredVotesCount * 100) / entriesCount) : 0; - - if (voteContent.isAllowText()) { - mapStandardNominationsContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); - mapStandardNominationsHTMLedContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); - } - - 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"); - - request.setAttribute(LIST_USER_ENTRIES_CONTENT, userEntries); - - request.getSession().setAttribute(MAP_STANDARD_NOMINATIONS_CONTENT, mapStandardNominationsContent); - - request.getSession().setAttribute(MAP_STANDARD_RATES_CONTENT, mapStandardRatesContent); - - if (voteGeneralLearnerFlowDTO != null) { - voteGeneralLearnerFlowDTO.setMapStandardNominationsContent(mapStandardNominationsContent); - voteGeneralLearnerFlowDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); - voteGeneralLearnerFlowDTO.setMapStandardRatesContent(mapStandardRatesContent); - voteGeneralLearnerFlowDTO.setMapStandardUserCount(mapStandardUserCount); - voteGeneralLearnerFlowDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); - voteGeneralLearnerFlowDTO.setMapStandardQuestionUid(mapStandardQuestionUid); - } - - if (voteGeneralMonitoringDTO != null) { - voteGeneralMonitoringDTO.setMapStandardNominationsContent(mapStandardNominationsContent); - voteGeneralMonitoringDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); - voteGeneralMonitoringDTO.setMapStandardRatesContent(mapStandardRatesContent); - voteGeneralMonitoringDTO.setMapStandardUserCount(mapStandardUserCount); - voteGeneralMonitoringDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); - voteGeneralMonitoringDTO.setMapStandardQuestionUid(mapStandardQuestionUid); - } - - request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); - } - public static boolean notebookEntriesExist(IVoteService voteService, VoteContent voteContent) { - Iterator iteratorSession = voteContent.getVoteSessions().iterator(); + Iterator iteratorSession = voteContent.getVoteSessions().iterator(); while (iteratorSession.hasNext()) { - VoteSession voteSession = (VoteSession) iteratorSession.next(); + VoteSession voteSession = iteratorSession.next(); if (voteSession != null) { @@ -617,54 +476,10 @@ } } - public static Map buildGroupsAttemptData(HttpServletRequest request, VoteContent voteContent, - IVoteService voteService, VoteQueContent voteQueContent, String questionUid, String currentSessionId) { - - List listMonitoredAttemptsContainerDTO = new LinkedList(); - - Map summaryToolSessions = populateToolSessionsId(voteContent, voteService); - - Iterator itMap = summaryToolSessions.entrySet().iterator(); - - /* request is for monitoring summary */ - - if (currentSessionId != null) { - if (currentSessionId.equals("All")) { - // **summary request is for All** - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry) itMap.next(); - if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) { - VoteSession voteSession = voteService - .retrieveVoteSession(new Long(pairs.getValue().toString())); - if (voteSession != null) { - List listUsers = voteService.getUserBySessionOnly(voteSession); - Map sessionUsersAttempts = populateSessionUsersAttempts(request, voteService, - voteSession.getVoteSessionId(), listUsers, questionUid, true, false, null); - listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - } - } - } - } else if (!currentSessionId.equals("All")) { - // **summary request is for currentSessionId** currentSessionId - VoteSession voteSession = voteService.retrieveVoteSession(new Long(currentSessionId.toString())); - - List listUsers = voteService.getUserBySessionOnly(voteSession); - - Map sessionUsersAttempts = populateSessionUsersAttempts(request, voteService, - new Long(currentSessionId), listUsers, questionUid, true, false, null); - listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - } - } - - Map mapMonitoredAttemptsContainerDTO = convertToMap(listMonitoredAttemptsContainerDTO); - return mapMonitoredAttemptsContainerDTO; - } - public static Map populateSessionUsersAttempts(HttpServletRequest request, IVoteService voteService, Long sessionId, List users, String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, String userId) { - Map mapMonitoredUserContainerDTO = new TreeMap(new VoteStringComparator()); List listMonitoredUserContainerDTO = new LinkedList(); Iterator itUsers = users.iterator(); @@ -819,23 +634,17 @@ } } - - mapMonitoredUserContainerDTO = convertToMcMonitoredUserDTOMap(listMonitoredUserContainerDTO); - return mapMonitoredUserContainerDTO; - } - - public static Map convertToMcMonitoredUserDTOMap(List list) { - Map map = new TreeMap(new VoteStringComparator()); - - Iterator listIterator = list.iterator(); + + //convertToMcMonitoredUserDTOMap + Map mapMonitoredUserContainerDTO = new TreeMap(new VoteStringComparator()); + Iterator listIterator = listMonitoredUserContainerDTO.iterator(); Long mapIndex = new Long(1); - while (listIterator.hasNext()) { VoteMonitoredUserDTO data = (VoteMonitoredUserDTO) listIterator.next(); - map.put(mapIndex.toString(), data); + mapMonitoredUserContainerDTO.put(mapIndex.toString(), data); mapIndex = new Long(mapIndex.longValue() + 1); } - return map; + return mapMonitoredUserContainerDTO; } public static void repopulateRequestParameters(HttpServletRequest request, VoteMonitoringForm voteMonitoringForm, Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteChartGeneratorAction.java =================================================================== diff -u -r601fd92095193321a6b2286ef55108fbe5f9dfc4 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteChartGeneratorAction.java (.../VoteChartGeneratorAction.java) (revision 601fd92095193321a6b2286ef55108fbe5f9dfc4) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteChartGeneratorAction.java (.../VoteChartGeneratorAction.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -23,6 +23,9 @@ package org.lamsfoundation.lams.tool.vote.web; import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -34,14 +37,19 @@ import org.apache.struts.action.ActionMapping; import org.apache.tomcat.util.json.JSONException; import org.apache.tomcat.util.json.JSONObject; +import org.lamsfoundation.lams.tool.vote.SessionDTO; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; +import org.lamsfoundation.lams.tool.vote.VoteGeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.vote.VoteGeneralMonitoringDTO; +import org.lamsfoundation.lams.tool.vote.VoteUtils; import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteSession; import org.lamsfoundation.lams.tool.vote.service.IVoteService; import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy; import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.util.AttributeNames; /** * Prepares data for charts. @@ -51,30 +59,48 @@ public class VoteChartGeneratorAction extends LamsDispatchAction { private static IVoteService voteService; - private static MessageService messageService; @SuppressWarnings("unchecked") public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws JSONException, IOException { String currentSessionId = request.getParameter("currentSessionId"); - if (!StringUtils.isBlank(currentSessionId)) { - // it is a call from Monitor + Map nominationNames = new HashMap(); + Map nominationVotes = new HashMap(); + + //request for the all session summary + if ("0".equals(currentSessionId)) { + long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + LinkedList sessionDTOs = getVoteService().getSessionDTOs(toolContentID); + + // check allSessionsSummary exists + SessionDTO allSessionsSummary = sessionDTOs.getFirst(); + if ("0".equals(allSessionsSummary.getSessionId())) { + nominationNames = allSessionsSummary.getMapStandardNominationsHTMLedContent(); + nominationVotes = allSessionsSummary.getMapStandardRatesContent(); + + //replace all html tags + for (Long index : nominationNames.keySet()) { + String name = nominationNames.get(index); + String noHTMLNomination = VoteUtils.stripHTML(name); + nominationNames.put(index, noHTMLNomination); + } + } + + //sessionId should not be blank + } else if (!StringUtils.isBlank(currentSessionId)) { VoteSession voteSession = getVoteService().retrieveVoteSession(new Long(currentSessionId)); VoteContent voteContent = voteSession.getVoteContent(); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - MonitoringUtil.prepareChartData(request, getVoteService(), null, voteContent.getVoteContentId().toString(), - voteSession.getUid().toString(), null, voteGeneralMonitoringDTO, getMessageService()); + VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = getVoteService().prepareChartData(request, + voteContent.getVoteContentId(), voteSession.getUid(), new VoteGeneralLearnerFlowDTO()); + + nominationNames = voteGeneralLearnerFlowDTO.getMapStandardNominationsContent(); + nominationVotes = voteGeneralLearnerFlowDTO.getMapStandardRatesContent(); } - Map nominationNames = (Map) request.getSession().getAttribute( - VoteAppConstants.MAP_STANDARD_NOMINATIONS_CONTENT); - Map nominationVotes = (Map) request.getSession().getAttribute( - VoteAppConstants.MAP_STANDARD_RATES_CONTENT); - JSONObject responseJSON = new JSONObject(); - for (String index : nominationNames.keySet()) { + for (Long index : nominationNames.keySet()) { JSONObject nomination = new JSONObject(); // nominations' names and values go separately nomination.put("name", nominationNames.get(index)); @@ -87,13 +113,6 @@ return null; } - private MessageService getMessageService() { - if (messageService == null) { - messageService = (MessageService) VoteServiceProxy.getMessageService(getServlet().getServletContext()); - } - return messageService; - } - private IVoteService getVoteService() { if (voteService == null) { voteService = (IVoteService) VoteServiceProxy.getVoteService(getServlet().getServletContext()); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java =================================================================== diff -u -r96866054a8598fbe1b6719c40ea9a5ed898f5daf -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java (.../VoteLearningAction.java) (revision 96866054a8598fbe1b6719c40ea9a5ed898f5daf) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java (.../VoteLearningAction.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -139,10 +139,7 @@ Set userAttempts = voteService.getAttemptsForUserAndSession(existingVoteQueUsr.getUid(), toolSessionUid); request.setAttribute(LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId().toString(), - voteSession.getUid().toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, - getMessageService()); + voteService.prepareChartData(request, toolContentID, toolSessionUid, voteGeneralLearnerFlowDTO); voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString()); String reflectionSubject = VoteUtils.replaceNewLines(voteContent.getReflectionSubject()); @@ -462,9 +459,7 @@ voteLearningForm.setNominationsSubmited(new Boolean(true).toString()); voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(true).toString()); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - MonitoringUtil.prepareChartData(request, voteService, null, toolContentID.toString(), - toolSessionUid.toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, getMessageService()); + voteService.prepareChartData(request, toolContentID, toolSessionUid, voteGeneralLearnerFlowDTO); voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString()); voteGeneralLearnerFlowDTO.setReflectionSubject(voteContent.getReflectionSubject()); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java =================================================================== diff -u -r2c216a6b9beeb0e248612814f4ad2ae3c9a95399 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java (.../VoteLearningStarterAction.java) (revision 2c216a6b9beeb0e248612814f4ad2ae3c9a95399) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java (.../VoteLearningStarterAction.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -268,10 +268,8 @@ voteLearningForm.setReportViewOnly(new Boolean(true).toString()); voteGeneralLearnerFlowDTO.setReportViewOnly(new Boolean(true).toString()); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId().toString(), - voteSession.getUid().toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, - getMessageService()); + voteService.prepareChartData(request, voteContent.getVoteContentId(), voteSession.getUid(), + voteGeneralLearnerFlowDTO); boolean isGroupedActivity = voteService.isGroupedActivity(new Long(voteLearningForm.getToolContentID())); request.setAttribute("isGroupedActivity", isGroupedActivity); @@ -311,10 +309,8 @@ sessionUid); request.setAttribute(VoteAppConstants.LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId().toString(), - voteSession.getUid().toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, - getMessageService()); + voteService.prepareChartData(request, voteContent.getVoteContentId(), voteSession.getUid(), + voteGeneralLearnerFlowDTO); String isContentLockOnFinish = voteLearningForm.getLockOnFinish(); if (isContentLockOnFinish.equals(new Boolean(true).toString()) && isResponseFinalised == true) { Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java =================================================================== diff -u -re4da02a26c682a8b710501b48f3da29dd07e0bc0 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -575,8 +575,50 @@ voteMonitoredAnswersDTO.setSessionId(currentSessionId); voteMonitoredAnswersDTO.setSessionName(currentSessionName); - Map questionAttemptData = MonitoringUtil.buildGroupsAttemptData(request, voteContent, voteService, - voteQueContent, voteQueContent.getUid().toString(), currentSessionId); + String questionUid = voteQueContent.getUid().toString(); + + List listMonitoredAttemptsContainerDTO = new LinkedList(); + + Map summaryToolSessions = MonitoringUtil.populateToolSessionsId(voteContent, + voteService); + + Iterator itMap = summaryToolSessions.entrySet().iterator(); + + /* request is for monitoring summary */ + + if (currentSessionId != null) { + if (currentSessionId.equals("All")) { + // **summary request is for All** + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + if (!(pairs.getValue().toString().equals("None")) + && !(pairs.getValue().toString().equals("All"))) { + VoteSession voteSession2 = voteService.retrieveVoteSession(new Long(pairs + .getValue().toString())); + if (voteSession2 != null) { + List listUsers = voteService.getUserBySessionOnly(voteSession2); + Map sessionUsersAttempts = MonitoringUtil.populateSessionUsersAttempts( + request, voteService, voteSession2.getVoteSessionId(), listUsers, + questionUid, true, false, null); + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + } + } + } + } else if (!currentSessionId.equals("All")) { + // **summary request is for currentSessionId** currentSessionId + + List listUsers = voteService.getUserBySessionOnly(voteSession); + + Map sessionUsersAttempts = MonitoringUtil.populateSessionUsersAttempts(request, + voteService, new Long(currentSessionId), listUsers, questionUid, true, false, + null); + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + } + } + + Map questionAttemptData = MonitoringUtil.convertToMap(listMonitoredAttemptsContainerDTO); + + voteMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); listMonitoredAnswersContainerDTO.add(voteMonitoredAnswersDTO); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java =================================================================== diff -u -re4da02a26c682a8b710501b48f3da29dd07e0bc0 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -140,22 +140,9 @@ request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); /* ...till here */ - return submitSession(mapping, voteMonitoringForm, request, response, voteService, - messageService, voteGeneralMonitoringDTO); - } - - public ActionForward submitSession(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response, IVoteService voteService, MessageService messageService, - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) throws IOException, ServletException { - - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; - MonitoringUtil.repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - String toolContentID = voteMonitoringForm.getToolContentID(); - VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); - List sessionDTOs = getSessionDTOs(request, voteService, voteMonitoringForm, - voteContent.getVoteContentId(), messageService); + List sessionDTOs = voteService.getSessionDTOs(new Long(toolContentID)); voteGeneralMonitoringDTO.setSessionDTOs(sessionDTOs); boolean isGroupedActivity = voteService.isGroupedActivity(new Long(toolContentID)); @@ -166,17 +153,14 @@ // initInstructionsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); /* setting editable screen properties */ - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle()); - voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions()); - Map mapOptionsContent = new TreeMap(new VoteComparator()); + Map mapOptionsContent2 = new TreeMap(new VoteComparator()); Iterator queIterator = voteContent.getVoteQueContents().iterator(); Long mapIndex = new Long(1); while (queIterator.hasNext()) { VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); if (voteQueContent != null) { - mapOptionsContent.put(mapIndex.toString(), voteQueContent.getQuestion()); + mapOptionsContent2.put(mapIndex.toString(), voteQueContent.getQuestion()); /** * make the first entry the default(first) one for jsp */ @@ -188,10 +172,10 @@ } } - int maxIndex = mapOptionsContent.size(); - voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); + int maxIndex2 = mapOptionsContent2.size(); + voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex2); - voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); + voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent2); boolean isContentInUse = VoteUtils.isContentInUse(voteContent); voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(false).toString()); @@ -238,178 +222,8 @@ return mapping.findForward(VoteAppConstants.LOAD_MONITORING); } - - /** - * Generates chart data for all sessions in the Monitoring Summary. - * - * @param request - * @param voteService - * @param voteMonitoringForm - * @param toolContentID - * @return - */ - private static List getSessionDTOs(HttpServletRequest request, IVoteService voteService, - VoteMonitoringForm voteMonitoringForm, Long toolContentID, MessageService messageService) { - - LinkedList sessionDTOs = new LinkedList(); - - VoteContent voteContent = voteService.retrieveVote(toolContentID); - for (VoteSession session: (Set)voteContent.getVoteSessions()) { - - SessionDTO sessionDTO = new SessionDTO(); - sessionDTO.setSessionId(session.getVoteSessionId().toString()); - sessionDTO.setSessionName(session.getSession_name()); - - int entriesCount = voteService.getSessionEntriesCount(session.getUid()); - - // potentialUserCount - int potentialUserCount = voteService.getVoteSessionPotentialLearnersCount(session.getUid()); - sessionDTO.setSessionUserCount(potentialUserCount); - - //completedSessionUserCount - int completedSessionUserCount = voteService.getCompletedVoteUserBySessionUid(session.getUid()); - sessionDTO.setCompletedSessionUserCount(completedSessionUserCount); - - Long mapIndex = 1L; - int totalStandardVotesCount = 0; - - 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()); - - for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) { - mapStandardNominationsHTMLedContent.put(mapIndex, question.getQuestion()); - - int votesCount = voteService.getStandardAttemptsForQuestionContentAndSessionUid(question.getUid(), - session.getUid()); - totalStandardVotesCount += votesCount; - mapStandardUserCount.put(mapIndex, new Long(votesCount)); - - mapStandardQuestionUid.put(mapIndex, question.getUid()); - mapStandardToolSessionUid.put(mapIndex, session.getUid()); - - Double voteRate = (entriesCount != 0) ? ((votesCount * 100) / entriesCount) : 0d; - mapVoteRates.put(mapIndex, voteRate); - - // mapIndex++ - mapIndex = new Long(mapIndex + 1); - } - - //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); - } - - sessionDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); - sessionDTO.setMapStandardUserCount(mapStandardUserCount); - sessionDTO.setMapStandardRatesContent(mapVoteRates); - sessionDTO.setMapStandardQuestionUid(mapStandardQuestionUid); - sessionDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); - - List openVotes = VoteMonitoringAction.processUserEnteredNominations(voteService, voteContent, - session.getVoteSessionId().toString(), true, null, false); - sessionDTO.setOpenVotes(openVotes); - boolean isExistsOpenVote = openVotes.size() > 0; - sessionDTO.setExistsOpenVote(isExistsOpenVote); - - 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")); - - List totalOpenVotes = new ArrayList(); - int totalPotentialUserCount = 0; - int totalCompletedSessionUserCount = 0; - int allSessionsVotesCount = 0; - Map totalMapStandardUserCount = new TreeMap(new VoteComparator()); - for (SessionDTO sessionDTO : sessionDTOs) { - - 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()); - } - 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); - - // All groups total -- totalMapVoteRates part - Long mapIndex = 1L; - Map totalMapVoteRates = new TreeMap(new VoteComparator()); - int totalStandardVotesCount = 0; - for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) { - - Long votesCount = totalMapStandardUserCount.get(mapIndex); - - double voteRate = (allSessionsVotesCount != 0) ? ((votesCount * 100) / allSessionsVotesCount) : 0d; - totalMapVoteRates.put(mapIndex, voteRate); - - totalStandardVotesCount += votesCount; - - // mapIndex++ - mapIndex = new Long(mapIndex + 1); - } - // open votes - if (voteContent.isAllowText()) { - int userEnteredVotesCount = allSessionsVotesCount - totalStandardVotesCount; - double voteRate = (userEnteredVotesCount != 0) ? ((userEnteredVotesCount * 100) / allSessionsVotesCount) - : 0; - totalMapVoteRates.put(mapIndex, voteRate); - } - totalSessionDTO.setMapStandardRatesContent(totalMapVoteRates); - - sessionDTOs.addFirst(totalSessionDTO); - } - - return sessionDTOs; - } - - private boolean initialiseMonitoringData(ActionMapping mapping, ActionForm form, HttpServletRequest request, + private boolean initialiseMonitoringData(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, IVoteService voteService, VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) { VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; Fisheye: Tag febc7a671d18a9979caf91b0b77684674b61438c refers to a dead (removed) revision in file `lams_tool_vote/web/BaseContent.jsp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag febc7a671d18a9979caf91b0b77684674b61438c refers to a dead (removed) revision in file `lams_tool_vote/web/Footer.jsp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag febc7a671d18a9979caf91b0b77684674b61438c refers to a dead (removed) revision in file `lams_tool_vote/web/Header.jsp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag febc7a671d18a9979caf91b0b77684674b61438c refers to a dead (removed) revision in file `lams_tool_vote/web/SystemErrorContent.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_vote/web/export/ExportContent.jsp =================================================================== diff -u -rded6335c9a04246994586bba62b43b577d2e6fb2 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/web/export/ExportContent.jsp (.../ExportContent.jsp) (revision ded6335c9a04246994586bba62b43b577d2e6fb2) +++ lams_tool_vote/web/export/ExportContent.jsp (.../ExportContent.jsp) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -1,24 +1,3 @@ -<%-- -Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) -License Information: http://lamsfoundation.org/licensing/lams/2.0/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - USA - - http://www.gnu.org/licenses/gpl.txt ---%> - <%@ include file="/common/taglibs.jsp"%> @@ -60,7 +39,7 @@ -  ( ) +  ( ) @@ -131,7 +110,7 @@ -  ( ) +  ( ) Index: lams_tool_vote/web/export/exportportfolio.jsp =================================================================== diff -u -r18e5e690d2e1a7c3d918759f7a2827c8205feaac -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/web/export/exportportfolio.jsp (.../exportportfolio.jsp) (revision 18e5e690d2e1a7c3d918759f7a2827c8205feaac) +++ lams_tool_vote/web/export/exportportfolio.jsp (.../exportportfolio.jsp) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -1,24 +1,3 @@ -<%-- -Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) -License Information: http://lamsfoundation.org/licensing/lams/2.0/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - USA - - http://www.gnu.org/licenses/gpl.txt ---%> - Index: lams_tool_vote/web/learning/AllNominations.jsp =================================================================== diff -u -r883c4cc054a636dc8017da1b244b89bdaf0ff974 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/web/learning/AllNominations.jsp (.../AllNominations.jsp) (revision 883c4cc054a636dc8017da1b244b89bdaf0ff974) +++ lams_tool_vote/web/learning/AllNominations.jsp (.../AllNominations.jsp) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -164,7 +164,7 @@ -  ( +  ( ) @@ -179,12 +179,12 @@ + onclick="javascript:drawChart('pie', 0, {'currentSessionId' : '${formBean.toolSessionID}'})"> + onclick="javascript:drawChart('bar', 0, {'currentSessionId' : '${formBean.toolSessionID}'})"> Index: lams_tool_vote/web/learning/RevisitedDisplay.jsp =================================================================== diff -u -rdb4fc43d6e110f7298d227fae4683af2e1e681f3 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/web/learning/RevisitedDisplay.jsp (.../RevisitedDisplay.jsp) (revision db4fc43d6e110f7298d227fae4683af2e1e681f3) +++ lams_tool_vote/web/learning/RevisitedDisplay.jsp (.../RevisitedDisplay.jsp) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -95,7 +95,7 @@ -  ( +  ( ) @@ -110,12 +110,11 @@ - + onclick="javascript:drawChart('pie', 0, {'currentSessionId' : '${VoteLearningForm.toolSessionID}'})"> + onclick="javascript:drawChart('bar', 0, {'currentSessionId' : '${VoteLearningForm.toolSessionID}'})"> Index: lams_tool_vote/web/learning/mobile/AllNominations.jsp =================================================================== diff -u -r883c4cc054a636dc8017da1b244b89bdaf0ff974 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/web/learning/mobile/AllNominations.jsp (.../AllNominations.jsp) (revision 883c4cc054a636dc8017da1b244b89bdaf0ff974) +++ lams_tool_vote/web/learning/mobile/AllNominations.jsp (.../AllNominations.jsp) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -172,7 +172,7 @@ -  ( +  ( ) @@ -188,12 +188,12 @@ + onclick="javascript:drawChart('pie', 0, {'currentSessionId' : '${formBean.toolSessionID}'})"> + onclick="javascript:drawChart('bar', 0, {'currentSessionId' : '${formBean.toolSessionID}'})"> Index: lams_tool_vote/web/learning/mobile/RevisitedDisplay.jsp =================================================================== diff -u -rdb4fc43d6e110f7298d227fae4683af2e1e681f3 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/web/learning/mobile/RevisitedDisplay.jsp (.../RevisitedDisplay.jsp) (revision db4fc43d6e110f7298d227fae4683af2e1e681f3) +++ lams_tool_vote/web/learning/mobile/RevisitedDisplay.jsp (.../RevisitedDisplay.jsp) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -95,7 +95,7 @@ -  ( +  ( ) @@ -111,12 +111,12 @@ + onclick="javascript:drawChart('pie', 0, {'currentSessionId' : '${VoteLearningForm.toolSessionID}'})"> + onclick="javascript:drawChart('bar', 0, {'currentSessionId' : '${VoteLearningForm.toolSessionID}'})"> Index: lams_tool_vote/web/monitoring/AllSessionsSummary.jsp =================================================================== diff -u -re4da02a26c682a8b710501b48f3da29dd07e0bc0 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/web/monitoring/AllSessionsSummary.jsp (.../AllSessionsSummary.jsp) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) +++ lams_tool_vote/web/monitoring/AllSessionsSummary.jsp (.../AllSessionsSummary.jsp) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -147,14 +147,24 @@ - - -

+

+ + +

+ + + -

+




Index: lams_tool_vote/web/monitoring/SummaryContent.jsp =================================================================== diff -u -re4da02a26c682a8b710501b48f3da29dd07e0bc0 -rfebc7a671d18a9979caf91b0b77684674b61438c --- lams_tool_vote/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision e4da02a26c682a8b710501b48f3da29dd07e0bc0) +++ lams_tool_vote/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision febc7a671d18a9979caf91b0b77684674b61438c) @@ -20,10 +20,7 @@ $(document).ready(function(){ - - drawChart('bar', ${currentDto.sessionId}0, {'currentSessionId' : '${currentDto.sessionId}'}); - drawChart('pie', ${currentDto.sessionId}1, {'currentSessionId' : '${currentDto.sessionId}'}); - + drawChart('pie', ${currentDto.sessionId}, {'currentSessionId' : '${currentDto.sessionId}', 'toolContentID' : '${toolContentID}'}); });