This commit is contained in:
Markos Calderon 2013-06-04 10:19:18 -05:00
commit 9b27343347
2 changed files with 126 additions and 176 deletions

View File

@ -88,9 +88,12 @@
private var webClosed:Boolean; private var webClosed:Boolean;
private var notified:Boolean; private var notified:Boolean;
private var refreshTimer:Timer = new Timer(1000); private var refreshTimer:Timer = new Timer(1000);
private var answersAC:ArrayCollection = new ArrayCollection(); [Bindable] private var answerCollection:ArrayCollection = new ArrayCollection();
private function init():void{ private function init():void{
answerCollection = trackingPoll.generateStats();
conference = UserManager.getInstance().getConference(); conference = UserManager.getInstance().getConference();
webPollText.visible = (UsersUtil.amIPresenter() && (!reviewing && trackingPoll.publishToWeb)); webPollText.visible = (UsersUtil.amIPresenter() && (!reviewing && trackingPoll.publishToWeb));
btnClosePoll.visible = UsersUtil.amIPresenter(); btnClosePoll.visible = UsersUtil.amIPresenter();
@ -102,9 +105,6 @@
generate.poll = trackingPoll; generate.poll = trackingPoll;
dispatchEvent(generate); dispatchEvent(generate);
} }
refreshTimer.addEventListener(TimerEvent.TIMER, autoRefresh);
refreshTimer.start();
answersAC = trackingPoll.generateStats();
notified = false; notified = false;
} }
@ -151,6 +151,7 @@
public function setUrlBoxText():void{ public function setUrlBoxText():void{
webPollURLBox.text = webPollUrl; webPollURLBox.text = webPollUrl;
webPollURLBox.accessibilityName = ResourceUtil.getInstance().getString('bbb.polling.stats.webPollBoxAccessName', [webPollUrl]);
LogUtil.debug("webPollURLBox.Text is : " + webPollURLBox.text); LogUtil.debug("webPollURLBox.Text is : " + webPollURLBox.text);
if (UsersUtil.amIPresenter()) if (UsersUtil.amIPresenter())
messageForRecording(ResourceUtil.getInstance().getString('bbb.polling.stats.webPollURL') + " " + webPollUrl); messageForRecording(ResourceUtil.getInstance().getString('bbb.polling.stats.webPollURL') + " " + webPollUrl);
@ -247,142 +248,78 @@
dispatchEvent(stopPollEvent); dispatchEvent(stopPollEvent);
} }
// function receives Array.length and ArrayCollection
private function createResultsTable(amount:uint, content:Array):void{ private function createResultsTable(amount:uint, content:Array):void{
var _tx: Text; answerCollection = trackingPoll.generateStats();
var _votes: Text; answerCollection.addItem(didNotVote());
var _percent: Text; resultsGrid.dataProvider = answerCollection;
var _hb: HBox; }
var _line: HRule;
var totalVotes:int = 0;
for (var n:int = 0; n < trackingPoll.votes.length; n++){
totalVotes+= int(trackingPoll.votes[n]);
}
// delete existing rows
resultBox.removeAllChildren();
// creating rows one by one
for (var i:int = 0; i < amount; i++) {
_tx = new Text();
_votes= new Text;
_percent= new Text();
_hb = new HBox();
_line = new HRule();
_line.width = 290;
_tx.name = "option" +i;
_tx.width = 200;
_tx.text =content[i].toString();
_votes.name = "votes" +i;
_votes.width = 30;
_votes.text = trackingPoll.votes[i];
_percent.name = "percent" +i;
_percent.width = 50;
// Percentage is in terms of how many votes each option has in terms of total votes
if (totalVotes > 0){
_percent.text = Math.round(100*(trackingPoll.votes[i]/totalVotes)) + "%";
}else{
// Prevents percentages from displaying misleading results before any votes come in, and from dividing by zero
_percent.text = " ";
}
resultBox.addChild(_hb);
_hb.addChild(_tx);
_hb.addChild(_votes);
_hb.addChild(_percent);
resultBox.addChild(_line);
} // end of loop
didNotVote();
invalidateDisplayList();
resultBox.validateNow();
} // end of function createResultsTable
private function didNotVote():void{ private function didNotVote():PollStatLineObject{
var _tx:Text = new Text(); var pso:PollStatLineObject = new PollStatLineObject();
var _votes:Text= new Text; pso.answer = ResourceUtil.getInstance().getString('bbb.polling.stats.didNotVote');
var _hb:HBox = new HBox(); pso.votes = trackingPoll.didNotVote.toString();
_tx.name = "optionNull"; pso.percentage = "";
_tx.width = 200; return pso;
_tx.text = ResourceUtil.getInstance().getString('bbb.polling.stats.didNotVote');
_votes.name = "voteNull";
_votes.width = 30;
_votes.text = trackingPoll.didNotVote.toString();
resultBox.addChild(_hb);
_hb.addChild(_tx);
_hb.addChild(_votes);
} }
]]> ]]>
</mx:Script> </mx:Script>
<!-- Prototype of Polling Statistics View Design --> <!-- Accessible statistics view -->
<mx:VBox width="100%" <mx:VBox width="100%"
height="75%" height="75%"
horizontalAlign="center" horizontalAlign="center"
paddingLeft="10" paddingLeft="10"
paddingRight="10" paddingRight="10"
focusEnabled="true" focusEnabled="true">
accessibilityDescription="Alpha">
<mx:HBox width="90%" <mx:HBox width="90%"
paddingTop="10" paddingTop="10"
focusEnabled="true" focusEnabled="true">
accessibilityDescription="Bravo">
<mx:Text id="webPollText" <mx:Text id="webPollText"
text="{ResourceUtil.getInstance().getString('bbb.polling.stats.webPollURL')}" text="{ResourceUtil.getInstance().getString('bbb.polling.stats.webPollURL')}"
width="140"/> width="140"
/>
</mx:HBox> </mx:HBox>
<mx:HBox id="webPollBox" <mx:HBox id="webPollBox"
width="90%" width="90%">
accessibilityDescription="Charlie">
<mx:TextArea id="webPollURLBox" <mx:TextArea id="webPollURLBox"
editable="false" editable="false"
text="" text=""
height="25" height="25"
width="95%" width="95%"
/> />
<!-- tabIndex="{baseIndex+4}" -->
</mx:HBox> </mx:HBox>
<mx:Text width="200" <mx:Text width="200"
paddingTop="15" paddingBottom="10" paddingTop="15" paddingBottom="10"
fontWeight="bold" textAlign="center" fontWeight="bold" textAlign="center"
text="{question}"/> text="{question}"/>
<mx:Box id="resultBox" <mx:DataGrid id="resultsGrid"
width="90%" dataProvider="{answerCollection}"
height="90%" /> rowCount="{answerCollection.length}"
width="90%"
<!-- Viewer's grid used as an example --> accessibilityName="{ResourceUtil.getInstance().getString('bbb.polling.stats.question', [trackingPoll.question])}"
<!--mx:DataGrid id="viewersGrid" dataProvider="{UserManager.getInstance().getConference().users}" editable="false" >
>>>>>>> poll-access <!-- tabIndex="{baseIndex+5}" -->
dragEnabled="false" width="90%" height="100%" accessibilityName="Users list."> <mx:columns>
<mx:columns> <mx:DataGridColumn id="answerColumn"
<mx:DataGridColumn dataField="role" dataField="answer"
headerText="{ResourceUtil.getInstance().getString('bbb.viewers.viewersGrid.roleItemRenderer')}" headerText="{ResourceUtil.getInstance().getString('bbb.polling.stats.answer')}"
dataTipField="Role" wordWrap="true"
editable="false" />
width="35" <mx:DataGridColumn id="voteColumn"
itemRenderer="org.bigbluebutton.modules.viewers.views.RoleItemRenderer" dataField="votes"
sortable="false" headerText="{ResourceUtil.getInstance().getString('bbb.polling.stats.votes')}"
id="roleField"/> width="40"
<mx:DataGridColumn dataField="name" />
headerText="{ResourceUtil.getInstance().getString('bbb.viewers.viewersGrid.nameItemRenderer')}" <mx:DataGridColumn id="percentColumn"
editable="true" dataField="percentage"
width="100" headerText="{ResourceUtil.getInstance().getString('bbb.polling.stats.percentage')}"
sortable="false" width="70"
itemRenderer="org.bigbluebutton.modules.viewers.views.NameItemRenderer"/> />
<mx:DataGridColumn dataField="status" </mx:columns>
headerText="{ResourceUtil.getInstance().getString('bbb.viewers.viewersGrid.statusItemRenderer')}" </mx:DataGrid>
dataTipField="Status"
id="statusField"
sortable="false"
itemRenderer="org.bigbluebutton.modules.viewers.views.StatusItemRenderer"/>
</mx:columns>
</mx:DataGrid-->
</mx:VBox> </mx:VBox>
<mx:ControlBar width="100%" height="10%"> <mx:ControlBar width="100%" height="10%">
<mx:Spacer width="100%"/> <mx:Spacer width="100%"/>
<mx:Button id="btnRefreshResults" <mx:Button id="btnRefreshResults"

