From 087223b3fe81c762c1dcba49e7cd7f02909ed9f5 Mon Sep 17 00:00:00 2001 From: Chad Pilkey Date: Fri, 26 Jun 2015 18:31:14 -0400 Subject: [PATCH] first pass at a UI for voting and viewing votes --- .../locale/en_US/bbbResources.properties | 22 +- .../modules/polling/model/SimplePoll.as | 2 +- .../polling/service/PollDataProcessor.as | 2 +- .../present/ui/views/PresentationWindow.mxml | 304 ++++++++++-------- .../modules/present/ui/views/SlideView.mxml | 23 -- 5 files changed, 174 insertions(+), 179 deletions(-) diff --git a/bigbluebutton-client/locale/en_US/bbbResources.properties b/bigbluebutton-client/locale/en_US/bbbResources.properties index c2ed8052d5..6ac7d467b3 100755 --- a/bigbluebutton-client/locale/en_US/bbbResources.properties +++ b/bigbluebutton-client/locale/en_US/bbbResources.properties @@ -493,17 +493,17 @@ bbb.shortcutkey.chat.chatbox.debug.function = Temporary debug hotkey bbb.polling.startButton.tooltip = Start a poll bbb.polling.publishButton.label = Publish bbb.polling.closeButton.label = Close -bbb.polling.answer.yes = Yes -bbb.polling.answer.no = No -bbb.polling.answer.true = True -bbb.polling.answer.false = False -bbb.polling.answer.a0 = A -bbb.polling.answer.a1 = B -bbb.polling.answer.a2 = C -bbb.polling.answer.a3 = D -bbb.polling.answer.a4 = E -bbb.polling.answer.a5 = F -bbb.polling.answer.a6 = G +bbb.polling.answer.Y = Yes +bbb.polling.answer.N = No +bbb.polling.answer.T = True +bbb.polling.answer.F = False +bbb.polling.answer.A = A +bbb.polling.answer.B = B +bbb.polling.answer.C = C +bbb.polling.answer.D = D +bbb.polling.answer.E = E +bbb.polling.answer.F = F +bbb.polling.answer.G = G bbb.publishVideo.startPublishBtn.labelText = Start Sharing bbb.publishVideo.changeCameraBtn.labelText = Change Webcam Settings diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/polling/model/SimplePoll.as b/bigbluebutton-client/src/org/bigbluebutton/modules/polling/model/SimplePoll.as index fcab88e6b4..65880493fe 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/polling/model/SimplePoll.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/polling/model/SimplePoll.as @@ -18,7 +18,7 @@ package org.bigbluebutton.modules.polling.model } - public function answers():Array { + public function get answers():Array { return _answers; } diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/polling/service/PollDataProcessor.as b/bigbluebutton-client/src/org/bigbluebutton/modules/polling/service/PollDataProcessor.as index af3a119edf..4d19361bbe 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/polling/service/PollDataProcessor.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/polling/service/PollDataProcessor.as @@ -36,7 +36,7 @@ package org.bigbluebutton.modules.polling.service for (var j:int = 0; j < answers.length; j++) { var a:Object = answers[j]; - ans.push(new SimpleAnswer(a.id as Number, a.key)); + ans.push(new SimpleAnswer(Number(String(a.id)), a.key)); } model.setCurrentPoll(new SimplePoll(pollId, ans)); diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/PresentationWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/PresentationWindow.mxml index fd08732c08..91f9aca165 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/PresentationWindow.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/PresentationWindow.mxml @@ -60,61 +60,66 @@ with BigBlueButton; if not, see . - + + . [Bindable] private var DEFAULT_X_POSITION:Number = 237; [Bindable] private var DEFAULT_Y_POSITION:Number = 0; - [Bindable] private var CONTROL_BAR_HEIGHT:Number; + [Bindable] private var controlBarHeight:Number; private static const TOP_WINDOW_BORDER:Number = 30; private static const WIDTH_PADDING:Number = 6; @@ -155,7 +160,7 @@ with BigBlueButton; if not, see . } private function onCreationComplete():void{ - setCurrentState("presenter"); + setControlBarState("presenter"); thumbY = this.height - 160; @@ -276,7 +281,7 @@ with BigBlueButton; if not, see . if (this.minimized) return; // Send the available space to display the slide. - sendWindowResizedEvent((this.width - WIDTH_PADDING), (this.height - CONTROL_BAR_HEIGHT - TOP_WINDOW_BORDER)); + sendWindowResizedEvent((this.width - WIDTH_PADDING), (this.height - controlBarHeight - TOP_WINDOW_BORDER)); } /* @@ -413,9 +418,9 @@ with BigBlueButton; if not, see . btnFitToPage.visible = showButtons; if(isPresenter) { - CONTROL_BAR_HEIGHT = 45; + controlBarHeight = CONTROL_BAR_HEIGHT; } else { - CONTROL_BAR_HEIGHT = 0; + controlBarHeight = 0; } fitSlideToWindowMaintainingAspectRatio(); } @@ -643,45 +648,39 @@ with BigBlueButton; if not, see . } - // For testing only. Generate random response; - var tempNumChoice:int = 2; - private function menuClickHandler(e:MenuEvent):void { if(pollMenuData[e.index] != undefined) { // start the requested poll - if (e.index == 0) { - tempNumChoice = 2; - var ynEvent:StartPollEvent = new StartPollEvent("YN"); - dispatchEvent(ynEvent); - } else if (e.index == 1) { - tempNumChoice = 2; - var tfEvent:StartPollEvent = new StartPollEvent("TF"); - dispatchEvent(tfEvent); - } else if (e.index == 2) { - tempNumChoice = 2; - var a1Event:StartPollEvent = new StartPollEvent("A-2"); - dispatchEvent(a1Event); - } else if (e.index == 3) { - tempNumChoice = 3; - var a2Event:StartPollEvent = new StartPollEvent("A-3"); - dispatchEvent(a2Event); - } else if (e.index == 4) { - tempNumChoice = 4; - var a3Event:StartPollEvent = new StartPollEvent("A-4"); - dispatchEvent(a3Event); - } else if (e.index == 5) { - tempNumChoice = 5; - var a4Event:StartPollEvent = new StartPollEvent("A-5"); - dispatchEvent(a4Event); - } else if (e.index == 6) { - tempNumChoice = 7; - var a5Event:StartPollEvent = new StartPollEvent("A-6"); - dispatchEvent(a5Event); - } else if (e.index == 7) { - tempNumChoice = 7; - var a6Event:StartPollEvent = new StartPollEvent("A-7"); - dispatchEvent(a6Event); - } + var pollEvent:StartPollEvent = null; + switch (e.index) { + case 0: + pollEvent = new StartPollEvent("YN"); + break; + case 1: + pollEvent = new StartPollEvent("TF"); + break; + case 2: + pollEvent = new StartPollEvent("A-2"); + break; + case 3: + pollEvent = new StartPollEvent("A-3"); + break; + case 4: + pollEvent = new StartPollEvent("A-4"); + break; + case 5: + pollEvent = new StartPollEvent("A-5"); + break; + case 6: + pollEvent = new StartPollEvent("A-6"); + break; + case 7: + pollEvent = new StartPollEvent("A-7"); + break; + } + var dispatcher:Dispatcher = new Dispatcher(); + //dispatcher. + dispatchEvent(pollEvent); } } @@ -690,54 +689,29 @@ with BigBlueButton; if not, see . var pollXY:Point = pollStartBtn.localToGlobal(new Point(pollStartBtn.width + 2, pollStartBtn.height - pollMenu.height)); pollMenu.x = pollXY.x; pollMenu.y = pollXY.y; - } - + } - private function pollStartedHandler(e:Event):void { - var pollType:String = "TF"; - + private function pollStartedHandler(e:PollStartedEvent):void { // the event for this doesn't exist yet if (UsersUtil.amIPresenter()) { - // display the results view likey in the SlideView + // display the results view + var popUp:PollResultsModal = PopUpManager.createPopUp(this, PollResultsModal, true) as PollResultsModal; + popUp.setPoll(e.poll); + PopUpManager.centerPopUp(popUp); } else { //switch to vote state - setCurrentState("vote"); - CONTROL_BAR_HEIGHT = 45; + setControlBarState("vote"); //clear the past buttons pollVoteBox.removeAllChildren(); //display the vote buttons var voteBtn:Button; - if (pollType == "YN") { - voteBtn = new Button(); - voteBtn.label = ResourceUtil.getInstance().getString('bbb.polling.answer.yes'); - voteBtn.name = "Y"; - voteBtn.addEventListener(MouseEvent.CLICK, voteButtonClickHandler); - pollVoteBox.addChild(voteBtn); - voteBtn = new Button(); - voteBtn.label = ResourceUtil.getInstance().getString('bbb.polling.answer.no'); - voteBtn.name = "N" - voteBtn.addEventListener(MouseEvent.CLICK, voteButtonClickHandler); - pollVoteBox.addChild(voteBtn); - } else if (pollType == "TF") { - voteBtn = new Button(); - voteBtn.label = ResourceUtil.getInstance().getString('bbb.polling.answer.true'); - voteBtn.name = "T"; - voteBtn.addEventListener(MouseEvent.CLICK, voteButtonClickHandler); - pollVoteBox.addChild(voteBtn); - voteBtn = new Button(); - voteBtn.label = ResourceUtil.getInstance().getString('bbb.polling.answer.false'); - voteBtn.name = "F"; - voteBtn.addEventListener(MouseEvent.CLICK, voteButtonClickHandler); - pollVoteBox.addChild(voteBtn); - } else if (pollType.charAt(0) == "A") { - var numBtns:int = int(pollType.charAt(pollType.length-1)); - for (var i:int=0; i. private function voteButtonClickHandler(e:MouseEvent):void { //still have to figure out how to determine which button was pressed trace("vote clicked - answer is " + e.target.name); - //dispatchEvent(new VotePollEvent(randomRounded)); - } -/* - private function onPollStopButtonClicked():void { - dispatchEvent(new StopPollEvent()); + setControlBarState("presenter"); + dispatchEvent(new VotePollEvent(Number(e.target.name))); } - private function onPollVoteButtonClicked():void { - var randomRounded : int = Math.floor(Math.random() * (tempNumChoice + 1)); - + private function setControlBarState(state:String):void { + if (state == "vote") { + presenterControls.visible = false; + presenterControls.includeInLayout = false; + pollVoteBox.visible = true; + pollVoteBox.includeInLayout = true; + controlBarHeight = CONTROL_BAR_HEIGHT; + } else if (state == "presenter") { + presenterControls.visible = true; + presenterControls.includeInLayout = true; + pollVoteBox.visible = false; + pollVoteBox.includeInLayout = false; + if (UsersUtil.amIPresenter()) { + controlBarHeight = CONTROL_BAR_HEIGHT; + } else { + controlBarHeight = 0; + } + } } - private function onPollShowResultButtonClicked():void { - dispatchEvent(new ShowPollResultEvent(true)); - } -*/ + private function pollStoppedHandler(e:PollStoppedEvent):void { + setControlBarState("presenter"); + } ]]> @@ -770,10 +755,44 @@ with BigBlueButton; if not, see . - - + + + + + + + + + + + + + + + + - + + - - - + + --> diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/SlideView.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/SlideView.mxml index 096b2ca4f0..24413ee768 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/SlideView.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/SlideView.mxml @@ -39,8 +39,6 @@ with BigBlueButton; if not, see . - - . import org.bigbluebutton.core.managers.UserManager; import org.bigbluebutton.main.events.MadePresenterEvent; import org.bigbluebutton.main.events.ShortcutEvent; - import org.bigbluebutton.modules.polling.events.PollVotedEvent; - import org.bigbluebutton.modules.polling.model.SimpleAnswerResult; import org.bigbluebutton.modules.present.commands.GoToPageCommand; import org.bigbluebutton.modules.present.events.CursorEvent; import org.bigbluebutton.modules.present.events.DisplaySlideEvent; @@ -295,25 +291,6 @@ with BigBlueButton; if not, see . // If delta is negative, the presenter is zooming-out of the presentation. return delta < 0; } - - private function handlePollVotedEvent(e:PollVotedEvent):void { - var that:SlideView = this; - - var resultData:Array = new Array(); - var answers:Array = e.result.answers; - for (var j:int = 0; j < answers.length; j++) { - var a:SimpleAnswerResult = answers[j] as SimpleAnswerResult; - resultData.push({a:a.key, v:a.numVotes}); - } - - var poll:PollResultsView = new PollResultsView(resultData); - that.addChild(poll); - - that.callLater(function():void { - poll.x = that.width - poll.width; - poll.y = that.height - poll.height; - }); - } /** * Handles notification from presenter that the slide has moved.