2ce8ae9ad7f352b33c761ddcacd501282a808723
1 const message
= require("./public/javascripts/utils/socketMessages");
2 const params
= require("./config/parameters");
3 const AssessmentModel
= require("./models/assessment");
4 const ObjectId
= require("bson-objectid");
6 module
.exports = function(io
)
8 io
.of("/").on("connection", socket
=> {
9 const aid
= socket
.handshake
.query
.aid
;
11 // Student or monitor connexion
12 const isTeacher
= !!socket
.handshake
.query
.secret
&& socket
.handshake
.query
.secret
== params
.secret
;
16 socket
.on(message
.newAnswer
, m
=> { //got answer from student
17 socket
.emit(message
.newAnswer
, m
);
19 socket
.on(message
.allAnswers
, m
=> { //send feedback to student (answers)
20 socket
.broadcast
.to(aid
).emit(message
.allAnswers
, m
);
25 const number
= socket
.handshake
.query
.number
;
26 const password
= socket
.handshake
.query
.password
;
27 AssessmentModel
.checkPassword(ObjectId(aid
), number
, password
, (err
,ret
) => {
29 return; //wrong password, or some unexpected error...
30 socket
.on("disconnect", () => {
31 //TODO: notify monitor (grey low opacity background)
32 //Also send to server: discoTime in assessment.papers ...