Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAllSessionsDTO.java =================================================================== diff -u --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAllSessionsDTO.java (revision 0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAllSessionsDTO.java (revision 6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86) @@ -0,0 +1,148 @@ +/*************************************************************************** + * 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.0 + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.vote; + +import java.util.Map; + +import org.apache.commons.lang.builder.ToStringBuilder; + + +/** + *
DTO that holds summary data for all the sessions
+ * + * @author Ozgur Demirtas + */ +public class VoteAllSessionsDTO implements Comparable +{ + private String sessionUserCount; + private String completedSessionUserCount; + private String completedSessionUserPercent; + private String sessionId; + private Map mapStandardNominationsContent; + private Map mapStandardUserCount; + private Map mapStandardRatesContent; + + /** + * @return Returns the mapStandardRatesContent. + */ + public Map getMapStandardRatesContent() { + return mapStandardRatesContent; + } + /** + * @param mapStandardRatesContent The mapStandardRatesContent to set. + */ + public void setMapStandardRatesContent(Map mapStandardRatesContent) { + this.mapStandardRatesContent = mapStandardRatesContent; + } + /** + * @return Returns the mapStandardUserCount. + */ + public Map getMapStandardUserCount() { + return mapStandardUserCount; + } + /** + * @param mapStandardUserCount The mapStandardUserCount to set. + */ + public void setMapStandardUserCount(Map mapStandardUserCount) { + this.mapStandardUserCount = mapStandardUserCount; + } + public String toString() { + return new ToStringBuilder(this) + .append("sessionId", getSessionId()) + .toString(); + } + + public int compareTo(Object o) + { + VoteAllSessionsDTO voteAllSessionsDTO = (VoteAllSessionsDTO) o; + + if (voteAllSessionsDTO == null) + return 1; + else + return (int) (new Long(sessionId).longValue() - new Long(voteAllSessionsDTO.sessionId).longValue()); + } + + /** + * @return Returns the completedSessionUserCount. + */ + public String getCompletedSessionUserCount() { + return completedSessionUserCount; + } + /** + * @param completedSessionUserCount The completedSessionUserCount to set. + */ + public void setCompletedSessionUserCount(String completedSessionUserCount) { + this.completedSessionUserCount = completedSessionUserCount; + } + /** + * @return Returns the sessionId. + */ + public String getSessionId() { + return sessionId; + } + /** + * @param sessionId The sessionId to set. + */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + /** + * @return Returns the sessionUserCount. + */ + public String getSessionUserCount() { + return sessionUserCount; + } + /** + * @param sessionUserCount The sessionUserCount to set. + */ + public void setSessionUserCount(String sessionUserCount) { + this.sessionUserCount = sessionUserCount; + } + + /** + * @return Returns the completedSessionUserPercent. + */ + public String getCompletedSessionUserPercent() { + return completedSessionUserPercent; + } + /** + * @param completedSessionUserPercent The completedSessionUserPercent to set. + */ + public void setCompletedSessionUserPercent( + String completedSessionUserPercent) { + this.completedSessionUserPercent = completedSessionUserPercent; + } + /** + * @return Returns the mapStandardNominationsContent. + */ + public Map getMapStandardNominationsContent() { + return mapStandardNominationsContent; + } + /** + * @param mapStandardNominationsContent The mapStandardNominationsContent to set. + */ + public void setMapStandardNominationsContent( + Map mapStandardNominationsContent) { + this.mapStandardNominationsContent = mapStandardNominationsContent; + } +} Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java =================================================================== diff -u -rffd708b0c89a0ecd273136ba315818b697ee1d54 -r6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision ffd708b0c89a0ecd273136ba315818b697ee1d54) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision 6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86) @@ -161,6 +161,7 @@ public static final String LIST_UPLOADED_ONLINE_FILENAMES ="listUploadedOnlineFileNames"; public static final String LIST_OFFLINEFILES_METADATA ="listOfflineFilesMetadata"; public static final String LIST_ONLINEFILES_METADATA ="listOnlineFilesMetadata"; + public static final String LIST_VOTE_ALLSESSIONS_DTO ="listVoteAllSessionsDTO"; public static final String ATTACHMENT_LIST ="attachmentList"; public static final String DELETED_ATTACHMENT_LIST ="deletedAttachmentList"; Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java =================================================================== diff -u -r22789974b076931e27e1e37ed7d91bd17f4f9cb6 -r6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 22789974b076931e27e1e37ed7d91bd17f4f9cb6) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86) @@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.vote.VoteAllSessionsDTO; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.VoteComparator; import org.lamsfoundation.lams.tool.vote.VoteMonitoredAnswersDTO; @@ -659,6 +660,147 @@ return map; } + + public static List prepareChartDTO(HttpServletRequest request, IVoteService voteService, VoteMonitoringForm voteMonitoringForm, Long toolContentId) + { + logger.debug("start preparing ChartDTO with voteMonitoringForm: " + voteMonitoringForm); + logger.debug("start preparing ChartDTO with toolContentId: " + toolContentId); + + List listVoteAllSessionsDTO= new LinkedList(); + + VoteContent voteContent=voteService.retrieveVote(toolContentId); + logger.debug("existing voteContent:" + voteContent); + logger.debug("will be building groups question data for content:..." + voteContent); + + Iterator itListSessions = voteContent.getVoteSessions().iterator(); + while (itListSessions.hasNext()) + { + VoteSession voteSession =(VoteSession)itListSessions.next(); + logger.debug("voteSession:..." + voteSession); + logger.debug("current voteSession id :..." + voteSession.getVoteSessionId()); + logger.debug("current toolSessionUid :..." + voteSession.getUid()); + + Map mapOptionsContent= new TreeMap(new VoteComparator()); + logger.debug("mapOptionsContent: " + mapOptionsContent); + + Map mapVoteRatesContent= new TreeMap(new VoteComparator()); + logger.debug("mapVoteRatesContent: " + mapVoteRatesContent); + + VoteAllSessionsDTO voteAllSessionsDTO= new VoteAllSessionsDTO(); + voteAllSessionsDTO.setSessionId(voteSession.getVoteSessionId().toString()); + + int entriesCount=voteService.getSessionEntriesCount(voteSession.getUid()); + logger.debug("entriesCount: " + entriesCount); + Set userEntries=voteService.getSessionUserEntriesSet(voteSession.getUid()); + logger.debug("sessionUserCount: " + userEntries.size()); + + int potentialUserCount=voteService.getVoteSessionPotentialLearnersCount(voteSession.getUid()); + logger.debug("potentialUserCount: " + potentialUserCount); + voteAllSessionsDTO.setSessionUserCount(Integer.toString(potentialUserCount)); + + int completedSessionUserCount=voteService.getCompletedVoteUserBySessionUid(voteSession.getUid()); + logger.debug("completedSessionUserCount: " + completedSessionUserCount); + voteAllSessionsDTO.setCompletedSessionUserCount(new Integer(completedSessionUserCount).toString()); + + if (potentialUserCount != 0) + { + double completedPercent=(completedSessionUserCount*100) / potentialUserCount; + logger.debug("completed percent: " + completedPercent); + voteAllSessionsDTO.setCompletedSessionUserPercent(new Double(completedPercent).toString()); + } + else + { + voteAllSessionsDTO.setCompletedSessionUserPercent("Not Available"); + } + + + logger.debug("entriesCount: " + entriesCount); + logger.debug("userEntries: " + userEntries); + + Map mapStandardUserCount= new TreeMap(new VoteComparator()); + + logger.debug("setting existing content data from the db"); + mapOptionsContent.clear(); + Iterator queIterator=voteContent.getVoteQueContents().iterator(); + Long mapIndex=new Long(1); + logger.debug("mapOptionsContent: " + mapOptionsContent); + int totalStandardVotesCount=0; + + logger.debug("using entriesCount: " + entriesCount); + + while (queIterator.hasNext()) + { + VoteQueContent voteQueContent=(VoteQueContent) queIterator.next(); + if (voteQueContent != null) + { + logger.debug("question: " + voteQueContent.getQuestion()); + mapOptionsContent.put(mapIndex.toString(),voteQueContent.getQuestion()); + + int votesCount=0; + logger.debug("getting votesCount based on session: " + voteSession.getUid()); + votesCount=voteService.getStandardAttemptsForQuestionContentAndSessionUid(voteQueContent.getUid(), voteSession.getUid()); + logger.debug("votesCount for questionContent uid: " + votesCount + " for" + voteQueContent.getUid()); + mapStandardUserCount.put(mapIndex.toString(),new Integer(votesCount).toString()); + totalStandardVotesCount=totalStandardVotesCount + votesCount; + + + double voteRate=0d; + if (entriesCount != 0) + { + voteRate=((votesCount * 100)/ entriesCount); + } + + logger.debug("voteRate" + voteRate); + + mapVoteRatesContent.put(mapIndex.toString(), new Double(voteRate).toString()); + mapIndex=new Long(mapIndex.longValue()+1); + } + } + logger.debug("test1: Map initialized with existing contentid to: " + mapOptionsContent); + Map mapStandardNominationsContent= new TreeMap(new VoteComparator()); + mapStandardNominationsContent=mapOptionsContent; + logger.debug("mapStandardNominationsContent: " + mapStandardNominationsContent); + + Map mapStandardRatesContent= new TreeMap(new VoteComparator()); + mapStandardRatesContent=mapVoteRatesContent; + logger.debug("test1: mapStandardRatesContent: " + mapStandardRatesContent); + logger.debug("test1: mapStandardUserCount: " + mapStandardUserCount); + + Iterator itListQuestions = userEntries.iterator(); + int mapVoteRatesSize=mapVoteRatesContent.size(); + logger.debug("mapVoteRatesSize: " + mapVoteRatesSize); + mapIndex=new Long(mapVoteRatesSize+1); + logger.debug("updated mapIndex: " + mapIndex); + + double total=MonitoringUtil.calculateTotal(mapVoteRatesContent); + logger.debug("updated mapIndex: " + mapIndex); + double share=100d-total ; + logger.debug("share: " + share); + + logger.debug("totalStandardVotesCount: " + totalStandardVotesCount); + int userEnteredVotesCount=entriesCount - totalStandardVotesCount; + logger.debug("userEnteredVotesCount for this session: " + userEnteredVotesCount); + + mapStandardNominationsContent.put(mapIndex.toString(), "Open Vote"); + mapStandardRatesContent.put(mapIndex.toString(), new Double(share).toString()); + mapStandardUserCount.put(mapIndex.toString(), new Integer(userEnteredVotesCount).toString()); + + logger.debug("processed for prepareChartDTO: MAP_STANDARD_NOMINATIONS_CONTENT: " + request.getSession().getAttribute(MAP_STANDARD_NOMINATIONS_CONTENT)); + logger.debug("processed for prepareChartDTO: MAP_STANDARD_RATES_CONTENT: " + request.getSession().getAttribute(MAP_STANDARD_RATES_CONTENT)); + logger.debug("processed for prepareChartDTO: MAP_STANDARD_USER_COUNT: " + request.getSession().getAttribute(MAP_STANDARD_USER_COUNT)); + + voteAllSessionsDTO.setMapStandardNominationsContent(mapStandardNominationsContent); + voteAllSessionsDTO.setMapStandardUserCount(mapStandardUserCount); + voteAllSessionsDTO.setMapStandardRatesContent(mapStandardRatesContent); + + + listVoteAllSessionsDTO.add(voteAllSessionsDTO); + } + logger.debug("listVoteAllSessionsDTO: " + listVoteAllSessionsDTO); + + return listVoteAllSessionsDTO; + } + /** * generates JFreeChart for the learner module * Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteChartGenerator.java =================================================================== diff -u -r22789974b076931e27e1e37ed7d91bd17f4f9cb6 -r6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteChartGenerator.java (.../VoteChartGenerator.java) (revision 22789974b076931e27e1e37ed7d91bd17f4f9cb6) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteChartGenerator.java (.../VoteChartGenerator.java) (revision 6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86) @@ -40,6 +40,8 @@ import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.general.DefaultPieDataset; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; +import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; +import org.lamsfoundation.lams.tool.vote.service.IVoteService; /** *Enables generation of enerates JFreeCharts
@@ -64,6 +66,30 @@ try{ String type=request.getParameter("type"); logger.debug("type: " + type); + + String currentSessionId=request.getParameter("currentSessionId"); + logger.debug("currentSessionId: " + currentSessionId); + + if (currentSessionId != null) + { + IVoteService voteService=null; + voteService = (IVoteService)request.getSession().getAttribute(TOOL_SERVICE); + logger.debug("voteService: " + voteService); + + Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("toolContentId: " + toolContentId); + + VoteContent voteContent=voteService.retrieveVote(toolContentId); + logger.debug("existing voteContent:" + voteContent); + + MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId(), new Long(currentSessionId)); + logger.debug("creating maps MAP_STANDARD_NOMINATIONS_CONTENT and MAP_STANDARD_RATES_CONTENT: " + currentSessionId); + + logger.debug("post prepareChartData : MAP_STANDARD_NOMINATIONS_CONTENT: " + request.getSession().getAttribute(MAP_STANDARD_NOMINATIONS_CONTENT)); + logger.debug("post prepareChartData : MAP_STANDARD_RATES_CONTENT: " + request.getSession().getAttribute(MAP_STANDARD_RATES_CONTENT)); + } + + JFreeChart chart=null; logger.debug("creating pie chart" + type); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java =================================================================== diff -u -r0f6c8333c4187ad33fafc3fc874525e091be8d21 -r6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision 0f6c8333c4187ad33fafc3fc874525e091be8d21) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision 6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86) @@ -141,21 +141,24 @@ String currentMonitoredToolSession=voteMonitoringForm.getSelectedToolSessionId(); logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + + Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("toolContentId: " + toolContentId); - + VoteContent voteContent=voteService.retrieveVote(toolContentId); + logger.debug("existing voteContent:" + voteContent); + /* SELECTION_CASE == 1 indicates a selected group other than "All" */ if (currentMonitoredToolSession.equals("All")) { request.getSession().setAttribute(SELECTION_CASE, new Long(2)); + logger.debug("generate DTO for All sessions: "); + List listVoteAllSessionsDTO=MonitoringUtil.prepareChartDTO(request, voteService, voteMonitoringForm, voteContent.getVoteContentId()); + logger.debug("listVoteAllSessionsDTO: " + listVoteAllSessionsDTO); + request.getSession().setAttribute(LIST_VOTE_ALLSESSIONS_DTO, listVoteAllSessionsDTO); } else { - VoteSession voteSession=voteService.retrieveVoteSession(new Long(currentMonitoredToolSession)); - logger.debug("retrieving voteSession: " + voteSession); - - VoteContent voteContent=voteSession.getVoteContent(); - logger.debug("using voteContent: " + voteContent); - logger.debug("preparing chart data for content id: " + voteContent.getVoteContentId()); logger.debug("preparing chart data for currentMonitoredToolSession: " + currentMonitoredToolSession); MonitoringUtil.prepareChartData(request, voteService, voteMonitoringForm, voteContent.getVoteContentId(), new Long(currentMonitoredToolSession)); @@ -175,6 +178,8 @@ logger.debug("test4: MAP_STANDARD_NOMINATIONS_CONTENT: " + request.getSession().getAttribute(MAP_STANDARD_NOMINATIONS_CONTENT)); logger.debug("test4: MAP_STANDARD_RATES_CONTENT: " + request.getSession().getAttribute(MAP_STANDARD_RATES_CONTENT)); + + logger.debug("test4: LIST_VOTE_ALLSESSIONS_DTO: " + request.getSession().getAttribute(LIST_VOTE_ALLSESSIONS_DTO)); return (mapping.findForward(LOAD_MONITORING)); } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java =================================================================== diff -u -r1a81f68941dbfe322ed23348d2806fa0b3fc615d -r6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 1a81f68941dbfe322ed23348d2806fa0b3fc615d) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86) @@ -102,7 +102,6 @@ Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); logger.debug("toolContentId: " + toolContentId); - logger.debug("calling prepareChartData: " + toolContentId); VoteContent voteContent=voteService.retrieveVote(toolContentId); /*true means there is at least 1 response*/ @@ -125,6 +124,7 @@ request.getSession().setAttribute(REQUEST_LEARNING_REPORT, new Boolean(false).toString()); request.getSession().setAttribute(IS_PORTFOLIO_EXPORT, new Boolean(false).toString()); voteMonitoringForm.setShowOpenVotesSection(new Boolean(false).toString()); + return voteMonitoringAction.submitSession(mapping, form, request, response); } Index: lams_tool_vote/web/monitoring/SummaryContent.jsp =================================================================== diff -u -r9d3b73b44f51fa4497afbc5a84a74dde79a25503 -r6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86 --- lams_tool_vote/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision 9d3b73b44f51fa4497afbc5a84a74dde79a25503) +++ lams_tool_vote/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision 6337b44d0387e4f1bb2c1a7511a483e3b2f6fb86) @@ -43,20 +43,7 @@ |
-
- |
-
+ |
+ |
+ ||||||||||||||||||||
+ |
+ |
+ ||||||||||||||||||||
   | +|||||||||||||||||||||
+
|