View File

@ -76,11 +76,16 @@
} }
private function onCreationComplete():void{ private function onCreationComplete():void{
questionText.text = question;
if (isMultiple)
questionText.text += " " + ResourceUtil.getInstance().getString('bbb.polling.pollPreview.checkAll');
if (isMultiple) if (isMultiple)
errorMessage.text = ResourceUtil.getInstance().getString('bbb.polling.vote.error.check'); errorMessage.text = ResourceUtil.getInstance().getString('bbb.polling.vote.error.check');
else else
errorMessage.text = ResourceUtil.getInstance().getString('bbb.polling.vote.error.radio'); errorMessage.text = ResourceUtil.getInstance().getString('bbb.polling.vote.error.radio');
checkInstructions.visible = isMultiple; ExternalInterface.call("addAlert", errorMessage.text);
//checkInstructions.visible = isMultiple;
createButtons(answers.length,answers); createButtons(answers.length,answers);
invalidateDisplayList(); invalidateDisplayList();
validateNow(); validateNow();
@ -88,8 +93,7 @@
for(var s:String in answers){ for(var s:String in answers){
lines = lines + ((s.length / 28) + 1); lines = lines + ((s.length / 28) + 1);
} }
height = height + (lines * 50); height = height + ((lines+1) * 45);
//questionBox.
} }
// This function will receive information and generate radiobuttons on fly // This function will receive information and generate radiobuttons on fly
@ -100,35 +104,41 @@
var _tx: Text; var _tx: Text;
var _hb: HBox; var _hb: HBox;
var _rb_group:RadioButtonGroup = new RadioButtonGroup(); var _rb_group:RadioButtonGroup = new RadioButtonGroup();
var totalOptions:int = content.length;
// creating buttons one by one // creating buttons one by one
for (var i:int = 0; i < amount; i++) { for (var i:int = 0; i < amount; i++) {
var indicator:String = ResourceUtil.getInstance().getString('bbb.polling.vote.indicator', [i+1, totalOptions])
_tx = new Text(); _tx = new Text();
_hb = new HBox(); _hb = new HBox();
_tx.name = "option" +i; _tx.name = "option" +i;
_tx.width = 200; _tx.width = 200;
// assigning array element to text field // assigning array element to text field
_tx.text =content[i].toString(); _tx.text = content[i].toString();
answerBox.addChild(_hb); answerBox.addChild(_hb);
// if global var isMultiple is true it means user wants checkboxes, // if global var isMultiple is true it means user wants checkboxes,
//otherwise radiobutton (if multiple choices are allowed) //otherwise radiobutton (if multiple choices are allowed)
if(isMultiple){ if(isMultiple){
_cb= new CheckBox(); _cb= new CheckBox();
_cb.id = "answers"+i; _cb.id = "answers"+i;
_cb.addEventListener(MouseEvent.CLICK, checkBoxClick); _cb.accessibilityName = indicator + content[i].toString();
// gap between the buttons _cb.addEventListener(MouseEvent.CLICK, checkBoxClick);
_cb.y=i*20; // gap between the buttons
// adding buttons to the Horizontal Box _cb.y=i*20;
_hb.addChild(_cb); //_cb.tabIndex = baseIndex++;
}else{ // adding buttons to the Horizontal Box
_rb = new RadioButton(); _hb.addChild(_cb);
_rb.groupName = "answersGroup"; }else{
_rb.name = content[i].toString(); // giving button a name of array elelment to process it easier later _rb = new RadioButton();
_rb.id = "answers"+i; _rb.groupName = "answersGroup";
_rb.name = content[i].toString(); // giving button a name of array elelment to process it easier later
_rb.id = "answers"+i;
_rb.addEventListener(MouseEvent.CLICK, radioClick); _rb.addEventListener(MouseEvent.CLICK, radioClick);
_hb.addChild(_rb); _rb.accessibilityName = indicator + content[i].toString();
} //_rb.tabIndex = baseIndex++;
_hb.addChild(_tx); // adding text near button _hb.addChild(_rb);
}
_hb.addChild(_tx); // adding text near button
} // end of loop } // end of loop
answerBox.validateNow(); answerBox.validateNow();
} // end of function createButtons } // end of function createButtons
@ -149,8 +159,10 @@
dispatchEvent(voteEvent); dispatchEvent(voteEvent);
closeWindow(); closeWindow();
} }
else else{
errorMessage.visible = true; errorMessage.visible = true;
ExternalInterface.call("addAlert", errorMessage.text);
}
} // _vote } // _vote
// As the user clicks CheckBoxes, this function keeps a running tally of which boxes are and are not selected // As the user clicks CheckBoxes, this function keeps a running tally of which boxes are and are not selected
@ -181,38 +193,39 @@
</mx:Script> </mx:Script>
<mx:RadioButtonGroup id="answersGroup"/> <mx:RadioButtonGroup id="answersGroup"/>
<!-- Prototype of Polling Module Design --> <!-- Prototype of Polling Module Design -->
<mx:VBox accessibilityDescription="The question will go into the V BOX" <mx:VBox id="votingBox"
width="100%" width="90%"
height="75%" height="90%">
horizontalAlign="center" <mx:Panel id="titleShow"
paddingLeft="10" width="90%" >
paddingRight="10" <mx:VBox paddingTop="10"
focusEnabled="true"> paddingLeft="40"
<mx:HBox accessibilityDescription="The question will go into the H BOX"/> paddingBottom="40"
<mx:Text width="200" horizontalAlign="center"
paddingTop="30" >
paddingBottom="10" <mx:TextArea id="questionText"
fontWeight="bold" width="90%"
textAlign="center" fontWeight="bold"
text="{question}" textAlign="center"
accessibilityDescription="The question will go into the m x TEXT" editable="false"
/> borderSkin="{null}"
<mx:Text id="checkInstructions" />
text="{ResourceUtil.getInstance().getString('bbb.polling.pollPreview.checkAll')}"/> <mx:Box id="answerBox" />
<mx:Box id="answerBox" <mx:Text id="errorMessage"
width="90%" color="red"
height="90%" /> visible="false"/>
<mx:Text id="errorMessage" </mx:VBox>
color="red" </mx:Panel>
visible="false"/>
</mx:VBox> </mx:VBox>
<mx:ControlBar width="100%"
horizontalAlign="center"> <mx:ControlBar width="100%"
<mx:Button id="btnAcceptPoll" horizontalAlign="center">
label="{ResourceUtil.getInstance().getString('bbb.polling.pollView.vote')}" <mx:Button id="btnAcceptPoll"
click="Vote()" label="{ResourceUtil.getInstance().getString('bbb.polling.pollView.vote')}"
width="100" click="Vote()"
height="30"/> width="100"
</mx:ControlBar> height="30"
/>
</mx:ControlBar>
</MDIWindow> </MDIWindow>