- implement get polls from server
This commit is contained in:
parent
2f68693023
commit
8ecbc79ec0
@ -45,10 +45,10 @@ class PollMessageConverter {
|
||||
i += 1
|
||||
}
|
||||
|
||||
//new PollVO(randomAlphanumericString(12), title, cvoArray.toArray)
|
||||
new PollVO(randomAlphanumericString(12), title, cvoArray.toArray)
|
||||
|
||||
// Hardocde for now for testing
|
||||
new PollVO("pollID", title, cvoArray.toArray)
|
||||
//new PollVO("pollID", title, cvoArray.toArray)
|
||||
}
|
||||
|
||||
def convertUpdatePollMessage(msg:String):PollVO = {
|
||||
|
@ -7,6 +7,23 @@ class PollModel {
|
||||
|
||||
private val polls = new HashMap[String, Poll]()
|
||||
|
||||
createSamplePoll
|
||||
|
||||
def createSamplePoll() {
|
||||
val r1 = new ResponseVO("0", "Answer 1")
|
||||
val r2 = new ResponseVO("1", "Answer 2")
|
||||
val r3 = new ResponseVO("2", "Answer 3")
|
||||
val r4 = new ResponseVO("3", "Answer 4")
|
||||
|
||||
var q = new QuestionVO("q1", true, "What is my name?", Array(r1, r2, r3))
|
||||
val pvo = new PollVO("pollID-100", "sample poll", Array(q))
|
||||
|
||||
createPoll(pvo)
|
||||
|
||||
respondToQuestion("pollID-100", "q1", "1", new Responder("user1", "Juan Tamad"))
|
||||
respondToQuestion("pollID-100", "q1", "0", new Responder("user2", "Asyong Aksaya"))
|
||||
}
|
||||
|
||||
def numPolls():Int = {
|
||||
polls.size
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ import org.bigbluebutton.core.apps.poll.messages.PollCreatedOutMsg
|
||||
import org.bigbluebutton.conference.meeting.messaging.red5.DirectClientMessage
|
||||
import com.google.gson.Gson
|
||||
import org.bigbluebutton.conference.meeting.messaging.red5.BroadcastClientMessage
|
||||
import java.util.ArrayList
|
||||
import org.bigbluebutton.core.apps.poll.PollVO
|
||||
|
||||
class PollClientMessageSender(service: ConnectionInvokerService) extends OutMessageListener2 {
|
||||
|
||||
@ -32,8 +34,17 @@ class PollClientMessageSender(service: ConnectionInvokerService) extends OutMess
|
||||
private def handleGetPollsReplyOutMsg(msg: GetPollsReplyOutMsg) {
|
||||
val gson = new Gson();
|
||||
val message = new java.util.HashMap[String, Object]()
|
||||
message.put("msg", gson.toJson(msg.polls))
|
||||
|
||||
val collection = new ArrayList[PollVO]();
|
||||
|
||||
msg.polls.foreach(p => {
|
||||
collection.add(p)
|
||||
})
|
||||
|
||||
message.put("msg", gson.toJson(collection))
|
||||
|
||||
// println("PollClientMessageSender - Handling GetPollsReplyOutMsg \n" + message.get("msg") + "\n")
|
||||
|
||||
var m = new DirectClientMessage(msg.meetingID, msg.requesterID, "pollGetPollsReply", message);
|
||||
service.sendMessage(m);
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package org.bigbluebutton.modules.polling.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class InitPollModuleEvent extends Event
|
||||
{
|
||||
public static const INITIALIZE_POLL_MODULE:String = "initialize poll module event";
|
||||
|
||||
public function InitPollModuleEvent()
|
||||
{
|
||||
super(INITIALIZE_POLL_MODULE, true, false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,19 @@
|
||||
package org.bigbluebutton.modules.polling.managers
|
||||
{
|
||||
|
||||
import org.bigbluebutton.modules.polling.model.PollingModel;
|
||||
|
||||
|
||||
import com.asfusion.mate.events.Dispatcher;
|
||||
import flash.events.IEventDispatcher;
|
||||
import org.bigbluebutton.modules.polling.events.GetPollsEvent;
|
||||
import org.bigbluebutton.modules.polling.model.PollingModel;
|
||||
|
||||
public class PollManager
|
||||
{
|
||||
|
||||
public static const LOG:String = "[PollManager] - ";
|
||||
|
||||
// Injected by Mate
|
||||
public var model:PollingModel;
|
||||
public var dispatcher:IEventDispatcher;
|
||||
|
||||
public function PollManager()
|
||||
{
|
||||
@ -20,5 +23,9 @@ package org.bigbluebutton.modules.polling.managers
|
||||
public function handleStartModuleEvent(module:PollingModule):void {
|
||||
|
||||
}
|
||||
|
||||
public function handleInitPollModuleEvent():void {
|
||||
dispatcher.dispatchEvent(new GetPollsEvent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,7 @@
|
||||
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.events.FlexEvent;
|
||||
|
||||
import mx.events.FlexEvent;
|
||||
import org.bigbluebutton.main.events.BBBEvent;
|
||||
import org.bigbluebutton.main.events.MadePresenterEvent;
|
||||
import org.bigbluebutton.modules.polling.events.*;
|
||||
@ -46,7 +45,11 @@
|
||||
|
||||
<EventHandlers type="{ModuleEvent.STOP}">
|
||||
</EventHandlers>
|
||||
|
||||
|
||||
<EventHandlers type="{InitPollModuleEvent.INITIALIZE_POLL_MODULE}">
|
||||
<MethodInvoker generator="{PollManager}" method="handleInitPollModuleEvent"/>
|
||||
</EventHandlers>
|
||||
|
||||
<EventHandlers type="{CreatePollEvent.CREATE_POLL}">
|
||||
<MethodInvoker generator="{PollingService}" method="handleCreatePollEvent" arguments="{event}"/>
|
||||
</EventHandlers>
|
||||
@ -78,6 +81,7 @@
|
||||
<Injectors target="{PollManager}">
|
||||
<ObjectBuilder generator="{PollingModel}" cache="global"/>
|
||||
<PropertyInjector targetKey="model" source="{PollingModel}"/>
|
||||
<PropertyInjector targetKey="dispatcher" source="{scope.dispatcher}"/>
|
||||
</Injectors>
|
||||
|
||||
<Injectors target="{PollingService}">
|
||||
|
@ -76,7 +76,7 @@ package org.bigbluebutton.modules.polling.model
|
||||
var r:ResultVO = results.results[i] as ResultVO;
|
||||
var q:Question = getQuestion(r.questionID);
|
||||
if (q != null) {
|
||||
q.updateResult(r.responseID, r.responseCount);
|
||||
q.updateResult(r.responseID, r.responder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ package org.bigbluebutton.modules.polling.model
|
||||
|
||||
public function PollingViewModel(model: PollingModel)
|
||||
{
|
||||
trace("************** Initing PollingViewModel ***************************");
|
||||
_model = model;
|
||||
}
|
||||
|
||||
@ -48,15 +49,16 @@ package org.bigbluebutton.modules.polling.model
|
||||
addSample1();
|
||||
addSample2();
|
||||
addSample3();
|
||||
trace("*** PollingViewModel num polls = [" + _model.getPolls().length + "] **** \n");
|
||||
}
|
||||
|
||||
private function addSample1():void {
|
||||
var _questions:Array = new Array();
|
||||
|
||||
var _resps1:Array = new Array();
|
||||
_resps1.push(new Response("1", "Answer 1"));
|
||||
_resps1.push(new Response("2", "Answer 2"));
|
||||
_resps1.push(new Response("3", "Answer 3"));
|
||||
_resps1.push(new Response("1", "Answer 1", new Array()));
|
||||
_resps1.push(new Response("2", "Answer 2", new Array()));
|
||||
_resps1.push(new Response("3", "Answer 3", new Array()));
|
||||
|
||||
var _q1:Question = new Question("qID", true, "What is my name?", _resps1);
|
||||
|
||||
@ -71,8 +73,8 @@ package org.bigbluebutton.modules.polling.model
|
||||
var _questions:Array = new Array();
|
||||
|
||||
var _resps1:Array = new Array();
|
||||
_resps1.push(new Response("1", "Chicken"));
|
||||
_resps1.push(new Response("2", "Egg"));
|
||||
_resps1.push(new Response("1", "Chicken", new Array()));
|
||||
_resps1.push(new Response("2", "Egg", new Array()));
|
||||
|
||||
var _q1:Question = new Question("qID", false, "Which came first?", _resps1);
|
||||
|
||||
@ -87,17 +89,17 @@ package org.bigbluebutton.modules.polling.model
|
||||
var _questions:Array = new Array();
|
||||
|
||||
var _resps1:Array = new Array();
|
||||
_resps1.push(new Response("1", "Dumaguete"));
|
||||
_resps1.push(new Response("2", "Cebu"));
|
||||
_resps1.push(new Response("3", "Zamboanga"));
|
||||
_resps1.push(new Response("4", "None of the above"));
|
||||
_resps1.push(new Response("1", "Dumaguete", new Array()));
|
||||
_resps1.push(new Response("2", "Cebu", new Array()));
|
||||
_resps1.push(new Response("3", "Zamboanga", new Array()));
|
||||
_resps1.push(new Response("4", "None of the above", new Array()));
|
||||
|
||||
var _q1:Question = new Question("qID", false, "What is the capital of the Philippines?", _resps1);
|
||||
|
||||
_q1.updateResult("1", 667);
|
||||
_q1.updateResult("2", 367);
|
||||
_q1.updateResult("3", 467);
|
||||
_q1.updateResult("4", 567);
|
||||
_q1.updateResult("1", new Responder("user1", "Asyong"));
|
||||
_q1.updateResult("2", new Responder("user2", "Pedro"));
|
||||
_q1.updateResult("3", new Responder("user3", "Bardagol"));
|
||||
_q1.updateResult("4", new Responder("user4", "Juan"));
|
||||
|
||||
_questions.push(_q1);
|
||||
|
||||
|
@ -30,10 +30,10 @@ package org.bigbluebutton.modules.polling.model
|
||||
return _question;
|
||||
}
|
||||
|
||||
public function updateResult(responseID:String, count:int):void {
|
||||
public function updateResult(responseID:String, responder:Responder):void {
|
||||
for (var i:int = 0; i < _responses.length; i++) {
|
||||
var r:Response = _responses[i] as Response;
|
||||
if (r.id == responseID) r.updateResult(count);
|
||||
if (r.id == responseID) r.addResponder(responder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package org.bigbluebutton.modules.polling.model
|
||||
{
|
||||
public class Responder
|
||||
{
|
||||
private var _userID:String;
|
||||
private var _username:String;
|
||||
|
||||
public function Responder(userID:String, username:String)
|
||||
{
|
||||
_userID = userID;
|
||||
_username = username;
|
||||
}
|
||||
|
||||
public function get userID():String {
|
||||
return _userID;
|
||||
}
|
||||
|
||||
public function get username():String {
|
||||
return _username;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,16 +5,17 @@ package org.bigbluebutton.modules.polling.model
|
||||
private var _id:String;
|
||||
private var _response:String;
|
||||
|
||||
private var _responseCount:int = 0;
|
||||
private var _responders:Array;
|
||||
|
||||
public function Response(id:String, response:String)
|
||||
public function Response(id:String, response:String, responders:Array)
|
||||
{
|
||||
_id = id;
|
||||
_response = response;
|
||||
_responders = responders;
|
||||
}
|
||||
|
||||
public function updateResult(count:int):void {
|
||||
_responseCount = count;
|
||||
public function addResponder(r:Responder):void {
|
||||
_responders.push(r);
|
||||
}
|
||||
|
||||
public function get id():String {
|
||||
@ -26,7 +27,7 @@ package org.bigbluebutton.modules.polling.model
|
||||
}
|
||||
|
||||
public function get numResponses():int {
|
||||
return _responseCount;
|
||||
return _responders.length;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,14 @@
|
||||
package org.bigbluebutton.modules.polling.service
|
||||
{
|
||||
|
||||
import flash.events.IEventDispatcher;
|
||||
import flash.events.IEventDispatcher;
|
||||
|
||||
import org.bigbluebutton.modules.polling.events.PollEvent;
|
||||
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;
|
||||
|
||||
public class PollDataProcessor
|
||||
{
|
||||
@ -15,7 +19,67 @@ package org.bigbluebutton.modules.polling.service
|
||||
public var dispatcher:IEventDispatcher;
|
||||
|
||||
public function handleGetPollsReply(msg:Object):void {
|
||||
trace("*** Poll getPollsReply " + msg.msg + " **** \n");
|
||||
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 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);
|
||||
|
||||
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[1];
|
||||
|
||||
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 {
|
||||
@ -29,7 +93,7 @@ package org.bigbluebutton.modules.polling.service
|
||||
}
|
||||
|
||||
public function handlePollCreatedMesage(msg:Object):void {
|
||||
trace("*** Poll Created " + msg.msg + " **** \n");
|
||||
trace(LOG + "*** Poll Created " + msg.msg + " **** \n");
|
||||
|
||||
var map:Object = JSON.parse(msg.msg);
|
||||
|
||||
@ -40,13 +104,13 @@ package org.bigbluebutton.modules.polling.service
|
||||
var poll:Poll = new Poll(id, title, questions);
|
||||
model.createPoll(poll);
|
||||
|
||||
trace("*** Poll Created id=[" + map.id + "] title=[" + map.title + "] questions = [" + questions.length + "] **** \n");
|
||||
trace(LOG + "*** Poll Created id=[" + map.id + "] title=[" + map.title + "] questions = [" + questions.length + "] **** \n");
|
||||
dispatcher.dispatchEvent(new PollEvent(PollEvent.POLL_CREATED, poll.id));
|
||||
}
|
||||
}
|
||||
|
||||
public function handlePollUpdatedMesage(msg:Object):void {
|
||||
trace("*** Poll updated " + msg.msg + " **** \n");
|
||||
trace(LOG + "*** Poll updated " + msg.msg + " **** \n");
|
||||
/*
|
||||
if (model.hasPoll(msg.id)) {
|
||||
var id:String = msg.id;
|
||||
@ -60,7 +124,7 @@ package org.bigbluebutton.modules.polling.service
|
||||
}
|
||||
|
||||
public function handlePollDestroyedMesage(msg:Object):void {
|
||||
trace("*** Poll destroyed " + msg.msg + " **** \n");
|
||||
trace(LOG + "*** Poll destroyed " + msg.msg + " **** \n");
|
||||
/*
|
||||
if (model.hasPoll(msg.id)) {
|
||||
model.destroyPoll(msg.id);
|
||||
@ -71,7 +135,7 @@ package org.bigbluebutton.modules.polling.service
|
||||
}
|
||||
|
||||
public function handlePollStartedMesage(msg:Object):void {
|
||||
trace("*** Poll started " + msg.msg + " **** \n");
|
||||
trace(LOG + "*** Poll started " + msg.msg + " **** \n");
|
||||
/*
|
||||
if (model.hasPoll(msg.id)) {
|
||||
model.startPoll(msg.id);
|
||||
@ -82,7 +146,7 @@ package org.bigbluebutton.modules.polling.service
|
||||
}
|
||||
|
||||
public function handlePollStoppedMesage(msg:Object):void {
|
||||
trace("*** Poll stopped " + msg.msg + " **** \n");
|
||||
trace(LOG + "*** Poll stopped " + msg.msg + " **** \n");
|
||||
/*
|
||||
if (model.hasPoll(msg.id)) {
|
||||
model.stopPoll(msg.id);
|
||||
|
@ -18,6 +18,8 @@
|
||||
private function onPreInit():void {
|
||||
|
||||
_polls = viewModel.polls;
|
||||
|
||||
trace("************** PollMainPanel num polls = [" + _polls.length + "]");
|
||||
}
|
||||
|
||||
private function isDuplicateAnswers(arr:Array):Boolean{
|
||||
|
@ -27,23 +27,26 @@
|
||||
xmlns:mate="http://mate.asfusion.com/"
|
||||
toolTip="{ResourceUtil.getInstance().getString('bbb.polling.toolbar.toolTip')}"
|
||||
implements="org.bigbluebutton.common.IBbbToolbarComponent"
|
||||
initialize="init();"
|
||||
initialize="init();" creationComplete="onCreationComplete()"
|
||||
click="createAndShow();"
|
||||
icon="{pollIcon}"
|
||||
accessibilityName="{ResourceUtil.getInstance().getString('bbb.polling.buttonName')}"
|
||||
>
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import flash.events.FocusEvent;
|
||||
import flash.events.FocusEvent;
|
||||
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.controls.Menu;
|
||||
import mx.events.MenuEvent;
|
||||
import mx.events.MenuEvent;
|
||||
|
||||
import org.bigbluebutton.common.Images;
|
||||
import org.bigbluebutton.common.LogUtil;
|
||||
import org.bigbluebutton.core.managers.UserManager;
|
||||
import org.bigbluebutton.main.events.ShortcutEvent;
|
||||
import org.bigbluebutton.main.model.users.Conference;
|
||||
import org.bigbluebutton.main.views.MainToolbar;
|
||||
import org.bigbluebutton.modules.polling.events.InitPollModuleEvent;
|
||||
import org.bigbluebutton.modules.polling.events.OpenPollMainWindowEvent;
|
||||
import org.bigbluebutton.modules.polling.events.OpenPollResultWindowEvent;
|
||||
import org.bigbluebutton.modules.polling.events.OpenPollUpdateWindowEvent;
|
||||
@ -71,6 +74,10 @@
|
||||
[Bindable] public var titleList:Array;
|
||||
[Bindable] public var pollList:ArrayCollection;
|
||||
|
||||
public function onCreationComplete():void {
|
||||
dispatchEvent(new InitPollModuleEvent());
|
||||
}
|
||||
|
||||
public function init():void {
|
||||
LogUtil.debug("Initializing Polling toolbar button.");
|
||||
myMenuData = new ArrayCollection();
|
||||
|
@ -1,16 +1,18 @@
|
||||
package org.bigbluebutton.modules.polling.vo
|
||||
{
|
||||
import org.bigbluebutton.modules.polling.model.Responder;
|
||||
|
||||
public class ResultVO
|
||||
{
|
||||
private var _questionID:String;
|
||||
private var _responseID:String;
|
||||
private var _responseCount:int;
|
||||
private var _responder:Responder;
|
||||
|
||||
public function ResultVO(questionID:String, responseID:String, responseCount:int)
|
||||
public function ResultVO(questionID:String, responseID:String, responder:Responder)
|
||||
{
|
||||
_questionID = questionID;
|
||||
_responseID = responseID;
|
||||
_responseCount = responseCount;
|
||||
_responder = responder;
|
||||
}
|
||||
|
||||
public function get questionID():String {
|
||||
@ -21,8 +23,8 @@ package org.bigbluebutton.modules.polling.vo
|
||||
return _responseID;
|
||||
}
|
||||
|
||||
public function get responseCount():int {
|
||||
return _responseCount;
|
||||
public function get responder():Responder {
|
||||
return _responder;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user