- implement taking poll
This commit is contained in:
parent
4324655bc3
commit
526f6d69a6
@ -156,6 +156,6 @@ class BigBlueButtonInGW(bbbGW: BigBlueButtonGateway) extends IBigBlueButtonInGW
|
||||
}
|
||||
|
||||
def respondPoll(meetingID: String, requesterID: String, msg: String) {
|
||||
|
||||
pollGW.respondPoll(meetingID, requesterID, msg)
|
||||
}
|
||||
}
|
@ -3,8 +3,8 @@ package org.bigbluebutton.core.apps.poll
|
||||
import scala.collection.mutable.HashMap
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
||||
case class QuestionResponsesVO(val questionID:String, val responses:Array[String])
|
||||
case class PollResponseVO(val responses: Array[QuestionResponsesVO])
|
||||
case class QuestionResponsesVO(val questionID:String, val responseIDs:Array[String])
|
||||
case class PollResponseVO(val pollID: String, val responses: Array[QuestionResponsesVO])
|
||||
case class ResponderVO(responseID: String, user: Responder)
|
||||
|
||||
case class ResponseVO(id: String, text: String, responders: Array[Responder] = Array[Responder]())
|
||||
|
@ -22,10 +22,32 @@ class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway, us
|
||||
case startPoll: StartPoll => handleStartPoll(startPoll)
|
||||
case clearPoll: ClearPoll => handleClearPoll(clearPoll)
|
||||
case getPolls: GetPolls => handleGetPolls(getPolls)
|
||||
case respondPoll: RespondToPoll => handleRespondToPoll(respondPoll)
|
||||
case _ => // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
private def handleRespondToPoll(msg: RespondToPoll) {
|
||||
val pollID = msg.response.pollID
|
||||
|
||||
if (model.hasPoll(pollID)) {
|
||||
if (usersApp.hasUser(msg.requesterID)) {
|
||||
val user = usersApp.getUser(msg.requesterID)
|
||||
val responder = new Responder(user.userID, user.name)
|
||||
msg.response.responses.foreach(question => {
|
||||
question.responseIDs.foreach(response => {
|
||||
model.respondToQuestion(pollID, question.questionID, response, responder)
|
||||
})
|
||||
})
|
||||
|
||||
model.getPoll(msg.response.pollID) match {
|
||||
case Some(poll) => outGW.send(new PollResponseOutMsg(meetingID, recorded, responder, msg.response))
|
||||
case None => // do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private def handleGetPolls(msg: GetPolls) {
|
||||
var polls = model.getPolls
|
||||
outGW.send(new GetPollsReplyOutMsg(meetingID, recorded, msg.requesterID, polls))
|
||||
|
@ -8,6 +8,7 @@ import org.bigbluebutton.core.apps.poll.messages.StartPoll
|
||||
import org.bigbluebutton.core.apps.poll.messages.StopPoll
|
||||
import org.bigbluebutton.core.apps.poll.messages.RemovePoll
|
||||
import org.bigbluebutton.core.apps.poll.messages.GetPolls
|
||||
import org.bigbluebutton.core.apps.poll.messages.RespondToPoll
|
||||
|
||||
class PollInGateway(bbbGW: BigBlueButtonGateway) {
|
||||
|
||||
@ -43,6 +44,7 @@ class PollInGateway(bbbGW: BigBlueButtonGateway) {
|
||||
}
|
||||
|
||||
def respondPoll(meetingID: String, requesterID: String, msg: String) {
|
||||
|
||||
val pollResponse = msgConverter.convertTakePollMessage(msg)
|
||||
bbbGW.accept(new RespondToPoll(meetingID, requesterID, pollResponse))
|
||||
}
|
||||
}
|
@ -152,6 +152,6 @@ class PollMessageConverter {
|
||||
qVO += new QuestionResponsesVO(questionID, rvoArray.toArray)
|
||||
}
|
||||
|
||||
new PollResponseVO(qVO.toArray)
|
||||
new PollResponseVO(pollID, qVO.toArray)
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ class PollModel {
|
||||
|
||||
private val polls = new HashMap[String, Poll]()
|
||||
|
||||
// createSamplePoll
|
||||
createSamplePoll
|
||||
|
||||
def createSamplePoll() {
|
||||
addSamplePoll1()
|
||||
|
@ -17,7 +17,7 @@ case class StopPoll(meetingID:String, requesterID: String, pollID: String) exten
|
||||
case class StartPoll(meetingID:String, requesterID: String, pollID: String) extends InMessage
|
||||
case class ClearPoll(meetingID: String, requesterID: String, pollID: String, force: Boolean=false) extends InMessage
|
||||
case class GetPollResult(meetingID:String, requesterID: String, pollID: String) extends InMessage
|
||||
case class RespondToPoll(meetingID: String, requesterID: String, pollID: String, responses : Array[PollResponseVO])
|
||||
case class RespondToPoll(meetingID: String, requesterID: String, response: PollResponseVO) extends InMessage
|
||||
|
||||
|
||||
|
||||
@ -35,3 +35,4 @@ case class PollStoppedOutMsg(meetingID: String, recorded: Boolean, pollID: Strin
|
||||
case class PollRemovedOutMsg(meetingID: String, recorded: Boolean, pollID: String) extends IOutMessage
|
||||
case class PollUpdatedOutMsg(meetingID: String, recorded: Boolean, pollID: String, pollVO: PollVO) extends IOutMessage
|
||||
case class PollCreatedOutMsg(meetingID: String, recorded: Boolean, pollID: String, pollVO: PollVO) extends IOutMessage
|
||||
case class PollResponseOutMsg(meetingID: String, recorded: Boolean, responder: Responder, response: PollResponseVO) extends IOutMessage
|
@ -15,6 +15,7 @@ import com.google.gson.Gson
|
||||
import org.bigbluebutton.conference.meeting.messaging.red5.BroadcastClientMessage
|
||||
import java.util.ArrayList
|
||||
import org.bigbluebutton.core.apps.poll.PollVO
|
||||
import org.bigbluebutton.core.apps.poll.messages.PollResponseOutMsg
|
||||
|
||||
class PollClientMessageSender(service: ConnectionInvokerService) extends OutMessageListener2 {
|
||||
|
||||
@ -27,10 +28,26 @@ class PollClientMessageSender(service: ConnectionInvokerService) extends OutMess
|
||||
case pollRemovedOutMsg: PollRemovedOutMsg => handlePollRemovedOutMsg(pollRemovedOutMsg)
|
||||
case pollUpdatedOutMsg: PollUpdatedOutMsg => handlePollUpdatedOutMsg(pollUpdatedOutMsg)
|
||||
case pollCreatedOutMsg: PollCreatedOutMsg => handlePollCreatedOutMsg(pollCreatedOutMsg)
|
||||
case pollResponseOutMsg: PollResponseOutMsg => handlePollResponseOutMsg(pollResponseOutMsg)
|
||||
case _ => // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
private def handlePollResponseOutMsg(msg: PollResponseOutMsg) {
|
||||
val gson = new Gson();
|
||||
val map = new java.util.HashMap[String, Object]()
|
||||
map.put("responder", msg.responder)
|
||||
map.put("response", msg.response)
|
||||
|
||||
val message = new java.util.HashMap[String, Object]()
|
||||
message.put("msg", gson.toJson(map))
|
||||
|
||||
println("PollClientMessageSender - Handling PollResponseOutMsg \n" + message.get("msg") + "\n")
|
||||
|
||||
var m = new BroadcastClientMessage(msg.meetingID, "pollResultUpdatedMessage", message);
|
||||
service.sendMessage(m);
|
||||
}
|
||||
|
||||
private def handleGetPollsReplyOutMsg(msg: GetPollsReplyOutMsg) {
|
||||
val gson = new Gson();
|
||||
val message = new java.util.HashMap[String, Object]()
|
||||
|
@ -48,6 +48,10 @@ class UsersApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) {
|
||||
currentPresenter
|
||||
}
|
||||
|
||||
def hasUser(userID: String):Boolean = {
|
||||
users.hasUser(userID)
|
||||
}
|
||||
|
||||
def getUser(userID:String):UserVO = {
|
||||
users.getUser(userID)
|
||||
}
|
||||
|
@ -71,13 +71,10 @@ package org.bigbluebutton.modules.polling.model
|
||||
return _questions;
|
||||
}
|
||||
|
||||
public function updateResults(results:ResultsVO):void {
|
||||
for (var i:int = 0; i < results.results.length; i++) {
|
||||
var r:ResultVO = results.results[i] as ResultVO;
|
||||
var q:Question = getQuestion(r.questionID);
|
||||
public function updateResults(questionID:String, responseID:String, responder:Responder):void {
|
||||
var q:Question = getQuestion(questionID);
|
||||
if (q != null) {
|
||||
q.updateResult(r.responseID, r.responder);
|
||||
}
|
||||
q.updateResult(responseID, responder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,10 @@ package org.bigbluebutton.modules.polling.model
|
||||
return _polls.toArray();
|
||||
}
|
||||
|
||||
public function updateResults(pollID:String, results:ResultsVO):void {
|
||||
public function updateResults(pollID:String, questionID:String, responseID:String, responder:Responder):void {
|
||||
if (hasPoll(pollID)) {
|
||||
var poll:Poll = getPoll(pollID);
|
||||
poll.updateResults(results);
|
||||
poll.updateResults(questionID, responseID, responder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,12 +83,66 @@ package org.bigbluebutton.modules.polling.service
|
||||
}
|
||||
|
||||
public function handlePollResultUpdatedMesage(msg:Object):void {
|
||||
var pollResult:Object = JSON.parse(msg.mesage);
|
||||
/*** Incoming message
|
||||
* {"response":{"pollID":"pollID-103","responses":[{"questionID":"q1","responseIDs":["0","1"]}]},"responder":{"userID":"enfjadjc5xnn","name":"RED"}}
|
||||
*/
|
||||
|
||||
if (! model.hasPoll(pollResult.id)) {
|
||||
trace(LOG + "*** Poll Result Update " + msg + " **** \n");
|
||||
|
||||
model.updateResults(pollResult.id, msg.results);
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.POLL_RESULTS_UPDATED, msg.id));
|
||||
if (msg.foo == undefined) {
|
||||
trace(LOG + "handlePollResultUpdatedMesage - No [foo] parameter.");
|
||||
}
|
||||
|
||||
if (msg.msg == undefined) {
|
||||
trace(LOG + "handlePollResultUpdatedMesage - No [msg] parameter.");
|
||||
return;
|
||||
}
|
||||
|
||||
trace(LOG + "*** Poll Result Update " + msg.msg + " **** \n");
|
||||
var map:Object = JSON.parse(msg.msg);
|
||||
|
||||
if (map.response == undefined) {
|
||||
trace(LOG + "handlePollResultUpdatedMesage - No [response] parameter.");
|
||||
return;
|
||||
}
|
||||
|
||||
var response:Object = map.response;
|
||||
|
||||
if (response.pollID == undefined) {
|
||||
trace(LOG + "handlePollResultUpdatedMesage - No [response.pollID] parameter.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (map.responder == undefined || map.responder.userID == undefined || map.responder.name == undefined) {
|
||||
trace(LOG + "handlePollResultUpdatedMesage - No [responder] parameter.");
|
||||
return;
|
||||
}
|
||||
|
||||
var responder:Responder = new Responder(map.responder.userID, map.responder.name);
|
||||
|
||||
if (model.hasPoll(response.pollID)) {
|
||||
if (response.responses == undefined) {
|
||||
trace(LOG + "handlePollResultUpdatedMesage - No [response.responses] parameter.");
|
||||
return;
|
||||
}
|
||||
var responses:Array = response.responses as Array;
|
||||
|
||||
for (var j:int = 0; j < responses.length; j++) {
|
||||
var resp:Object = responses[j];
|
||||
if (resp.questionID == undefined || resp.responseIDs == undefined) {
|
||||
trace(LOG + "handlePollResultUpdatedMesage - No [response.questionID or response.responseIDs] parameter.");
|
||||
return;
|
||||
}
|
||||
var questionID:String = resp.questionID;
|
||||
|
||||
var responseIDs:Array = resp.responseIDs as Array;
|
||||
for (var i:int = 0; i < responseIDs.length; i++) {
|
||||
var respID:String = responseIDs[i] as String
|
||||
model.updateResults(response.pollID, questionID, respID, responder);
|
||||
}
|
||||
}
|
||||
trace(LOG + "*** handlePollResultUpdatedMesage pollID = [" + response.pollID + "] **** \n")
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.POLL_RESULTS_UPDATED, response.pollID));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ package org.bigbluebutton.modules.polling.vo
|
||||
|
||||
public function toMap():Object {
|
||||
var map:Object = new Object();
|
||||
map.id = _id;
|
||||
map.pollID = _id;
|
||||
map.questions = _questions;
|
||||
|
||||
return map;
|
||||
|
Loading…
Reference in New Issue
Block a user