diff --git a/polls/api/src/java/org/sakaiproject/poll/logic/ExternalLogic.java b/polls/api/src/java/org/sakaiproject/poll/logic/ExternalLogic.java index 9c14052a7a9a..aed160cecb87 100644 --- a/polls/api/src/java/org/sakaiproject/poll/logic/ExternalLogic.java +++ b/polls/api/src/java/org/sakaiproject/poll/logic/ExternalLogic.java @@ -232,5 +232,10 @@ public interface ExternalLogic { * Register a statement with the system LearningResourceStoreService */ public void registerStatement(String pollText, boolean newPoll, String pollId); + + /** + * Get the total number of users that have permission for voting + */ + public int getNumberUsersCanVote(); } diff --git a/polls/impl/src/java/org/sakaiproject/poll/logic/impl/ExternalLogicImpl.java b/polls/impl/src/java/org/sakaiproject/poll/logic/impl/ExternalLogicImpl.java index d798d92db87d..e72c64b49d29 100644 --- a/polls/impl/src/java/org/sakaiproject/poll/logic/impl/ExternalLogicImpl.java +++ b/polls/impl/src/java/org/sakaiproject/poll/logic/impl/ExternalLogicImpl.java @@ -515,5 +515,12 @@ public void registerStatement(String pollText, boolean newPoll, String pollId) { eventTrackingService.post(event); } } + + @Override + public int getNumberUsersCanVote() { + ArrayList siteGroupRefs = new ArrayList<>(); + siteGroupRefs.add(siteService.siteReference(developerHelperService.getCurrentLocationId())); + return (authzGroupService.getUsersIsAllowed(PollListManager.PERMISSION_VOTE, siteGroupRefs).size()); + } } diff --git a/polls/impl/src/test/org/sakaiproject/poll/logic/test/stubs/ExternalLogicStubb.java b/polls/impl/src/test/org/sakaiproject/poll/logic/test/stubs/ExternalLogicStubb.java index f784f04861a6..79d3fe3b1aa4 100644 --- a/polls/impl/src/test/org/sakaiproject/poll/logic/test/stubs/ExternalLogicStubb.java +++ b/polls/impl/src/test/org/sakaiproject/poll/logic/test/stubs/ExternalLogicStubb.java @@ -211,5 +211,10 @@ public void registerStatement(String pollText, Vote vote) { public void registerStatement(String pollText, boolean newPoll, String pollId) { // TODO Auto-generated method stub } + + @Override + public int getNumberUsersCanVote() { + return 0; + } } diff --git a/polls/tool/src/bundle/org/sakaiproject/poll/bundle/Messages_es.properties b/polls/tool/src/bundle/org/sakaiproject/poll/bundle/Messages_es.properties index c7d78a77411d..c8c5004e9673 100644 --- a/polls/tool/src/bundle/org/sakaiproject/poll/bundle/Messages_es.properties +++ b/polls/tool/src/bundle/org/sakaiproject/poll/bundle/Messages_es.properties @@ -97,7 +97,7 @@ results_answers_reset_ordering=Borrar orden results_answers_numbering=N\u00famero de opci\u00f3n results_answers_numbering_tooltip=Ordenar por opci\u00f3n result_novote=No ha seleccionado ninguna opci\u00f3n -results_poll_size=N\u00famero de votos\: {0} +results_poll_size=N\u00famero de votantes\: {0} results_cancel=Volver results_cancel_tooltip=Volver results_chart_type=Tipo de gr\u00e1fico\: diff --git a/polls/tool/src/java/org/sakaiproject/poll/tool/producers/ResultsProducer.java b/polls/tool/src/java/org/sakaiproject/poll/tool/producers/ResultsProducer.java index cf821c69298b..c9469a948c3b 100644 --- a/polls/tool/src/java/org/sakaiproject/poll/tool/producers/ResultsProducer.java +++ b/polls/tool/src/java/org/sakaiproject/poll/tool/producers/ResultsProducer.java @@ -21,6 +21,8 @@ package org.sakaiproject.poll.tool.producers; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.NumberFormat; import java.util.ArrayList; import java.util.HashMap; @@ -135,9 +137,11 @@ public void fillComponents(UIContainer tofill, ViewParameters viewparams, //get the number of votes int voters = pollVoteManager.getDisctinctVotersForPoll(poll); - //Object[] args = new Object[] { Integer.valueOf(voters).toString()}; - if (poll.getMaxOptions()>1) - UIOutput.make(tofill,"poll-size",messageLocator.getMessage("results_poll_size",Integer.valueOf(voters).toString())); + int totalVoters = externalLogic.getNumberUsersCanVote(); + BigDecimal percentVoters = new BigDecimal(voters).divide(new BigDecimal(totalVoters),4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); + String statsVoters = String.format("%d / %d (%.02f %%)",voters,totalVoters,percentVoters); + + UIOutput.make(tofill,"poll-size",messageLocator.getMessage("results_poll_size",statsVoters)); log.debug(voters + " have voted on this poll");