Skip to content

Commit

Permalink
Update user experience.
Browse files Browse the repository at this point in the history
Update getUsersInRoom to pass tutorialId and userid.
  • Loading branch information
glutSolidSphere committed Apr 7, 2017
1 parent 1770cc3 commit 2699b06
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions source/model/lobby.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var app = require ('../../app');
var io = require ('socket.io')();
var Tutorial = require ('./Tutorial');
var lobbyio = io.of ('/lobby');

var listen = function (server) {
Expand Down Expand Up @@ -103,6 +104,8 @@ Lobby.prototype.getUsersInRoom = function (roomName) {
userSockets.push ({
'username' : lobbyio.connected[socketId].username,
'userType' : lobbyio.connected[socketId].userType,
'userId' : lobbyio.connected[socketId].userId,
'tutorialId' : lobbyio.connected[socketId].tutorialId,
'socketId' : socketId
});
}
Expand Down Expand Up @@ -205,6 +208,7 @@ lobbyio.on ('connection', function (socket) {
}

socket.tutorialGroup = data.tutorialId;
socket.tutorialId = data.tutorialUuid;
socket.moduleGroup = data.moduleId;
socket.namespace = lobby.namespace;
socket.userId = data.userId;
Expand All @@ -227,8 +231,6 @@ lobbyio.on ('connection', function (socket) {
'defaultGroup': lobby.namespace
});

console.log (lobby.questions);

updateUsers (lobby, socket);

//Update all clients whenever a user successfully joins the lobby.
Expand Down Expand Up @@ -328,6 +330,15 @@ lobbyio.on ('connection', function (socket) {
});
});

lobby.questions[data.uuid].groups.forEach (function (groupName, i) {
var socketsInGroup = lobby.getUsersInRoom (groupName);
socketsInGroup.forEach (function (socketClient, i) {
if (socketClient.userType == 'student') {
Tutorial.changeExp (socketClient.userId, socketClient.tutorialId, lobby.questions[data.uuid].groupAnswers[groupName].experience);
}
});
});

console.log (lobby.questions);
console.log ("COMPARE AND CONTRAST");
console.log (data);
Expand Down

0 comments on commit 2699b06

Please sign in to comment.