Skip to content

Commit

Permalink
Merge pull request #13 from isa-group/feature/#10-CodeCreation
Browse files Browse the repository at this point in the history
Feature/#10 code creation
  • Loading branch information
davbrican authored Jul 1, 2021
2 parents d0ed244 + e3840eb commit 3cbb1bd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
29 changes: 25 additions & 4 deletions consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,35 @@ async function notifyParticipants(sessionName, io) {

Logger.dbg("notifyParticipants - Re-assigning rooms to avoid race conditions!");

var femaleList = []
var maleList = []
for (const participant in participants) {
console.log(participant.firstName + " PARTICIPANTE");
if (participant.gender == "Male") {
maleList.push(participant);
}
else if (participant.gender == "Female") {
femaleList.push(participant);
}
}

participantNumber = 0;

for(i=0;i<roomCount;i++){
let peer1 = participants[i*2];
let peer2 = participants[(i*2)+1];
let peer1 = maleList[i*2];
let peer2 = femaleList[i*2];
//console.log(peer1 + " PARTICIPANTE");
peer1.room = i+initialRoom;
peer2.room = i+initialRoom;

peer1.blind = session.blindParticipant;
peer2.blind = false;
if (i%2==0) {
peer1.blind = session.blindParticipant;
peer2.blind = false;
}
else {
peer1.blind = false;
peer2.blind = session.blindParticipant;
}
Logger.dbg("notifyParticipants - Pair created in room <"+peer1.room+">:\n"+
" -"+ peer1.code+", "+peer1.firstName+", "+peer1.firstName+", "+peer1.gender+", "+peer1.blind+"\n"+
" -"+ peer2.code+", "+peer2.firstName+", "+peer2.firstName+", "+peer2.gender+", "+peer2.blind);
Expand Down
4 changes: 2 additions & 2 deletions models/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const SessionSchema = new Schema({
testCounter: { type: Number, default: 0 },
exerciseCounter: { type: Number, default: -1 },
running: { type: Boolean, default: false },
pairingMode: { type: String, default: "AUTO" },
pairingMode: { type: String, default: "MANUAL" },
registrationText: { type: String },
finishMessage: { type: String },
blindParticipant: { type: Boolean, default: false },
blindParticipant: { type: Boolean, default: true },
});

SessionSchema.index(
Expand Down
17 changes: 17 additions & 0 deletions routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ router.post("/login", (req, res) => {

router.post("/signup", async (req, res) => {
const code = Math.floor(Math.random() * 1000000 + 1);
/*
//code = 350526; Example of an already created user code
try {
const userFound = await User.findOne({
code: code,
environment: process.env.NODE_ENV,
}).then(async(response) => {
console.log(response);
});
while (userFound!=null) {
code = Math.floor(Math.random() * 1000000 + 1);
}
} catch (error) {
;
}
*/

const newUser = new User(req.body);
newUser.code = code;
Expand Down

0 comments on commit 3cbb1bd

Please sign in to comment.