Merge pull request #696 from ritzalam/add-num-responders
Add num responders
This commit is contained in:
commit
88be8696f8
@ -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"
|
||||
)}
|
||||
|
||||
|
||||
|
@ -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]()
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) => {
|
||||
|
@ -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"
|
||||
)}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -424,6 +424,9 @@ public class Util {
|
||||
Map<String, Object> finalAnnotation = new HashMap<String, Object>();
|
||||
|
||||
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<String, Object> decodeSimplePoll(JsonObject poll) {
|
||||
Map<String, Object> pollMap = new HashMap<String, Object>();
|
||||
@ -637,7 +644,10 @@ public class Util {
|
||||
Map<String, Object> pollMap = new HashMap<String, Object>();
|
||||
|
||||
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<Map<String, Object>> collection = new ArrayList<Map<String, Object>>();
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user