From 39c69675a478285edbd268d15aad48c3fb275603 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Wed, 28 Apr 2021 21:34:21 +0000 Subject: [PATCH] - sort answers based on number of votes - limit display of responses to 7 to prevent squishing of display in the whiteboard --- .../org/bigbluebutton/core/models/Polls.scala | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Polls.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Polls.scala index 205c7eb0a5..841cb3b851 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Polls.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Polls.scala @@ -259,9 +259,25 @@ object Polls { shape += "status" -> WhiteboardKeyUtil.DRAW_END_STATUS val answers = new ArrayBuffer[SimpleVoteOutVO] - result.answers.foreach(ans => { - answers += SimpleVoteOutVO(ans.id, ans.key, ans.numVotes) - }) + + def sortByNumVotes(s1: SimpleVoteOutVO, s2: SimpleVoteOutVO) = { + s1.numVotes > s2.numVotes + } + + val sorted_answers = result.answers.sortWith(sortByNumVotes) + + // Limit the number of answers displayed to minimize + // squishing the display. + if (sorted_answers.length < 7) { + sorted_answers.foreach(ans => { + answers += SimpleVoteOutVO(ans.id, ans.key, ans.numVotes) + }) + } else { + for (i <- 0 until 7) { + val ans = sorted_answers(i) + answers += SimpleVoteOutVO(ans.id, ans.key, ans.numVotes) + } + } shape += "result" -> answers