diff --git a/akka-bbb-apps/build.sbt b/akka-bbb-apps/build.sbt index fd706f1369..b33e2aa3e6 100755 --- a/akka-bbb-apps/build.sbt +++ b/akka-bbb-apps/build.sbt @@ -50,7 +50,7 @@ libraryDependencies ++= { "com.google.code.gson" % "gson" % "1.7.1", "redis.clients" % "jedis" % "2.1.0", "org.apache.commons" % "commons-lang3" % "3.2", - "org.bigbluebutton" % "bbb-common-message" % "0.0.8" + "org.bigbluebutton" % "bbb-common-message" % "0.0.9" )} diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MessageSenderActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MessageSenderActor.scala index 1a8d56dad5..e367a9e039 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MessageSenderActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MessageSenderActor.scala @@ -395,7 +395,8 @@ class MessageSenderActor(val meetingId: String, val service: MessageSender) private def pollResultVOtoMap(msg: SimplePollResultOutVO): java.util.HashMap[String, Object] = { val pollVO = new java.util.HashMap[String, Object]() pollVO.put("id", msg.id) - + pollVO.put("num_respondents", msg.numRespondents: java.lang.Integer) + pollVO.put("num_responders", msg.numResponders: java.lang.Integer) val answers = new java.util.ArrayList[java.util.Map[String, Any]]; msg.answers.foreach(ans => { val amap = new java.util.HashMap[String, Any]() diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/Poll.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/Poll.scala index 5aec47d5a7..eece8ec2d3 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/Poll.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/Poll.scala @@ -87,12 +87,12 @@ object PollFactory { questionOption } - def createPoll(id: String, pollType: String): Option[Poll] = { + def createPoll(id: String, pollType: String, numRespondents: Int): Option[Poll] = { var poll: Option[Poll] = None createQuestion(pollType) match { case Some(question) => { - poll = Some(new Poll(id, Array(question), None)) + poll = Some(new Poll(id, Array(question), numRespondents, None)) } case None => poll = None } @@ -118,13 +118,13 @@ case class SimpleAnswerOutVO(id: Int, key: String) case class SimplePollOutVO(id: String, answers: Array[SimpleAnswerOutVO]) case class SimpleVoteOutVO(id: Int, key: String, numVotes: Int) -case class SimplePollResultOutVO(id: String, answers: Array[SimpleVoteOutVO]) +case class SimplePollResultOutVO(id: String, answers: Array[SimpleVoteOutVO], numRespondents: Int, numResponders: Int) -class Poll(val id: String, val questions: Array[Question], val title: Option[String]) { +class Poll(val id: String, val questions: Array[Question], val numRespondents: Int, val title: Option[String]) { private var _started: Boolean = false private var _stopped: Boolean = false - private var _showResult: Boolean = false + private var _numResponders: Int = 0 def showingResult() { _showResult = true } def hideResult() { _showResult = false } @@ -152,6 +152,7 @@ class Poll(val id: String, val questions: Array[Question], val title: Option[Str questions.foreach(q => { if (q.id == questionID) { q.respondToQuestion(responseID, responder) + _numResponders += 1 } }) } @@ -170,7 +171,7 @@ class Poll(val id: String, val questions: Array[Question], val title: Option[Str } def toSimplePollResultOutVO(): SimplePollResultOutVO = { - new SimplePollResultOutVO(id, questions(0).toSimpleVotesOutVO()) + new SimplePollResultOutVO(id, questions(0).toSimpleVotesOutVO(), numRespondents, _numResponders) } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/PollApp.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/PollApp.scala index a217048dcd..dad67c0257 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/PollApp.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/PollApp.scala @@ -66,6 +66,8 @@ trait PollApp { def pollResultToWhiteboardShape(result: SimplePollResultOutVO, msg: ShowPollResultRequest): scala.collection.immutable.Map[String, Object] = { val shape = new scala.collection.mutable.HashMap[String, Object]() + shape += "num_respondents" -> new Integer(result.numRespondents) + shape += "num_responders" -> new Integer(result.numResponders) val answers = new ArrayBuffer[java.util.HashMap[String, Object]]; result.answers.foreach(ans => { @@ -135,7 +137,8 @@ trait PollApp { presModel.getCurrentPage() foreach { page => val pollId = page.id + "/" + System.currentTimeMillis() - PollFactory.createPoll(pollId, msg.pollType) foreach (poll => pollModel.addPoll(poll)) + val numRespondents = usersModel.numUsers() - 1 // subtract the presenter + PollFactory.createPoll(pollId, msg.pollType, numRespondents) foreach (poll => pollModel.addPoll(poll)) pollModel.getSimplePoll(pollId) match { case Some(poll) => { diff --git a/akka-bbb-fsesl/build.sbt b/akka-bbb-fsesl/build.sbt index 6253f5e1b6..05b0e342b3 100755 --- a/akka-bbb-fsesl/build.sbt +++ b/akka-bbb-fsesl/build.sbt @@ -50,7 +50,7 @@ libraryDependencies ++= { "com.google.code.gson" % "gson" % "1.7.1", "redis.clients" % "jedis" % "2.1.0", "org.apache.commons" % "commons-lang3" % "3.2", - "org.bigbluebutton" % "bbb-common-message" % "0.0.8", + "org.bigbluebutton" % "bbb-common-message" % "0.0.9", "org.bigbluebutton" % "bbb-fsesl-client" % "0.0.2" )} diff --git a/bbb-common-message/build.sbt b/bbb-common-message/build.sbt index d15b61d81a..ace74b877b 100755 --- a/bbb-common-message/build.sbt +++ b/bbb-common-message/build.sbt @@ -4,7 +4,7 @@ name := "bbb-common-message" organization := "org.bigbluebutton" -version := "0.0.8" +version := "0.0.9" // We want to have our jar files in lib_managed dir. // This way we'll have the right path when we import diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/PollShowResultMessage.java b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/PollShowResultMessage.java index 9458e9ed80..79064aea45 100755 --- a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/PollShowResultMessage.java +++ b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/PollShowResultMessage.java @@ -46,7 +46,7 @@ public class PollShowResultMessage implements ISubscribedMessage { if (payload.has(Constants.MEETING_ID) && payload.has(POLL)) { String id = payload.get(Constants.MEETING_ID).getAsString(); - + JsonObject poll = payload.get(POLL).getAsJsonObject(); Util util = new Util(); diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/Util.java b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/Util.java index 32f78f99ad..36e707a8b9 100755 --- a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/Util.java +++ b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/Util.java @@ -424,6 +424,9 @@ public class Util { Map finalAnnotation = new HashMap(); String whiteboardId = annotationElement.get("whiteboardId").getAsString(); + Integer numRespondents = annotationElement.get(NUM_RESPONDENTS).getAsInt(); + Integer numResponders = annotationElement.get(NUM_RESPONDERS).getAsInt(); + String resultJson = annotationElement.get("result").getAsString(); JsonParser parser = new JsonParser(); JsonArray resultJsonArray = parser.parse(resultJson).getAsJsonArray(); @@ -456,6 +459,8 @@ public class Util { } finalAnnotation.put("whiteboardId", whiteboardId); + finalAnnotation.put(NUM_RESPONDENTS, numRespondents); + finalAnnotation.put(NUM_RESPONDERS, numResponders); finalAnnotation.put("result", collection); finalAnnotation.put("points", pointsArray); @@ -589,6 +594,8 @@ public class Util { public static final String ANSWERS = "answers"; public static final String KEY = "key"; public static final String NUM_VOTES = "num_votes"; + public static final String NUM_RESPONDERS = "num_responders"; + public static final String NUM_RESPONDENTS = "num_respondents"; public Map decodeSimplePoll(JsonObject poll) { Map pollMap = new HashMap(); @@ -637,7 +644,10 @@ public class Util { Map pollMap = new HashMap(); if (poll.has(Constants.ID) && poll.has(ANSWERS)) { - String id = poll.get(Constants.ID).getAsString(); + String id = poll.get(Constants.ID).getAsString(); + Integer numRespondents = poll.get(NUM_RESPONDENTS).getAsInt(); + Integer numResponders = poll.get(NUM_RESPONDERS).getAsInt(); + JsonArray answers = poll.get(ANSWERS).getAsJsonArray(); ArrayList> collection = new ArrayList>(); @@ -654,6 +664,8 @@ public class Util { } pollMap.put(Constants.ID, id); + pollMap.put(NUM_RESPONDENTS, numRespondents); + pollMap.put(NUM_RESPONDERS, numResponders); pollMap.put(ANSWERS, collection); } diff --git a/bigbluebutton-apps/build.gradle b/bigbluebutton-apps/build.gradle index d9a54ee90a..ab0e7bbdc2 100755 --- a/bigbluebutton-apps/build.gradle +++ b/bigbluebutton-apps/build.gradle @@ -112,7 +112,7 @@ dependencies { compile 'com.google.code.gson:gson:1.7.1' providedCompile 'org.apache.commons:commons-lang3:3.2' - compile 'org.bigbluebutton:bbb-common-message:0.0.8' + compile 'org.bigbluebutton:bbb-common-message:0.0.9' } test {