Merge pull request #18284 from hiroshisuga/patch-5

[fix] Cannot pick an escaping student who knows he will be picked next
This commit is contained in:
Gustavo Trott 2023-07-10 11:48:38 -03:00 committed by GitHub
commit 300ffee642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,15 +37,21 @@ trait SelectRandomViewerReqMsgHdlr extends RightsManagementTrait {
val usersPicked = Users2x.getRandomlyPickableUsers(liveMeeting.users2x, reduceDuplicatedPick) val usersPicked = Users2x.getRandomlyPickableUsers(liveMeeting.users2x, reduceDuplicatedPick)
val randNum = new scala.util.Random val randNum = new scala.util.Random
val pickedUser = if (usersPicked.size == 0) "" else usersPicked(randNum.nextInt(usersPicked.size)).intId var pickedUser = if (usersPicked.size == 0) "" else usersPicked(randNum.nextInt(usersPicked.size)).intId
if (reduceDuplicatedPick) { if (reduceDuplicatedPick) {
if (usersPicked.size == 1) { if (usersPicked.size <= 1) {
// Initialise the exemption // Initialise the exemption
val usersToUnexempt = Users2x.findAll(liveMeeting.users2x) val usersToUnexempt = Users2x.findAll(liveMeeting.users2x)
usersToUnexempt foreach { u => usersToUnexempt foreach { u =>
Users2x.setUserExempted(liveMeeting.users2x, u.intId, false) Users2x.setUserExempted(liveMeeting.users2x, u.intId, false)
} }
if (usersPicked.size == 0) {
// Pick again
val usersRepicked = Users2x.getRandomlyPickableUsers(liveMeeting.users2x, reduceDuplicatedPick)
pickedUser = if (usersRepicked.size == 0) "" else usersRepicked(randNum.nextInt(usersRepicked.size)).intId
Users2x.setUserExempted(liveMeeting.users2x, pickedUser, true)
}
} else if (usersPicked.size > 1) { } else if (usersPicked.size > 1) {
Users2x.setUserExempted(liveMeeting.users2x, pickedUser, true) Users2x.setUserExempted(liveMeeting.users2x, pickedUser, true)
} }