- handle voting, stop, and show result in the client
This commit is contained in:
parent
dcfa4ee8fb
commit
d9295115c8
@ -231,7 +231,9 @@ class Answer(val id: Int, val key: String, val text: Option[String]) {
|
||||
responders.clear
|
||||
}
|
||||
def addResponder(responder: Responder) {
|
||||
println("********************************************************************** Add response for key=[" + key + "] votes=[" + numResponders + "]")
|
||||
responders += responder
|
||||
println("********************************************************************** Added response for key=[" + key + "] votes=[" + numResponders + "]")
|
||||
}
|
||||
|
||||
def numResponders(): Int = {
|
||||
@ -249,6 +251,7 @@ class Answer(val id: Int, val key: String, val text: Option[String]) {
|
||||
}
|
||||
|
||||
def toSimpleVoteOutVO(): SimpleVoteOutVO = {
|
||||
println("********************************************************************** Num response for key=[" + key + "] votes=[" + numResponders + "]")
|
||||
new SimpleVoteOutVO(id, key, numResponders)
|
||||
}
|
||||
}
|
@ -129,9 +129,19 @@ trait PollApp {
|
||||
getUser(msg.requesterId) match {
|
||||
case Some(user) => {
|
||||
val responder = new Responder(user.userID, user.name)
|
||||
pollModel.respondToQuestion(poll.id, msg.questionId, msg.answerId, responder)
|
||||
/*
|
||||
* Hardcode to zero as we are assuming the poll has only one question.
|
||||
* Our data model supports multiple question polls but for this
|
||||
* release, we only have a simple poll which has one question per poll.
|
||||
* (ralam june 23, 2015)
|
||||
*/
|
||||
val questionId = 0
|
||||
pollModel.respondToQuestion(poll.id, questionId, msg.answerId, responder)
|
||||
users.getCurrentPresenter foreach { cp =>
|
||||
outGW.send(new UserRespondedToPollMessage(mProps.meetingID, mProps.recorded, cp.userID, msg.pollId, poll))
|
||||
pollModel.getSimplePollResult(poll.id) foreach { updatedPoll =>
|
||||
outGW.send(new UserRespondedToPollMessage(mProps.meetingID, mProps.recorded, cp.userID, msg.pollId, updatedPoll))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,16 +68,6 @@ class PollingEventRedisPublisher(service: MessageSender) extends OutMessageListe
|
||||
}
|
||||
|
||||
private def pollStartedMessageToJson(msg: PollStartedMessage): String = {
|
||||
// val payload = new java.util.HashMap[String, Any]()
|
||||
// payload.put(Constants.MEETING_ID, msg.meetingID)
|
||||
// payload.put(org.bigbluebutton.common.messages.PollStartedMessage.REQUESTER_ID, msg.requesterId)
|
||||
|
||||
// val pollVO = pollVOtoMap(msg.poll)
|
||||
// payload.put(org.bigbluebutton.common.messages.PollStartedMessage.POLL, pollVO)
|
||||
|
||||
// val header = Util.buildHeader(org.bigbluebutton.common.messages.PollStartedMessage.POLL_STARTED, None)
|
||||
// Util.buildJson(header, payload)
|
||||
|
||||
val pollVO = pollVOtoMap(msg.poll)
|
||||
val psm = new org.bigbluebutton.common.messages.PollStartedMessage(msg.meetingID, msg.requesterId, pollVO)
|
||||
psm.toJson
|
||||
|
@ -41,7 +41,7 @@ public class PollingService {
|
||||
String meetingID = Red5.getConnectionLocal().getScope().getName();
|
||||
String userId = getBbbSession().getInternalUserID();
|
||||
String pollId = (String) message.get("pollId");
|
||||
Integer questionId = (Integer) message.get("questionId");
|
||||
Integer questionId = (Integer) message.get("answerId");
|
||||
Integer answerId = (Integer) message.get("answerId");
|
||||
|
||||
red5GW.votePoll(meetingID, userId, pollId, questionId, answerId);
|
||||
|
@ -0,0 +1,17 @@
|
||||
package org.bigbluebutton.modules.polling.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class PollStartedEvent extends Event
|
||||
{
|
||||
public static const POLL_STARTED:String = "poll started";
|
||||
|
||||
public var pollId:String;
|
||||
|
||||
public function PollStartedEvent(pollId:String)
|
||||
{
|
||||
super(POLL_STARTED, true, false);
|
||||
this.pollId = pollId;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,13 +7,11 @@ package org.bigbluebutton.modules.polling.events
|
||||
|
||||
public static const SHOW_POLL_RESULT:String = "show poll result";
|
||||
|
||||
public var pollId: String;
|
||||
public var show: Boolean;
|
||||
|
||||
public function ShowPollResultEvent(pollId:String, show:Boolean)
|
||||
public function ShowPollResultEvent(show:Boolean)
|
||||
{
|
||||
super(SHOW_POLL_RESULT, true, false);
|
||||
this.pollId = pollId;
|
||||
this.show = show;
|
||||
}
|
||||
}
|
||||
|
@ -24,13 +24,11 @@ package org.bigbluebutton.modules.polling.events
|
||||
{
|
||||
public static const START:String = "start poll";
|
||||
|
||||
public var pollId: String;
|
||||
public var pollType: String;
|
||||
|
||||
public function StartPollEvent(pollId: String, pollType: String)
|
||||
public function StartPollEvent(pollType: String)
|
||||
{
|
||||
super(START, true, false);
|
||||
this.pollId = pollId;
|
||||
this.pollType = pollType;
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,10 @@ package org.bigbluebutton.modules.polling.events
|
||||
public class StopPollEvent extends Event
|
||||
{
|
||||
public static const STOP_POLL:String = "stop poll";
|
||||
public var pollId : String;
|
||||
|
||||
public function StopPollEvent(pollId: String)
|
||||
public function StopPollEvent()
|
||||
{
|
||||
super(STOP_POLL, true, false);
|
||||
this.pollId = pollId;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,15 +24,11 @@ package org.bigbluebutton.modules.polling.events
|
||||
{
|
||||
public static const VOTE_POLL:String = "vote poll";
|
||||
|
||||
public var pollId: String;
|
||||
public var questionId: Number;
|
||||
public var answerId: Number;
|
||||
|
||||
public function StartPollEvent(pollId: String, questionId: Number, answerId: Number)
|
||||
public function VotePollEvent(answerId: Number)
|
||||
{
|
||||
super(VOTE_POLL, true, false);
|
||||
this.pollId = pollId;
|
||||
this.questionId = questionId;
|
||||
this.answerId = answerId;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
import org.bigbluebutton.modules.polling.service.NetworkPollDataService;
|
||||
import org.bigbluebutton.modules.polling.service.PollDataProcessor;
|
||||
import org.bigbluebutton.modules.polling.service.PollingService;
|
||||
import org.bigbluebutton.modules.polling.service.ShortCircuitPollDataService;
|
||||
|
||||
]]>
|
||||
|
||||
@ -47,10 +46,7 @@
|
||||
<EventHandlers type="{ModuleEvent.STOP}">
|
||||
</EventHandlers>
|
||||
|
||||
<EventHandlers type="{InitPollModuleEvent.INITIALIZE_POLL_MODULE}">
|
||||
|
||||
</EventHandlers>
|
||||
|
||||
<EventHandlers type="{InitPollModuleEvent.INITIALIZE_POLL_MODULE}"/>
|
||||
|
||||
<EventHandlers type="{UpdatePollEvent.UPDATE_POLL}">
|
||||
<MethodInvoker generator="{PollingService}" method="handleUpdatePollEvent" arguments="{event}"/>
|
||||
@ -60,22 +56,23 @@
|
||||
<MethodInvoker generator="{PollingService}" method="handleStartPollEvent" arguments="{event}"/>
|
||||
</EventHandlers>
|
||||
|
||||
<EventHandlers type="{PollEvent.STOP_POLL}">
|
||||
<EventHandlers type="{StopPollEvent.STOP_POLL}">
|
||||
<MethodInvoker generator="{PollingService}" method="handleStopPollEvent" arguments="{event}"/>
|
||||
</EventHandlers>
|
||||
|
||||
<EventHandlers type="{PollEvent.REMOVE_POLL}">
|
||||
<MethodInvoker generator="{PollingService}" method="handleRemovePollEvent" arguments="{event}"/>
|
||||
<EventHandlers type="{VotePollEvent.VOTE_POLL}">
|
||||
<MethodInvoker generator="{PollingService}" method="handleVotePollEvent" arguments="{event}"/>
|
||||
</EventHandlers>
|
||||
|
||||
<EventHandlers type="{RespondEvent.RESPOND_EVENT}">
|
||||
<MethodInvoker generator="{PollingService}" method="handleRespondPollEvent" arguments="{event}"/>
|
||||
<EventHandlers type="{ShowPollResultEvent.SHOW_POLL_RESULT}">
|
||||
<MethodInvoker generator="{PollingService}" method="handleShowPollResultEvent" arguments="{event}"/>
|
||||
</EventHandlers>
|
||||
|
||||
|
||||
<Injectors target="{PollingService}">
|
||||
<ObjectBuilder generator="{PollDataProcessor}" cache="global"/>
|
||||
<PropertyInjector targetKey="dataService" source="{NetworkPollDataService}"/>
|
||||
<PropertyInjector targetKey="model" source="{PollingModel}"/>
|
||||
</Injectors>
|
||||
|
||||
<Injectors target="{NetworkPollDataService}">
|
||||
@ -83,10 +80,6 @@
|
||||
<PropertyInjector targetKey="sender" source="{MessageSender}"/>
|
||||
</Injectors>
|
||||
|
||||
<Injectors target="{ShortCircuitPollDataService}">
|
||||
<PropertyInjector targetKey="processor" source="{PollDataProcessor}"/>
|
||||
</Injectors>
|
||||
|
||||
<Injectors target="{PollDataProcessor}">
|
||||
<PropertyInjector targetKey="model" source="{PollingModel}"/>
|
||||
<PropertyInjector targetKey="dispatcher" source="{scope.dispatcher}"/>
|
||||
|
@ -7,6 +7,9 @@ package org.bigbluebutton.modules.polling.model
|
||||
|
||||
public class PollingModel
|
||||
{
|
||||
|
||||
private var _currentPoll:SimplePoll;
|
||||
|
||||
private var _polls:ArrayCollection
|
||||
|
||||
private var _initialized:Boolean = false;
|
||||
@ -20,6 +23,14 @@ package org.bigbluebutton.modules.polling.model
|
||||
return _initialized;
|
||||
}
|
||||
|
||||
public function setCurrentPoll(poll:SimplePoll):void {
|
||||
_currentPoll = poll;
|
||||
}
|
||||
|
||||
public function getCurrentPoll():SimplePoll {
|
||||
return _currentPoll;
|
||||
}
|
||||
|
||||
public function getPolls():Array {
|
||||
return _polls.toArray();
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package org.bigbluebutton.modules.polling.model
|
||||
{
|
||||
import mx.collections.ArrayCollection;
|
||||
|
||||
import org.bigbluebutton.modules.polling.vo.ResultVO;
|
||||
import org.bigbluebutton.modules.polling.vo.ResultsVO;
|
||||
|
||||
public class SimpleAnswer
|
||||
{
|
||||
private var _id:Number;
|
||||
private var _key: String;
|
||||
|
||||
public function SimpleAnswer(id:Number, key:String)
|
||||
{
|
||||
_id = id;
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public function get id():Number {
|
||||
return _id;
|
||||
}
|
||||
|
||||
|
||||
public function get key():String {
|
||||
return _key;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package org.bigbluebutton.modules.polling.model
|
||||
{
|
||||
import mx.collections.ArrayCollection;
|
||||
|
||||
import org.bigbluebutton.modules.polling.vo.ResultVO;
|
||||
import org.bigbluebutton.modules.polling.vo.ResultsVO;
|
||||
|
||||
public class SimplePoll
|
||||
{
|
||||
private var _id:String;
|
||||
private var _questions: Array;
|
||||
|
||||
public function SimplePoll(id:String, questions:Array)
|
||||
{
|
||||
_id = id;
|
||||
_questions = questions;
|
||||
}
|
||||
|
||||
public function get id():String {
|
||||
return _id;
|
||||
}
|
||||
|
||||
|
||||
public function questions():Array {
|
||||
return _questions;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -6,19 +6,13 @@ package org.bigbluebutton.modules.polling.service
|
||||
|
||||
public interface IPollDataService
|
||||
{
|
||||
|
||||
function getPolls():void;
|
||||
|
||||
function createPoll(poll:CreatePollVO):void;
|
||||
|
||||
function updatePoll(poll:UpdatePollVO):void;
|
||||
|
||||
|
||||
function startPoll(pollId:String, pollType: String):void;
|
||||
|
||||
function stopPoll(pollID:String):void;
|
||||
|
||||
function removePoll(pollID:String):void;
|
||||
function votePoll(pollId:String, answerId:Number):void;
|
||||
|
||||
function respondPoll(resp:PollResponseVO):void;
|
||||
function showPollResult(pollId:String, show:Boolean):void;
|
||||
}
|
||||
}
|
@ -43,17 +43,8 @@ package org.bigbluebutton.modules.polling.service
|
||||
trace(LOG + "received message " + messageName);
|
||||
|
||||
switch (messageName) {
|
||||
case "pollGetPollsReply":
|
||||
processor.handleGetPollsReply(message);
|
||||
break;
|
||||
case "pollCreatedMessage":
|
||||
processor.handlePollCreatedMesage(message);
|
||||
break;
|
||||
case "pollUpdatedMessage":
|
||||
processor.handlePollUpdatedMesage(message);
|
||||
break;
|
||||
case "pollDestroyedMessage":
|
||||
processor.handlePollDestroyedMesage(message);
|
||||
case "pollShowResultMessage":
|
||||
processor.handlePollShowResultMessage(message);
|
||||
break;
|
||||
case "pollStartedMessage":
|
||||
processor.handlePollStartedMesage(message);
|
||||
@ -61,8 +52,8 @@ package org.bigbluebutton.modules.polling.service
|
||||
case "pollStoppedMessage":
|
||||
processor.handlePollStoppedMesage(message);
|
||||
break;
|
||||
case "pollResultUpdatedMessage":
|
||||
processor.handlePollResultUpdatedMesage(message);
|
||||
case "pollUserVotedMessage":
|
||||
processor.handlePollUserVotedMessage(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,8 @@
|
||||
package org.bigbluebutton.modules.polling.service
|
||||
{
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.Responder;
|
||||
import flash.net.Responder;
|
||||
|
||||
import org.bigbluebutton.common.LogUtil;
|
||||
import org.bigbluebutton.core.BBB;
|
||||
import org.bigbluebutton.core.managers.ConnectionManager;
|
||||
@ -36,58 +37,7 @@ package org.bigbluebutton.modules.polling.service
|
||||
public class MessageSender
|
||||
{
|
||||
private static const LOG:String = "Poll::MessageSender - ";
|
||||
|
||||
public function getPolls():void
|
||||
{
|
||||
trace(LOG + "getPolls ");
|
||||
|
||||
var _nc:ConnectionManager = BBB.initConnectionManager();
|
||||
_nc.sendMessage("poll.getPolls",
|
||||
function(result:String):void {
|
||||
LogUtil.debug(result);
|
||||
},
|
||||
function(status:String):void {
|
||||
LogUtil.error(status);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function createPoll(poll:CreatePollVO):void
|
||||
{
|
||||
var jsonMsg:String = JSON.stringify(poll.toMap());
|
||||
|
||||
trace(LOG + "createPoll [" + jsonMsg + "]");
|
||||
|
||||
var _nc:ConnectionManager = BBB.initConnectionManager();
|
||||
_nc.sendMessage("poll.createPoll",
|
||||
function(result:String):void {
|
||||
LogUtil.debug(result);
|
||||
},
|
||||
function(status:String):void {
|
||||
LogUtil.error(status);
|
||||
},
|
||||
jsonMsg
|
||||
);
|
||||
}
|
||||
|
||||
public function updatePoll(poll:UpdatePollVO):void
|
||||
{
|
||||
var jsonMsg:String = JSON.stringify(poll.toMap());
|
||||
|
||||
trace(LOG + "updatePoll [" + jsonMsg + "]");
|
||||
|
||||
var _nc:ConnectionManager = BBB.initConnectionManager();
|
||||
_nc.sendMessage("poll.updatePoll",
|
||||
function(result:String):void {
|
||||
LogUtil.debug(result);
|
||||
},
|
||||
function(status:String):void {
|
||||
LogUtil.error(status);
|
||||
},
|
||||
jsonMsg
|
||||
);
|
||||
}
|
||||
|
||||
public function startPoll(pollId:String, pollType: String):void
|
||||
{
|
||||
var map:Object = new Object();
|
||||
@ -110,10 +60,10 @@ package org.bigbluebutton.modules.polling.service
|
||||
);
|
||||
}
|
||||
|
||||
public function stopPoll(pollID:String):void
|
||||
public function stopPoll(pollId:String):void
|
||||
{
|
||||
var map:Object = new Object();
|
||||
map.pollID = pollID;
|
||||
map["pollId"] = pollId;
|
||||
|
||||
var jsonMsg:String = JSON.stringify(map);
|
||||
|
||||
@ -127,45 +77,50 @@ package org.bigbluebutton.modules.polling.service
|
||||
function(status:String):void {
|
||||
LogUtil.error(status);
|
||||
},
|
||||
jsonMsg
|
||||
map
|
||||
);
|
||||
}
|
||||
|
||||
public function removePoll(pollID:String):void
|
||||
public function votePoll(pollId:String, answerId:Number):void
|
||||
{
|
||||
var map:Object = new Object();
|
||||
map.pollID = pollID;
|
||||
map["pollId"] = pollId;
|
||||
map["answerId"] = answerId;
|
||||
|
||||
var jsonMsg:String = JSON.stringify(map);
|
||||
|
||||
trace(LOG + "removePoll [" + jsonMsg + "]");
|
||||
trace(LOG + "votePoll [" + jsonMsg + "]");
|
||||
|
||||
var _nc:ConnectionManager = BBB.initConnectionManager();
|
||||
_nc.sendMessage("poll.removePoll",
|
||||
_nc.sendMessage("poll.votePoll",
|
||||
function(result:String):void {
|
||||
LogUtil.debug(result);
|
||||
},
|
||||
function(status:String):void {
|
||||
LogUtil.error(status);
|
||||
},
|
||||
jsonMsg
|
||||
map
|
||||
);
|
||||
}
|
||||
|
||||
public function respondPoll(resp:PollResponseVO):void {
|
||||
var jsonMsg:String = JSON.stringify(resp.toMap());
|
||||
public function showPollResult(pollId:String, show:Boolean):void {
|
||||
var map:Object = new Object();
|
||||
map["pollId"] = pollId;
|
||||
map["show"] = show;
|
||||
|
||||
trace(LOG + "respondPoll [" + jsonMsg + "]");
|
||||
var jsonMsg:String = JSON.stringify(map);
|
||||
|
||||
trace(LOG + "showPollResult [" + jsonMsg + "]");
|
||||
|
||||
var _nc:ConnectionManager = BBB.initConnectionManager();
|
||||
_nc.sendMessage("poll.respondPoll",
|
||||
_nc.sendMessage("poll.showPollResult",
|
||||
function(result:String):void {
|
||||
LogUtil.debug(result);
|
||||
},
|
||||
function(status:String):void {
|
||||
LogUtil.error(status);
|
||||
},
|
||||
jsonMsg
|
||||
map
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -14,22 +14,7 @@ package org.bigbluebutton.modules.polling.service
|
||||
/* Injected by Mate */
|
||||
public var receiver:MessageReceiver;
|
||||
public var sender:MessageSender;
|
||||
|
||||
public function getPolls():void
|
||||
{
|
||||
sender.getPolls();
|
||||
}
|
||||
|
||||
public function createPoll(poll:CreatePollVO):void
|
||||
{
|
||||
sender.createPoll(poll);
|
||||
}
|
||||
|
||||
public function updatePoll(poll:UpdatePollVO):void
|
||||
{
|
||||
sender.updatePoll(poll);
|
||||
}
|
||||
|
||||
|
||||
public function startPoll(pollId:String, pollType: String):void
|
||||
{
|
||||
sender.startPoll(pollId, pollType);
|
||||
@ -40,14 +25,14 @@ package org.bigbluebutton.modules.polling.service
|
||||
sender.stopPoll(pollID);
|
||||
}
|
||||
|
||||
public function removePoll(pollID:String):void
|
||||
public function votePoll(pollId:String, answerId:Number):void
|
||||
{
|
||||
sender.removePoll(pollID);
|
||||
sender.votePoll(pollId, answerId);
|
||||
}
|
||||
|
||||
public function respondPoll(response:PollResponseVO):void
|
||||
public function showPollResult(pollId:String, show:Boolean):void
|
||||
{
|
||||
sender.respondPoll(response);
|
||||
sender.showPollResult(pollId, show);
|
||||
}
|
||||
}
|
||||
}
|
@ -5,11 +5,14 @@ package org.bigbluebutton.modules.polling.service
|
||||
|
||||
import org.bigbluebutton.core.UsersUtil;
|
||||
import org.bigbluebutton.modules.polling.events.PollEvent;
|
||||
import org.bigbluebutton.modules.polling.events.PollStartedEvent;
|
||||
import org.bigbluebutton.modules.polling.model.Poll;
|
||||
import org.bigbluebutton.modules.polling.model.PollingModel;
|
||||
import org.bigbluebutton.modules.polling.model.Question;
|
||||
import org.bigbluebutton.modules.polling.model.Responder;
|
||||
import org.bigbluebutton.modules.polling.model.Response;
|
||||
import org.bigbluebutton.modules.polling.model.SimpleAnswer;
|
||||
import org.bigbluebutton.modules.polling.model.SimplePoll;
|
||||
|
||||
public class PollDataProcessor
|
||||
{
|
||||
@ -18,237 +21,49 @@ package org.bigbluebutton.modules.polling.service
|
||||
/* Injected by Mate */
|
||||
public var model:PollingModel;
|
||||
public var dispatcher:IEventDispatcher;
|
||||
|
||||
public function handleGetPollsReply(msg:Object):void {
|
||||
trace(LOG + "*** getPollsReply " + msg.msg + " **** \n");
|
||||
var polls:Array = JSON.parse(msg.msg) as Array;
|
||||
|
||||
trace(LOG + "*** getPollsReply " + polls.length + " **** \n");
|
||||
|
||||
for (var i:int = 0; i < polls.length; i++) {
|
||||
var map:Object = polls[i];
|
||||
var id:String = map.id;
|
||||
var title:String = map.title;
|
||||
var started:Boolean = map.started;
|
||||
var stopped:Boolean = map.stopped;
|
||||
|
||||
var questions:Array = map.questions as Array;
|
||||
|
||||
var qs:Array = new Array();
|
||||
|
||||
for (var j:int = 0; j < questions.length; j++) {
|
||||
qs.push(buildQuestion(questions[j]));
|
||||
}
|
||||
|
||||
var poll:Poll = new Poll(id, title, qs, started, stopped);
|
||||
|
||||
model.createPoll(poll);
|
||||
}
|
||||
|
||||
trace(LOG + "*** getPollsReply num polls = [" + model.getPolls().length + "] **** \n")
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function buildQuestion(question:Object):Question {
|
||||
var resps:Array = question.responses as Array;
|
||||
|
||||
var _resps1:Array = buildResponses(resps);
|
||||
|
||||
trace(LOG + "*** buildQuestion [" + question.id + "," + question.multiResponse + "," + question.question + "] **** \n")
|
||||
|
||||
var _q1:Question = new Question(question.id, question.multiResponse, question.question, _resps1);
|
||||
|
||||
return _q1;
|
||||
}
|
||||
|
||||
private function buildResponses(resps:Array):Array {
|
||||
|
||||
var _resps1:Array = new Array();
|
||||
|
||||
for (var i:int = 0; i < resps.length; i++) {
|
||||
var r:Object = resps[i];
|
||||
|
||||
var responders:Array = buildResponders(r);
|
||||
|
||||
_resps1.push(new Response(r.id, r.text, responders));
|
||||
}
|
||||
|
||||
return _resps1;
|
||||
}
|
||||
|
||||
private function buildResponders(response:Object):Array {
|
||||
var responders:Array = new Array();
|
||||
|
||||
var users:Array = response.responders as Array;
|
||||
for (var k:int = 0; k < users.length; k++) {
|
||||
responders.push(new Responder(users[k].userID, users[k].name));
|
||||
}
|
||||
|
||||
return responders;
|
||||
}
|
||||
|
||||
public function handlePollResultUpdatedMesage(msg:Object):void {
|
||||
/*** Incoming message
|
||||
* {"response":{"pollID":"pollID-103","responses":[{"questionID":"q1","responseIDs":["0","1"]}]},"responder":{"userID":"enfjadjc5xnn","name":"RED"}}
|
||||
*/
|
||||
|
||||
trace(LOG + "*** Poll Result Update " + msg + " **** \n");
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (UsersUtil.isMe(responder.userID)) {
|
||||
model.userHasResponded(response.pollID);
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.USER_RESPONDED, response.pollID));
|
||||
}
|
||||
|
||||
trace(LOG + "*** handlePollResultUpdatedMesage pollID = [" + response.pollID + "] **** \n")
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.POLL_RESULTS_UPDATED, response.pollID));
|
||||
}
|
||||
}
|
||||
|
||||
public function handlePollCreatedMesage(msg:Object):void {
|
||||
trace(LOG + "*** Poll Created " + msg.msg + " **** \n");
|
||||
|
||||
var map:Object = JSON.parse(msg.msg);
|
||||
|
||||
if (! model.hasPoll(map.id)) {
|
||||
var id:String = map.id;
|
||||
var title:String = map.title;
|
||||
var questions:Array = map.questions as Array;
|
||||
|
||||
var qs:Array = new Array();
|
||||
|
||||
for (var j:int = 0; j < questions.length; j++) {
|
||||
qs.push(buildQuestion(questions[j]));
|
||||
}
|
||||
|
||||
var poll:Poll = new Poll(id, title, qs, false, false);
|
||||
|
||||
model.createPoll(poll);
|
||||
|
||||
trace(LOG + "*** Poll Created id=[" + map.id + "] title=[" + map.title + "] questions = [" + questions.length + "] **** \n");
|
||||
trace(LOG + "*** handlePollCreatedMesage num polls = [" + model.getPolls().length + "] **** \n")
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.POLL_CREATED, poll.id));
|
||||
}
|
||||
}
|
||||
|
||||
public function handlePollUpdatedMesage(msg:Object):void {
|
||||
trace(LOG + "*** Poll updated " + msg.msg + " **** \n");
|
||||
|
||||
var map:Object = JSON.parse(msg.msg);
|
||||
|
||||
if (model.hasPoll(map.id)) {
|
||||
var id:String = map.id;
|
||||
var title:String = map.title;
|
||||
var questions:Array = map.questions as Array;
|
||||
|
||||
var qs:Array = new Array();
|
||||
|
||||
for (var j:int = 0; j < questions.length; j++) {
|
||||
qs.push(buildQuestion(questions[j]));
|
||||
}
|
||||
|
||||
var poll:Poll = new Poll(id, title, qs, false, false);
|
||||
|
||||
model.updatePoll(poll);
|
||||
|
||||
trace(LOG + "*** Poll updated id=[" + map.id + "] title=[" + map.title + "] questions = [" + questions.length + "] **** \n");
|
||||
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.POLL_UPDATED, poll.id));
|
||||
}
|
||||
}
|
||||
|
||||
public function handlePollDestroyedMesage(msg:Object):void {
|
||||
trace(LOG + "*** Poll destroyed " + msg.msg + " **** \n");
|
||||
|
||||
var map:Object = JSON.parse(msg.msg);
|
||||
var pollID:String = map.pollID;
|
||||
|
||||
trace(LOG + "*** Destroying " + pollID + " **** \n");
|
||||
if (model.hasPoll(pollID)) {
|
||||
model.destroyPoll(pollID);
|
||||
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.POLL_DESTROYED, pollID));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function handlePollStartedMesage(msg:Object):void {
|
||||
trace(LOG + "*** Poll started " + msg.msg + " **** \n");
|
||||
/*
|
||||
|
||||
var map:Object = JSON.parse(msg.msg);
|
||||
var pollID:String = map.pollID;
|
||||
if (map.hasOwnProperty("poll")) {
|
||||
var poll:Object = map.poll;
|
||||
if (poll.hasOwnProperty("id") && poll.hasOwnProperty("answers")) {
|
||||
var pollId:String = poll.id;
|
||||
|
||||
var answers:Array = poll.answers as Array;
|
||||
|
||||
var ans:Array = new Array();
|
||||
|
||||
for (var j:int = 0; j < answers.length; j++) {
|
||||
var a:Object = answers[j];
|
||||
ans.push(new SimpleAnswer(a.id as Number, a.key));
|
||||
}
|
||||
|
||||
model.setCurrentPoll(new SimplePoll(pollId, ans));
|
||||
dispatcher.dispatchEvent(new PollStartedEvent(pollId));
|
||||
}
|
||||
|
||||
if (model.hasPoll(pollID)) {
|
||||
model.startPoll(pollID);
|
||||
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.POLL_STARTED, pollID));
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
public function handlePollStoppedMesage(msg:Object):void {
|
||||
trace(LOG + "*** Poll stopped " + msg.msg + " **** \n");
|
||||
var map:Object = JSON.parse(msg.msg);
|
||||
var pollID:String = map.pollID;
|
||||
|
||||
}
|
||||
|
||||
public function handlePollShowResultMessage(msg:Object):void {
|
||||
trace(LOG + "*** Poll show result " + msg.msg + " **** \n");
|
||||
var map:Object = JSON.parse(msg.msg);
|
||||
|
||||
if (model.hasPoll(pollID)) {
|
||||
model.stopPoll(pollID);
|
||||
}
|
||||
|
||||
public function handlePollUserVotedMessage(msg:Object):void {
|
||||
trace(LOG + "*** Poll user voted " + msg.msg + " **** \n");
|
||||
var map:Object = JSON.parse(msg.msg);
|
||||
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.POLL_STOPPED, pollID));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -25,8 +25,15 @@ package org.bigbluebutton.modules.polling.service
|
||||
import org.bigbluebutton.core.managers.UserManager;
|
||||
import org.bigbluebutton.modules.polling.events.PollEvent;
|
||||
import org.bigbluebutton.modules.polling.events.RespondEvent;
|
||||
import org.bigbluebutton.modules.polling.events.ShowPollResultEvent;
|
||||
import org.bigbluebutton.modules.polling.events.StartPollEvent;
|
||||
import org.bigbluebutton.modules.polling.events.UpdatePollEvent;
|
||||
import org.bigbluebutton.modules.polling.events.StopPollEvent;
|
||||
import org.bigbluebutton.modules.polling.events.UpdatePollEvent;
|
||||
import org.bigbluebutton.modules.polling.events.VotePollEvent;
|
||||
import org.bigbluebutton.modules.polling.model.PollingModel;
|
||||
import org.bigbluebutton.modules.polling.model.SimplePoll;
|
||||
import org.bigbluebutton.modules.present.model.Presentation;
|
||||
import org.bigbluebutton.modules.present.model.PresentationModel;
|
||||
|
||||
public class PollingService
|
||||
{
|
||||
@ -34,29 +41,43 @@ package org.bigbluebutton.modules.polling.service
|
||||
|
||||
/* Injected by Mate */
|
||||
public var dataService:IPollDataService;
|
||||
|
||||
public var model:PollingModel;
|
||||
|
||||
public function handleStartModuleEvent(module:PollingModule):void {
|
||||
trace(LOG + " module started event");
|
||||
}
|
||||
|
||||
public function handleUpdatePollEvent(event:UpdatePollEvent):void {
|
||||
dataService.updatePoll(event.poll);
|
||||
}
|
||||
|
||||
private function generatePollId():String {
|
||||
var curPres:Presentation = PresentationModel.getInstance().getCurrentPresentation();
|
||||
if (curPres != null) {
|
||||
var date:Date = new Date();
|
||||
var pollId: String = curPres.id + "/" + curPres.getCurrentPage().num + "/" + date.time;
|
||||
return pollId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function handleStartPollEvent(event:StartPollEvent):void {
|
||||
dataService.startPoll(event.pollId, event.pollType);
|
||||
var pollId:String = generatePollId();
|
||||
if (pollId == null) return;
|
||||
dataService.startPoll(pollId, event.pollType);
|
||||
}
|
||||
|
||||
public function handleStopPollEvent(event:PollEvent):void {
|
||||
dataService.stopPoll(event.pollID);
|
||||
public function handleStopPollEvent(event:StopPollEvent):void {
|
||||
var curPoll:SimplePoll = model.getCurrentPoll();
|
||||
dataService.stopPoll(curPoll.id);
|
||||
}
|
||||
|
||||
public function handleRemovePollEvent(event:PollEvent):void {
|
||||
dataService.removePoll(event.pollID);
|
||||
public function handleVotePollEvent(event:VotePollEvent):void {
|
||||
var curPoll:SimplePoll = model.getCurrentPoll();
|
||||
dataService.votePoll(curPoll.id, event.answerId);
|
||||
}
|
||||
|
||||
public function handleRespondPollEvent(event:RespondEvent):void {
|
||||
dataService.respondPoll(event.response);
|
||||
public function handleShowPollResultEvent(event:ShowPollResultEvent):void {
|
||||
var curPoll:SimplePoll = model.getCurrentPoll();
|
||||
dataService.showPollResult(curPoll.id, event.show);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
package org.bigbluebutton.modules.polling.service
|
||||
{
|
||||
import org.bigbluebutton.modules.polling.vo.CreatePollVO;
|
||||
import org.bigbluebutton.modules.polling.vo.PollResponseVO;
|
||||
import org.bigbluebutton.modules.polling.vo.UpdatePollVO;
|
||||
|
||||
/***
|
||||
* Used for development and testing where we short circuit the message
|
||||
* path. Instead of sending the message to the server, we short-circuit it
|
||||
* here.
|
||||
*/
|
||||
public class ShortCircuitPollDataService implements IPollDataService
|
||||
{
|
||||
private static const LOG:String = "Poll::ShortCircuitPollDataService - ";
|
||||
|
||||
/* Injected by Mate */
|
||||
public var processor:PollDataProcessor;
|
||||
|
||||
|
||||
public function getPolls():void
|
||||
{
|
||||
}
|
||||
|
||||
public function createPoll(poll:CreatePollVO):void
|
||||
{
|
||||
}
|
||||
|
||||
public function updatePoll(poll:UpdatePollVO):void
|
||||
{
|
||||
}
|
||||
|
||||
public function startPoll(pollID:String, pollType: String):void
|
||||
{
|
||||
}
|
||||
|
||||
public function stopPoll(pollID:String):void
|
||||
{
|
||||
}
|
||||
|
||||
public function removePoll(pollID:String):void
|
||||
{
|
||||
}
|
||||
|
||||
public function respondPoll(resp:PollResponseVO):void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -88,7 +88,10 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
import org.bigbluebutton.main.events.MadePresenterEvent;
|
||||
import org.bigbluebutton.main.events.ShortcutEvent;
|
||||
import org.bigbluebutton.main.views.MainCanvas;
|
||||
import org.bigbluebutton.modules.polling.events.ShowPollResultEvent;
|
||||
import org.bigbluebutton.modules.polling.events.StartPollEvent;
|
||||
import org.bigbluebutton.modules.polling.events.StopPollEvent;
|
||||
import org.bigbluebutton.modules.polling.events.VotePollEvent;
|
||||
import org.bigbluebutton.modules.present.commands.GoToNextPageCommand;
|
||||
import org.bigbluebutton.modules.present.commands.GoToPrevPageCommand;
|
||||
import org.bigbluebutton.modules.present.events.AddOverlayCanvasEvent;
|
||||
@ -637,47 +640,33 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
pollMenu.show();
|
||||
|
||||
}
|
||||
|
||||
private function generatePollId():String {
|
||||
var curPres:Presentation = PresentationModel.getInstance().getCurrentPresentation();
|
||||
if (curPres != null) {
|
||||
var date:Date = new Date();
|
||||
var pollId: String = curPres.id + "/" + curPres.getCurrentPage().num + "/" + date.time;
|
||||
return pollId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private function menuClickHandler(e:MenuEvent):void {
|
||||
if(pollMenuData[e.index] != undefined) {
|
||||
var pollId:String = generatePollId();
|
||||
if (pollId == null) return;
|
||||
|
||||
// start the requested poll
|
||||
if (e.index == 0) {
|
||||
var ynEvent:StartPollEvent = new StartPollEvent(pollId, "YN");
|
||||
var ynEvent:StartPollEvent = new StartPollEvent("YN");
|
||||
dispatchEvent(ynEvent);
|
||||
} else if (e.index == 1) {
|
||||
var tfEvent:StartPollEvent = new StartPollEvent(pollId, "TF");
|
||||
var tfEvent:StartPollEvent = new StartPollEvent("TF");
|
||||
dispatchEvent(tfEvent);
|
||||
} else if (e.index == 2) {
|
||||
var a1Event:StartPollEvent = new StartPollEvent(pollId, "A-2");
|
||||
var a1Event:StartPollEvent = new StartPollEvent("A-2");
|
||||
dispatchEvent(a1Event);
|
||||
} else if (e.index == 3) {
|
||||
var a2Event:StartPollEvent = new StartPollEvent(pollId, "A-3");
|
||||
var a2Event:StartPollEvent = new StartPollEvent("A-3");
|
||||
dispatchEvent(a2Event);
|
||||
} else if (e.index == 4) {
|
||||
var a3Event:StartPollEvent = new StartPollEvent(pollId, "A-4");
|
||||
var a3Event:StartPollEvent = new StartPollEvent("A-4");
|
||||
dispatchEvent(a3Event);
|
||||
} else if (e.index == 5) {
|
||||
var a4Event:StartPollEvent = new StartPollEvent(pollId, "A-5");
|
||||
var a4Event:StartPollEvent = new StartPollEvent("A-5");
|
||||
dispatchEvent(a4Event);
|
||||
} else if (e.index == 6) {
|
||||
var a5Event:StartPollEvent = new StartPollEvent(pollId, "A-6");
|
||||
var a5Event:StartPollEvent = new StartPollEvent("A-6");
|
||||
dispatchEvent(a5Event);
|
||||
} else if (e.index == 7) {
|
||||
var a6Event:StartPollEvent = new StartPollEvent(pollId, "A-7");
|
||||
var a6Event:StartPollEvent = new StartPollEvent("A-7");
|
||||
dispatchEvent(a6Event);
|
||||
}
|
||||
}
|
||||
@ -689,6 +678,18 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
pollMenu.x = pollXY.x;
|
||||
pollMenu.y = pollXY.y;
|
||||
}
|
||||
|
||||
private function onPollStopButtonClicked():void {
|
||||
dispatchEvent(new StopPollEvent());
|
||||
}
|
||||
|
||||
private function onPollVoteButtonClicked():void {
|
||||
dispatchEvent(new VotePollEvent(1));
|
||||
}
|
||||
|
||||
private function onPollShowResultButtonClicked():void {
|
||||
dispatchEvent(new ShowPollResultEvent(true));
|
||||
}
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
@ -705,6 +706,15 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
<mx:Button id="pollStartBtn" visible="false" height="30" styleName="pollStartButtonStyle"
|
||||
toolTip="Start a poll"
|
||||
click="onPollStartButtonClicked()" tabIndex="{baseIndex+6}"/>
|
||||
<mx:Button id="pollStopBtn" visible="true" height="30" styleName="pollStartButtonStyle"
|
||||
toolTip="Stop a poll"
|
||||
click="onPollStopButtonClicked()" tabIndex="{baseIndex+6}"/>
|
||||
<mx:Button id="pollVoteBtn" visible="true" height="30" styleName="pollStartButtonStyle"
|
||||
toolTip="Vote on poll"
|
||||
click="onPollVoteButtonClicked()" tabIndex="{baseIndex+6}"/>
|
||||
<mx:Button id="pollShowResultBtn" visible="true" height="30" styleName="pollStartButtonStyle"
|
||||
toolTip="Show result of poll"
|
||||
click="onPollShowResultButtonClicked()" tabIndex="{baseIndex+6}"/>
|
||||
<mx:Spacer width="100%" id="spacer1"/>
|
||||
<mx:Button id="backButton" visible="false" width="45" height="30" styleName="presentationBackButtonStyle"
|
||||
toolTip="{ResourceUtil.getInstance().getString('bbb.presentation.backBtn.toolTip')}" click="gotoPreviousSlide()"
|
||||
|
Loading…
Reference in New Issue
Block a user